From a6e3f19bf797a4f39d500ab785b68a0aeae692ee Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 31 Jan 2017 23:54:40 -0800 Subject: [PATCH] GUACAMOLE-149: Ignore zero-width characters. --- src/terminal/buffer.c | 4 ++++ src/terminal/display.c | 4 ++++ src/terminal/terminal.c | 21 ++++++++++++--------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/terminal/buffer.c b/src/terminal/buffer.c index 95324524..e536d92a 100644 --- a/src/terminal/buffer.c +++ b/src/terminal/buffer.c @@ -182,6 +182,10 @@ void guac_terminal_buffer_set_columns(guac_terminal_buffer* buffer, int row, int i, j; guac_terminal_char* current; + /* Do nothing if glyph is empty */ + if (character->width == 0) + return; + /* Build continuation char (for multicolumn characters) */ guac_terminal_char continuation_char; continuation_char.value = GUAC_CHAR_CONTINUATION; diff --git a/src/terminal/display.c b/src/terminal/display.c index 295bdb57..e671c608 100644 --- a/src/terminal/display.c +++ b/src/terminal/display.c @@ -438,6 +438,10 @@ void guac_terminal_display_set_columns(guac_terminal_display* display, int row, int i; guac_terminal_operation* current; + /* Do nothing if glyph is empty */ + if (character->width == 0) + return; + /* Ignore operations outside display bounds */ if (row < 0 || row >= display->height) return; diff --git a/src/terminal/terminal.c b/src/terminal/terminal.c index 849b7ed7..5c327742 100644 --- a/src/terminal/terminal.c +++ b/src/terminal/terminal.c @@ -657,18 +657,21 @@ char* guac_terminal_prompt(guac_terminal* terminal, const char* title, int guac_terminal_set(guac_terminal* term, int row, int col, int codepoint) { - int width; - - /* Build character with current attributes */ - guac_terminal_char guac_char; - guac_char.value = codepoint; - guac_char.attributes = term->current_attributes; - - width = wcwidth(codepoint); + /* Calculate width in columns */ + int width = wcwidth(codepoint); if (width < 0) width = 1; - guac_char.width = width; + /* Do nothing if glyph is empty */ + else if (width == 0) + return 0; + + /* Build character with current attributes */ + guac_terminal_char guac_char = { + .value = codepoint, + .attributes = term->current_attributes, + .width = width + }; guac_terminal_set_columns(term, row, col, col + width - 1, &guac_char);