MCPcopy Create free account
hub / github.com/cogentcore/core / Init

Method Init

texteditor/editor.go:216–267  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

214}
215
216func (ed *Editor) Init() {
217 ed.Frame.Init()
218 ed.AddContextMenu(ed.contextMenu)
219 ed.SetBuffer(NewBuffer())
220 ed.Styler(func(s *styles.Style) {
221 s.SetAbilities(true, abilities.Activatable, abilities.Focusable, abilities.Hoverable, abilities.Slideable, abilities.DoubleClickable, abilities.TripleClickable)
222 ed.CursorWidth.Dp(2)
223 ed.LineNumberColor = colors.Uniform(colors.Transparent)
224 ed.SelectColor = colors.Scheme.Select.Container
225 ed.HighlightColor = colors.Scheme.Warn.Container
226 ed.CursorColor = colors.Scheme.Primary.Base
227
228 s.VirtualKeyboard = styles.KeyboardMultiLine
229 s.Cursor = cursors.Text
230 if core.SystemSettings.Editor.WordWrap {
231 s.Text.WhiteSpace = styles.WhiteSpacePreWrap
232 } else {
233 s.Text.WhiteSpace = styles.WhiteSpacePre
234 }
235 s.SetMono(true)
236 s.Grow.Set(1, 0)
237 s.Overflow.Set(styles.OverflowAuto) // absorbs all
238 s.Border.Radius = styles.BorderRadiusLarge
239 s.Margin.Zero()
240 s.Padding.Set(units.Em(0.5))
241 s.Align.Content = styles.Start
242 s.Align.Items = styles.Start
243 s.Text.Align = styles.Start
244 s.Text.AlignV = styles.Start
245 s.Text.TabSize = core.SystemSettings.Editor.TabSize
246 s.Color = colors.Scheme.OnSurface
247 s.Min.X.Em(10)
248
249 s.MaxBorder.Width.Set(units.Dp(2))
250 s.Background = colors.Scheme.SurfaceContainerLow
251 // note: a blank background does NOT work for depth color rendering
252 if s.Is(states.Focused) {
253 s.StateLayer = 0
254 s.Border.Width.Set(units.Dp(2))
255 }
256 })
257
258 ed.handleKeyChord()
259 ed.handleMouse()
260 ed.handleLinkCursor()
261 ed.handleFocus()
262 ed.OnClose(func(e events.Event) {
263 ed.editDone()
264 })
265
266 ed.Updater(ed.NeedsLayout)
267}
268
269func (ed *Editor) Destroy() {
270 ed.stopCursor()

Callers

nothing calls this directly

Calls 15

SetBufferMethod · 0.95
handleKeyChordMethod · 0.95
handleMouseMethod · 0.95
handleLinkCursorMethod · 0.95
handleFocusMethod · 0.95
editDoneMethod · 0.95
UniformFunction · 0.92
EmFunction · 0.92
DpFunction · 0.92
AddContextMenuMethod · 0.80
StylerMethod · 0.80
SetAbilitiesMethod · 0.80

Tested by

no test coverage detected