dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git
Log | Files | Refs | README | LICENSE

commit c15128cf3cae3f4864d90642592990111eb6f7ad
parent 487f1eb46c81714a1252a61f2be45e2fe44f3796
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Fri, 31 Oct 2014 11:18:29 +0100

Rename functions

Diffstat:
vt.c | 65++++++++++++++++++++++++++++++++---------------------------------
1 file changed, 32 insertions(+), 33 deletions(-)

diff --git a/vt.c b/vt.c @@ -518,7 +518,7 @@ static Row *buffer_row_prev(Buffer *b, Row *row) return --row; } -static void clamp_cursor_to_bounds(Vt *t) +static void cursor_clamp(Vt *t) { Buffer *b = t->buffer; Row *lines = t->relposmode ? b->scroll_top : b->lines; @@ -534,22 +534,37 @@ static void clamp_cursor_to_bounds(Vt *t) b->curs_col = b->cols - 1; } -static void save_curs(Vt *t) +static void cursor_line_down(Vt *t) +{ + Buffer *b = t->buffer; + row_set(b->curs_row, b->cols, b->maxcols - b->cols, NULL); + b->curs_row++; + if (b->curs_row < b->scroll_bot) + return; + + vt_noscroll(t); + + b->curs_row = b->scroll_bot - 1; + buffer_scroll(b, 1); + row_set(b->curs_row, 0, b->cols, b); +} + +static void cursor_save(Vt *t) { Buffer *b = t->buffer; b->curs_srow = b->curs_row - b->lines; b->curs_scol = b->curs_col; } -static void restore_curs(Vt *t) +static void cursor_restore(Vt *t) { Buffer *b = t->buffer; b->curs_row = b->lines + b->curs_srow; b->curs_col = b->curs_scol; - clamp_cursor_to_bounds(t); + cursor_clamp(t); } -static void save_attrs(Vt *t) +static void attributes_save(Vt *t) { Buffer *b = t->buffer; b->savattrs = b->curattrs; @@ -558,7 +573,7 @@ static void save_attrs(Vt *t) t->savgraphmode = t->graphmode; } -static void restore_attrs(Vt *t) +static void attributes_restore(Vt *t) { Buffer *b = t->buffer; b->curattrs = b->savattrs; @@ -567,21 +582,6 @@ static void restore_attrs(Vt *t) t->graphmode = t->savgraphmode; } -static void cursor_line_down(Vt *t) -{ - Buffer *b = t->buffer; - row_set(b->curs_row, b->cols, b->maxcols - b->cols, NULL); - b->curs_row++; - if (b->curs_row < b->scroll_bot) - return; - - vt_noscroll(t); - - b->curs_row = b->scroll_bot - 1; - buffer_scroll(b, 1); - row_set(b->curs_row, 0, b->cols, b); -} - static void new_escape_sequence(Vt *t) { t->escaped = true; @@ -705,7 +705,7 @@ static void interpret_csi_ed(Vt *t, int param[], int pcount) Row *row, *start, *end; Buffer *b = t->buffer; - save_attrs(t); + attributes_save(t); b->curattrs = A_NORMAL; b->curfg = b->curbg = -1; @@ -725,7 +725,7 @@ static void interpret_csi_ed(Vt *t, int param[], int pcount) for (row = start; row < end; row++) row_set(row, 0, b->cols, b); - restore_attrs(t); + attributes_restore(t); } /* interprets a 'move cursor' (CUP) escape sequence */ @@ -745,7 +745,7 @@ static void interpret_csi_cup(Vt *t, int param[], int pcount) b->curs_col = param[1] - 1; } - clamp_cursor_to_bounds(t); + cursor_clamp(t); } /* Interpret the 'relative mode' sequences: CUU, CUD, CUF, CUB, CNL, @@ -787,7 +787,7 @@ static void interpret_csi_c(Vt *t, char verb, int param[], int pcount) break; } - clamp_cursor_to_bounds(t); + cursor_clamp(t); } /* Interpret the 'erase line' escape sequence */ @@ -1059,10 +1059,10 @@ static void interpret_csi(Vt *t) interpret_csi_decstbm(t, csiparam, param_count); break; case 's': /* save cursor location */ - save_curs(t); + cursor_save(t); break; case 'u': /* restore cursor location */ - restore_curs(t); + cursor_restore(t); break; case 'n': /* query cursor location */ if (param_count == 1 && csiparam[0] == 6) @@ -1178,12 +1178,12 @@ static void try_interpret_escape_seq(Vt *t) } break; case '7': /* DECSC: save cursor and attributes */ - save_attrs(t); - save_curs(t); + attributes_save(t); + cursor_save(t); goto handled; case '8': /* DECRC: restore cursor and attributes */ - restore_attrs(t); - restore_curs(t); + attributes_restore(t); + cursor_restore(t); goto handled; case 'D': /* IND: index */ interpret_csi_ind(t); @@ -1416,7 +1416,6 @@ void vt_default_colors_set(Vt *t, attr_t attrs, short fg, short bg) t->defbg = bg; } - Vt *vt_create(int rows, int cols, int scroll_size) { Vt *t; @@ -1449,7 +1448,7 @@ void vt_resize(Vt *t, int rows, int cols) vt_noscroll(t); buffer_resize(&t->buffer_normal, rows, cols); buffer_resize(&t->buffer_alternate, rows, cols); - clamp_cursor_to_bounds(t); + cursor_clamp(t); ioctl(t->pty, TIOCSWINSZ, &ws); kill(-t->pid, SIGWINCH); }