Added search in settings
This commit is contained in:
1 parent
438f202dfe
commit
f6a2f65cd4
1 file changed
+297
-140
+297
-140
@@ -1972,6 +1972,7 @@ struct Moorly {
|
|||||||
saved_shortcuts: Shortcuts,
|
saved_shortcuts: Shortcuts,
|
||||||
shortcut_capture: Option<ShortcutCapture>,
|
shortcut_capture: Option<ShortcutCapture>,
|
||||||
settings_section: SettingsSection,
|
settings_section: SettingsSection,
|
||||||
|
settings_search: String,
|
||||||
pending_settings_section: Option<SettingsSection>,
|
pending_settings_section: Option<SettingsSection>,
|
||||||
show_start_tab: bool,
|
show_start_tab: bool,
|
||||||
show_start_tab_draft: bool,
|
show_start_tab_draft: bool,
|
||||||
@@ -5204,6 +5205,7 @@ impl Default for Moorly {
|
|||||||
saved_shortcuts: shortcuts,
|
saved_shortcuts: shortcuts,
|
||||||
shortcut_capture: None,
|
shortcut_capture: None,
|
||||||
settings_section: SettingsSection::default(),
|
settings_section: SettingsSection::default(),
|
||||||
|
settings_search: String::new(),
|
||||||
pending_settings_section: None,
|
pending_settings_section: None,
|
||||||
show_start_tab,
|
show_start_tab,
|
||||||
show_start_tab_draft: show_start_tab,
|
show_start_tab_draft: show_start_tab,
|
||||||
@@ -5337,6 +5339,7 @@ enum Message {
|
|||||||
SelectTab(window::Id, Tab),
|
SelectTab(window::Id, Tab),
|
||||||
CloseTab(window::Id, Tab),
|
CloseTab(window::Id, Tab),
|
||||||
SelectSettingsSection(SettingsSection),
|
SelectSettingsSection(SettingsSection),
|
||||||
|
SettingsSearchChanged(String),
|
||||||
SetShowStartTab(bool),
|
SetShowStartTab(bool),
|
||||||
AutostartChoiceSelected(AutostartChoice),
|
AutostartChoiceSelected(AutostartChoice),
|
||||||
SelectAutostart(usize),
|
SelectAutostart(usize),
|
||||||
@@ -6222,9 +6225,9 @@ fn update(state: &mut Moorly, message: Message) -> Task<Message> {
|
|||||||
close_window_if_empty(state, window),
|
close_window_if_empty(state, window),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
Message::SettingsSearchChanged(value) => state.settings_search = value,
|
||||||
Message::SelectSettingsSection(section) => {
|
Message::SelectSettingsSection(section) => {
|
||||||
state.folder_menu = None;
|
state.folder_menu = None;
|
||||||
|
|
||||||
if section == SettingsSection::General {
|
if section == SettingsSection::General {
|
||||||
state.autostart_at_login = autostart::enabled();
|
state.autostart_at_login = autostart::enabled();
|
||||||
}
|
}
|
||||||
@@ -8963,63 +8966,23 @@ fn color_swatch_row<'a>(
|
|||||||
fn shortcuts_panel(state: &Moorly) -> Element<'_, Message> {
|
fn shortcuts_panel(state: &Moorly) -> Element<'_, Message> {
|
||||||
let mut panel = column![
|
let mut panel = column![
|
||||||
text("Press ... to change a shortcut.").size(12),
|
text("Press ... to change a shortcut.").size(12),
|
||||||
shortcut_row(
|
shortcut_setting(state, ShortcutAction::Settings),
|
||||||
&state.typography.h3,
|
shortcut_setting(state, ShortcutAction::Quit),
|
||||||
ShortcutAction::Settings,
|
|
||||||
state.shortcuts.get(ShortcutAction::Settings),
|
|
||||||
),
|
|
||||||
shortcut_row(
|
|
||||||
&state.typography.h3,
|
|
||||||
ShortcutAction::Quit,
|
|
||||||
state.shortcuts.get(ShortcutAction::Quit)
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
.spacing(8);
|
.spacing(8);
|
||||||
|
|
||||||
if hotkeys::backend() == hotkeys::Backend::Native {
|
if hotkeys::backend() == hotkeys::Backend::Native {
|
||||||
panel = panel.push(shortcut_row(
|
panel = panel.push(shortcut_setting(state, ShortcutAction::ToggleWindow));
|
||||||
&state.typography.h3,
|
|
||||||
ShortcutAction::ToggleWindow,
|
|
||||||
state.shortcuts.get(ShortcutAction::ToggleWindow),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
panel = panel
|
panel = panel
|
||||||
.push(shortcut_row(
|
.push(shortcut_setting(state, ShortcutAction::CommandPalette))
|
||||||
&state.typography.h3,
|
.push(shortcut_setting(state, ShortcutAction::QuickTerminal))
|
||||||
ShortcutAction::CommandPalette,
|
.push(shortcut_setting(state, ShortcutAction::QuickSsh))
|
||||||
state.shortcuts.get(ShortcutAction::CommandPalette),
|
.push(shortcut_setting(state, ShortcutAction::CloseTab))
|
||||||
))
|
.push(shortcut_setting(state, ShortcutAction::MinimizeAll))
|
||||||
.push(shortcut_row(
|
.push(shortcut_setting(state, ShortcutAction::TerminalCopy))
|
||||||
&state.typography.h3,
|
.push(shortcut_setting(state, ShortcutAction::TerminalPaste));
|
||||||
ShortcutAction::QuickTerminal,
|
|
||||||
state.shortcuts.get(ShortcutAction::QuickTerminal),
|
|
||||||
))
|
|
||||||
.push(shortcut_row(
|
|
||||||
&state.typography.h3,
|
|
||||||
ShortcutAction::QuickSsh,
|
|
||||||
state.shortcuts.get(ShortcutAction::QuickSsh),
|
|
||||||
))
|
|
||||||
.push(shortcut_row(
|
|
||||||
&state.typography.h3,
|
|
||||||
ShortcutAction::CloseTab,
|
|
||||||
state.shortcuts.get(ShortcutAction::CloseTab),
|
|
||||||
))
|
|
||||||
.push(shortcut_row(
|
|
||||||
&state.typography.h3,
|
|
||||||
ShortcutAction::MinimizeAll,
|
|
||||||
state.shortcuts.get(ShortcutAction::MinimizeAll),
|
|
||||||
))
|
|
||||||
.push(shortcut_row(
|
|
||||||
&state.typography.h3,
|
|
||||||
ShortcutAction::TerminalCopy,
|
|
||||||
state.shortcuts.get(ShortcutAction::TerminalCopy),
|
|
||||||
))
|
|
||||||
.push(shortcut_row(
|
|
||||||
&state.typography.h3,
|
|
||||||
ShortcutAction::TerminalPaste,
|
|
||||||
state.shortcuts.get(ShortcutAction::TerminalPaste),
|
|
||||||
));
|
|
||||||
|
|
||||||
if hotkeys::backend() == hotkeys::Backend::Portal {
|
if hotkeys::backend() == hotkeys::Backend::Portal {
|
||||||
panel = panel.push(
|
panel = panel.push(
|
||||||
@@ -9063,6 +9026,15 @@ fn shortcut_row(
|
|||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// One shortcut option, dimmed when it does not match the settings search.
|
||||||
|
fn shortcut_setting(state: &Moorly, action: ShortcutAction) -> Element<'_, Message> {
|
||||||
|
dim_setting(
|
||||||
|
state,
|
||||||
|
action.label(),
|
||||||
|
shortcut_row(&state.typography.h3, action, state.shortcuts.get(action)),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/// Popover shown while a new shortcut is being recorded.
|
/// Popover shown while a new shortcut is being recorded.
|
||||||
fn shortcut_capture_panel(capture: &ShortcutCapture) -> Element<'_, Message> {
|
fn shortcut_capture_panel(capture: &ShortcutCapture) -> Element<'_, Message> {
|
||||||
let preview = capture
|
let preview = capture
|
||||||
@@ -10466,13 +10438,17 @@ fn start_page(state: &Moorly, window: window::Id) -> Element<'_, Message> {
|
|||||||
/// Reference table of every command the command palette can offer.
|
/// Reference table of every command the command palette can offer.
|
||||||
fn command_palette_panel(state: &Moorly) -> Element<'_, Message> {
|
fn command_palette_panel(state: &Moorly) -> Element<'_, Message> {
|
||||||
let mut rows = column![
|
let mut rows = column![
|
||||||
row![
|
dim_setting(
|
||||||
styled_text(&state.typography.h3, "Enable command palette"),
|
state,
|
||||||
space::horizontal(),
|
"Enable command palette command palette",
|
||||||
toggler(state.command_palette_enabled_draft)
|
row![
|
||||||
.on_toggle(Message::SetCommandPaletteEnabled),
|
styled_text(&state.typography.h3, "Enable command palette"),
|
||||||
]
|
space::horizontal(),
|
||||||
.align_y(Alignment::Center),
|
toggler(state.command_palette_enabled_draft)
|
||||||
|
.on_toggle(Message::SetCommandPaletteEnabled),
|
||||||
|
]
|
||||||
|
.align_y(Alignment::Center),
|
||||||
|
),
|
||||||
rule::horizontal(1),
|
rule::horizontal(1),
|
||||||
row![
|
row![
|
||||||
container(text("Command").size(13)).width(180),
|
container(text("Command").size(13)).width(180),
|
||||||
@@ -10484,10 +10460,14 @@ fn command_palette_panel(state: &Moorly) -> Element<'_, Message> {
|
|||||||
.spacing(8);
|
.spacing(8);
|
||||||
|
|
||||||
for command in Command::ALL {
|
for command in Command::ALL {
|
||||||
rows = rows.push(command_palette_row(
|
let label = command.label(state);
|
||||||
&state.typography.caption,
|
let description = command.description(state);
|
||||||
command.label(state),
|
let search = format!("{label} {description}");
|
||||||
command.description(state),
|
|
||||||
|
rows = rows.push(dim_setting(
|
||||||
|
state,
|
||||||
|
&search,
|
||||||
|
command_palette_row(&state.typography.caption, label, description),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10503,10 +10483,16 @@ fn command_palette_panel(state: &Moorly) -> Element<'_, Message> {
|
|||||||
"Focuses the matching window, or moves the active tab into it",
|
"Focuses the matching window, or moves the active tab into it",
|
||||||
),
|
),
|
||||||
] {
|
] {
|
||||||
rows = rows.push(command_palette_row(
|
let search = format!("{label} {description}");
|
||||||
&state.typography.caption,
|
|
||||||
label.to_owned(),
|
rows = rows.push(dim_setting(
|
||||||
description.to_owned(),
|
state,
|
||||||
|
&search,
|
||||||
|
command_palette_row(
|
||||||
|
&state.typography.caption,
|
||||||
|
label.to_owned(),
|
||||||
|
description.to_owned(),
|
||||||
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10562,31 +10548,41 @@ fn parse_scrollback(value: &str) -> Option<usize> {
|
|||||||
|
|
||||||
fn general_panel(state: &Moorly) -> Element<'_, Message> {
|
fn general_panel(state: &Moorly) -> Element<'_, Message> {
|
||||||
let mut panel = column![
|
let mut panel = column![
|
||||||
row![
|
dim_setting(
|
||||||
styled_text(&state.typography.h3, "Fade In/Fade out animation"),
|
state,
|
||||||
space::horizontal(),
|
"Fade In/Fade out animation fade animation",
|
||||||
toggler(state.fade_settings_draft).on_toggle(Message::SetFadeSettings),
|
row![
|
||||||
]
|
styled_text(&state.typography.h3, "Fade In/Fade out animation"),
|
||||||
.align_y(Alignment::Center),
|
space::horizontal(),
|
||||||
row![
|
toggler(state.fade_settings_draft).on_toggle(Message::SetFadeSettings),
|
||||||
styled_text(&state.typography.h3, "Close window to tray"),
|
]
|
||||||
space::horizontal(),
|
.align_y(Alignment::Center),
|
||||||
toggler(state.close_to_tray_draft).on_toggle(Message::SetCloseToTray),
|
),
|
||||||
]
|
dim_setting(
|
||||||
.align_y(Alignment::Center),
|
state,
|
||||||
|
"Close window to tray close tray",
|
||||||
|
row![
|
||||||
|
styled_text(&state.typography.h3, "Close window to tray"),
|
||||||
|
space::horizontal(),
|
||||||
|
toggler(state.close_to_tray_draft).on_toggle(Message::SetCloseToTray),
|
||||||
|
]
|
||||||
|
.align_y(Alignment::Center),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
.spacing(12);
|
.spacing(12);
|
||||||
|
|
||||||
// Wayland clients cannot query whether their window was minimized.
|
// Wayland clients cannot query whether their window was minimized.
|
||||||
if !needs_window_recreation() {
|
if !needs_window_recreation() {
|
||||||
panel = panel.push(
|
panel = panel.push(dim_setting(
|
||||||
|
state,
|
||||||
|
"Minimize window to tray minimize tray",
|
||||||
row![
|
row![
|
||||||
styled_text(&state.typography.h3, "Minimize window to tray"),
|
styled_text(&state.typography.h3, "Minimize window to tray"),
|
||||||
space::horizontal(),
|
space::horizontal(),
|
||||||
toggler(state.minimize_to_tray_draft).on_toggle(Message::SetMinimizeToTray),
|
toggler(state.minimize_to_tray_draft).on_toggle(Message::SetMinimizeToTray),
|
||||||
]
|
]
|
||||||
.align_y(Alignment::Center),
|
.align_y(Alignment::Center),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut tray_style_picker = row![].spacing(6);
|
let mut tray_style_picker = row![].spacing(6);
|
||||||
@@ -10602,7 +10598,9 @@ fn general_panel(state: &Moorly) -> Element<'_, Message> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
panel = panel.push(
|
panel = panel.push(dim_setting(
|
||||||
|
state,
|
||||||
|
"System Tray tray icon style icon",
|
||||||
column![
|
column![
|
||||||
styled_text(&state.typography.h2, "System Tray"),
|
styled_text(&state.typography.h2, "System Tray"),
|
||||||
row![
|
row![
|
||||||
@@ -10620,17 +10618,21 @@ fn general_panel(state: &Moorly) -> Element<'_, Message> {
|
|||||||
.align_y(Alignment::Center),
|
.align_y(Alignment::Center),
|
||||||
]
|
]
|
||||||
.spacing(8),
|
.spacing(8),
|
||||||
);
|
));
|
||||||
|
|
||||||
panel = panel.push(
|
panel = panel.push(dim_setting(
|
||||||
|
state,
|
||||||
|
"Right-click behavior right click copy paste context menu",
|
||||||
column![
|
column![
|
||||||
styled_text(&state.typography.h2, "Right-click behavior"),
|
styled_text(&state.typography.h2, "Right-click behavior"),
|
||||||
right_click_behavior_picker(state),
|
right_click_behavior_picker(state),
|
||||||
]
|
]
|
||||||
.spacing(8),
|
.spacing(8),
|
||||||
);
|
));
|
||||||
|
|
||||||
panel = panel.push(
|
panel = panel.push(dim_setting(
|
||||||
|
state,
|
||||||
|
"Terminal scrollback size history lines",
|
||||||
column![
|
column![
|
||||||
styled_text(&state.typography.h2, "Terminal"),
|
styled_text(&state.typography.h2, "Terminal"),
|
||||||
row![
|
row![
|
||||||
@@ -10656,7 +10658,7 @@ fn general_panel(state: &Moorly) -> Element<'_, Message> {
|
|||||||
.align_y(Alignment::Center),
|
.align_y(Alignment::Center),
|
||||||
]
|
]
|
||||||
.spacing(8),
|
.spacing(8),
|
||||||
);
|
));
|
||||||
|
|
||||||
let login_action: Element<'_, Message> = if state.autostart_at_login {
|
let login_action: Element<'_, Message> = if state.autostart_at_login {
|
||||||
button("Remove autostart")
|
button("Remove autostart")
|
||||||
@@ -10672,7 +10674,9 @@ fn general_panel(state: &Moorly) -> Element<'_, Message> {
|
|||||||
.into()
|
.into()
|
||||||
};
|
};
|
||||||
|
|
||||||
panel = panel.push(
|
panel = panel.push(dim_setting(
|
||||||
|
state,
|
||||||
|
"Autostart at login start automatically sign in",
|
||||||
row![
|
row![
|
||||||
column![
|
column![
|
||||||
styled_text(&state.typography.h2, "Autostart at login"),
|
styled_text(&state.typography.h2, "Autostart at login"),
|
||||||
@@ -10686,7 +10690,7 @@ fn general_panel(state: &Moorly) -> Element<'_, Message> {
|
|||||||
login_action,
|
login_action,
|
||||||
]
|
]
|
||||||
.align_y(Alignment::Center),
|
.align_y(Alignment::Center),
|
||||||
);
|
));
|
||||||
|
|
||||||
panel.into()
|
panel.into()
|
||||||
}
|
}
|
||||||
@@ -11066,30 +11070,41 @@ fn startup_panel(state: &Moorly) -> Element<'_, Message> {
|
|||||||
.style(theme::positive_option);
|
.style(theme::positive_option);
|
||||||
|
|
||||||
column![
|
column![
|
||||||
row![
|
dim_setting(
|
||||||
styled_text(&state.typography.h3, "Show Start tab at startup"),
|
state,
|
||||||
space::horizontal(),
|
"Show Start tab at startup start tab",
|
||||||
toggler(state.show_start_tab_draft).on_toggle(Message::SetShowStartTab),
|
row![
|
||||||
]
|
styled_text(&state.typography.h3, "Show Start tab at startup"),
|
||||||
.align_y(Alignment::Center),
|
space::horizontal(),
|
||||||
styled_text(&state.typography.h1, "Autostarting profiles"),
|
toggler(state.show_start_tab_draft).on_toggle(Message::SetShowStartTab),
|
||||||
styled_text(
|
]
|
||||||
&state.typography.caption,
|
.align_y(Alignment::Center),
|
||||||
"Profiles in this list start automatically when Moorly launches. \
|
),
|
||||||
They are started in order from top to bottom.",
|
dim_setting(
|
||||||
|
state,
|
||||||
|
"Autostarting profiles autostart start automatically launch order quick terminal PowerShell",
|
||||||
|
column![
|
||||||
|
styled_text(&state.typography.h1, "Autostarting profiles"),
|
||||||
|
styled_text(
|
||||||
|
&state.typography.caption,
|
||||||
|
"Profiles in this list start automatically when Moorly launches. \
|
||||||
|
They are started in order from top to bottom.",
|
||||||
|
),
|
||||||
|
list,
|
||||||
|
row![
|
||||||
|
pick_list(
|
||||||
|
choices,
|
||||||
|
state.autostart_choice.clone(),
|
||||||
|
Message::AutostartChoiceSelected
|
||||||
|
)
|
||||||
|
.width(Length::Fill),
|
||||||
|
add,
|
||||||
|
]
|
||||||
|
.spacing(8)
|
||||||
|
.align_y(Alignment::Center),
|
||||||
|
]
|
||||||
|
.spacing(12),
|
||||||
),
|
),
|
||||||
list,
|
|
||||||
row![
|
|
||||||
pick_list(
|
|
||||||
choices,
|
|
||||||
state.autostart_choice.clone(),
|
|
||||||
Message::AutostartChoiceSelected
|
|
||||||
)
|
|
||||||
.width(Length::Fill),
|
|
||||||
add,
|
|
||||||
]
|
|
||||||
.spacing(8)
|
|
||||||
.align_y(Alignment::Center),
|
|
||||||
]
|
]
|
||||||
.spacing(12)
|
.spacing(12)
|
||||||
.into()
|
.into()
|
||||||
@@ -11098,31 +11113,55 @@ fn startup_panel(state: &Moorly) -> Element<'_, Message> {
|
|||||||
/// Appearance settings that are edited as a draft until saved.
|
/// Appearance settings that are edited as a draft until saved.
|
||||||
fn appearance_panel(state: &Moorly) -> Element<'_, Message> {
|
fn appearance_panel(state: &Moorly) -> Element<'_, Message> {
|
||||||
column![
|
column![
|
||||||
theme_picker(state),
|
dim_setting(
|
||||||
typography_panel(state),
|
state,
|
||||||
advanced_panel(state),
|
"Theme colors palette appearance light dark",
|
||||||
|
theme_picker(state),
|
||||||
|
),
|
||||||
|
dim_setting(
|
||||||
|
state,
|
||||||
|
"Typography font size bold italic underline strikethrough text H1 H2 H3 Caption Terminal SSH",
|
||||||
|
typography_panel(state),
|
||||||
|
),
|
||||||
|
dim_setting(
|
||||||
|
state,
|
||||||
|
"Advanced theme colors Accent color Active tab outline Main background Sidebar background Text color Border color Profile list background Visible profiles Hidden profile save undo delete",
|
||||||
|
advanced_panel(state),
|
||||||
|
),
|
||||||
styled_text(&state.typography.h2, "Tab bar"),
|
styled_text(&state.typography.h2, "Tab bar"),
|
||||||
row![
|
dim_setting(
|
||||||
styled_text(&state.typography.h3, "Show new Session Button"),
|
state,
|
||||||
space::horizontal(),
|
"Show new Session Button tab bar new session",
|
||||||
toggler(state.show_new_session_button_draft)
|
row![
|
||||||
.on_toggle(Message::SetShowNewSessionButton),
|
styled_text(&state.typography.h3, "Show new Session Button"),
|
||||||
]
|
space::horizontal(),
|
||||||
.align_y(Alignment::Center),
|
toggler(state.show_new_session_button_draft)
|
||||||
row![
|
.on_toggle(Message::SetShowNewSessionButton),
|
||||||
styled_text(&state.typography.h3, "Hide tab close icon"),
|
]
|
||||||
space::horizontal(),
|
.align_y(Alignment::Center),
|
||||||
toggler(state.hide_tab_close_draft).on_toggle(Message::SetHideTabClose),
|
),
|
||||||
]
|
dim_setting(
|
||||||
.align_y(Alignment::Center),
|
state,
|
||||||
|
"Hide tab close icon tab bar close",
|
||||||
|
row![
|
||||||
|
styled_text(&state.typography.h3, "Hide tab close icon"),
|
||||||
|
space::horizontal(),
|
||||||
|
toggler(state.hide_tab_close_draft).on_toggle(Message::SetHideTabClose),
|
||||||
|
]
|
||||||
|
.align_y(Alignment::Center),
|
||||||
|
),
|
||||||
styled_text(&state.typography.h2, "Command Palette"),
|
styled_text(&state.typography.h2, "Command Palette"),
|
||||||
row![
|
dim_setting(
|
||||||
styled_text(&state.typography.h3, "Show command palette description"),
|
state,
|
||||||
space::horizontal(),
|
"Show command palette description command palette",
|
||||||
toggler(state.show_command_palette_description_draft)
|
row![
|
||||||
.on_toggle(Message::SetShowCommandPaletteDescription),
|
styled_text(&state.typography.h3, "Show command palette description"),
|
||||||
]
|
space::horizontal(),
|
||||||
.align_y(Alignment::Center),
|
toggler(state.show_command_palette_description_draft)
|
||||||
|
.on_toggle(Message::SetShowCommandPaletteDescription),
|
||||||
|
]
|
||||||
|
.align_y(Alignment::Center),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
.spacing(12)
|
.spacing(12)
|
||||||
.into()
|
.into()
|
||||||
@@ -11264,6 +11303,70 @@ fn profile_context_menu(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Searchable text for a settings category, used to dim non-matching tabs in
|
||||||
|
/// the settings menu.
|
||||||
|
fn settings_section_search_text(section: SettingsSection) -> &'static str {
|
||||||
|
match section {
|
||||||
|
SettingsSection::General => {
|
||||||
|
"Fade In/Fade out animation animation Close window to tray minimize window to tray \
|
||||||
|
System Tray tray icon style Right-click behavior copy paste context menu Terminal \
|
||||||
|
Scrollback size history Autostart at login"
|
||||||
|
}
|
||||||
|
SettingsSection::Startup => {
|
||||||
|
"Show Start tab at startup Autostarting profiles autostart order quick terminal PowerShell"
|
||||||
|
}
|
||||||
|
SettingsSection::Appearance => {
|
||||||
|
"Theme colors palette Accent color Active tab outline Main background Sidebar background \
|
||||||
|
Text color Border color Profile list background Visible profiles Hidden profile \
|
||||||
|
Typography font size bold italic underline strikethrough H1 H2 H3 Caption Terminal SSH \
|
||||||
|
Advanced theme Tab bar Show new Session Button Hide tab close icon Command Palette \
|
||||||
|
Show command palette description"
|
||||||
|
}
|
||||||
|
SettingsSection::Shortcuts => {
|
||||||
|
"Shortcuts Settings Quit Show/hide window Command palette Quick terminal Quick SSH \
|
||||||
|
Close active tab Minimize all windows Copy terminal text Paste into terminal"
|
||||||
|
}
|
||||||
|
SettingsSection::CommandPalette => {
|
||||||
|
"Command Palette Enable command palette Command Description Profile name Tab title Window title"
|
||||||
|
}
|
||||||
|
SettingsSection::Profiles => {
|
||||||
|
"Profiles Folders Filter Add profile edit delete hide unhide copy move"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Whether `text` contains the current settings search.
|
||||||
|
fn settings_search_matches(state: &Moorly, text: &str) -> bool {
|
||||||
|
let query = state.settings_search.trim().to_lowercase();
|
||||||
|
|
||||||
|
query.is_empty() || text.to_lowercase().contains(&query)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Fades an option that does not match the active settings search. The overlay
|
||||||
|
/// is inert, so the control underneath still works.
|
||||||
|
fn dim_setting<'a>(
|
||||||
|
state: &Moorly,
|
||||||
|
text: &str,
|
||||||
|
content: impl Into<Element<'a, Message>>,
|
||||||
|
) -> Element<'a, Message> {
|
||||||
|
let content = content.into();
|
||||||
|
|
||||||
|
if settings_search_matches(state, text) {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
let background = state.colors[ColorOption::MainBackground.index()].scale_alpha(0.72);
|
||||||
|
let overlay = container(space::horizontal())
|
||||||
|
.width(Length::Fill)
|
||||||
|
.height(Length::Fill)
|
||||||
|
.style(move |_| container::Style {
|
||||||
|
background: Some(background.into()),
|
||||||
|
..container::Style::default()
|
||||||
|
});
|
||||||
|
|
||||||
|
stack![content, overlay].width(Length::Fill).into()
|
||||||
|
}
|
||||||
|
|
||||||
fn settings_dirty(state: &Moorly) -> bool {
|
fn settings_dirty(state: &Moorly) -> bool {
|
||||||
state.show_start_tab_draft != state.show_start_tab
|
state.show_start_tab_draft != state.show_start_tab
|
||||||
|| state.autostart_profiles_draft != state.autostart_profiles
|
|| state.autostart_profiles_draft != state.autostart_profiles
|
||||||
@@ -11319,11 +11422,27 @@ fn settings_page(state: &Moorly, window: window::Id) -> Element<'_, Message> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let menu =
|
let section_items = column(SettingsSection::ALL.map(|section| {
|
||||||
container(column(SettingsSection::ALL.map(|section| menu_item(section).into())).spacing(2))
|
let search = format!(
|
||||||
.width(menu_width)
|
"{} {}",
|
||||||
.height(Length::Fill)
|
section.label(),
|
||||||
.padding(8);
|
settings_section_search_text(section)
|
||||||
|
);
|
||||||
|
|
||||||
|
dim_setting(state, &search, menu_item(section))
|
||||||
|
}))
|
||||||
|
.spacing(2);
|
||||||
|
|
||||||
|
let search = text_input("Search settings", &state.settings_search)
|
||||||
|
.on_input(Message::SettingsSearchChanged)
|
||||||
|
.padding(6)
|
||||||
|
.style(theme::filter_field)
|
||||||
|
.width(Length::Fill);
|
||||||
|
|
||||||
|
let menu = container(column![search, section_items].spacing(8))
|
||||||
|
.width(menu_width)
|
||||||
|
.height(Length::Fill)
|
||||||
|
.padding(8);
|
||||||
|
|
||||||
let scrolls = state.settings_section != SettingsSection::Profiles;
|
let scrolls = state.settings_section != SettingsSection::Profiles;
|
||||||
|
|
||||||
@@ -11353,7 +11472,11 @@ fn settings_page(state: &Moorly, window: window::Id) -> Element<'_, Message> {
|
|||||||
content = content.push(command_palette_panel(state));
|
content = content.push(command_palette_panel(state));
|
||||||
}
|
}
|
||||||
if state.settings_section == SettingsSection::Profiles {
|
if state.settings_section == SettingsSection::Profiles {
|
||||||
content = content.push(profiles_panel(state, window, true));
|
content = content.push(dim_setting(
|
||||||
|
state,
|
||||||
|
settings_section_search_text(SettingsSection::Profiles),
|
||||||
|
profiles_panel(state, window, true),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let body: Element<'_, Message> = if scrolls {
|
let body: Element<'_, Message> = if scrolls {
|
||||||
@@ -13096,6 +13219,7 @@ mod tests {
|
|||||||
saved_shortcuts: super::Shortcuts::default(),
|
saved_shortcuts: super::Shortcuts::default(),
|
||||||
shortcut_capture: None,
|
shortcut_capture: None,
|
||||||
settings_section: super::SettingsSection::default(),
|
settings_section: super::SettingsSection::default(),
|
||||||
|
settings_search: String::new(),
|
||||||
pending_settings_section: None,
|
pending_settings_section: None,
|
||||||
show_start_tab: true,
|
show_start_tab: true,
|
||||||
show_start_tab_draft: true,
|
show_start_tab_draft: true,
|
||||||
@@ -13677,6 +13801,39 @@ mod tests {
|
|||||||
assert_eq!(state.scrollback_size, super::terminal::MAX_SCROLLBACK_SIZE);
|
assert_eq!(state.scrollback_size, super::terminal::MAX_SCROLLBACK_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn settings_search_matches_options_and_categories() {
|
||||||
|
let mut state = state();
|
||||||
|
state.settings_search = "scroll".to_owned();
|
||||||
|
|
||||||
|
assert!(super::settings_search_matches(&state, "Scrollback size"));
|
||||||
|
assert!(!super::settings_search_matches(&state, "Typography"));
|
||||||
|
assert!(super::settings_search_matches(
|
||||||
|
&state,
|
||||||
|
super::settings_section_search_text(super::SettingsSection::General)
|
||||||
|
));
|
||||||
|
assert!(!super::settings_search_matches(
|
||||||
|
&state,
|
||||||
|
super::settings_section_search_text(super::SettingsSection::Appearance)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn dimmed_settings_options_still_respond_to_clicks() {
|
||||||
|
let mut state = state();
|
||||||
|
window_state_mut(&mut state).active_tab = Some(Tab::Settings);
|
||||||
|
state.settings_section = super::SettingsSection::Shortcuts;
|
||||||
|
state.settings_search = "no such setting".to_owned();
|
||||||
|
|
||||||
|
let mut ui = iced_test::simulator(super::view(&state, test_window()));
|
||||||
|
ui.click("Default").unwrap();
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
ui.into_messages()
|
||||||
|
.any(|message| matches!(message, Message::DefaultShortcut(_)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hiding_tab_close_waits_for_save_or_undo() {
|
fn hiding_tab_close_waits_for_save_or_undo() {
|
||||||
let mut state = state();
|
let mut state = state();
|
||||||
|
|||||||
Reference in new issue
Block a user