aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-11-17 11:13:36 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-11-17 11:13:36 +0000
commit686405b7031736445eeb35206e4a797a8dd78d91 (patch)
treeff2284c38ff145e6c3042415c9b9d2be7eede32f
parentcsi: implement 'CPL' - Cursor Previous Line (diff)
term: new function: term_autowrap()
Adds a linebreak (+ scroll if necessary) if we're in a deferred wrap and auto-margins are enabled. Return true when we wrapped, false otherwise.
-rw-r--r--terminal.c15
-rw-r--r--terminal.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/terminal.c b/terminal.c
index 5511eba5..ae52d7a2 100644
--- a/terminal.c
+++ b/terminal.c
@@ -1192,6 +1192,21 @@ term_reverse_index(struct terminal *term)
term_cursor_up(term, 1);
}
+bool
+term_autowrap(struct terminal *term)
+{
+ if (unlikely(term->cursor.lcf) && term->auto_margin) {
+ if (term->cursor.point.row == term->scroll_region.end - 1) {
+ term_scroll(term, 1);
+ term_cursor_to(term, term->cursor.point.row, 0);
+ } else
+ term_cursor_to(term, term->cursor.point.row + 1, 0);
+
+ return true;
+ } else
+ return false;
+}
+
void
term_reset_view(struct terminal *term)
{
diff --git a/terminal.h b/terminal.h
index f5d7658f..bd12764c 100644
--- a/terminal.h
+++ b/terminal.h
@@ -360,6 +360,7 @@ void term_scroll_reverse_partial(
void term_linefeed(struct terminal *term);
void term_reverse_index(struct terminal *term);
+bool term_autowrap(struct terminal *term);
void term_restore_cursor(struct terminal *term);