Przeglądaj źródła

LibVT: Put TerminalWidget in the VT namespace :^)

Andreas Kling 4 lat temu
rodzic
commit
2c1f71055f

+ 12 - 12
Userland/Applications/Terminal/main.cpp

@@ -177,7 +177,7 @@ static pid_t run_command(int ptm_fd, String command)
     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();
     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");
 
     switch (terminal.bell_mode()) {
-    case TerminalWidget::BellMode::Visible:
+    case VT::TerminalWidget::BellMode::Visible:
         visual_bell_radio.set_checked(true);
         break;
-    case TerminalWidget::BellMode::AudibleBeep:
+    case VT::TerminalWidget::BellMode::AudibleBeep:
         beep_bell_radio.set_checked(true);
         break;
-    case TerminalWidget::BellMode::Disabled:
+    case VT::TerminalWidget::BellMode::Disabled:
         no_bell_radio.set_checked(true);
         break;
     }
 
     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) {
-        terminal.set_bell_mode(TerminalWidget::BellMode::Visible);
+        terminal.set_bell_mode(VT::TerminalWidget::BellMode::Visible);
     };
     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");
@@ -230,7 +230,7 @@ static RefPtr<GUI::Window> create_settings_window(TerminalWidget& terminal)
     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();
     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_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 = [&] {
         app->quit(0);
     };
@@ -381,11 +381,11 @@ int main(int argc, char** argv)
 
     auto bell = config->read_entry("Window", "Bell", "Visible");
     if (bell == "AudibleBeep") {
-        terminal.set_bell_mode(TerminalWidget::BellMode::AudibleBeep);
+        terminal.set_bell_mode(VT::TerminalWidget::BellMode::AudibleBeep);
     } else if (bell == "Disabled") {
-        terminal.set_bell_mode(TerminalWidget::BellMode::Disabled);
+        terminal.set_bell_mode(VT::TerminalWidget::BellMode::Disabled);
     } else {
-        terminal.set_bell_mode(TerminalWidget::BellMode::Visible);
+        terminal.set_bell_mode(VT::TerminalWidget::BellMode::Visible);
     }
 
     RefPtr<GUI::Window> settings_window;

+ 1 - 1
Userland/DevTools/HackStudio/TerminalWrapper.cpp

@@ -178,7 +178,7 @@ TerminalWrapper::TerminalWrapper(bool user_spawned)
     set_layout<GUI::VerticalBoxLayout>();
 
     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)
         run_command("Shell");

+ 3 - 4
Userland/DevTools/HackStudio/TerminalWrapper.h

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

+ 4 - 0
Userland/Libraries/LibVT/TerminalWidget.cpp

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

+ 4 - 0
Userland/Libraries/LibVT/TerminalWidget.h

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