feat/hints a471fa4

scale.go RawHistoryFolder

1package core
2
3import "math"
4
5// Scales are in 1/120 steps, the wp_fractional_scale_v1 unit.
6const scaleDen = 120
7
8// CleanScales lists scales between 1 and 3 where the output divides into whole
9// logical pixels, so window edges land on physical pixels. Scales below 1.1
10// are skipped: 1.067 on 5120 wide outputs is too close to 1 to be useful.
11func CleanScales(width, height int) []float64 {
12	out := []float64{1}
13	for n := scaleDen + 1; n <= 3*scaleDen; n++ {
14		if width*scaleDen%n != 0 || height*scaleDen%n != 0 {
15			continue
16		}
17		if s := float64(n) / scaleDen; s >= 1.1 {
18			out = append(out, s)
19		}
20	}
21	return out
22}
23
24// StepScale returns the next clean scale above (dir 1) or below (dir -1) cur,
25// or cur at the ends.
26func StepScale(width, height int, cur float64, dir int) float64 {
27	list := CleanScales(width, height)
28	if dir > 0 {
29		for _, s := range list {
30			if s > cur+1e-6 {
31				return s
32			}
33		}
34		return cur
35	}
36	for i := len(list) - 1; i >= 0; i-- {
37		if list[i] < cur-1e-6 {
38			return list[i]
39		}
40	}
41	return cur
42}
43
44// SnapScale rounds to the nearest 1/120 and clamps to [1, 4].
45func SnapScale(s float64) float64 {
46	if !(s >= 1) {
47		return 1
48	}
49	return math.Round(min(s, 4)*scaleDen) / scaleDen
50}
51
52// logical converts a physical size to logical pixels.
53func logical(v int, scale float64) int { return int(math.Round(float64(v) / scale)) }

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 25

Tags 10

↑↓ moveenter openesc close