More vi motions
This commit is contained in:
parent
9fdbdf448f
commit
a8e879289d
1 changed files with 16 additions and 1 deletions
|
|
@ -94,9 +94,18 @@ textEditor = name \
|
||||||
| Word \ nextWordStart state.lines from.row from.col
|
| Word \ nextWordStart state.lines from.row from.col
|
||||||
| BackWord \ prevWordStart state.lines from.row from.col
|
| BackWord \ prevWordStart state.lines from.row from.col
|
||||||
| WholeLine \ { row = from.row, col = 0, linewise = True }
|
| WholeLine \ { row = from.row, col = 0, linewise = True }
|
||||||
|
| StartOfLine \ { row = from.row, col = 0 }
|
||||||
|
| StartOfLineChars \ nextWordStart state.lines from.row 0
|
||||||
| EndOfLine \ (
|
| EndOfLine \ (
|
||||||
line = nth state.cursorRow state.lines ~ unwrapOr "";
|
line = nth state.cursorRow state.lines ~ unwrapOr "";
|
||||||
{ row = state.cursorRow, col = (len line) - 1 })
|
{ row = state.cursorRow, col = (len line) - 1 })
|
||||||
|
| FirstLine \ (
|
||||||
|
line = nth 0 state.lines ~ unwrapOr "";
|
||||||
|
{ row = 0, col = len line - 1 })
|
||||||
|
| LastLine \ (
|
||||||
|
lastRow = len state.lines - 1;
|
||||||
|
line = nth lastRow state.lines ~ unwrapOr "";
|
||||||
|
{ row = lastRow, col = len line - 1 })
|
||||||
| Cursor \ { row = state.cursorRow, col = state.cursorCol + 1 };
|
| Cursor \ { row = state.cursorRow, col = state.cursorCol + 1 };
|
||||||
{ from = from, to = to };
|
{ from = from, to = to };
|
||||||
|
|
||||||
|
|
@ -326,14 +335,20 @@ textEditor = name \
|
||||||
| _ \ { state = state.{ pending = Some Delete }, emit = [] })
|
| _ \ { state = state.{ pending = Some Delete }, emit = [] })
|
||||||
| Key { key = "b" } \ handleMotion BackWord state
|
| Key { key = "b" } \ handleMotion BackWord state
|
||||||
| Key { key = "w" } \ handleMotion Word state
|
| Key { key = "w" } \ handleMotion Word state
|
||||||
|
| Key { key = "0" } \ handleMotion StartOfLine state
|
||||||
|
| Key { key = "^" } \ handleMotion StartOfLineChars state
|
||||||
| Key { key = "$" } \ handleMotion EndOfLine state
|
| Key { key = "$" } \ handleMotion EndOfLine state
|
||||||
|
| Key { key = "g" } \ (state.pending
|
||||||
|
| Some "g" \ handleMotion FirstLine state.{ pending = None }
|
||||||
|
| _ \ { state = state.{ pending = Some "g" }, emit = [] })
|
||||||
|
| Key { key = "G" } \ handleMotion LastLine state
|
||||||
| Key { key = "." } \ (state.lastAction
|
| Key { key = "." } \ (state.lastAction
|
||||||
| None \ { state = state, emit = [] }
|
| None \ { state = state, emit = [] }
|
||||||
| Some action \ applyOperator action.operator action.motion state)
|
| Some action \ applyOperator action.operator action.motion state)
|
||||||
| Key { key = "W", ctrl = True, shift = True } \ write state
|
| Key { key = "W", ctrl = True, shift = True } \ write state
|
||||||
| Key { key = "A", ctrl = True, shift = True } \ apply state
|
| Key { key = "A", ctrl = True, shift = True } \ apply state
|
||||||
# any other key or event
|
# any other key or event
|
||||||
| _ \ { state = state, emit = [] }
|
| _ \ { state = state.{ pending = None }, emit = [] }
|
||||||
),
|
),
|
||||||
|
|
||||||
view = state emit \
|
view = state emit \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue