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

Method setCursor

texteditor/nav.go:55–77  ·  view source on GitHub ↗

setCursor sets a new cursor position, enforcing it in range. This is the main final pathway for all cursor movement.

(pos lexer.Pos)

Source from the content-addressed store, hash-verified

53// setCursor sets a new cursor position, enforcing it in range.
54// This is the main final pathway for all cursor movement.
55func (ed *Editor) setCursor(pos lexer.Pos) {
56 if ed.NumLines == 0 || ed.Buffer == nil {
57 ed.CursorPos = lexer.PosZero
58 return
59 }
60
61 ed.clearScopelights()
62 ed.CursorPos = ed.Buffer.ValidPos(pos)
63 ed.cursorMovedEvent()
64 txt := ed.Buffer.Line(ed.CursorPos.Ln)
65 ch := ed.CursorPos.Ch
66 if ch < len(txt) {
67 r := txt[ch]
68 if r == '{' || r == '}' || r == '(' || r == ')' || r == '[' || r == ']' {
69 tp, found := ed.Buffer.BraceMatch(txt[ch], ed.CursorPos)
70 if found {
71 ed.scopelights = append(ed.scopelights, text.NewRegionPos(ed.CursorPos, lexer.Pos{ed.CursorPos.Ln, ed.CursorPos.Ch + 1}))
72 ed.scopelights = append(ed.scopelights, text.NewRegionPos(tp, lexer.Pos{tp.Ln, tp.Ch + 1}))
73 }
74 }
75 }
76 ed.NeedsRender()
77}
78
79// SetCursorShow sets a new cursor position, enforcing it in range, and shows
80// the cursor (scroll to if hidden, render)

Callers 12

iSearchSelectMatchMethod · 0.95
qReplaceSelectMatchMethod · 0.95
qReplaceReplaceMethod · 0.95
SetCursorShowMethod · 0.95
cursorPageDownMethod · 0.95
cursorPageUpMethod · 0.95
cursorStartLineMethod · 0.95
CursorStartDocMethod · 0.95
cursorEndLineMethod · 0.95
cursorEndDocMethod · 0.95
keyInputMethod · 0.95
setCursorFromMouseMethod · 0.95

Calls 7

clearScopelightsMethod · 0.95
cursorMovedEventMethod · 0.95
NewRegionPosFunction · 0.92
ValidPosMethod · 0.80
BraceMatchMethod · 0.80
NeedsRenderMethod · 0.80
LineMethod · 0.65

Tested by

no test coverage detected