mod editor;
mod io;
mod list;
mod variables_reference;
use super::SettingsUI;
use super::section::{collapsing_section_with_state, section_matches};
use std::collections::HashSet;
pub fn show(
ui: &mut egui::Ui,
settings: &mut SettingsUI,
changes_this_frame: &mut bool,
collapsed: &mut HashSet<String>,
) {
let query = settings.search_query.trim().to_lowercase();
if section_matches(
&query,
"Snippets",
&[
"snippet",
"text",
"insert",
"template",
"variable",
"keybinding",
"folder",
"shortcut",
"quick insert",
"auto-execute",
],
) {
show_snippets_section(ui, settings, changes_this_frame, collapsed);
}
if section_matches(
&query,
"Variables Reference",
&[
"variable",
"builtin",
"built-in",
"reference",
"date",
"time",
"hostname",
],
) {
variables_reference::show_variables_reference_section(ui, settings, collapsed);
}
crate::actions_tab::show(ui, settings, changes_this_frame, collapsed);
}
fn show_snippets_section(
ui: &mut egui::Ui,
settings: &mut SettingsUI,
changes_this_frame: &mut bool,
collapsed: &mut HashSet<String>,
) {
collapsing_section_with_state(
ui,
"Snippets",
"snippets_list",
true,
collapsed,
|ui, collapsed| {
ui.label("Saved text blocks for quick insertion. Supports variable substitution.");
ui.add_space(4.0);
list::render_snippet_list(ui, settings, changes_this_frame, collapsed);
ui.separator();
if settings.adding_new_snippet {
editor::show_snippet_edit_form(ui, settings, changes_this_frame, None, collapsed);
} else {
list::render_add_import_bar(ui, settings, changes_this_frame);
}
},
);
}
pub fn keywords() -> &'static [&'static str] {
&[
"snippet",
"snippets",
"text",
"insert",
"template",
"variable",
"keybinding",
"folder",
"substitution",
"date",
"time",
"hostname",
"path",
"title",
"name",
"content",
"body",
"description",
"category",
"auto-execute",
"auto execute",
"record",
"export",
"import",
"yaml",
"action",
"actions",
"custom action",
"shell command",
"text insert",
"key sequence",
"macro",
"automation",
"shortcut",
"binding",
"arguments",
]
}