Repository navigation
Expand file tree
/
Copy pathcursor.go
More file actions
73 lines (62 loc) · 1.59 KB
/
Copy pathcursor.go
File metadata and controls
73 lines (62 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package headlessterm
// CursorStyle determines how the cursor is rendered.
type CursorStyle int
const (
CursorStyleBlinkingBlock CursorStyle = iota
CursorStyleSteadyBlock
CursorStyleBlinkingUnderline
CursorStyleSteadyUnderline
CursorStyleBlinkingBar
CursorStyleSteadyBar
)
// Cursor tracks the current position and rendering style (0-based coordinates).
type Cursor struct {
Row int
Col int
Style CursorStyle
Visible bool
}
// NewCursor creates a cursor at (0, 0) with blinking block style, visible.
func NewCursor() *Cursor {
return &Cursor{
Row: 0,
Col: 0,
Style: CursorStyleBlinkingBlock,
Visible: true,
}
}
// SavedCursor stores cursor position, cell attributes, and charset state for restoration.
// Used when switching between primary and alternate screens.
type SavedCursor struct {
Row int
Col int
Attrs CellTemplate
OriginMode bool
CharsetIndex int
Charsets [4]Charset
}
// CellTemplate defines default attributes applied to newly written characters.
// Modified by SGR (Select Graphic Rendition) escape sequences.
type CellTemplate struct {
Cell
}
// NewCellTemplate creates a template with default attributes (no colors, no flags).
func NewCellTemplate() CellTemplate {
return CellTemplate{
Cell: NewCell(),
}
}
// Charset selects the character encoding variant.
type Charset int
const (
CharsetASCII Charset = iota
CharsetLineDrawing
)
// CharsetIndex selects one of four character set slots (G0-G3).
type CharsetIndex int
const (
CharsetIndexG0 CharsetIndex = iota
CharsetIndexG1
CharsetIndexG2
CharsetIndexG3
)