aboutsummaryrefslogtreecommitdiff
path: root/win32/winansi.c
diff options
context:
space:
mode:
Diffstat (limited to 'win32/winansi.c')
-rw-r--r--win32/winansi.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/win32/winansi.c b/win32/winansi.c
index e2e7010fb..d95bd473b 100644
--- a/win32/winansi.c
+++ b/win32/winansi.c
@@ -91,6 +91,48 @@ static void erase_in_line(void)
91 NULL); 91 NULL);
92} 92}
93 93
94static void erase_till_end_of_screen(void)
95{
96 CONSOLE_SCREEN_BUFFER_INFO sbi;
97 COORD pos;
98
99 if (!console)
100 return;
101
102 GetConsoleScreenBufferInfo(console, &sbi);
103 FillConsoleOutputCharacterA(console, ' ',
104 sbi.dwSize.X - sbi.dwCursorPosition.X, sbi.dwCursorPosition,
105 NULL);
106
107 pos.X = 0;
108 for (pos.Y = sbi.dwCursorPosition.Y+1; pos.Y < sbi.dwSize.Y; pos.Y++)
109 FillConsoleOutputCharacterA(console, ' ', sbi.dwSize.X,
110 pos, NULL);
111}
112
113static void move_cursor_back(int n)
114{
115 CONSOLE_SCREEN_BUFFER_INFO sbi;
116
117 if (!console)
118 return;
119
120 GetConsoleScreenBufferInfo(console, &sbi);
121 sbi.dwCursorPosition.X -= n;
122 SetConsoleCursorPosition(console, sbi.dwCursorPosition);
123}
124
125static void move_cursor(int x, int y)
126{
127 COORD pos;
128
129 if (!console)
130 return;
131
132 pos.X = x;
133 pos.Y = y;
134 SetConsoleCursorPosition(console, pos);
135}
94 136
95static const char *set_attr(const char *str) 137static const char *set_attr(const char *str)
96{ 138{
@@ -230,6 +272,23 @@ static const char *set_attr(const char *str)
230 272
231 set_console_attr(); 273 set_console_attr();
232 break; 274 break;
275 case 'D':
276 move_cursor_back(strtol(str, (char **)&str, 10));
277 break;
278 case 'H':
279 if (!len)
280 move_cursor(0, 0);
281 else {
282 int row = strtol(str, (char **)&str, 10);
283 if (*str == ';') {
284 int col = strtol(str+1, (char **)&str, 10);
285 move_cursor(col, row);
286 }
287 }
288 break;
289 case 'J':
290 erase_till_end_of_screen();
291 break;
233 case 'K': 292 case 'K':
234 erase_in_line(); 293 erase_in_line();
235 break; 294 break;