MCPcopy Index your code
hub / github.com/c-bata/go-prompt / GetCursorUpPosition

Method GetCursorUpPosition

document.go:346–359  ·  view source on GitHub ↗

GetCursorUpPosition return the relative cursor position (character index) where we would be if the user pressed the arrow-up button.

(count int, preferredColumn int)

Source from the content-addressed store, hash-verified

344// GetCursorUpPosition return the relative cursor position (character index) where we would be
345// if the user pressed the arrow-up button.
346func (d *Document) GetCursorUpPosition(count int, preferredColumn int) int {
347 var col int
348 if preferredColumn == -1 { // -1 means nil
349 col = d.CursorPositionCol()
350 } else {
351 col = preferredColumn
352 }
353
354 row := d.CursorPositionRow() - count
355 if row < 0 {
356 row = 0
357 }
358 return d.TranslateRowColToIndex(row, col) - d.cursorPosition
359}
360
361// GetCursorDownPosition return the relative cursor position (character index) where we would be if the
362// user pressed the arrow-down button.

Callers 2

CursorUpMethod · 0.80

Calls 3

CursorPositionColMethod · 0.95
CursorPositionRowMethod · 0.95

Tested by 1