kilo

Kilo: minimal text editor written in C
git clone git://git.dimitrijedobrota.com/kilo.git
Log | Files | Refs

commit 7b402b17b4b1e56094ab2acd4f950d4c9296d3ae
parent 40afadb33793d415717d0e7910863aba7242c148
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Sun,  9 Apr 2023 19:52:41 +0200

Soft Tabs

Diffstat:
Mkilo.c | 11+++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/kilo.c b/kilo.c @@ -49,6 +49,7 @@ int numberOfDigits(int n) { #define KILO_VERSION "0.0.1" #define KILO_TAB_STOP 8 +#define KILO_TAP_SOFT 1 #define KILO_QUIT_TIMES 3 #define CTRL_KEY(k) ((k)&0x1f) @@ -636,8 +637,14 @@ void editorRowDelChar(erow *row, int at) { void editorInsertChar(int c) { if (E.cy == E.numrows) { editorInsertRow(E.numrows, "", 0); } - editorRowInsertChar(&E.row[E.cy], E.cx, c); - E.cx++; + + if (KILO_TAP_SOFT && c == '\t') { + for (int i = 0; i < KILO_TAB_STOP; i++) + editorRowInsertChar(&E.row[E.cy], E.cx++, ' '); + return; + } + + editorRowInsertChar(&E.row[E.cy], E.cx++, c); } void editorInsertNewline() {