From f6f62d7ff684d1ea9c74747964d696373c310c00 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 3 Mar 2023 10:50:46 +0100 Subject: [PATCH] TerminalSettings: Move scrollback settings from "Terminal" to "View" The scrollback is really a property of the view, not the terminal. --- .../TerminalSettings/TerminalSettingsMain.gml | 32 ------------- .../TerminalSettings/TerminalSettingsView.gml | 32 +++++++++++++ .../TerminalSettingsWidget.cpp | 48 +++++++++---------- .../TerminalSettings/TerminalSettingsWidget.h | 8 ++-- 4 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Userland/Applications/TerminalSettings/TerminalSettingsMain.gml b/Userland/Applications/TerminalSettings/TerminalSettingsMain.gml index 131825f48f9..e9b11c4220e 100644 --- a/Userland/Applications/TerminalSettings/TerminalSettingsMain.gml +++ b/Userland/Applications/TerminalSettings/TerminalSettingsMain.gml @@ -5,38 +5,6 @@ spacing: 5 } - @GUI::GroupBox { - title: "Scrollback" - preferred_height: "fit" - layout: @GUI::VerticalBoxLayout { - margins: [8] - spacing: 8 - } - - @GUI::Widget { - preferred_height: "shrink" - layout: @GUI::HorizontalBoxLayout {} - - @GUI::SpinBox { - name: "history_size_spinbox" - min: 0 - max: 40960 - orientation: "Horizontal" - preferred_width: 100 - } - - @GUI::Label { - text: "lines" - autosize: true - } - } - - @GUI::CheckBox { - name: "terminal_show_scrollbar" - text: "Show terminal scrollbar" - } - } - @GUI::GroupBox { title: "Bell mode" preferred_height: "fit" diff --git a/Userland/Applications/TerminalSettings/TerminalSettingsView.gml b/Userland/Applications/TerminalSettings/TerminalSettingsView.gml index a63b48a2075..21bd43c73d8 100644 --- a/Userland/Applications/TerminalSettings/TerminalSettingsView.gml +++ b/Userland/Applications/TerminalSettings/TerminalSettingsView.gml @@ -96,4 +96,36 @@ } } } + + @GUI::GroupBox { + title: "Scrollback" + preferred_height: "fit" + layout: @GUI::VerticalBoxLayout { + margins: [8] + spacing: 8 + } + + @GUI::Widget { + preferred_height: "shrink" + layout: @GUI::HorizontalBoxLayout {} + + @GUI::SpinBox { + name: "history_size_spinbox" + min: 0 + max: 40960 + orientation: "Horizontal" + preferred_width: 100 + } + + @GUI::Label { + text: "lines" + autosize: true + } + } + + @GUI::CheckBox { + name: "terminal_show_scrollbar" + text: "Show terminal scrollbar" + } + } } diff --git a/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp b/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp index 6f5c559568e..df005586b11 100644 --- a/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp +++ b/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp @@ -68,26 +68,6 @@ TerminalSettingsMainWidget::TerminalSettingsMainWidget() set_modified(true); }; - m_max_history_size = Config::read_i32("Terminal"sv, "Terminal"sv, "MaxHistorySize"sv); - m_original_max_history_size = m_max_history_size; - auto& history_size_spinbox = *find_descendant_of_type_named("history_size_spinbox"); - history_size_spinbox.set_value(m_max_history_size, GUI::AllowCallback::No); - history_size_spinbox.on_change = [this](int value) { - m_max_history_size = value; - Config::write_i32("Terminal"sv, "Terminal"sv, "MaxHistorySize"sv, static_cast(m_max_history_size)); - set_modified(true); - }; - - m_show_scrollbar = Config::read_bool("Terminal"sv, "Terminal"sv, "ShowScrollBar"sv, true); - m_orignal_show_scrollbar = m_show_scrollbar; - auto& show_scrollbar_checkbox = *find_descendant_of_type_named("terminal_show_scrollbar"); - show_scrollbar_checkbox.on_checked = [&](bool show_scrollbar) { - m_show_scrollbar = show_scrollbar; - Config::write_bool("Terminal"sv, "Terminal"sv, "ShowScrollBar"sv, show_scrollbar); - set_modified(true); - }; - show_scrollbar_checkbox.set_checked(m_show_scrollbar, GUI::AllowCallback::No); - m_confirm_close = Config::read_bool("Terminal"sv, "Terminal"sv, "ConfirmClose"sv, true); m_orignal_confirm_close = m_confirm_close; auto& confirm_close_checkbox = *find_descendant_of_type_named("terminal_confirm_close"); @@ -207,6 +187,26 @@ TerminalSettingsViewWidget::TerminalSettingsViewWidget() Config::write_string("Terminal"sv, "Cursor"sv, "Shape"sv, "Bar"sv); }; terminal_cursor_bar.set_checked(Config::read_string("Terminal"sv, "Cursor"sv, "Shape"sv) == "Bar"sv); + + m_max_history_size = Config::read_i32("Terminal"sv, "Terminal"sv, "MaxHistorySize"sv); + m_original_max_history_size = m_max_history_size; + auto& history_size_spinbox = *find_descendant_of_type_named("history_size_spinbox"); + history_size_spinbox.set_value(m_max_history_size, GUI::AllowCallback::No); + history_size_spinbox.on_change = [this](int value) { + m_max_history_size = value; + Config::write_i32("Terminal"sv, "Terminal"sv, "MaxHistorySize"sv, static_cast(m_max_history_size)); + set_modified(true); + }; + + m_show_scrollbar = Config::read_bool("Terminal"sv, "Terminal"sv, "ShowScrollBar"sv, true); + m_original_show_scrollbar = m_show_scrollbar; + auto& show_scrollbar_checkbox = *find_descendant_of_type_named("terminal_show_scrollbar"); + show_scrollbar_checkbox.on_checked = [&](bool show_scrollbar) { + m_show_scrollbar = show_scrollbar; + Config::write_bool("Terminal"sv, "Terminal"sv, "ShowScrollBar"sv, show_scrollbar); + set_modified(true); + }; + show_scrollbar_checkbox.set_checked(m_show_scrollbar, GUI::AllowCallback::No); } VT::TerminalWidget::BellMode TerminalSettingsMainWidget::parse_bell(StringView bell_string) @@ -233,16 +233,12 @@ DeprecatedString TerminalSettingsMainWidget::stringify_bell(VT::TerminalWidget:: void TerminalSettingsMainWidget::apply_settings() { - m_original_max_history_size = m_max_history_size; - m_orignal_show_scrollbar = m_show_scrollbar; m_original_bell_mode = m_bell_mode; m_orignal_confirm_close = m_confirm_close; write_back_settings(); } void TerminalSettingsMainWidget::write_back_settings() const { - Config::write_i32("Terminal"sv, "Terminal"sv, "MaxHistorySize"sv, static_cast(m_original_max_history_size)); - Config::write_bool("Terminal"sv, "Terminal"sv, "ShowScrollBar"sv, m_orignal_show_scrollbar); Config::write_bool("Terminal"sv, "Terminal"sv, "ConfirmClose"sv, m_orignal_confirm_close); Config::write_string("Terminal"sv, "Window"sv, "Bell"sv, stringify_bell(m_original_bell_mode)); } @@ -258,6 +254,8 @@ void TerminalSettingsViewWidget::apply_settings() m_original_font = m_font; m_original_cursor_shape = m_cursor_shape; m_original_cursor_is_blinking_set = m_cursor_is_blinking_set; + m_original_max_history_size = m_max_history_size; + m_original_show_scrollbar = m_show_scrollbar; write_back_settings(); } @@ -267,6 +265,8 @@ void TerminalSettingsViewWidget::write_back_settings() const Config::write_string("Terminal"sv, "Text"sv, "Font"sv, m_original_font->qualified_name()); Config::write_string("Terminal"sv, "Cursor"sv, "Shape"sv, VT::TerminalWidget::stringify_cursor_shape(m_original_cursor_shape)); Config::write_bool("Terminal"sv, "Cursor"sv, "Blinking"sv, m_original_cursor_is_blinking_set); + Config::write_i32("Terminal"sv, "Terminal"sv, "MaxHistorySize"sv, static_cast(m_original_max_history_size)); + Config::write_bool("Terminal"sv, "Terminal"sv, "ShowScrollBar"sv, m_original_show_scrollbar); } void TerminalSettingsViewWidget::cancel_settings() diff --git a/Userland/Applications/TerminalSettings/TerminalSettingsWidget.h b/Userland/Applications/TerminalSettings/TerminalSettingsWidget.h index b8ff45469fc..03cba593a6a 100644 --- a/Userland/Applications/TerminalSettings/TerminalSettingsWidget.h +++ b/Userland/Applications/TerminalSettings/TerminalSettingsWidget.h @@ -27,13 +27,9 @@ private: static DeprecatedString stringify_bell(VT::TerminalWidget::BellMode bell_mode); VT::TerminalWidget::BellMode m_bell_mode { VT::TerminalWidget::BellMode::Disabled }; - size_t m_max_history_size; - bool m_show_scrollbar { true }; bool m_confirm_close { true }; VT::TerminalWidget::BellMode m_original_bell_mode; - size_t m_original_max_history_size; - bool m_orignal_show_scrollbar { true }; bool m_orignal_confirm_close { true }; }; @@ -52,10 +48,14 @@ private: DeprecatedString m_color_scheme; VT::CursorShape m_cursor_shape { VT::CursorShape::Block }; bool m_cursor_is_blinking_set { true }; + size_t m_max_history_size; + bool m_show_scrollbar { true }; RefPtr m_original_font; float m_original_opacity; DeprecatedString m_original_color_scheme; VT::CursorShape m_original_cursor_shape; bool m_original_cursor_is_blinking_set; + size_t m_original_max_history_size; + bool m_original_show_scrollbar { true }; };