-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
To make implementation easier, the different modes in Sapling are implemented as a state machine (technically a DFA). So each 'mode' should have a struct which implements editor::state::State (like editor::normal_mode::State).
The most useful part of this trait is the 'transition function', which is run every time the user presses a key. It also returns Box<dyn state::State>, which allows for state transitions on key presses (i.e. if the user presses : in normal mode, it should return the default command mode state to enter command mode).
So implementing command mode basically boils down to the following:
- Create a new
Statefor command mode (would make sense to put it ineditor/command_mode.rs). - Add an extra keybinding for
:in normal mode, which switches the editor into command mode (see quitting the editor withqfor how to do this). - Move
wandqfrom insert mode into command mode, and if you want you can also add a command to write the.dotcode for theDagto either the log or a file.
If you want more pointers, then just ask 😁 - the state transition code is quite unintuitive.
stokhos
Metadata
Metadata
Assignees
Labels
No labels