From f3bce397271d207eac7925e0fe7aed28f9f75cf1 Mon Sep 17 00:00:00 2001 From: Martin Kustermann Date: Tue, 8 Oct 2024 08:24:12 +0000 Subject: [PATCH] [tools] Hide cursor while drawing prompt in heapsnapshot analysis tool to avoid flickering cursor Change-Id: I544bfd16a1fc5f4bbb243d66d73526995037e9bc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388821 Commit-Queue: Martin Kustermann Reviewed-by: Slava Egorov --- runtime/tools/heapsnapshot/lib/src/console.dart | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/runtime/tools/heapsnapshot/lib/src/console.dart b/runtime/tools/heapsnapshot/lib/src/console.dart index 2aca6abac8c..bece14bd6ca 100644 --- a/runtime/tools/heapsnapshot/lib/src/console.dart +++ b/runtime/tools/heapsnapshot/lib/src/console.dart @@ -25,11 +25,18 @@ class SmartConsole extends Console { write('\x1b[${column + 1}`'); } + void hideCursor() { + write('\x1b[? 5l'); + } + + void showCursor() { + write('\x1b[? 5h'); + } + ReadLineResult smartReadLine() { final buffer = LineEditBuffer(); drawPrompt(buffer); - while (true) { final key = readKey(); @@ -73,6 +80,7 @@ class SmartConsole extends Console { } void drawPrompt(LineEditBuffer buffer) { + hideCursor(); const prefix = '(hsa) '; moveCursorToColumn(0); @@ -93,6 +101,7 @@ class SmartConsole extends Console { } moveCursorToColumn(prefix.length + buffer.index); + showCursor(); } }