aboutsummaryrefslogtreecommitdiff
path: root/terminal.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-07-16 06:53:20 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-07-16 06:53:20 +0000
commitde75a2035e63b744b41e7297af71fc0088b33f93 (patch)
tree9025d222575b778fbefaec2ce684dac2f9a9fb2b /terminal.c
parentchangelog: use bemenu instead of fuzzel in pipe-visible example (diff)
parentterm: line-wrap: don't move cursor outside the grid (diff)
Merge branch 'master' into pipe-grid-to-external-tool
Diffstat (limited to 'terminal.c')
-rw-r--r--terminal.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/terminal.c b/terminal.c
index c720aea4..86672f06 100644
--- a/terminal.c
+++ b/terminal.c
@@ -1432,7 +1432,7 @@ term_font_size_adjust(struct terminal *term, double amount)
old_pt_size = term->font_sizes[i].px_size * 72. / dpi;
}
- term->font_sizes[i].pt_size = old_pt_size + amount;
+ term->font_sizes[i].pt_size = fmax(old_pt_size + amount, 0);
term->font_sizes[i].px_size = -1;
}
@@ -2307,12 +2307,15 @@ print_linewrap(struct terminal *term)
}
term->grid->cursor.lcf = false;
- if (term->grid->cursor.point.row == term->scroll_region.end - 1)
+
+ const int row = term->grid->cursor.point.row;
+
+ if (row == term->scroll_region.end - 1)
term_scroll(term, 1);
else {
- assert(term->grid->cursor.point.row < term->scroll_region.end - 1);
- term->grid->cursor.point.row++;
- term->grid->cur_row = grid_row(term->grid, term->grid->cursor.point.row);
+ const int new_row = min(row + 1, term->rows - 1);
+ term->grid->cursor.point.row = new_row;
+ term->grid->cur_row = grid_row(term->grid, new_row);
}
term->grid->cursor.point.col = 0;
@@ -2353,8 +2356,7 @@ print_spacer(struct terminal *term, int col)
void
term_print(struct terminal *term, wchar_t wc, int width)
{
- if (unlikely(width <= 0))
- return;
+ assert(width > 0);
print_linewrap(term);
print_insert(term, width);