From 6da3469fe7f0c7bbd8dcbfc70dadc69eb7a9d50e Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sat, 30 Jan 2016 09:17:10 +0100 Subject: [PATCH] When clearing the screen move the cursor to the top --- cmdline/mingw.c | 3 +++ cmdline/state.c | 4 +++- cmdline/unix.c | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cmdline/mingw.c b/cmdline/mingw.c index e15b1e3a..381ac75e 100644 --- a/cmdline/mingw.c +++ b/cmdline/mingw.c @@ -291,6 +291,9 @@ void os_clear(void) coord.X = 0; coord.Y = 0; FillConsoleOutputCharacterA(console, ' ', screen.dwSize.X * screen.dwSize.Y, coord, &written); + + /* set the cursor at the top left corner */ + SetConsoleCursorPosition(console, coord); } /** diff --git a/cmdline/state.c b/cmdline/state.c index 6b56b5bb..6c3c8773 100644 --- a/cmdline/state.c +++ b/cmdline/state.c @@ -4055,7 +4055,7 @@ static void state_progress_graph(struct snapraid_state* state, struct snapraid_i printf("\n"); if (oldest == PROGRESS_MAX) { - const char* legend = "wait time"; + const char* legend = "wait time (total)"; printc(' ', 5 + pad + 1 + bar / 2 - strlen(legend) / 2); printf("%s", legend); printf("\n"); @@ -4065,6 +4065,8 @@ static void state_progress_graph(struct snapraid_state* state, struct snapraid_i printf(legend_d, PROGRESS_MAX); printf("\n"); } + + printf("\n"); } int state_progress(struct snapraid_state* state, struct snapraid_io* io, block_off_t blockpos, block_off_t countpos, block_off_t countmax, data_off_t countsize) diff --git a/cmdline/unix.c b/cmdline/unix.c index b6681e42..5d1324be 100644 --- a/cmdline/unix.c +++ b/cmdline/unix.c @@ -1228,8 +1228,9 @@ void os_abort(void) void os_clear(void) { - /* ANSI code for clear screen */ - printf("\033[2J"); + /* ANSI codes */ + printf("\033[H"); /* cursor at topleft */ + printf("\033[2J"); /* clear screen */ } #endif