edo

Experimental text editor.
Log | Files | Refs | LICENSE

commit d8cce42d9f3e7faa6d2f7079b93f38fa286c1a97
parent 94752f718dc41fb5a54a986d70404a9d34481350
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Mon, 22 Dec 2025 21:03:29 +0100

Call cursor v/h fix in the right order.

Diffstat:
Medo.c | 13++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/edo.c b/edo.c @@ -290,6 +290,7 @@ _view_cursor_hfix(View *v) { void view_cursor_hfix(View *v) { Line *l = v->buf->lines[v->line_num]; + if (v->col_num < 0) v->col_num = 0; if (v->col_num > l->len) v->col_num = l->len; } @@ -298,7 +299,6 @@ void view_cursor_vfix(View *v) { if (v->line_num >= v->buf->lines_tot) v->line_num = v->buf->lines_tot - 1; - if (v->line_num < 0) v->line_num = 0; } @@ -493,9 +493,16 @@ run(void) { else if(ev.key == 'q') running = 0; else if(ev.key == 'D') { buffer_delete_line(vcur->buf, vcur->line_num, 1); - view_cursor_hfix(vcur); + + /* TODO: when called together vfix must + * *always* be called first. We better join + * their code into an ad-hoc function which is + * called after each change to the buffer. + * Otherwise we can call them separately but + * provide a view_cursor_fix() which call them + * both in the right order. */ view_cursor_vfix(vcur); - view_scroll_fix(vcur); + view_cursor_hfix(vcur); } else if(ev.key == 'K') { Line *l = line_create(NULL); buffer_insert_line(vcur->buf, vcur->line_num, l);