v0.7.2 71ebe61

atlas_dirty_test.go RawHistoryFolder

1package text
2
3import (
4	"bytes"
5	"image"
6	"testing"
7
8	"github.com/go-text/typesetting/font"
9)
10
11func TestMarkAllDirty(t *testing.T) {
12	a, err := NewAtlas(16, 2)
13	if err != nil {
14		t.Fatal(err)
15	}
16	a.MarkAllDirty()
17	if got := a.Uploads(); len(got) != 0 {
18		t.Fatalf("empty atlas: %v", got)
19	}
20	m := Mask{Alpha: image.NewAlpha(image.Rect(0, 0, 2, 2))}
21	m.Alpha.Pix[0] = 123
22	if _, err := a.Insert(Key{Glyph: 1}, m); err != nil {
23		t.Fatal(err)
24	}
25	a.Uploads()
26	a.MarkAllDirty()
27	a.MarkAllDirty()
28	got := a.Uploads()
29	if len(got) != 1 || got[0].Page != 0 || got[0].Rect != image.Rect(0, 0, 16, 16) || !bytes.Equal(got[0].Bytes, a.pages[0].pixels) {
30		t.Fatalf("dirty snapshot: %v", got)
31	}
32	if got := a.Uploads(); len(got) != 0 {
33		t.Fatalf("not drained: %v", got)
34	}
35}
36
37// TestAtlasCachesEmptyGlyphs keeps spaces out of the per-frame raster path and
38// bounds their entries, which no page eviction removes.
39func TestAtlasCachesEmptyGlyphs(t *testing.T) {
40	a, err := NewAtlas(16, 1)
41	if err != nil {
42		t.Fatal(err)
43	}
44	space := Mask{Alpha: image.NewAlpha(image.Rect(0, 0, 0, 0)), Origin: image.Pt(0, -3)}
45	if p, err := a.Insert(Key{Glyph: 3}, space); err != nil || p.Page != -1 {
46		t.Fatalf("insert: %+v %v", p, err)
47	}
48	a.BeginFrame()
49	if p, ok := a.Lookup(Key{Glyph: 3}); !ok || p.Page != -1 || p.Origin != space.Origin {
50		t.Fatalf("lookup: %+v %v", p, ok)
51	}
52	// Evicting the only page for a new glyph must keep the empty entry.
53	ink := Mask{Alpha: image.NewAlpha(image.Rect(0, 0, 10, 10))}
54	for g := range 3 {
55		a.BeginFrame()
56		if _, err := a.Insert(Key{Glyph: font.GID(10 + g)}, ink); err != nil {
57			t.Fatal(err)
58		}
59	}
60	if _, ok := a.Lookup(Key{Glyph: 3}); !ok {
61		t.Fatal("page eviction dropped an empty glyph")
62	}
63	for g := range maxEmptyGlyphs + 10 {
64		if _, err := a.Insert(Key{Glyph: font.GID(100 + g)}, space); err != nil {
65			t.Fatal(err)
66		}
67	}
68	if a.empty > maxEmptyGlyphs || len(a.entries) > maxEmptyGlyphs+1 {
69		t.Fatalf("empty glyphs unbounded: %d counted, %d entries", a.empty, len(a.entries))
70	}
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