aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2014-04-09 20:26:52 +0100
committerRon Yorston <rmy@pobox.com>2014-04-09 20:26:52 +0100
commit612f6c6c4ef0ff01dfdb6c87712209e2f80d18b7 (patch)
treea2e891b0e3a6651e977ce172331a29dc94bfd81c
parentc8f20188ae14ce2f9da8d263fbefbe88bda16075 (diff)
downloadbusybox-w32-612f6c6c4ef0ff01dfdb6c87712209e2f80d18b7.tar.gz
busybox-w32-612f6c6c4ef0ff01dfdb6c87712209e2f80d18b7.tar.bz2
busybox-w32-612f6c6c4ef0ff01dfdb6c87712209e2f80d18b7.zip
Implement escape sequence for cursor down
-rw-r--r--win32/winansi.c33
1 files changed, 12 insertions, 21 deletions
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)
123 pos, &dummy); 123 pos, &dummy);
124} 124}
125 125
126static void move_cursor_up(int n) 126static void move_cursor_row(int n)
127{ 127{
128 CONSOLE_SCREEN_BUFFER_INFO sbi; 128 CONSOLE_SCREEN_BUFFER_INFO sbi;
129 129
@@ -131,11 +131,11 @@ static void move_cursor_up(int n)
131 return; 131 return;
132 132
133 GetConsoleScreenBufferInfo(console, &sbi); 133 GetConsoleScreenBufferInfo(console, &sbi);
134 sbi.dwCursorPosition.Y -= n; 134 sbi.dwCursorPosition.Y += n;
135 SetConsoleCursorPosition(console, sbi.dwCursorPosition); 135 SetConsoleCursorPosition(console, sbi.dwCursorPosition);
136} 136}
137 137
138static void move_cursor_forward(int n) 138static void move_cursor_column(int n)
139{ 139{
140 CONSOLE_SCREEN_BUFFER_INFO sbi; 140 CONSOLE_SCREEN_BUFFER_INFO sbi;
141 141
@@ -147,18 +147,6 @@ static void move_cursor_forward(int n)
147 SetConsoleCursorPosition(console, sbi.dwCursorPosition); 147 SetConsoleCursorPosition(console, sbi.dwCursorPosition);
148} 148}
149 149
150static void move_cursor_back(int n)
151{
152 CONSOLE_SCREEN_BUFFER_INFO sbi;
153
154 if (!console)
155 return;
156
157 GetConsoleScreenBufferInfo(console, &sbi);
158 sbi.dwCursorPosition.X -= n;
159 SetConsoleCursorPosition(console, sbi.dwCursorPosition);
160}
161
162static void move_cursor(int x, int y) 150static void move_cursor(int x, int y)
163{ 151{
164 COORD pos; 152 COORD pos;
@@ -309,14 +297,17 @@ static const char *set_attr(const char *str)
309 297
310 set_console_attr(); 298 set_console_attr();
311 break; 299 break;
312 case 'A': 300 case 'A': /* up */
313 move_cursor_up(strtol(str, (char **)&str, 10)); 301 move_cursor_row(-strtol(str, (char **)&str, 10));
302 break;
303 case 'B': /* down */
304 move_cursor_row(strtol(str, (char **)&str, 10));
314 break; 305 break;
315 case 'C': 306 case 'C': /* forward */
316 move_cursor_forward(strtol(str, (char **)&str, 10)); 307 move_cursor_column(strtol(str, (char **)&str, 10));
317 break; 308 break;
318 case 'D': 309 case 'D': /* back */
319 move_cursor_back(strtol(str, (char **)&str, 10)); 310 move_cursor_column(-strtol(str, (char **)&str, 10));
320 break; 311 break;
321 case 'H': 312 case 'H':
322 if (!len) 313 if (!len)