mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
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! :^)
This commit is contained in:
parent
e263dc8427
commit
165f69023b
Notes:
sideshowbarker
2024-07-19 05:55:58 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/165f69023b7
6 changed files with 20 additions and 0 deletions
|
@ -307,6 +307,11 @@ void VirtualConsole::set_window_title(const StringView&)
|
|||
// Do nothing.
|
||||
}
|
||||
|
||||
void VirtualConsole::set_window_progress(int, int)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
void VirtualConsole::terminal_did_resize(u16 columns, u16 rows)
|
||||
{
|
||||
ASSERT(columns == 80);
|
||||
|
|
|
@ -59,6 +59,7 @@ private:
|
|||
// ^TerminalClient
|
||||
virtual void beep() override;
|
||||
virtual void set_window_title(const StringView&) override;
|
||||
virtual void set_window_progress(int, int) 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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue