v0.6.1 aa12db3

edit_scroll.go RawHistoryFolder

1package ui
2
3import (
4	"math"
5
6	"github.com/bnema/nefergui/internal/layout"
7)
8
9func (r *runtime) scrollCaret(root *element, out *layout.Output) bool {
10	if root == nil || r.state.focus == nil {
11		return false
12	}
13	id := idKey(r.state.focus)
14	var find func(*element) *element
15	find = func(e *element) *element {
16		if e == nil {
17			return nil
18		}
19		if idKey(e.identity) == id {
20			return e
21		}
22		for _, child := range e.children {
23			if v := find(child); v != nil {
24				return v
25			}
26		}
27		return nil
28	}
29	e := find(root)
30	if e == nil || e.disabled || (e.typ != "input" && e.typ != "textarea") {
31		return false
32	}
33	s := r.edits[id]
34	n := resultByID(out.Tree, id)
35	if s == nil || n == nil {
36		return false
37	}
38	geometry := newEditorGeometry(s, n, out.Display, e.password)
39	caret, found := geometry.caret(s.Cursor)
40	if !found {
41		return false
42	}
43	old := r.state.scroll[id]
44	next := old
45	if e.typ == "input" {
46		if caret.x < n.Content.X {
47			next.W += caret.x - n.Content.X
48		} else if caret.x > n.Content.X+n.Content.W-1 {
49			next.W += caret.x - (n.Content.X + n.Content.W - 1)
50		}
51		next.H = 0
52	} else {
53		height := geometry.lineHeight(caret.line)
54		if caret.y < n.Content.Y {
55			next.H += caret.y - n.Content.Y
56		} else if caret.y+height > n.Content.Y+n.Content.H {
57			next.H += caret.y + height - (n.Content.Y + n.Content.H)
58		}
59		next.W = 0
60	}
61	next.W = math.Max(0, math.Min(next.W, math.Max(0, n.ContentSize.W-n.Content.W)))
62	next.H = math.Max(0, math.Min(next.H, math.Max(0, n.ContentSize.H-n.Content.H)))
63	if next == old {
64		return false
65	}
66	if r.state.scroll == nil {
67		r.state.scroll = make(map[string]layout.Size)
68	}
69	r.state.scroll[id] = next
70	return true
71}

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 1

Tags 12

↑↓ moveenter openesc close