v0.5.0 31affde

style.go RawHistoryFolder

1package core
2
3type RGB struct {
4	R uint8
5	G uint8
6	B uint8
7}
8
9type StyleAttrs uint16
10
11const (
12	AttrDim StyleAttrs = 1 << iota
13	AttrUnderline
14	AttrBlink
15	AttrStrikethrough
16)
17
18type UnderlineStyle uint8
19
20const (
21	UnderlineNone UnderlineStyle = iota
22	UnderlineSingle
23	UnderlineDouble
24	UnderlineCurly
25	UnderlineDotted
26	UnderlineDashed
27)
28
29type Style struct {
30	Bold       bool
31	Italic     bool
32	Inverse    bool
33	Attrs      StyleAttrs
34	Foreground int // -1 means unset; ignored when HasForegroundRGB is true
35	Background int // -1 means unset; ignored when HasBackgroundRGB is true
36
37	HasForegroundRGB bool
38	ForegroundRGB    RGB
39	HasBackgroundRGB bool
40	BackgroundRGB    RGB
41
42	UnderlineStyle       UnderlineStyle
43	HasUnderlineColor    bool
44	UnderlineColor       int // ignored when HasUnderlineColorRGB is true
45	HasUnderlineColorRGB bool
46	UnderlineColorRGB    RGB
47}
48
49func DefaultStyle() Style { return Style{Foreground: -1, Background: -1} }
50
51// Canonical returns the unique representation of s under Equal. Fields that
52// are inactive for the selected color form are cleared. Canonical does not
53// treat the zero Style as the default style: indexed color zero remains
54// distinct from the unset colors returned by DefaultStyle.
55func (s Style) Canonical() Style {
56	if s.HasForegroundRGB {
57		s.Foreground = 0
58	} else {
59		s.ForegroundRGB = RGB{}
60	}
61	if s.HasBackgroundRGB {
62		s.Background = 0
63	} else {
64		s.BackgroundRGB = RGB{}
65	}
66	if s.HasUnderlineColorRGB {
67		s.HasUnderlineColor = false
68		s.UnderlineColor = 0
69	} else {
70		s.UnderlineColorRGB = RGB{}
71		if !s.HasUnderlineColor {
72			s.UnderlineColor = 0
73		}
74	}
75	return s
76}
77
78func (s Style) Equal(other Style) bool {
79	if s.Bold != other.Bold || s.Italic != other.Italic || s.Inverse != other.Inverse || s.Attrs != other.Attrs || s.UnderlineStyle != other.UnderlineStyle {
80		return false
81	}
82	if s.HasForegroundRGB != other.HasForegroundRGB || s.HasBackgroundRGB != other.HasBackgroundRGB || s.HasUnderlineColorRGB != other.HasUnderlineColorRGB {
83		return false
84	}
85	if s.HasForegroundRGB {
86		if s.ForegroundRGB != other.ForegroundRGB {
87			return false
88		}
89	} else if s.Foreground != other.Foreground {
90		return false
91	}
92	if s.HasBackgroundRGB {
93		if s.BackgroundRGB != other.BackgroundRGB {
94			return false
95		}
96	} else if s.Background != other.Background {
97		return false
98	}
99	if s.HasUnderlineColorRGB {
100		return s.UnderlineColorRGB == other.UnderlineColorRGB
101	}
102	if s.HasUnderlineColor != other.HasUnderlineColor {
103		return false
104	}
105	if s.HasUnderlineColor {
106		return s.UnderlineColor == other.UnderlineColor
107	}
108	return true
109}

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