v0.7.2 ab6686c

screen_cursor.go RawHistoryFolder

1package vt
2
3import (
4	"strconv"
5	"strings"
6
7	renderer "github.com/bnema/vev-vt/core"
8)
9
10type cursorState struct {
11	row          int
12	col          int
13	style        renderer.Style
14	originMode   bool
15	insertMode   bool
16	autoWrapMode bool
17	charsets     [2]byte
18	shiftOut     bool
19	saved        bool
20}
21
22func (s *Screen) cursorReportRow() int {
23	if s.originMode {
24		return clamp(s.Row, s.cursorMinRow(), s.cursorMaxRow()) - s.cursorMinRow() + 1
25	}
26	return s.Row + 1
27}
28
29func (s *Screen) cursorMinRow() int {
30	if s.originMode {
31		return clamp(s.scrollTop, 0, s.frame.Height-1)
32	}
33	return 0
34}
35
36func (s *Screen) cursorMaxRow() int {
37	if s.originMode {
38		return clamp(s.scrollBottom, 0, s.frame.Height-1)
39	}
40	return max(s.frame.Height-1, 0)
41}
42
43func (s *Screen) addressedRow(row int) int {
44	if s.originMode {
45		return clamp(s.scrollTop+row-1, s.cursorMinRow(), s.cursorMaxRow())
46	}
47	return clamp(row-1, 0, s.frame.Height-1)
48}
49
50func (s *Screen) addressCursor(row, col int) {
51	s.Row = s.addressedRow(row)
52	s.Col = clamp(col-1, 0, s.frame.Width-1)
53}
54
55func (s *Screen) homeCursor() {
56	s.addressCursor(1, 1)
57}
58
59func (s *Screen) applyCursorStyle(params string) {
60	if strings.HasPrefix(params, ">") || !strings.HasSuffix(params, " ") {
61		return
62	}
63	styleParam := strings.TrimSuffix(params, " ")
64	style := 0
65	if styleParam != "" {
66		v, err := strconv.Atoi(styleParam)
67		if err != nil {
68			return
69		}
70		style = v
71	}
72	if style < 0 || style > 6 {
73		return
74	}
75	s.cursorStyle = style
76	s.cursorStyleSet = true
77}
78
79func (s *Screen) saveCursor() {
80	s.savedCursor = cursorState{
81		row: s.Row, col: s.Col, style: s.Style,
82		originMode: s.originMode, insertMode: s.insertMode,
83		autoWrapMode: s.autoWrapMode, charsets: s.charsets,
84		shiftOut: s.shiftOut, saved: true,
85	}
86}
87
88func (s *Screen) restoreCursor() {
89	if !s.savedCursor.saved {
90		return
91	}
92	s.Row = clamp(s.savedCursor.row, 0, s.frame.Height-1)
93	s.Col = clamp(s.savedCursor.col, 0, s.frame.Width-1)
94	s.Style = s.savedCursor.style
95	s.originMode = s.savedCursor.originMode
96	s.insertMode = s.savedCursor.insertMode
97	s.autoWrapMode = s.savedCursor.autoWrapMode
98	s.charsets = s.savedCursor.charsets
99	s.shiftOut = s.savedCursor.shiftOut
100}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 2

Tags 13

↑↓ moveenter openesc close