From 612f6c6c4ef0ff01dfdb6c87712209e2f80d18b7 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 9 Apr 2014 20:26:52 +0100 Subject: Implement escape sequence for cursor down --- win32/winansi.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'win32') diff --git a/win32/winansi.c b/win32/winansi.c index 415105fcd..c47e29a28 100644 --- a/win32/winansi.c +++ b/win32/winansi.c @@ -123,7 +123,7 @@ static void erase_till_end_of_screen(void) pos, &dummy); } -static void move_cursor_up(int n) +static void move_cursor_row(int n) { CONSOLE_SCREEN_BUFFER_INFO sbi; @@ -131,11 +131,11 @@ static void move_cursor_up(int n) return; GetConsoleScreenBufferInfo(console, &sbi); - sbi.dwCursorPosition.Y -= n; + sbi.dwCursorPosition.Y += n; SetConsoleCursorPosition(console, sbi.dwCursorPosition); } -static void move_cursor_forward(int n) +static void move_cursor_column(int n) { CONSOLE_SCREEN_BUFFER_INFO sbi; @@ -147,18 +147,6 @@ static void move_cursor_forward(int n) SetConsoleCursorPosition(console, sbi.dwCursorPosition); } -static void move_cursor_back(int n) -{ - CONSOLE_SCREEN_BUFFER_INFO sbi; - - if (!console) - return; - - GetConsoleScreenBufferInfo(console, &sbi); - sbi.dwCursorPosition.X -= n; - SetConsoleCursorPosition(console, sbi.dwCursorPosition); -} - static void move_cursor(int x, int y) { COORD pos; @@ -309,14 +297,17 @@ static const char *set_attr(const char *str) set_console_attr(); break; - case 'A': - move_cursor_up(strtol(str, (char **)&str, 10)); + case 'A': /* up */ + move_cursor_row(-strtol(str, (char **)&str, 10)); + break; + case 'B': /* down */ + move_cursor_row(strtol(str, (char **)&str, 10)); break; - case 'C': - move_cursor_forward(strtol(str, (char **)&str, 10)); + case 'C': /* forward */ + move_cursor_column(strtol(str, (char **)&str, 10)); break; - case 'D': - move_cursor_back(strtol(str, (char **)&str, 10)); + case 'D': /* back */ + move_cursor_column(-strtol(str, (char **)&str, 10)); break; case 'H': if (!len) -- cgit v1.2.3-55-g6feb