From 8448296bb3c0fa96f5af5cb7ec563bb0c7e99093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 9 May 2020 11:57:19 +0200 Subject: [PATCH] term: print: line-wrap multi-column characters instead of cutting them in half --- CHANGELOG.md | 2 +- terminal.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c2e7c68..a52f68f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,7 +71,7 @@ * `OSC 12 ?` to return the cursor color, not the cursor's text color. * `OSC 12;#000000` to configure the cursor to use inverted foreground/background colors. - +* Double-width characters line wrapping at end of line. ### Security diff --git a/terminal.c b/terminal.c index 44046f1c..ccc5ca99 100644 --- a/terminal.c +++ b/terminal.c @@ -2284,9 +2284,11 @@ term_disable_app_sync_updates(struct terminal *term) } static inline void -print_linewrap(struct terminal *term) +print_linewrap(struct terminal *term, int width) { - if (likely(!term->grid->cursor.lcf)) { + if (likely(!(term->grid->cursor.lcf || + term->grid->cursor.point.col + width > term->cols))) + { /* Not and end of line */ return; } @@ -2329,7 +2331,7 @@ term_print(struct terminal *term, wchar_t wc, int width) if (unlikely(width <= 0)) return; - print_linewrap(term); + print_linewrap(term, width); print_insert(term, width); sixel_delete_at_cursor(term);