sim

the sim text editor
git clone git://ssnf.xyz/sim
Log | Files | Refs | README

commit 7fb5f9bd6648277484a8d68e2fcc6b9398065cd8
parent 9d4a59227d2c988f7aa21f674e93b530e62444c2
Author: ssnf <ssnf@ssnf.xyz>
Date:   Sat, 21 Aug 2021 20:13:06 +0000

added change() command

Diffstat:
Mconfig.def.h | 2++
Msim.c | 35+++++++++++++++++++++++++++++++++--
2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -22,6 +22,8 @@ Key keys[] = { { 'O', insert , Up }, { 'd', delete }, { 'x', delete , 'x' }, + { 'c', change }, + { 'C', change , 'c' }, { 'E', file_open }, { 'q', file_close, -1 }, { 'S', file_save, -1 }, diff --git a/sim.c b/sim.c @@ -66,6 +66,7 @@ void* emalloc(ulong); void* erealloc(void*, ulong); static void blind_reader(Frame* fr, String* s, Posn p0); static void blind_writer(String* s, Frame* fr, ushort line, ushort offset, ushort top, ushort bot); +static void change(int arg); static void delete(int arg); static void escape(int c); static void init(); @@ -197,6 +198,38 @@ blind_writer(String* s, Frame* fr, ushort line, ushort offset, ushort top, ushor } static void +change(int arg) +{ + if (!arg) + arg = fgetc(stdin); + switch (arg) { + case 'x': + delete('x'); + break; + case 'c': + delete('d'); + insert(Up); + return; + case 'G': + delete('G'); + insert(Down); + return; + case 'g': + delete('g'); + break; + case 'w': + delete('w'); + break; + case 't': + delete('t'); + break; + default: + return; + } + insert(0); +} + +static void delete(int arg) { Posn m, n; @@ -334,8 +367,6 @@ insert(int arg) str_insert(f->s, &s, f->dot.p0); str_zero(&s); break; - default: - break; } for (;;) { win_query(&w);