summaryrefslogtreecommitdiff
path: root/Libraries/LibVT
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-05-30 22:11:35 +0200
committerAndreas Kling <kling@serenityos.org>2020-05-30 23:00:35 +0200
commit165f69023b73898e424949a8c6a2a9de86077cfd (patch)
tree09a530abee47e218e8fa604f122968d6501ea2de /Libraries/LibVT
parente263dc8427aff08307faa02e1278d13c4901e810 (diff)
downloadserenity-165f69023b73898e424949a8c6a2a9de86077cfd.zip
LibVT: Allow updating the window progress via an escape sequence
You can now request an update of the terminal's window progress by sending this escape sequence: <esc>]9;<value>;<max_value>;<escape><backslash> I'm sure we can find many interesting uses for this! :^)
Diffstat (limited to 'Libraries/LibVT')
-rw-r--r--Libraries/LibVT/Terminal.cpp3
-rw-r--r--Libraries/LibVT/Terminal.h1
-rw-r--r--Libraries/LibVT/TerminalWidget.cpp9
-rw-r--r--Libraries/LibVT/TerminalWidget.h1
4 files changed, 14 insertions, 0 deletions
diff --git a/Libraries/LibVT/Terminal.cpp b/Libraries/LibVT/Terminal.cpp
index 22af6fa62b..42c8dd7aec 100644
--- a/Libraries/LibVT/Terminal.cpp
+++ b/Libraries/LibVT/Terminal.cpp
@@ -573,6 +573,9 @@ void Terminal::execute_xterm_command()
// FIXME: Respect the provided ID
m_current_attribute.href_id = String::format("%u", m_next_href_id++);
break;
+ case 9:
+ m_client.set_window_progress(numeric_params[1], numeric_params[2]);
+ break;
default:
unimplemented_xterm_escape();
break;
diff --git a/Libraries/LibVT/Terminal.h b/Libraries/LibVT/Terminal.h
index 4f8d10ad50..1ce3b81d4f 100644
--- a/Libraries/LibVT/Terminal.h
+++ b/Libraries/LibVT/Terminal.h
@@ -42,6 +42,7 @@ public:
virtual void beep() = 0;
virtual void set_window_title(const StringView&) = 0;
+ virtual void set_window_progress(int value, int max) = 0;
virtual void terminal_did_resize(u16 columns, u16 rows) = 0;
virtual void terminal_history_changed() = 0;
virtual void emit(const u8*, size_t) = 0;
diff --git a/Libraries/LibVT/TerminalWidget.cpp b/Libraries/LibVT/TerminalWidget.cpp
index aa381566ee..ab666cc641 100644
--- a/Libraries/LibVT/TerminalWidget.cpp
+++ b/Libraries/LibVT/TerminalWidget.cpp
@@ -47,6 +47,7 @@
#include <LibGfx/Font.h>
#include <LibGfx/Palette.h>
#include <errno.h>
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -361,6 +362,14 @@ void TerminalWidget::paint_event(GUI::PaintEvent& event)
}
}
+void TerminalWidget::set_window_progress(int value, int max)
+{
+ float float_value = value;
+ float float_max = max;
+ float progress = (float_value / float_max) * 100.0f;
+ window()->set_progress((int)roundf(progress));
+}
+
void TerminalWidget::set_window_title(const StringView& title)
{
if (!Utf8View(title).validate()) {
diff --git a/Libraries/LibVT/TerminalWidget.h b/Libraries/LibVT/TerminalWidget.h
index efd46068f1..6b48308955 100644
--- a/Libraries/LibVT/TerminalWidget.h
+++ b/Libraries/LibVT/TerminalWidget.h
@@ -108,6 +108,7 @@ private:
// ^TerminalClient
virtual void beep() override;
virtual void set_window_title(const StringView&) override;
+ virtual void set_window_progress(int value, int max) override;
virtual void terminal_did_resize(u16 columns, u16 rows) override;
virtual void terminal_history_changed() override;
virtual void emit(const u8*, size_t) override;