1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:27:35 +00:00

LibVT: Put TerminalWidget in the VT namespace :^)

This commit is contained in:
Andreas Kling 2021-02-27 17:49:08 +01:00
parent 340180ba05
commit 2c1f71055f
5 changed files with 24 additions and 17 deletions

View file

@ -177,7 +177,7 @@ static pid_t run_command(int ptm_fd, String command)
return pid; return pid;
} }
static RefPtr<GUI::Window> create_settings_window(TerminalWidget& terminal) static RefPtr<GUI::Window> create_settings_window(VT::TerminalWidget& terminal)
{ {
auto window = GUI::Window::construct(); auto window = GUI::Window::construct();
window->set_window_type(GUI::WindowType::ToolWindow); window->set_window_type(GUI::WindowType::ToolWindow);
@ -194,25 +194,25 @@ static RefPtr<GUI::Window> create_settings_window(TerminalWidget& terminal)
auto& no_bell_radio = *settings.find_descendant_of_type_named<GUI::RadioButton>("no_bell_radio"); auto& no_bell_radio = *settings.find_descendant_of_type_named<GUI::RadioButton>("no_bell_radio");
switch (terminal.bell_mode()) { switch (terminal.bell_mode()) {
case TerminalWidget::BellMode::Visible: case VT::TerminalWidget::BellMode::Visible:
visual_bell_radio.set_checked(true); visual_bell_radio.set_checked(true);
break; break;
case TerminalWidget::BellMode::AudibleBeep: case VT::TerminalWidget::BellMode::AudibleBeep:
beep_bell_radio.set_checked(true); beep_bell_radio.set_checked(true);
break; break;
case TerminalWidget::BellMode::Disabled: case VT::TerminalWidget::BellMode::Disabled:
no_bell_radio.set_checked(true); no_bell_radio.set_checked(true);
break; break;
} }
beep_bell_radio.on_checked = [&terminal](bool) { beep_bell_radio.on_checked = [&terminal](bool) {
terminal.set_bell_mode(TerminalWidget::BellMode::AudibleBeep); terminal.set_bell_mode(VT::TerminalWidget::BellMode::AudibleBeep);
}; };
visual_bell_radio.on_checked = [&terminal](bool) { visual_bell_radio.on_checked = [&terminal](bool) {
terminal.set_bell_mode(TerminalWidget::BellMode::Visible); terminal.set_bell_mode(VT::TerminalWidget::BellMode::Visible);
}; };
no_bell_radio.on_checked = [&terminal](bool) { no_bell_radio.on_checked = [&terminal](bool) {
terminal.set_bell_mode(TerminalWidget::BellMode::Disabled); terminal.set_bell_mode(VT::TerminalWidget::BellMode::Disabled);
}; };
auto& slider = *settings.find_descendant_of_type_named<GUI::OpacitySlider>("background_opacity_slider"); auto& slider = *settings.find_descendant_of_type_named<GUI::OpacitySlider>("background_opacity_slider");
@ -230,7 +230,7 @@ static RefPtr<GUI::Window> create_settings_window(TerminalWidget& terminal)
return window; return window;
} }
static RefPtr<GUI::Window> create_find_window(TerminalWidget& terminal) static RefPtr<GUI::Window> create_find_window(VT::TerminalWidget& terminal)
{ {
auto window = GUI::Window::construct(); auto window = GUI::Window::construct();
window->set_window_type(GUI::WindowType::ToolWindow); window->set_window_type(GUI::WindowType::ToolWindow);
@ -365,7 +365,7 @@ int main(int argc, char** argv)
window->set_background_color(Color::Black); window->set_background_color(Color::Black);
window->set_double_buffering_enabled(false); window->set_double_buffering_enabled(false);
auto& terminal = window->set_main_widget<TerminalWidget>(ptm_fd, true, config); auto& terminal = window->set_main_widget<VT::TerminalWidget>(ptm_fd, true, config);
terminal.on_command_exit = [&] { terminal.on_command_exit = [&] {
app->quit(0); app->quit(0);
}; };
@ -381,11 +381,11 @@ int main(int argc, char** argv)
auto bell = config->read_entry("Window", "Bell", "Visible"); auto bell = config->read_entry("Window", "Bell", "Visible");
if (bell == "AudibleBeep") { if (bell == "AudibleBeep") {
terminal.set_bell_mode(TerminalWidget::BellMode::AudibleBeep); terminal.set_bell_mode(VT::TerminalWidget::BellMode::AudibleBeep);
} else if (bell == "Disabled") { } else if (bell == "Disabled") {
terminal.set_bell_mode(TerminalWidget::BellMode::Disabled); terminal.set_bell_mode(VT::TerminalWidget::BellMode::Disabled);
} else { } else {
terminal.set_bell_mode(TerminalWidget::BellMode::Visible); terminal.set_bell_mode(VT::TerminalWidget::BellMode::Visible);
} }
RefPtr<GUI::Window> settings_window; RefPtr<GUI::Window> settings_window;

View file

@ -178,7 +178,7 @@ TerminalWrapper::TerminalWrapper(bool user_spawned)
set_layout<GUI::VerticalBoxLayout>(); set_layout<GUI::VerticalBoxLayout>();
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("Terminal"); RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("Terminal");
m_terminal_widget = add<TerminalWidget>(-1, false, config); m_terminal_widget = add<VT::TerminalWidget>(-1, false, config);
if (user_spawned) if (user_spawned)
run_command("Shell"); run_command("Shell");

View file

@ -27,8 +27,7 @@
#pragma once #pragma once
#include <LibGUI/Widget.h> #include <LibGUI/Widget.h>
#include <LibVT/TerminalWidget.h>
class TerminalWidget;
namespace HackStudio { namespace HackStudio {
@ -41,14 +40,14 @@ public:
void kill_running_command(); void kill_running_command();
bool user_spawned() const { return m_user_spawned; } bool user_spawned() const { return m_user_spawned; }
TerminalWidget& terminal() { return *m_terminal_widget; } VT::TerminalWidget& terminal() { return *m_terminal_widget; }
Function<void()> on_command_exit; Function<void()> on_command_exit;
private: private:
explicit TerminalWrapper(bool user_spawned = true); explicit TerminalWrapper(bool user_spawned = true);
RefPtr<TerminalWidget> m_terminal_widget; RefPtr<VT::TerminalWidget> m_terminal_widget;
pid_t m_pid { -1 }; pid_t m_pid { -1 };
bool m_user_spawned { true }; bool m_user_spawned { true };
}; };

View file

@ -58,6 +58,8 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <unistd.h> #include <unistd.h>
namespace VT {
void TerminalWidget::set_pty_master_fd(int fd) void TerminalWidget::set_pty_master_fd(int fd)
{ {
m_ptm_fd = fd; m_ptm_fd = fd;
@ -1130,3 +1132,5 @@ void TerminalWidget::set_font_and_resize_to_fit(const Gfx::Font& font)
set_font(font); set_font(font);
resize(widget_size_for_font(font)); resize(widget_size_for_font(font));
} }
}

View file

@ -37,6 +37,8 @@
#include <LibVT/Range.h> #include <LibVT/Range.h>
#include <LibVT/Terminal.h> #include <LibVT/Terminal.h>
namespace VT {
class TerminalWidget final class TerminalWidget final
: public GUI::Frame : public GUI::Frame
, public VT::TerminalClient { , public VT::TerminalClient {
@ -221,3 +223,5 @@ private:
Gfx::IntPoint m_left_mousedown_position; Gfx::IntPoint m_left_mousedown_position;
}; };
}