jim

Simple, lightweight, modal, vim-inspired text editor
git clone git://git.janpasierb.com/jim.git
Log | Files | Refs | README | LICENSE

commit 668afb124c43e5bbe3a72918b0a36485d1ed2241
parent f3c336684ccfab9b657cf999ba0dde2494f0dfa0
Author: Jan P. Pasierb <me@janpasierb.com>
Date:   Sun, 17 Jul 2022 20:52:47 +0100

Bumping version

Added debug step to makefile

Added character replacement

Diffstat:
MMakefile | 7+++++--
Minput.c | 14+++++++++-----
Mjim.h | 2++
Mmain.c | 1+
4 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile @@ -6,7 +6,7 @@ MANPREFIX = $(PREFIX)/share/man OBJ = main.o appbuf.o editor.o file.o find.o input.o output.o row.o syntax.o term.o SRC = main.c appbuf.c editor.c file.c find.c input.c output.c row.c syntax.c term.c HDR = jim.h appbuf.h editor.h file.h find.h input.h output.h row.h syntax.h term.h -VERSION = 0.0.1 +VERSION = 0.0.2 all: jim @@ -20,8 +20,11 @@ install: jim rm -f $(DESTDIR)$(MANPREFIX)/man1/jim.1 chmod 644 $(DESTDIR)$(MANPREFIX)/man1/jim.1.gz +debug: CFLAGS += -g +debug: jim + jim: main.o appbuf.o editor.o file.o find.o input.o output.o row.o syntax.o term.o - $(CC) $(LDFLAGS) -o jim $(OBJ) + $(CC) $(CFLAGS) -o jim $(OBJ) main.o: main.c jim.h output.h term.h file.h input.h output.h appbuf.o: appbuf.c appbuf.h diff --git a/input.c b/input.c @@ -89,9 +89,8 @@ char* editorPrompt(char* prompt, void (*callback)(char*, int)) { } } -int editorMoveCursor(char key) { +void editorMoveCursor(char key) { erow* row = (E.cy >= E.numrows) ? NULL : &E.row[E.cy]; - int ret = 0; switch(key) { case LEFT: @@ -121,8 +120,6 @@ int editorMoveCursor(char key) { if(E.cx >= rowlen) { E.cx = rowlen ? rowlen - 1 : 0; } - - return ret; } void editorProcessKeypress() { @@ -164,7 +161,11 @@ void editorProcessKeypress() { if(E.clusterkey != '\0') { processClusterKey(c); - } else { + } else if (E.isreplace) { + E.isreplace = 0; + editorDelChar(); + editorInsertChar(c); + } else { switch(c) { case QUIT: if(E.dirty) { @@ -224,6 +225,9 @@ void editorProcessKeypress() { if(E.cx == E.row[E.cy].size) E.cx--; break; + case REPLACE: + E.isreplace = 1; + break; case SAVE: if(editorSave()) editorSetDefaultStatusMessage(); diff --git a/jim.h b/jim.h @@ -20,6 +20,7 @@ enum editorKey { ESCAPE = '\x1b', BACKSPACE = '\x7f', RETURN = '\r', + REPLACE = 'r', QUIT = 'q', NEWLINE_BELOW = 'o', NEWLINE_ABOVE = 'O', @@ -84,6 +85,7 @@ struct editorConfig { int dirty; int isr; int isbold; + int isreplace; erow* row; char* filename; char statusmsg[80]; diff --git a/main.c b/main.c @@ -20,6 +20,7 @@ void initEditor() { E.dirty = 0; E.isr = 1; E.isbold = 0; + E.isreplace = 0; E.cx = 0; E.cy = 0; E.rx = 0;