types.go RawHistoryFolder
1package domain
2
3import "strings"
4
5// Anchor specifies a position in a 3x3 grid.
6type Anchor uint8
7
8const (
9 AnchorCenter Anchor = iota
10 AnchorTopLeft
11 AnchorTop
12 AnchorTopRight
13 AnchorLeft
14 AnchorRight
15 AnchorBottomLeft
16 AnchorBottom
17 AnchorBottomRight
18)
19
20// Valid reports whether a is a defined anchor.
21func (a Anchor) Valid() bool {
22 return a <= AnchorBottomRight
23}
24
25// String returns the canonical text representation of a.
26func (a Anchor) String() string {
27 switch a {
28 case AnchorCenter:
29 return "center"
30 case AnchorTopLeft:
31 return "top-left"
32 case AnchorTop:
33 return "top"
34 case AnchorTopRight:
35 return "top-right"
36 case AnchorLeft:
37 return "left"
38 case AnchorRight:
39 return "right"
40 case AnchorBottomLeft:
41 return "bottom-left"
42 case AnchorBottom:
43 return "bottom"
44 case AnchorBottomRight:
45 return "bottom-right"
46 default:
47 return "unknown"
48 }
49}
50
51// ParseAnchor parses a case-insensitive anchor name.
52func ParseAnchor(s string) (Anchor, bool) {
53 switch strings.ToLower(strings.TrimSpace(s)) {
54 case "center":
55 return AnchorCenter, true
56 case "top-left":
57 return AnchorTopLeft, true
58 case "top":
59 return AnchorTop, true
60 case "top-right":
61 return AnchorTopRight, true
62 case "left":
63 return AnchorLeft, true
64 case "right":
65 return AnchorRight, true
66 case "bottom-left":
67 return AnchorBottomLeft, true
68 case "bottom":
69 return AnchorBottom, true
70 case "bottom-right":
71 return AnchorBottomRight, true
72 default:
73 return AnchorCenter, false
74 }
75}
76
77// Size is a terminal dimension in columns and rows.
78type Size struct {
79 Cols, Rows int
80}
81
82// Valid reports whether sz has strictly positive columns and rows.
83func (sz Size) Valid() bool {
84 return sz.Cols > 0 && sz.Rows > 0
85}
86
87// Rect is an axis-aligned rectangle in cell coordinates.
88type Rect struct {
89 X, Y, Width, Height int
90}
91
92// SessionID uniquely identifies a session.
93type SessionID string
94
95// TabID identifies a tab by its session-local, user-facing ID.
96type TabID string
97
98// TabStableID identifies a tab independently of its mutable session position.
99type TabStableID string
100
101// PaneStableID identifies a pane independently of its layout-local PaneID.
102type PaneStableID string