aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-12-25 18:12:51 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-12-26 11:39:34 +0000
commit39bb6be8bfb3700947b21cbd3d466de755368b9b (patch)
tree496df5a54af0af23e9781503e3a50611ea39b6c2
parentMerge branch 'cell-colors-use-index' (diff)
term_erase(): replace coord-typed arguments with regular ints
-rw-r--r--csi.c68
-rw-r--r--terminal.c29
-rw-r--r--terminal.h4
3 files changed, 52 insertions, 49 deletions
diff --git a/csi.c b/csi.c
index 858befba..e05d95e2 100644
--- a/csi.c
+++ b/csi.c
@@ -339,10 +339,7 @@ decset_decrst(struct terminal *term, unsigned param, bool enable)
if (enable)
LOG_WARN("unimplemented: 132 column mode (DECCOLM)");
- term_erase(
- term,
- &(struct coord){0, 0},
- &(struct coord){term->cols - 1, term->rows - 1});
+ term_erase(term, 0, 0, term->rows - 1, term->cols - 1);
term_cursor_home(term);
break;
@@ -512,10 +509,7 @@ decset_decrst(struct terminal *term, unsigned param, bool enable)
min(term->normal.cursor.point.col, term->cols - 1));
tll_free(term->normal.scroll_damage);
- term_erase(
- term,
- &(struct coord){0, 0},
- &(struct coord){term->cols - 1, term->rows - 1});
+ term_erase(term, 0, 0, term->rows - 1, term->cols - 1);
}
else if (!enable && term->grid == &term->alt) {
@@ -885,27 +879,28 @@ csi_dispatch(struct terminal *term, uint8_t final)
int param = vt_param_get(term, 0, 0);
switch (param) {
- case 0:
+ case 0: {
/* From cursor to end of screen */
+ const struct coord *cursor = &term->grid->cursor.point;
term_erase(
term,
- &term->grid->cursor.point,
- &(struct coord){term->cols - 1, term->rows - 1});
+ cursor->row, cursor->col,
+ term->rows - 1, term->cols - 1);
term->grid->cursor.lcf = false;
break;
+ }
- case 1:
+ case 1: {
/* From start of screen to cursor */
- term_erase(term, &(struct coord){0, 0}, &term->grid->cursor.point);
+ const struct coord *cursor = &term->grid->cursor.point;
+ term_erase(term, 0, 0, cursor->row, cursor->col);
term->grid->cursor.lcf = false;
break;
+ }
case 2:
/* Erase entire screen */
- term_erase(
- term,
- &(struct coord){0, 0},
- &(struct coord){term->cols - 1, term->rows - 1});
+ term_erase(term, 0, 0, term->rows - 1, term->cols - 1);
term->grid->cursor.lcf = false;
break;
@@ -927,30 +922,32 @@ csi_dispatch(struct terminal *term, uint8_t final)
int param = vt_param_get(term, 0, 0);
switch (param) {
- case 0:
+ case 0: {
/* From cursor to end of line */
+ const struct coord *cursor = &term->grid->cursor.point;
term_erase(
term,
- &term->grid->cursor.point,
- &(struct coord){term->cols - 1, term->grid->cursor.point.row});
+ cursor->row, cursor->col,
+ cursor->row, term->cols - 1);
term->grid->cursor.lcf = false;
break;
+ }
- case 1:
+ case 1: {
/* From start of line to cursor */
- term_erase(
- term, &(struct coord){0, term->grid->cursor.point.row}, &term->grid->cursor.point);
+ const struct coord *cursor = &term->grid->cursor.point;
+ term_erase(term, cursor->row, 0, cursor->row, cursor->col);
term->grid->cursor.lcf = false;
break;
+ }
- case 2:
+ case 2: {
/* Entire line */
- term_erase(
- term,
- &(struct coord){0, term->grid->cursor.point.row},
- &(struct coord){term->cols - 1, term->grid->cursor.point.row});
+ const struct coord *cursor = &term->grid->cursor.point;
+ term_erase(term, cursor->row, 0, cursor->row, term->cols - 1);
term->grid->cursor.lcf = false;
break;
+ }
default:
UNHANDLED();
@@ -1020,10 +1017,11 @@ csi_dispatch(struct terminal *term, uint8_t final)
term->grid->cur_row->dirty = true;
/* Erase the remainder of the line */
+ const struct coord *cursor = &term->grid->cursor.point;
term_erase(
term,
- &(struct coord){term->grid->cursor.point.col + remaining, term->grid->cursor.point.row},
- &(struct coord){term->cols - 1, term->grid->cursor.point.row});
+ cursor->row, cursor->col + remaining,
+ cursor->row, term->cols - 1);
term->grid->cursor.lcf = false;
break;
}
@@ -1047,10 +1045,11 @@ csi_dispatch(struct terminal *term, uint8_t final)
term->grid->cur_row->dirty = true;
/* Erase (insert space characters) */
+ const struct coord *cursor = &term->grid->cursor.point;
term_erase(
term,
- &term->grid->cursor.point,
- &(struct coord){term->grid->cursor.point.col + count - 1, term->grid->cursor.point.row});
+ cursor->row, cursor->col,
+ cursor->row, cursor->col + count - 1);
term->grid->cursor.lcf = false;
break;
}
@@ -1074,10 +1073,11 @@ csi_dispatch(struct terminal *term, uint8_t final)
int count = min(
vt_param_get(term, 0, 1), term->cols - term->grid->cursor.point.col);
+ const struct coord *cursor = &term->grid->cursor.point;
term_erase(
term,
- &term->grid->cursor.point,
- &(struct coord){term->grid->cursor.point.col + count - 1, term->grid->cursor.point.row});
+ cursor->row, cursor->col,
+ cursor->row, cursor->col + count - 1);
term->grid->cursor.lcf = false;
break;
}
diff --git a/terminal.c b/terminal.c
index 73f003d6..fd8ff4ae 100644
--- a/terminal.c
+++ b/terminal.c
@@ -2108,31 +2108,32 @@ term_damage_scroll(struct terminal *term, enum damage_type damage_type,
}
void
-term_erase(struct terminal *term, const struct coord *start, const struct coord *end)
+term_erase(struct terminal *term, int start_row, int start_col,
+ int end_row, int end_col)
{
- xassert(start->row <= end->row);
- xassert(start->col <= end->col || start->row < end->row);
+ xassert(start_row <= end_row);
+ xassert(start_col <= end_col || start_row < end_row);
- if (start->row == end->row) {
- struct row *row = grid_row(term->grid, start->row);
- erase_cell_range(term, row, start->col, end->col);
- sixel_overwrite_by_row(term, start->row, start->col, end->col - start->col + 1);
+ if (start_row == end_row) {
+ struct row *row = grid_row(term->grid, start_row);
+ erase_cell_range(term, row, start_col, end_col);
+ sixel_overwrite_by_row(term, start_row, start_col, end_col - start_col + 1);
return;
}
- xassert(end->row > start->row);
+ xassert(end_row > start_row);
erase_cell_range(
- term, grid_row(term->grid, start->row), start->col, term->cols - 1);
- sixel_overwrite_by_row(term, start->row, start->col, term->cols - start->col);
+ term, grid_row(term->grid, start_row), start_col, term->cols - 1);
+ sixel_overwrite_by_row(term, start_row, start_col, term->cols - start_col);
- for (int r = start->row + 1; r < end->row; r++)
+ for (int r = start_row + 1; r < end_row; r++)
erase_line(term, grid_row(term->grid, r));
sixel_overwrite_by_rectangle(
- term, start->row + 1, 0, end->row - start->row, term->cols);
+ term, start_row + 1, 0, end_row - start_row, term->cols);
- erase_cell_range(term, grid_row(term->grid, end->row), 0, end->col);
- sixel_overwrite_by_row(term, end->row, 0, end->col + 1);
+ erase_cell_range(term, grid_row(term->grid, end_row), 0, end_col);
+ sixel_overwrite_by_row(term, end_row, 0, end_col + 1);
}
void
diff --git a/terminal.h b/terminal.h
index 09b04614..38314fa4 100644
--- a/terminal.h
+++ b/terminal.h
@@ -713,7 +713,9 @@ void term_damage_scroll(
struct scroll_region region, int lines);
void term_erase(
- struct terminal *term, const struct coord *start, const struct coord *end);
+ struct terminal *term,
+ int start_row, int start_col,
+ int end_row, int end_col);
void term_erase_scrollback(struct terminal *term);
int term_row_rel_to_abs(const struct terminal *term, int row);