be

based editor
git clone git://git.kocotian.pl/be.git
Log | Files | Refs | README | LICENSE

commit d0f97872735eba0cf018055cf39e2eb65d342ce4
parent 4e24bd3632ae1a18226865a0b9dee47225617cf7
Author: kocotian <kocotian@kocotian.pl>
Date:   Mon, 19 Apr 2021 08:40:22 +0200

Lang changes, anonymous buffer fix, better cursor

Diffstat:
Mbe.c | 24++++++++++++------------
Mlang/en_US.h | 17+++++++++++++----
Mlang/pl_PL.h | 17+++++++++++++----
3 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/be.c b/be.c @@ -173,7 +173,7 @@ getws(int *r, int *c) if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0) die("ioctl:"); if (ws.ws_col < 20 || ws.ws_row < 3) - die(lang[0], 20, 3); + die(lang_err[1], 20, 3); *c = ws.ws_col; *r = ws.ws_row; } @@ -243,9 +243,7 @@ appendStatus(String *ab) CURBUF(editor).anonymous ? "*anonymous*" : CURBUF(editor).name, CURBUF(editor).y + 1, - CURBUF(editor).mode == ModeNormal ? - "Normal" : CURBUF(editor).mode == ModeEdit ? - "Edit" : "Error" + lang_modes[CURBUF(editor).mode] ); } abAppend(ab, "\r\033[0m", 6); @@ -320,14 +318,13 @@ static void newBuffer(Buffer *buf) { Buffer init; - String ln = { - "", 0 - }; + String ln; if (buf == NULL) buf = &init; newVector(buf->rows); + ln.data = malloc(ln.len = 0); pushVector(buf->rows, ln); *(buf->path) = *(buf->name) = '\0'; buf->anonymous = 1; @@ -439,7 +436,7 @@ setup(char *filename) else editBuffer(NULL, filename); editor.curbuf = 0; - minibufferPrint(lang[1]); + minibufferPrint(lang_base[2]); } static void @@ -453,7 +450,7 @@ finish(void) static void usage(void) { - die("%s: %s [-hv] [FILE]", lang[2], argv0); + die("%s: %s [-hLv] [FILE]", lang_err[0], argv0); } /* editor functions */ @@ -519,8 +516,8 @@ cursormove(const Arg *arg) } else minibufferPrint("Already on top"); break; - case 3: /* up */ - if (CURBUF(editor).x < (signed)CURBUF(editor).rows.data[CURBUF(editor).y].len - 1) + case 3: /* right */ + if (CURBUF(editor).x < (signed)CURBUF(editor).rows.data[CURBUF(editor).y].len) ++(CURBUF(editor).x); else minibufferPrint("Already on end of line"); @@ -539,7 +536,7 @@ static void ending(const Arg *arg) { (void)arg; - CURBUF(editor).x = (signed)CURBUF(editor).rows.data[CURBUF(editor).y].len - 1; + CURBUF(editor).x = (signed)CURBUF(editor).rows.data[CURBUF(editor).y].len; } static void @@ -607,6 +604,9 @@ main(int argc, char *argv[]) case 'h': default: /* fallthrough */ usage(); break; + case 'L': + die("%s, %s", lang_base[0], lang_base[1]); + break; case 'v': die("be-" VERSION); break; diff --git a/lang/en_US.h b/lang/en_US.h @@ -1,5 +1,14 @@ -static char *lang[] = { - [0] = "screen is too small (min. %dx%d)", - [1] = "welcome to be, version " VERSION, - [2] = "usage", +static char +*lang_base[] = { + [0] = "en_US", + [1] = "English (US)", + [2] = "welcome to be, version " VERSION, +}, +*lang_modes[] = { + [ModeNormal] = "Normal", + [ModeEdit] = "Edit", +}, +*lang_err[] = { + [0] = "usage", + [1] = "screen is too small (min. %dx%d)", }; diff --git a/lang/pl_PL.h b/lang/pl_PL.h @@ -1,5 +1,14 @@ -static char *lang[] = { - [0] = "terminal jest zbyt mały (min. %dx%d)", - [1] = "witamy w be, wersja " VERSION, - [2] = "użycie", +static char +*lang_base[] = { + [0] = "pl_PL", + [1] = "Polski (Polska)", + [2] = "witamy w be, wersja " VERSION, +}, +*lang_modes[] = { + [ModeNormal] = "Normalny", + [ModeEdit] = "Edycja", +}, +*lang_err[] = { + [0] = "użycie", + [1] = "terminal jest zbyt mały (min. %dx%d)", };