GetCursorUpPosition return the relative cursor position (character index) where we would be if the user pressed the arrow-up button.
(count int, preferredColumn int)
| 344 | // GetCursorUpPosition return the relative cursor position (character index) where we would be |
| 345 | // if the user pressed the arrow-up button. |
| 346 | func (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. |