-
Notifications
You must be signed in to change notification settings - Fork 0
/
gtigen.go
274 lines (241 loc) · 16.5 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
// Code generated by "goki generate"; DO NOT EDIT.
package texteditor
import (
"goki.dev/colors"
"goki.dev/gi/v2/gi"
"goki.dev/girl/units"
"goki.dev/gti"
"goki.dev/ki/v2"
"goki.dev/mat32/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: "*goki.dev/gi/v2/texteditor.Buf", LocalType: "*Buf", Doc: "the text buffer that we're editing", Directives: gti.Directives{}, Tag: "set:\"-\" json:\"-\" xml:\"-\""}},
{"Placeholder", >i.Field{Name: "Placeholder", Type: "string", LocalType: "string", Doc: "text that is displayed when the field is empty, in a lower-contrast manner", Directives: gti.Directives{}, Tag: "json:\"-\" xml:\"placeholder\""}},
{"CursorWidth", >i.Field{Name: "CursorWidth", Type: "goki.dev/girl/units.Value", LocalType: "units.Value", Doc: "width of cursor -- set from cursor-width property (inherited)", Directives: gti.Directives{}, Tag: "xml:\"cursor-width\""}},
{"LineNumberColor", >i.Field{Name: "LineNumberColor", Type: "goki.dev/colors.Full", LocalType: "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{}, Tag: ""}},
{"SelectColor", >i.Field{Name: "SelectColor", Type: "goki.dev/colors.Full", LocalType: "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{}, Tag: ""}},
{"HighlightColor", >i.Field{Name: "HighlightColor", Type: "goki.dev/colors.Full", LocalType: "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{}, Tag: ""}},
{"CursorColor", >i.Field{Name: "CursorColor", Type: "goki.dev/colors.Full", LocalType: "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{}, Tag: ""}},
{"NLines", >i.Field{Name: "NLines", Type: "int", LocalType: "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{}, Tag: "set:\"-\" view:\"-\" json:\"-\" xml:\"-\""}},
{"Renders", >i.Field{Name: "Renders", Type: "[]goki.dev/girl/paint.Text", LocalType: "[]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{}, Tag: "set:\"-\" view:\"-\" json:\"-\" xml:\"-\""}},
{"Offs", >i.Field{Name: "Offs", Type: "[]float32", LocalType: "[]float32", Doc: "starting render offsets for top of each line", Directives: gti.Directives{}, Tag: "set:\"-\" view:\"-\" json:\"-\" xml:\"-\""}},
{"LineNoDigs", >i.Field{Name: "LineNoDigs", Type: "int", LocalType: "int", Doc: "number of line number digits needed", Directives: gti.Directives{}, Tag: "set:\"-\" view:\"-\" json:\"-\" xml:\"-\""}},
{"LineNoOff", >i.Field{Name: "LineNoOff", Type: "float32", LocalType: "float32", Doc: "horizontal offset for start of text after line numbers", Directives: gti.Directives{}, Tag: "set:\"-\" view:\"-\" json:\"-\" xml:\"-\""}},
{"LineNoRender", >i.Field{Name: "LineNoRender", Type: "goki.dev/girl/paint.Text", LocalType: "paint.Text", Doc: "render for line numbers", Directives: gti.Directives{}, Tag: "set:\"-\" view:\"-\" json:\"-\" xml:\"-\""}},
{"CursorPos", >i.Field{Name: "CursorPos", Type: "goki.dev/pi/v2/lex.Pos", LocalType: "lex.Pos", Doc: "current cursor position", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"CursorCol", >i.Field{Name: "CursorCol", Type: "int", LocalType: "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{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"ScrollToCursorOnRender", >i.Field{Name: "ScrollToCursorOnRender", Type: "bool", LocalType: "bool", Doc: "if true, scroll screen to cursor on next render", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"ScrollToCursorPos", >i.Field{Name: "ScrollToCursorPos", Type: "goki.dev/pi/v2/lex.Pos", LocalType: "lex.Pos", Doc: "cursor position to scroll to", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"PosHistIdx", >i.Field{Name: "PosHistIdx", Type: "int", LocalType: "int", Doc: "current index within PosHistory", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"SelectStart", >i.Field{Name: "SelectStart", Type: "goki.dev/pi/v2/lex.Pos", LocalType: "lex.Pos", Doc: "starting point for selection -- will either be the start or end of selected region depending on subsequent selection.", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"SelectReg", >i.Field{Name: "SelectReg", Type: "goki.dev/gi/v2/texteditor/textbuf.Region", LocalType: "textbuf.Region", Doc: "current selection region", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"PrevSelectReg", >i.Field{Name: "PrevSelectReg", Type: "goki.dev/gi/v2/texteditor/textbuf.Region", LocalType: "textbuf.Region", Doc: "previous selection region, that was actually rendered -- needed to update render", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"Highlights", >i.Field{Name: "Highlights", Type: "[]goki.dev/gi/v2/texteditor/textbuf.Region", LocalType: "[]textbuf.Region", Doc: "highlighted regions, e.g., for search results", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"Scopelights", >i.Field{Name: "Scopelights", Type: "[]goki.dev/gi/v2/texteditor/textbuf.Region", LocalType: "[]textbuf.Region", Doc: "highlighted regions, specific to scope markers", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"SelectMode", >i.Field{Name: "SelectMode", Type: "bool", LocalType: "bool", Doc: "if true, select text as cursor moves", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"ForceComplete", >i.Field{Name: "ForceComplete", Type: "bool", LocalType: "bool", Doc: "if true, complete regardless of any disqualifying reasons", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"ISearch", >i.Field{Name: "ISearch", Type: "goki.dev/gi/v2/texteditor.ISearch", LocalType: "ISearch", Doc: "interactive search data", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"QReplace", >i.Field{Name: "QReplace", Type: "goki.dev/gi/v2/texteditor.QReplace", LocalType: "QReplace", Doc: "query replace data", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"FontHeight", >i.Field{Name: "FontHeight", Type: "float32", LocalType: "float32", Doc: "font height, cached during styling", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"LineHeight", >i.Field{Name: "LineHeight", Type: "float32", LocalType: "float32", Doc: "line height, cached during styling", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"NLinesChars", >i.Field{Name: "NLinesChars", Type: "image.Point", LocalType: "image.Point", Doc: "height in lines and width in chars of the visible area", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"LinesSize", >i.Field{Name: "LinesSize", Type: "goki.dev/mat32/v2.Vec2", LocalType: "mat32.Vec2", Doc: "total size of all lines as rendered", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"TotalSize", >i.Field{Name: "TotalSize", Type: "goki.dev/mat32/v2.Vec2", LocalType: "mat32.Vec2", Doc: "TotalSize = LinesSize plus extra space and line numbers etc", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"LineLayoutSize", >i.Field{Name: "LineLayoutSize", Type: "goki.dev/mat32/v2.Vec2", LocalType: "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{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"BlinkOn", >i.Field{Name: "BlinkOn", Type: "bool", LocalType: "bool", Doc: "oscillates between on and off for blinking", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"CursorMu", >i.Field{Name: "CursorMu", Type: "sync.Mutex", LocalType: "sync.Mutex", Doc: "mutex protecting cursor rendering -- shared between blink and main code", Directives: gti.Directives{}, Tag: "set:\"-\" json:\"-\" xml:\"-\" view:\"-\""}},
{"HasLinks", >i.Field{Name: "HasLinks", Type: "bool", LocalType: "bool", Doc: "at least one of the renders has links -- determines if we set the cursor for hand movements", Directives: gti.Directives{}, Tag: "set:\"-\" readonly:\"-\" json:\"-\" xml:\"-\""}},
{"lastRecenter", >i.Field{Name: "lastRecenter", Type: "int", LocalType: "int", Doc: "", Directives: gti.Directives{}, Tag: ""}},
{"lastAutoInsert", >i.Field{Name: "lastAutoInsert", Type: "rune", LocalType: "rune", Doc: "", Directives: gti.Directives{}, Tag: ""}},
{"lastFilename", >i.Field{Name: "lastFilename", Type: "goki.dev/gi/v2/gi.FileName", LocalType: "gi.FileName", Doc: "", Directives: gti.Directives{}, Tag: ""}},
}),
Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
{"Layout", >i.Field{Name: "Layout", Type: "goki.dev/gi/v2/gi.Layout", LocalType: "gi.Layout", Doc: "", Directives: gti.Directives{}, Tag: ""}},
}),
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
}
// SetPlaceholder sets the [Editor.Placeholder]:
// text that is displayed when the field is empty, in a lower-contrast manner
func (t *Editor) SetPlaceholder(v string) *Editor {
t.Placeholder = v
return t
}
// SetCursorWidth sets the [Editor.CursorWidth]:
// width of cursor -- set from cursor-width property (inherited)
func (t *Editor) SetCursorWidth(v units.Value) *Editor {
t.CursorWidth = v
return t
}
// SetLineNumberColor sets the [Editor.LineNumberColor]:
// the color used for the side bar containing the line numbers; this should be set in Stylers like all other style properties
func (t *Editor) SetLineNumberColor(v colors.Full) *Editor {
t.LineNumberColor = v
return t
}
// SetSelectColor sets the [Editor.SelectColor]:
// the color used for the user text selection background color; this should be set in Stylers like all other style properties
func (t *Editor) SetSelectColor(v colors.Full) *Editor {
t.SelectColor = v
return t
}
// SetHighlightColor sets the [Editor.HighlightColor]:
// the color used for the text highlight background color (like in find); this should be set in Stylers like all other style properties
func (t *Editor) SetHighlightColor(v colors.Full) *Editor {
t.HighlightColor = v
return t
}
// SetCursorColor sets the [Editor.CursorColor]:
// the color used for the text field cursor (caret); this should be set in Stylers like all other style properties
func (t *Editor) SetCursorColor(v colors.Full) *Editor {
t.CursorColor = v
return t
}
// SetlastRecenter sets the [Editor.lastRecenter]
func (t *Editor) SetlastRecenter(v int) *Editor {
t.lastRecenter = v
return t
}
// SetlastAutoInsert sets the [Editor.lastAutoInsert]
func (t *Editor) SetlastAutoInsert(v rune) *Editor {
t.lastAutoInsert = v
return t
}
// SetlastFilename sets the [Editor.lastFilename]
func (t *Editor) SetlastFilename(v gi.FileName) *Editor {
t.lastFilename = v
return t
}
// SetTooltip sets the [Editor.Tooltip]
func (t *Editor) SetTooltip(v string) *Editor {
t.Tooltip = v
return t
}
// SetClass sets the [Editor.Class]
func (t *Editor) SetClass(v string) *Editor {
t.Class = v
return t
}
// SetCustomContextMenu sets the [Editor.CustomContextMenu]
func (t *Editor) SetCustomContextMenu(v func(m *gi.Scene)) *Editor {
t.CustomContextMenu = v
return t
}
// SetSpacing sets the [Editor.Spacing]
func (t *Editor) SetSpacing(v units.Value) *Editor {
t.Spacing = v
return t
}
// SetStackTop sets the [Editor.StackTop]
func (t *Editor) SetStackTop(v int) *Editor {
t.StackTop = v
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: "*goki.dev/gi/v2/texteditor.Buf", LocalType: "*Buf", Doc: "textbuf for A", Directives: gti.Directives{}, Tag: "json:\"-\" xml:\"-\""}},
{"BufB", >i.Field{Name: "BufB", Type: "*goki.dev/gi/v2/texteditor.Buf", LocalType: "*Buf", Doc: "textbuf for B", Directives: gti.Directives{}, Tag: "json:\"-\" xml:\"-\""}},
}),
Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
{"Splits", >i.Field{Name: "Splits", Type: "goki.dev/gi/v2/gi.Splits", LocalType: "gi.Splits", Doc: "", Directives: gti.Directives{}, Tag: ""}},
}),
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{}
}
// SetBufA sets the [TwinEditors.BufA]:
// textbuf for A
func (t *TwinEditors) SetBufA(v *Buf) *TwinEditors {
t.BufA = v
return t
}
// SetBufB sets the [TwinEditors.BufB]:
// textbuf for B
func (t *TwinEditors) SetBufB(v *Buf) *TwinEditors {
t.BufB = v
return t
}
// SetTooltip sets the [TwinEditors.Tooltip]
func (t *TwinEditors) SetTooltip(v string) *TwinEditors {
t.Tooltip = v
return t
}
// SetClass sets the [TwinEditors.Class]
func (t *TwinEditors) SetClass(v string) *TwinEditors {
t.Class = v
return t
}
// SetCustomContextMenu sets the [TwinEditors.CustomContextMenu]
func (t *TwinEditors) SetCustomContextMenu(v func(m *gi.Scene)) *TwinEditors {
t.CustomContextMenu = v
return t
}
// SetDim sets the [TwinEditors.Dim]
func (t *TwinEditors) SetDim(v mat32.Dims) *TwinEditors {
t.Dim = v
return t
}