From 122a8095e40978a9c1b0449b60883ef4aea1fe4f Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 2 Jun 2014 12:53:40 -0700 Subject: [PATCH] GUAC-718: Advance cursor by column width of echo'd characters. --- src/terminal/terminal_handlers.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/terminal/terminal_handlers.c b/src/terminal/terminal_handlers.c index fd723676..4d795f4d 100644 --- a/src/terminal/terminal_handlers.c +++ b/src/terminal/terminal_handlers.c @@ -28,6 +28,7 @@ #include "terminal_handlers.h" #include +#include /** * Response string sent when identification is requested. @@ -46,6 +47,8 @@ int guac_terminal_echo(guac_terminal* term, unsigned char c) { + int width; + static int bytes_remaining = 0; static int codepoint = 0; @@ -206,8 +209,12 @@ int guac_terminal_echo(guac_terminal* term, unsigned char c) { term->cursor_col, codepoint); + width = wcwidth(codepoint); + if (width < 0) + width = 1; + /* Advance cursor */ - term->cursor_col++; + term->cursor_col += width; }