dot in textEditor to repeat last action
This commit is contained in:
parent
717ec2048b
commit
0d43dc0128
1 changed files with 7 additions and 2 deletions
|
|
@ -109,12 +109,13 @@ textEditor = name \
|
|||
|
||||
applyOperator = operator motion state \
|
||||
target = resolveMotion motion state;
|
||||
action = { operator = operator, motion = motion };
|
||||
stateSnapshot = { lines = state.lines, cursorRow = state.cursorRow, cursorCol = state.cursorCol };
|
||||
newState = operator
|
||||
| Delete \ (motion
|
||||
| WholeLine \ deleteLine state
|
||||
| _ \ { state = deleteRange state target.from target.to, emit = [] });
|
||||
{ state = clampCursor newState.state.{ undoStack = [stateSnapshot, ...state.undoStack], pending = None }, emit = newState.emit };
|
||||
{ state = clampCursor newState.state.{ undoStack = [stateSnapshot, ...state.undoStack], pending = None, lastAction = Some action }, emit = newState.emit };
|
||||
|
||||
moveCursor = motion state \
|
||||
state.{ cursorCol = motion.to.col, cursorRow = motion.to.row };
|
||||
|
|
@ -276,7 +277,8 @@ textEditor = name \
|
|||
undoStack = [],
|
||||
redoStack = [],
|
||||
mode = Normal, # Normal | Insert | Visual
|
||||
pending = None # Some "d" | Some "g" | etc.
|
||||
pending = None, # Some "d" | Some "g" | etc.
|
||||
lastAction = None, # Some { operator, motion }
|
||||
},
|
||||
|
||||
update = state event \ state.mode
|
||||
|
|
@ -318,6 +320,9 @@ textEditor = name \
|
|||
| Key { key = "w" } \ (state.pending
|
||||
| None \ withScroll { state = moveCursor (resolveMotion Word state) state, emit = [] }
|
||||
| Some Delete \ withScroll (applyOperator Delete Word state))
|
||||
| Key { key = "." } \ (state.lastAction
|
||||
| None \ { state = state, emit = [] }
|
||||
| Some action \ applyOperator action.operator action.motion state)
|
||||
| Key { key = "W", ctrl = True, shift = True } \ write state
|
||||
| Key { key = "A", ctrl = True, shift = True } \ apply state
|
||||
# any other key or event
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue