v0.1.0 47aaa0f

ime_return_test.go RawHistoryFolder

1package ui
2
3import (
4	"testing"
5
6	"github.com/bnema/nefergui/internal/edit"
7	"github.com/bnema/nefergui/internal/keyboard"
8)
9
10func typed(name, text string) platformInput {
11	return platformInput{Kind: "key", Key: keyboard.Key{Name: name, Text: text, Pressed: true}}
12}
13
14// With text-input v3 the compositor routes keys to a grabbing input method;
15// keys that still arrive on wl_keyboard were not consumed and must be typed.
16func TestKeyboardTextInsertedWhileIMEEnabled(t *testing.T) {
17	r := newRuntime()
18	ime := &orderedIME{}
19	r.ime = ime
20	value := "ab"
21	view := func(f *Frame) { f.Root().Textarea("message", &value) }
22	r.Build(view)
23	r.route(key("Tab"))
24	r.Build(view)
25	if !r.edits[idKey(r.Target(0))].IMEActive() {
26		t.Fatal("IME not enabled on focus")
27	}
28	for _, k := range []platformInput{typed("c", "c"), typed("a", "a"), key("Return"), key("KP_Enter")} {
29		r.route(k)
30		r.Build(view)
31	}
32	if value != "abca\n\n" || len(ime.calls) == 0 {
33		t.Fatalf("keyboard text lost while IME enabled: %q", value)
34	}
35
36	// A shown preedit belongs to the input method until it commits: plain
37	// keys and Return must not interleave with it.
38	r.route(platformInput{Kind: "ime-done", IME: edit.IMEBatch{Preedit: "ni", Begin: 2, End: 2}})
39	r.Build(view)
40	for _, k := range []platformInput{typed("x", "x"), typed("a", "a"), key("Return")} {
41		r.route(k)
42		r.Build(view)
43	}
44	if value != "abca\n\n" {
45		t.Fatalf("plain keys inserted during preedit: %q", value)
46	}
47	r.route(platformInput{Kind: "ime-done", IME: edit.IMEBatch{Commit: "你"}})
48	r.Build(view)
49	r.route(typed("z", "z"))
50	r.Build(view)
51	if value != "abca\n\n你z" {
52		t.Fatalf("typing after commit: %q", value)
53	}
54}

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