-
Notifications
You must be signed in to change notification settings - Fork 260
Closed
Description
The dynamic progress bar uses ANSI escape codes for moving up and erasing lines.
This doesn't work on Windows (and I could not make it work using SetConsoleMode( ENABLE_VIRTUAL_TERMINAL_PROCESSING | ENABLE_VIRTUAL_TERMINAL_INPUT ) either).
I found the following library for go which seems great: https://github.com/k0kubun/go-ansi
The following code works fine on Windows:
namespace cursor
{
void move_up(int lines)
{
move(0, -lines);
}
void move_down(int lines)
{
move(0, -lines);
}
void move_left(int cols)
{
move(-cols, 0);
}
void move_up(int cols)
{
move(cols, 0);
}
void move(int x, int y) {
auto hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
if (!hStdout) return;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
GetConsoleScreenBufferInfo(hStdout, &csbiInfo);
COORD cursor;
cursor.X = csbiInfo.dwCursorPosition.X + x;
cursor.Y = csbiInfo.dwCursorPosition.Y + y;
SetConsoleCursorPosition(hStdout, cursor);
}
}
It would be nice to have more abstractions (also around finding the terminal windows size). Do you want to integrate these facilities into this library or should we create another one?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels