mod editor;
mod io;
mod list;
mod state;
mod variables_reference;
pub use state::SnippetsTabState;
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.snippets_tab.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",
"new tab",
"text insert",
"key sequence",
"macro",
"automation",
"shortcut",
"binding",
"arguments",
"split",
"split pane",
"pane",
"horizontal",
"vertical",
"workflow",
"sequence",
"condition",
"repeat",
"capture output",
"capture_output",
"exit code",
"step",
"agent command",
"agent-cmd",
"command file",
"delete command",
"agents",
"agent launcher",
"launch agent",
"launch default agent",
"autonomy",
"autonomous",
"default agent",
"cli agent",
"quick insert",
"variables reference",
"built-in",
"builtin",
"agent commands",
"mcp",
"palette",
"prefix",
]
}