Drying up some code
This commit is contained in:
parent
7e6d79582f
commit
9fdbdf448f
1 changed files with 8 additions and 9 deletions
|
|
@ -266,6 +266,11 @@ textEditor = name \
|
|||
newRow = state.cursorRow + diff;
|
||||
withScroll { state = clampCursor state.{ cursorRow = newRow }, emit = [] });
|
||||
|
||||
handleMotion = motion state \
|
||||
state.pending
|
||||
| None \ withScroll { state = moveCursor (resolveMotion motion state) state, emit = [] }
|
||||
| Some Delete \ withScroll (applyOperator Delete motion state);
|
||||
|
||||
ui.stateful {
|
||||
focusable = True,
|
||||
autoFocus = True,
|
||||
|
|
@ -319,15 +324,9 @@ textEditor = name \
|
|||
| Key { key = "d" } \ (state.pending
|
||||
| Some Delete \ applyOperator Delete WholeLine state
|
||||
| _ \ { state = state.{ pending = Some Delete }, emit = [] })
|
||||
| Key { key = "b" } \ (state.pending
|
||||
| None \ withScroll { state = moveCursor (resolveMotion BackWord state) state, emit = [] }
|
||||
| Some Delete \ withScroll (applyOperator Delete BackWord state))
|
||||
| Key { key = "w" } \ (state.pending
|
||||
| None \ withScroll { state = moveCursor (resolveMotion Word state) state, emit = [] }
|
||||
| Some Delete \ withScroll (applyOperator Delete Word state))
|
||||
| Key { key = "$" } \ (state.pending
|
||||
| None \ withScroll { state = moveCursor (resolveMotion EndOfLine state) state, emit = [] }
|
||||
| Some Delete \ withScroll (applyOperator Delete EndOfLine state))
|
||||
| Key { key = "b" } \ handleMotion BackWord state
|
||||
| Key { key = "w" } \ handleMotion Word state
|
||||
| Key { key = "$" } \ handleMotion EndOfLine state
|
||||
| Key { key = "." } \ (state.lastAction
|
||||
| None \ { state = state, emit = [] }
|
||||
| Some action \ applyOperator action.operator action.motion state)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue