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

Method renderCursor

texteditor/cursor.go:86–116  ·  view source on GitHub ↗

renderCursor renders the cursor on or off, as a sprite that is either on or off

(on bool)

Source from the content-addressed store, hash-verified

84
85// renderCursor renders the cursor on or off, as a sprite that is either on or off
86func (ed *Editor) renderCursor(on bool) {
87 if ed == nil || ed.This == nil {
88 return
89 }
90 if !on {
91 if ed.Scene == nil {
92 return
93 }
94 ms := ed.Scene.Stage.Main
95 if ms == nil {
96 return
97 }
98 spnm := ed.cursorSpriteName()
99 ms.Sprites.InactivateSprite(spnm)
100 return
101 }
102 if !ed.IsVisible() {
103 return
104 }
105 if ed.renders == nil {
106 return
107 }
108 ed.cursorMu.Lock()
109 defer ed.cursorMu.Unlock()
110
111 sp := ed.cursorSprite(on)
112 if sp == nil {
113 return
114 }
115 sp.Geom.Pos = ed.charStartPos(ed.CursorPos).ToPointFloor()
116}
117
118// cursorSpriteName returns the name of the cursor sprite
119func (ed *Editor) cursorSpriteName() string {

Callers 15

SetCursorShowMethod · 0.95
CursorToHistoryPrevMethod · 0.95
CursorToHistoryNextMethod · 0.95
cursorPageDownMethod · 0.95
cursorPageUpMethod · 0.95
cursorStartLineMethod · 0.95
CursorStartDocMethod · 0.95
cursorEndLineMethod · 0.95
cursorEndDocMethod · 0.95
cursorBackspaceMethod · 0.95
cursorBackspaceWordMethod · 0.95
keyInputMethod · 0.95

Calls 8

cursorSpriteNameMethod · 0.95
cursorSpriteMethod · 0.95
charStartPosMethod · 0.95
InactivateSpriteMethod · 0.80
ToPointFloorMethod · 0.80
IsVisibleMethod · 0.65
LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected