VI Worsened, a lightweight and fun VI clone. Inspired by the 6-domino-cascade from the React world.
# Fedora sudo dnf install ncurses-devel # Debian/Ubuntu sudo apt-get install libncurses5-dev
git clone https://github.com/lpan/viw cd viw/ make build ./viw [filename]
Using mingw compiler on Windows, you need to install
pacman -S mingw-w64-x86_64-ncurses mingw32-make build
0Cursor to the beginning of the line
$Cursor to the end of the line
IInsert at the beginning of the line
AInsert at the end of the line
oAppend line then insert
OPrepend line then insert
ddDelete line under the cursor
ggGo to the first line of the file
GGo the last line of the file
:wqsave then quit
Feel free to contribute! :)
update_state(state_t *st)will update all the computed properties (such as cursor position, rows to be displayed on the screen, etc) according to the new mutated
render_update(state_t *st)will actually render everything on the screen according to the result from
Viw's undo & redo functionality is based on the state machine replication principle
history stackand the push the result onto
history stackon top of it.
redo stackand apply the command immediately onto the current buffer.
redo stackwhen a command gets pushed to the
history stackby the user.
See https://github.com/lpan/viw/blob/master/src/controller.c#L152 for more details
state object has two children states, namely
screen. This seperation
makes it easier to perform unit tests against the
buffer. It also facilitates the migration
to a different rendering library in the future.
screen. Those states include cursor positions, aount of space reserved for line numbers, etc.