CursorToHistoryPrev moves cursor to previous position on history list -- returns true if moved
()
| 120 | // CursorToHistoryPrev moves cursor to previous position on history list -- |
| 121 | // returns true if moved |
| 122 | func (ed *Editor) CursorToHistoryPrev() bool { |
| 123 | if ed.NumLines == 0 || ed.Buffer == nil { |
| 124 | ed.CursorPos = lexer.PosZero |
| 125 | return false |
| 126 | } |
| 127 | sz := len(ed.Buffer.posHistory) |
| 128 | if sz == 0 { |
| 129 | return false |
| 130 | } |
| 131 | ed.posHistoryIndex-- |
| 132 | if ed.posHistoryIndex < 0 { |
| 133 | ed.posHistoryIndex = 0 |
| 134 | return false |
| 135 | } |
| 136 | ed.posHistoryIndex = min(sz-1, ed.posHistoryIndex) |
| 137 | pos := ed.Buffer.posHistory[ed.posHistoryIndex] |
| 138 | ed.CursorPos = ed.Buffer.ValidPos(pos) |
| 139 | ed.cursorMovedEvent() |
| 140 | ed.scrollCursorToCenterIfHidden() |
| 141 | ed.renderCursor(true) |
| 142 | return true |
| 143 | } |
| 144 | |
| 145 | // CursorToHistoryNext moves cursor to previous position on history list -- |
| 146 | // returns true if moved |
no test coverage detected