edo

Experimental text editor.
Log | Files | Refs | LICENSE

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

Remove old TUI line drawing code.

Diffstat:
Medo.c | 2+-
Mtui.c | 42+++---------------------------------------
Mui.h | 3+--
3 files changed, 5 insertions(+), 42 deletions(-)

diff --git a/edo.c b/edo.c @@ -423,7 +423,7 @@ draw_view(View *v) { continue; } nc = render(cells, l->buf, l->len, v->col_offset, v->screen_cols); - ui->draw_line_from_cells(ui, 0, y, cells, nc); + ui->draw_line(ui, 0, y, cells, nc); } free(cells); diff --git a/tui.c b/tui.c @@ -43,8 +43,7 @@ int tui_text_width(char *s, int len, int x); void tui_get_window_size(int *rows, int *cols); void tui_exit(void); void tui_move_cursor(int x, int y); -void tui_draw_line(int c, int r, char *txt, int len); -void tui_draw_line_from_cells(UI *ui, int x, int y, Cell *cells, int screen_cols); +void tui_draw_line(UI *ui, int x, int y, Cell *cells, int screen_cols); void tui_draw_symbol(int r, int c, Symbol sym); void tui_init(void); @@ -147,7 +146,8 @@ tui_move_cursor(int c, int r) { ab_printf(&frame, CURPOS, y, x); } -void tui_draw_line_from_cells(UI *ui, int x, int y, Cell *cells, int count) { +void +tui_draw_line(UI *ui, int x, int y, Cell *cells, int count) { assert(x < ws.ws_col && y < ws.ws_row); int w = 0, i; char *txt; @@ -167,41 +167,6 @@ void tui_draw_line_from_cells(UI *ui, int x, int y, Cell *cells, int count) { } void -tui_draw_line(int c, int r, char *txt, int len) { - if(c >= ws.ws_col || r >= ws.ws_row) return; - - int x = c; - int tabstop = 8; - int i = 0; - int cw, clen; - - tui_move_cursor(x < 0 ? 0 : x, r); - while(i < len) { - cw = (txt[i] == '\t' ? tabstop : 1); - - if(x + cw <= 0) - continue; - - if(txt[i] == '\t') { - int spaces = tabstop; - clen = 1; - - if(x < 0) spaces += x; - if(x + cw > ws.ws_col) spaces -= (x + cw - ws.ws_col); - while(spaces--) ab_write(&frame, " ", 1); - } else { - if(x + cw > ws.ws_col) break; - clen = 1; - ab_write(&frame, txt + i, clen); - } - - x += cw; - i += clen; - } - ab_write(&frame, CLEARRIGHT, strlen(CLEARRIGHT)); -} - -void tui_draw_symbol(int c, int r, Symbol sym) { int symch; @@ -262,7 +227,6 @@ UI ui_tui = { .text_width = tui_text_width, .move_cursor = tui_move_cursor, .draw_line = tui_draw_line, - .draw_line_from_cells = tui_draw_line_from_cells, .draw_symbol = tui_draw_symbol, .get_window_size = tui_get_window_size, .next_event = tui_next_event diff --git a/ui.h b/ui.h @@ -58,8 +58,7 @@ struct UI { void (*frame_flush)(void); int (*text_width)(char *s, int len, int x); void (*move_cursor)(int x, int y); - void (*draw_line)(int r, int c, char *txt, int len); - void (*draw_line_from_cells)(UI *ui, int x, int y, Cell *cells, int count); + void (*draw_line)(UI *ui, int x, int y, Cell *cells, int count); void (*draw_symbol)(int r, int c, Symbol sym); void (*get_window_size)(int *rows, int *cols); Event (*next_event)(void);