mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
TerminalSettings: Move scrollback settings from "Terminal" to "View"
The scrollback is really a property of the view, not the terminal.
This commit is contained in:
parent
3823f77d20
commit
f6f62d7ff6
Notes:
sideshowbarker
2024-07-17 02:22:23 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/f6f62d7ff6
4 changed files with 60 additions and 60 deletions
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<GUI::SpinBox>("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<i32>(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<GUI::CheckBox>("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<GUI::CheckBox>("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<GUI::SpinBox>("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<i32>(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<GUI::CheckBox>("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<i32>(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<i32>(m_original_max_history_size));
|
||||
Config::write_bool("Terminal"sv, "Terminal"sv, "ShowScrollBar"sv, m_original_show_scrollbar);
|
||||
}
|
||||
|
||||
void TerminalSettingsViewWidget::cancel_settings()
|
||||
|
|
|
@ -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<Gfx::Font const> 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 };
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue