aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2014-04-07 13:30:28 +0100
committerRon Yorston <rmy@pobox.com>2014-04-07 13:30:28 +0100
commitfee58ea68cdd08e7fb298960e12b2c921254a75b (patch)
treee0a5a109abdc5cd1dd2a99848d4c87e94845b6f4
parent20183fb965560d7d299d5f746bdeb5e2700f7e01 (diff)
downloadbusybox-w32-fee58ea68cdd08e7fb298960e12b2c921254a75b.tar.gz
busybox-w32-fee58ea68cdd08e7fb298960e12b2c921254a75b.tar.bz2
busybox-w32-fee58ea68cdd08e7fb298960e12b2c921254a75b.zip
Implement ANSI escape sequences for cursor up/forward
These escape sequences are required for proper handling of line editing when the input exceeds the console width.
-rw-r--r--win32/winansi.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/win32/winansi.c b/win32/winansi.c
index d929bcc66..415105fcd 100644
--- a/win32/winansi.c
+++ b/win32/winansi.c
@@ -123,6 +123,30 @@ 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)
127{
128 CONSOLE_SCREEN_BUFFER_INFO sbi;
129
130 if (!console)
131 return;
132
133 GetConsoleScreenBufferInfo(console, &sbi);
134 sbi.dwCursorPosition.Y -= n;
135 SetConsoleCursorPosition(console, sbi.dwCursorPosition);
136}
137
138static void move_cursor_forward(int n)
139{
140 CONSOLE_SCREEN_BUFFER_INFO sbi;
141
142 if (!console)
143 return;
144
145 GetConsoleScreenBufferInfo(console, &sbi);
146 sbi.dwCursorPosition.X += n;
147 SetConsoleCursorPosition(console, sbi.dwCursorPosition);
148}
149
126static void move_cursor_back(int n) 150static void move_cursor_back(int n)
127{ 151{
128 CONSOLE_SCREEN_BUFFER_INFO sbi; 152 CONSOLE_SCREEN_BUFFER_INFO sbi;
@@ -285,6 +309,12 @@ static const char *set_attr(const char *str)
285 309
286 set_console_attr(); 310 set_console_attr();
287 break; 311 break;
312 case 'A':
313 move_cursor_up(strtol(str, (char **)&str, 10));
314 break;
315 case 'C':
316 move_cursor_forward(strtol(str, (char **)&str, 10));
317 break;
288 case 'D': 318 case 'D':
289 move_cursor_back(strtol(str, (char **)&str, 10)); 319 move_cursor_back(strtol(str, (char **)&str, 10));
290 break; 320 break;