VI Worsened, a lightweight and fun VI clone.
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 mingw-w64-x86_64-ncurses
pacman -S mingw-w64-x86_64-ncurses
mingw32-make build
j
Cursor downk
Cursor uph
Cursor leftl
Cursor right0
Cursor to the beginning of the line$
Cursor to the end of the linei
Insert beforeI
Insert at the beginning of the linea
Insert afterA
Insert at the end of the lineo
Append line then insertO
Prepend line then insertdd
Delete line under the cursorgg
Go to the first line of the fileG
Go the last line of the fileu
Undor
Redo (Unstable):q
quit:w
save:wq
save then quitFeel free to contribute! :)
buffer
update_state(st)
and render_update(st)
selectors
in redux, update_state(state_t *st)
will update all thebuffer
state.render_update(state_t *st)
will actually render everything on the screen according toupdate_state()
.Viw’s undo & redo functionality is based on the state machine replication principle
history stack
and redo stack
).history stack
.undo
:history stack
and the push the result onto redo stack
.history stack
redo
:redo stack
and apply the command immediately onto the current buffer.redo stack
when a command gets pushed to the history stack
by the user.See https://github.com/lpan/viw/blob/master/src/controller.c#L152 for more details
Our main state
object has two children states, namely buffer
and 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.
buffer
and/or screen
. Those statesbuffer.h