Skip to content

Commit 1897713

Browse files
dschogitster
authored andcommitted
winansi: support ESC [ K (erase in line)
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 34df8ab commit 1897713

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

compat/winansi.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
1919
This file is git-specific. Therefore, this file does not attempt
2020
to implement any codes that are not used by git.
21-
22-
TODO: K
2321
*/
2422

2523
static HANDLE console;
@@ -79,6 +77,20 @@ static void set_console_attr(void)
7977
SetConsoleTextAttribute(console, attributes);
8078
}
8179

80+
static void erase_in_line(void)
81+
{
82+
CONSOLE_SCREEN_BUFFER_INFO sbi;
83+
84+
if (!console)
85+
return;
86+
87+
GetConsoleScreenBufferInfo(console, &sbi);
88+
FillConsoleOutputCharacterA(console, ' ',
89+
sbi.dwSize.X - sbi.dwCursorPosition.X, sbi.dwCursorPosition,
90+
NULL);
91+
}
92+
93+
8294
static const char *set_attr(const char *str)
8395
{
8496
const char *func;
@@ -218,7 +230,7 @@ static const char *set_attr(const char *str)
218230
set_console_attr();
219231
break;
220232
case 'K':
221-
/* TODO */
233+
erase_in_line();
222234
break;
223235
default:
224236
/* Unsupported code */

0 commit comments

Comments
 (0)