aboutsummaryrefslogtreecommitdiff
path: root/src/ui/terminal/line.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/terminal/line.cc')
-rw-r--r--src/ui/terminal/line.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/ui/terminal/line.cc b/src/ui/terminal/line.cc
index 0ae2d30..0848b22 100644
--- a/src/ui/terminal/line.cc
+++ b/src/ui/terminal/line.cc
@@ -39,6 +39,8 @@ namespace ec {
namespace {
+using ::goldfishterm::CursorVisibility;
+
constexpr absl::string_view kBeginningOfLine = "\r";
int CheckedCall(const char* what_arg, int r) {
@@ -94,6 +96,7 @@ TerminalLine::~TerminalLine() noexcept {
pthread_cancel(sigwinch_watcher_.native_handle());
sigwinch_watcher_.join();
+ tty_->SetCursorVisibility(CursorVisibility::kNormal);
ExitRawMode();
// Move the cursor to the start of the next line.
@@ -107,6 +110,8 @@ void TerminalLine::SetLine(std::string text) {
void TerminalLine::Refresh() {
absl::MutexLock lock(&mu_);
+ tty_->SetCursorVisibility(CursorVisibility::kInvisible);
+ tty_->Flush();
tty_->BeginningOfLine();
if (line_.size() < columns_) {
// We can fit the whole line and the cursor on the screen at once.
@@ -117,6 +122,7 @@ void TerminalLine::Refresh() {
tty_->Write(absl::string_view(&*line_.end() - to_display, to_display));
}
tty_->ClearToEndOfLine();
+ tty_->SetCursorVisibility(CursorVisibility::kNormal);
tty_->Flush();
}
@@ -145,11 +151,14 @@ void TerminalLine::Beep() {
void TerminalLine::PrintLine(absl::string_view message) {
{
absl::MutexLock lock(&mu_);
+ tty_->SetCursorVisibility(CursorVisibility::kInvisible);
+ tty_->Flush();
tty_->BeginningOfLine();
tty_->CursorDown();
tty_->Write(message);
tty_->BeginningOfLine();
tty_->CursorDown();
+ tty_->SetCursorVisibility(CursorVisibility::kNormal);
}
Refresh(); // includes a flush
}