-
Notifications
You must be signed in to change notification settings - Fork 0
/
gtigen.go
142 lines (129 loc) · 10 KB
/
gtigen.go
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// Code generated by "goki -v generate ./..."; DO NOT EDIT.
package texteditor
import (
"goki.dev/gti"
"goki.dev/ki/v2"
"goki.dev/ordmap"
)
// EditorType is the [gti.Type] for [Editor]
var EditorType = gti.AddType(>i.Type{
Name: "goki.dev/gi/v2/texteditor.Editor",
ShortName: "texteditor.Editor",
IDName: "editor",
Doc: "Editor is a widget for editing multiple lines of text (as compared to\n[gi.TextField] for a single line). The Editor is driven by a Buf buffer which\ncontains all the text, and manages all the edits, sending update signals\nout to the views -- multiple views can be attached to a given buffer. All\nupdating in the Editor should be within a single goroutine -- it would\nrequire extensive protections throughout code otherwise.",
Directives: gti.Directives{
>i.Directive{Tool: "goki", Directive: "embedder", Args: []string{}},
},
Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
{"Buf", >i.Field{Name: "Buf", Type: "*Buf", Doc: "the text buffer that we're editing", Directives: gti.Directives{}}},
{"Placeholder", >i.Field{Name: "Placeholder", Type: "string", Doc: "text that is displayed when the field is empty, in a lower-contrast manner", Directives: gti.Directives{}}},
{"CursorWidth", >i.Field{Name: "CursorWidth", Type: "units.Value", Doc: "width of cursor -- set from cursor-width property (inherited)", Directives: gti.Directives{}}},
{"LineNumberColor", >i.Field{Name: "LineNumberColor", Type: "colors.Full", Doc: "the color used for the side bar containing the line numbers; this should be set in Stylers like all other style properties", Directives: gti.Directives{}}},
{"SelectColor", >i.Field{Name: "SelectColor", Type: "colors.Full", Doc: "the color used for the user text selection background color; this should be set in Stylers like all other style properties", Directives: gti.Directives{}}},
{"HighlightColor", >i.Field{Name: "HighlightColor", Type: "colors.Full", Doc: "the color used for the text highlight background color (like in find); this should be set in Stylers like all other style properties", Directives: gti.Directives{}}},
{"CursorColor", >i.Field{Name: "CursorColor", Type: "colors.Full", Doc: "the color used for the text field cursor (caret); this should be set in Stylers like all other style properties", Directives: gti.Directives{}}},
{"NLines", >i.Field{Name: "NLines", Type: "int", Doc: "number of lines in the view -- sync'd with the Buf after edits, but always reflects storage size of Renders etc", Directives: gti.Directives{}}},
{"Renders", >i.Field{Name: "Renders", Type: "[]paint.Text", Doc: "renders of the text lines, with one render per line (each line could visibly wrap-around, so these are logical lines, not display lines)", Directives: gti.Directives{}}},
{"Offs", >i.Field{Name: "Offs", Type: "[]float32", Doc: "starting render offsets for top of each line", Directives: gti.Directives{}}},
{"LineNoDigs", >i.Field{Name: "LineNoDigs", Type: "int", Doc: "number of line number digits needed", Directives: gti.Directives{}}},
{"LineNoOff", >i.Field{Name: "LineNoOff", Type: "float32", Doc: "horizontal offset for start of text after line numbers", Directives: gti.Directives{}}},
{"LineNoRender", >i.Field{Name: "LineNoRender", Type: "paint.Text", Doc: "render for line numbers", Directives: gti.Directives{}}},
{"CursorPos", >i.Field{Name: "CursorPos", Type: "lex.Pos", Doc: "current cursor position", Directives: gti.Directives{}}},
{"CursorCol", >i.Field{Name: "CursorCol", Type: "int", Doc: "desired cursor column -- where the cursor was last when moved using left / right arrows -- used when doing up / down to not always go to short line columns", Directives: gti.Directives{}}},
{"ScrollToCursorOnRender", >i.Field{Name: "ScrollToCursorOnRender", Type: "bool", Doc: "if true, scroll screen to cursor on next render", Directives: gti.Directives{}}},
{"ScrollToCursorPos", >i.Field{Name: "ScrollToCursorPos", Type: "lex.Pos", Doc: "cursor position to scroll to", Directives: gti.Directives{}}},
{"PosHistIdx", >i.Field{Name: "PosHistIdx", Type: "int", Doc: "current index within PosHistory", Directives: gti.Directives{}}},
{"SelectStart", >i.Field{Name: "SelectStart", Type: "lex.Pos", Doc: "starting point for selection -- will either be the start or end of selected region depending on subsequent selection.", Directives: gti.Directives{}}},
{"SelectReg", >i.Field{Name: "SelectReg", Type: "textbuf.Region", Doc: "current selection region", Directives: gti.Directives{}}},
{"PrevSelectReg", >i.Field{Name: "PrevSelectReg", Type: "textbuf.Region", Doc: "previous selection region, that was actually rendered -- needed to update render", Directives: gti.Directives{}}},
{"Highlights", >i.Field{Name: "Highlights", Type: "[]textbuf.Region", Doc: "highlighted regions, e.g., for search results", Directives: gti.Directives{}}},
{"Scopelights", >i.Field{Name: "Scopelights", Type: "[]textbuf.Region", Doc: "highlighted regions, specific to scope markers", Directives: gti.Directives{}}},
{"SelectMode", >i.Field{Name: "SelectMode", Type: "bool", Doc: "if true, select text as cursor moves", Directives: gti.Directives{}}},
{"ForceComplete", >i.Field{Name: "ForceComplete", Type: "bool", Doc: "if true, complete regardless of any disqualifying reasons", Directives: gti.Directives{}}},
{"ISearch", >i.Field{Name: "ISearch", Type: "ISearch", Doc: "interactive search data", Directives: gti.Directives{}}},
{"QReplace", >i.Field{Name: "QReplace", Type: "QReplace", Doc: "query replace data", Directives: gti.Directives{}}},
{"FontHeight", >i.Field{Name: "FontHeight", Type: "float32", Doc: "font height, cached during styling", Directives: gti.Directives{}}},
{"LineHeight", >i.Field{Name: "LineHeight", Type: "float32", Doc: "line height, cached during styling", Directives: gti.Directives{}}},
{"NLinesChars", >i.Field{Name: "NLinesChars", Type: "image.Point", Doc: "height in lines and width in chars of the visible area", Directives: gti.Directives{}}},
{"LinesSize", >i.Field{Name: "LinesSize", Type: "mat32.Vec2", Doc: "total size of all lines as rendered", Directives: gti.Directives{}}},
{"TotalSize", >i.Field{Name: "TotalSize", Type: "mat32.Vec2", Doc: "TotalSize = LinesSize plus extra space and line numbers etc", Directives: gti.Directives{}}},
{"LineLayoutSize", >i.Field{Name: "LineLayoutSize", Type: "mat32.Vec2", Doc: "LineLayoutSize is LayState.Alloc.Size subtracting\nextra space and line numbers -- this is what\nLayoutStdLR sees for laying out each line", Directives: gti.Directives{}}},
{"BlinkOn", >i.Field{Name: "BlinkOn", Type: "bool", Doc: "oscillates between on and off for blinking", Directives: gti.Directives{}}},
{"CursorMu", >i.Field{Name: "CursorMu", Type: "sync.Mutex", Doc: "mutex protecting cursor rendering -- shared between blink and main code", Directives: gti.Directives{}}},
{"HasLinks", >i.Field{Name: "HasLinks", Type: "bool", Doc: "at least one of the renders has links -- determines if we set the cursor for hand movements", Directives: gti.Directives{}}},
{"lastRecenter", >i.Field{Name: "lastRecenter", Type: "int", Doc: "", Directives: gti.Directives{}}},
{"lastAutoInsert", >i.Field{Name: "lastAutoInsert", Type: "rune", Doc: "", Directives: gti.Directives{}}},
{"lastFilename", >i.Field{Name: "lastFilename", Type: "gi.FileName", Doc: "", Directives: gti.Directives{}}},
}),
Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
{"Layout", >i.Field{Name: "Layout", Type: "gi.Layout", Doc: "", Directives: gti.Directives{}}},
}),
Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}),
Instance: &Editor{},
})
// NewEditor adds a new [Editor] with the given name
// to the given parent. If the name is unspecified, it defaults
// to the ID (kebab-case) name of the type, plus the
// [ki.Ki.NumLifetimeChildren] of the given parent.
func NewEditor(par ki.Ki, name ...string) *Editor {
return par.NewChild(EditorType, name...).(*Editor)
}
// KiType returns the [*gti.Type] of [Editor]
func (t *Editor) KiType() *gti.Type {
return EditorType
}
// New returns a new [*Editor] value
func (t *Editor) New() ki.Ki {
return &Editor{}
}
// EditorEmbedder is an interface that all types that embed Editor satisfy
type EditorEmbedder interface {
AsEditor() *Editor
}
// AsEditor returns the given value as a value of type Editor if the type
// of the given value embeds Editor, or nil otherwise
func AsEditor(k ki.Ki) *Editor {
if k == nil || k.This() == nil {
return nil
}
if t, ok := k.(EditorEmbedder); ok {
return t.AsEditor()
}
return nil
}
// AsEditor satisfies the [EditorEmbedder] interface
func (t *Editor) AsEditor() *Editor {
return t
}
// TwinEditorsType is the [gti.Type] for [TwinEditors]
var TwinEditorsType = gti.AddType(>i.Type{
Name: "goki.dev/gi/v2/texteditor.TwinEditors",
ShortName: "texteditor.TwinEditors",
IDName: "twin-editors",
Doc: "TwinEditors presents two side-by-side [Editor]s in [gi.Splits]\nthat scroll in sync with each other.",
Directives: gti.Directives{},
Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
{"BufA", >i.Field{Name: "BufA", Type: "*Buf", Doc: "textbuf for A", Directives: gti.Directives{}}},
{"BufB", >i.Field{Name: "BufB", Type: "*Buf", Doc: "textbuf for B", Directives: gti.Directives{}}},
}),
Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
{"Splits", >i.Field{Name: "Splits", Type: "gi.Splits", Doc: "", Directives: gti.Directives{}}},
}),
Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}),
Instance: &TwinEditors{},
})
// NewTwinEditors adds a new [TwinEditors] with the given name
// to the given parent. If the name is unspecified, it defaults
// to the ID (kebab-case) name of the type, plus the
// [ki.Ki.NumLifetimeChildren] of the given parent.
func NewTwinEditors(par ki.Ki, name ...string) *TwinEditors {
return par.NewChild(TwinEditorsType, name...).(*TwinEditors)
}
// KiType returns the [*gti.Type] of [TwinEditors]
func (t *TwinEditors) KiType() *gti.Type {
return TwinEditorsType
}
// New returns a new [*TwinEditors] value
func (t *TwinEditors) New() ki.Ki {
return &TwinEditors{}
}