main ab6686c

output_style.go RawHistoryFolder

1package ansi
2
3type outputColorKind uint8
4
5const (
6	outputColorDefault outputColorKind = iota
7	outputColorANSI16
8	outputColorANSI256
9	outputColorRGB
10)
11
12type outputColor struct {
13	kind  outputColorKind
14	index int
15	rgb   RGB
16}
17
18type outputStyle struct {
19	bold           bool
20	italic         bool
21	inverse        bool
22	attrs          StyleAttrs
23	underlineStyle UnderlineStyle
24	foreground     outputColor
25	background     outputColor
26	underlineColor outputColor
27}
28
29type styleProjector struct {
30	profile ColorProfile
31}
32
33func (p styleProjector) project(style Style) outputStyle {
34	return outputStyle{
35		bold:           style.Bold,
36		italic:         style.Italic,
37		inverse:        style.Inverse,
38		attrs:          style.Attrs,
39		underlineStyle: style.UnderlineStyle,
40		foreground:     p.projectColor(style.Foreground, style.Foreground >= 0, style.ForegroundRGB, style.HasForegroundRGB, true),
41		background:     p.projectColor(style.Background, style.Background >= 0, style.BackgroundRGB, style.HasBackgroundRGB, true),
42		underlineColor: p.projectColor(style.UnderlineColor, style.HasUnderlineColor, style.UnderlineColorRGB, style.HasUnderlineColorRGB, false),
43	}
44}
45
46func (p styleProjector) projectColor(index int, hasIndex bool, rgb RGB, hasRGB, basicColor bool) outputColor {
47	switch p.profile {
48	case ColorProfileANSI256:
49		if hasRGB {
50			return outputColor{kind: outputColorANSI256, index: rgbToANSI256(rgb)}
51		}
52		if hasIndex && index >= 0 && index <= 255 {
53			return outputColor{kind: outputColorANSI256, index: index}
54		}
55	case ColorProfileANSI16:
56		if !basicColor {
57			return outputColor{}
58		}
59		if hasRGB {
60			return outputColor{kind: outputColorANSI16, index: rgbToANSI16(rgb)}
61		}
62		if hasIndex {
63			if index >= 0 && index < 16 {
64				return outputColor{kind: outputColorANSI16, index: index}
65			}
66			if resolved, ok := ansi256ToRGB(index); ok {
67				return outputColor{kind: outputColorANSI16, index: rgbToANSI16(resolved)}
68			}
69		}
70	case ColorProfileMonochrome:
71		return outputColor{}
72	default:
73		if hasRGB {
74			return outputColor{kind: outputColorRGB, rgb: rgb}
75		}
76		if hasIndex {
77			return outputColor{kind: outputColorANSI256, index: index}
78		}
79	}
80	return outputColor{}
81}

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