v0.33.2 57f21d6

zoom.go RawHistoryFolder

1package entity
2
3import (
4	"math"
5	"time"
6)
7
8// ZoomLevel represents the zoom factor for a specific domain.
9// Allows users to set persistent zoom levels per-site.
10type ZoomLevel struct {
11	Domain     string  // Domain name (e.g., "github.com")
12	ZoomFactor float64 // Zoom factor (1.0 = 100%, 1.5 = 150%)
13	UpdatedAt  time.Time
14}
15
16// Default zoom constants
17const (
18	ZoomDefault = 1.0
19	ZoomMin     = 0.25 // 25%
20	ZoomMax     = 5.0  // 500%
21	ZoomStep    = 0.1  // 10% increments
22)
23
24// NewZoomLevel creates a new zoom level for a domain.
25func NewZoomLevel(domain string, factor float64) *ZoomLevel {
26	return &ZoomLevel{
27		Domain:     domain,
28		ZoomFactor: clampZoom(factor),
29		UpdatedAt:  time.Now(),
30	}
31}
32
33// SetFactor updates the zoom factor, clamping to valid range.
34func (z *ZoomLevel) SetFactor(factor float64) {
35	z.ZoomFactor = clampZoom(factor)
36	z.UpdatedAt = time.Now()
37}
38
39// ZoomIn increases the zoom factor by one step.
40func (z *ZoomLevel) ZoomIn() {
41	z.SetFactor(z.ZoomFactor + ZoomStep)
42}
43
44// ZoomOut decreases the zoom factor by one step.
45func (z *ZoomLevel) ZoomOut() {
46	z.SetFactor(z.ZoomFactor - ZoomStep)
47}
48
49// Reset restores the zoom factor to default.
50func (z *ZoomLevel) Reset() {
51	z.SetFactor(ZoomDefault)
52}
53
54// IsDefault returns true if the zoom is at default level.
55func (z *ZoomLevel) IsDefault() bool {
56	return z.ZoomFactor == ZoomDefault
57}
58
59// ZoomPercentage returns a zoom factor as a whole percentage (e.g., 150 for
60// 1.5). Accumulated floating-point error is rounded away so a factor that equals
61// the default zoom in intent (0.9999999999999997) displays as 100, not 99.
62func ZoomPercentage(factor float64) int {
63	return int(math.Round(factor * 100))
64}
65
66// Percentage returns the zoom factor as a whole percentage.
67func (z *ZoomLevel) Percentage() int {
68	return ZoomPercentage(z.ZoomFactor)
69}
70
71// clampZoom constrains a zoom factor to the valid range.
72func clampZoom(factor float64) float64 {
73	if factor < ZoomMin {
74		return ZoomMin
75	}
76	if factor > ZoomMax {
77		return ZoomMax
78	}
79	return factor
80}

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 8

Tags 42

↑↓ moveenter openesc close