From 5be2c53d8c9e268d55ff1c63070ad2fcc343a8bb Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 8 Apr 2021 12:58:47 +0200 Subject: term/vt: only do reverse-wrapping (‘bw’) on cub1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Foot currently does reverse-wrapping (‘auto_left_margin’, or ’bw’) on everything that calls ‘term_cursor_left()’. This is wrong; it should only be done for cub1. From man terminfo: auto_left_margin | bw | bw | cub1 wraps from column 0 to last column This patch moves the reverse-wrapping logic from term_cursor_left() to the handling of BS (backspace). Closes #441 --- vt.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'vt.c') diff --git a/vt.c b/vt.c index af4691ea..d3523efd 100644 --- a/vt.c +++ b/vt.c @@ -142,8 +142,21 @@ action_execute(struct terminal *term, uint8_t c) #else if (term->grid->cursor.lcf) term->grid->cursor.lcf = false; - else - term_cursor_left(term, 1); + else { + /* Reverse wrap */ + if (unlikely(term->grid->cursor.point.col == 0) && + likely(term->reverse_wrap && term->auto_margin)) + { + if (term->grid->cursor.point.row <= term->scroll_region.start) { + /* Don’t wrap past, or inside, the scrolling region(?) */ + } else + term_cursor_to( + term, + term->grid->cursor.point.row - 1, + term->cols - 1); + } else + term_cursor_left(term, 1); + } #endif break; -- cgit v1.3