From 0210d1bf246aa8f89ae75310567a715b97b69073 Mon Sep 17 00:00:00 2001 From: cbracketdash Date: Sun, 27 Dec 2020 03:43:36 -0800 Subject: [PATCH] vrepl, term: return cursor to the top-left corner in vrepl after `clear` (#7600) --- cmd/tools/vrepl.v | 2 +- vlib/term/control.v | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/tools/vrepl.v b/cmd/tools/vrepl.v index ad029498f8..28a07a3462 100644 --- a/cmd/tools/vrepl.v +++ b/cmd/tools/vrepl.v @@ -146,7 +146,7 @@ fn run_repl(workdir string, vrepl_prefix string) { continue } if r.line == 'clear' { - term.erase_display('2') + term.erase_clear() continue } if r.line == 'help' { diff --git a/vlib/term/control.v b/vlib/term/control.v index d1f1a25676..664acec4b7 100644 --- a/vlib/term/control.v +++ b/vlib/term/control.v @@ -46,6 +46,7 @@ pub fn cursor_back(n int) { // type: 1 -> current cursor position to beginning of the screen // type: 2 -> clears entire screen // type: 3 -> clears entire screen and also delete scrollback buffer + pub fn erase_display(t string) { print('\x1b[' + t + 'J') } @@ -58,8 +59,9 @@ pub fn erase_tobeg() { erase_display('1') } +// clears entire screen and returns cursor to top left-corner pub fn erase_clear() { - erase_display('2') + print("\033[H\033[J") } pub fn erase_del_clear() {