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

Method cursorDown

texteditor/nav.go:263–302  ·  view source on GitHub ↗

cursorDown moves the cursor down line(s)

(steps int)

Source from the content-addressed store, hash-verified

261
262// cursorDown moves the cursor down line(s)
263func (ed *Editor) cursorDown(steps int) {
264 ed.validateCursor()
265 org := ed.CursorPos
266 pos := ed.CursorPos
267 for i := 0; i < steps; i++ {
268 gotwrap := false
269 if wln := ed.wrappedLines(pos.Ln); wln > 1 {
270 si, ri, _ := ed.wrappedLineNumber(pos)
271 if si < wln-1 {
272 si++
273 mxlen := min(len(ed.renders[pos.Ln].Spans[si].Text), ed.cursorColumn)
274 if ed.cursorColumn < mxlen {
275 ri = ed.cursorColumn
276 } else {
277 ri = mxlen
278 }
279 nwc, _ := ed.renders[pos.Ln].SpanPosToRuneIndex(si, ri)
280 pos.Ch = nwc
281 gotwrap = true
282
283 }
284 }
285 if !gotwrap {
286 pos.Ln++
287 if pos.Ln >= ed.NumLines {
288 pos.Ln = ed.NumLines - 1
289 break
290 }
291 mxlen := min(ed.Buffer.LineLen(pos.Ln), ed.cursorColumn)
292 if ed.cursorColumn < mxlen {
293 pos.Ch = ed.cursorColumn
294 } else {
295 pos.Ch = mxlen
296 }
297 }
298 }
299 ed.SetCursorShow(pos)
300 ed.cursorSelect(org)
301 ed.NeedsRender()
302}
303
304// cursorPageDown moves the cursor down page(s), where a page is defined abcdef
305// dynamically as just moving the cursor off the screen

Callers 1

keyInputMethod · 0.95

Calls 8

validateCursorMethod · 0.95
wrappedLinesMethod · 0.95
wrappedLineNumberMethod · 0.95
SetCursorShowMethod · 0.95
cursorSelectMethod · 0.95
SpanPosToRuneIndexMethod · 0.80
LineLenMethod · 0.80
NeedsRenderMethod · 0.80

Tested by

no test coverage detected