edo

Experimental text editor.
Log | Files | Refs | LICENSE

commit ba2086f9636486bee191fd866652ca19fcb34223
parent 733194ca2420112a75a9a98f167077b10abd21ab
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Mon, 15 Dec 2025 22:58:40 +0100

Always ensure we have at least a line.

This fixes the cases where the file exists but it's empty.

Diffstat:
Medo.c | 8++++----
Mui.h | 11-----------
2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/edo.c b/edo.c @@ -230,10 +230,10 @@ buffer_create(char *fn) { if(buffer_load_file(b)) printf("%s: cannot load file\n", fn); } - else { - /* ensure we have at least a line */ - buffer_insert_line(b, b->lines_tot, line_create(NULL)); - } + + /* ensure we have at least a line */ + if(!b->lines_tot) buffer_insert_line(b, 0, line_create(NULL)); + return b; } diff --git a/ui.h b/ui.h @@ -33,17 +33,6 @@ typedef struct { char text[CELL_POOL_THRESHOLD]; uint32_t pool_idx; } data; - /* - * For smarter backend we can also provide this fields: - * - * idx: index of the bytes into the file buffer - * type: char, tab, newline, eof, ecc. - * - * So the backend may say for example "Oh, it's a tab. Let's ignore the - * rendered cells with spaces and use an beatuful icon instead." - * - * We should also add the style here. - */ uint16_t len; uint16_t width; } Cell;