aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-02 19:43:49 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-02 19:43:49 +0000
commitdd4647e9ff792c93e596af87b9ff762e5d4580b4 (patch)
tree50452e43e4b08a8239ea36265382d6c1beddd2b7
parentterm: if the damage list gets too long, replace with a full redraw (diff)
term: simplify horizontal cursor movement
Since horizontal cursor movement is clamped to the current line, we can calculate the new linear cursor without any expensive multiplications and/or divisions.
-rw-r--r--terminal.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/terminal.c b/terminal.c
index 2aac7f6e..f11ddad6 100644
--- a/terminal.c
+++ b/terminal.c
@@ -175,14 +175,18 @@ void
term_cursor_left(struct terminal *term, int count)
{
int move_amount = min(term->cursor.col, count);
- term_cursor_to(term, term->cursor.row, term->cursor.col - move_amount);
+ term->cursor.linear -= move_amount;
+ term->cursor.col -= move_amount;
+ term->print_needs_wrap = false;
}
void
term_cursor_right(struct terminal *term, int count)
{
int move_amount = min(term->cols - term->cursor.col - 1, count);
- term_cursor_to(term, term->cursor.row, term->cursor.col + move_amount);
+ term->cursor.linear += move_amount;
+ term->cursor.col += move_amount;
+ term->print_needs_wrap = false;
}
void