v0.7.2 ab6686c

screen_charset_test.go RawHistoryFolder

1package vt
2
3import (
4	"strings"
5	"testing"
6)
7
8func TestCharsetsAndRepeat(t *testing.T) {
9	tests := []struct {
10		name  string
11		input string
12		want  string
13	}{
14		{name: "G0 DEC special graphics draws lines", input: "\x1b(0lqqk\x1b(Bq", want: "┌──┐q"},
15		{name: "G1 via SO and SI", input: "\x1b)0q\x0eqx\x0fq", want: "q─│q"},
16		{name: "SO without G1 designation stays ASCII", input: "\x0eq\x0f", want: "q"},
17		{name: "chars outside the graphics range pass through", input: "\x1b(0Aa~", want: "A▒·"},
18		{name: "DECSC and DECRC restore charsets", input: "\x1b(0\x1b7\x1b(B\x1b8q", want: "─"},
19		{name: "DECSTR resets charsets", input: "\x1b(0q\x1b[!pq", want: "─q"},
20		{name: "RIS resets charsets", input: "\x1b(0\x1bcq", want: "q"},
21		{name: "REP repeats the last graphic char", input: "\x1b(0q\x1b[4b", want: "─────"},
22		{name: "REP defaults to one", input: "a\x1b[b", want: "aa"},
23		{name: "REP without a prior char is ignored", input: "\x1b[3bx", want: "x"},
24		{name: "REP after a control is ignored", input: "ab\r\x1b[2b", want: "ab"},
25		{name: "REP after another sequence is ignored", input: "a\x1b[1m\x1b[2b", want: "a"},
26		{name: "consecutive REP repeats once", input: "a\x1b[b\x1b[b", want: "aa"},
27		{name: "DECSC and DECRC restore SO invocation", input: "\x1b)0\x0e\x1b7\x0f\x1b8q", want: "─"},
28		{name: "leaving 1049 restores charsets", input: "\x1b(0\x1b[?1049h\x1b(B\x1b[?1049lq", want: "─"},
29		{name: "leaving 47 keeps current charsets", input: "\x1b(0\x1b[?47h\x1b(B\x1b[?47lq", want: "q"},
30		{name: "leaving 1047 keeps current charsets", input: "\x1b(0\x1b[?1047h\x1b(B\x1b[?1047lq", want: "q"},
31		{name: "DECSTR saved cursor restores home", input: "\x1b[1;5Hx\x1b[!p\x1b8y", want: "y   x"},
32		{name: "partial charset escape across writes", input: "\x1b(", want: ""},
33	}
34	for _, tt := range tests {
35		t.Run(tt.name, func(t *testing.T) {
36			s := NewScreen(10, 3)
37			s.Write([]byte(tt.input))
38			if got := strings.TrimRight(lineText(s, 0), " "); got != tt.want {
39				t.Fatalf("line = %q, want %q", got, tt.want)
40			}
41		})
42	}
43}
44
45func TestCharsetDesignationSplitAcrossWrites(t *testing.T) {
46	s := NewScreen(10, 1)
47	s.Write([]byte("\x1b("))
48	s.Write([]byte("0q"))
49	if got := strings.TrimRight(lineText(s, 0), " "); got != "─" {
50		t.Fatalf("line = %q, want %q", got, "─")
51	}
52}
53
54func TestSoftResetCursorAppearance(t *testing.T) {
55	s := NewScreen(4, 1)
56	s.Write([]byte("\x1b[6 q\x1b[?25l\x1b[!p"))
57	if s.cursorStyleSet || s.cursorStyle != 0 || !s.cursorVisible {
58		t.Fatalf("cursor style=%d set=%v visible=%v, want defaults", s.cursorStyle, s.cursorStyleSet, s.cursorVisible)
59	}
60}
61
62func TestRepeatSplitAcrossWrites(t *testing.T) {
63	tests := []struct {
64		name   string
65		writes []string
66	}{
67		{name: "split inside CSI", writes: []string{"a\x1b[", "2b"}},
68		{name: "empty write after lone ESC", writes: []string{"a\x1b", "", "[2b"}},
69	}
70	for _, tt := range tests {
71		t.Run(tt.name, func(t *testing.T) {
72			s := NewScreen(10, 1)
73			for _, w := range tt.writes {
74				s.Write([]byte(w))
75			}
76			if got := strings.TrimRight(lineText(s, 0), " "); got != "aaa" {
77				t.Fatalf("line = %q, want %q", got, "aaa")
78			}
79		})
80	}
81}
82
83func TestRepeatAfterFragmentedKittyAPCIsIgnored(t *testing.T) {
84	s := NewScreen(10, 1)
85	s.Write([]byte("a\x1b_G"))
86	s.Write([]byte("a=q,i=1;\x1b\\"))
87	s.Write([]byte("\x1b[2b"))
88	if got := strings.TrimRight(lineText(s, 0), " "); got != "a" {
89		t.Fatalf("line = %q, want %q", got, "a")
90	}
91}
92
93func TestRepeatIsBounded(t *testing.T) {
94	s := NewScreen(4, 2)
95	s.Write([]byte("x\x1b[999999999b"))
96	if got := lineText(s, 0); got != "xxxx" {
97		t.Fatalf("line = %q, want %q", got, "xxxx")
98	}
99}

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