feat(core): implement builtin to show logs
This commit is contained in:
parent
c69544c1e2
commit
e2b6dcba38
|
@ -106,3 +106,13 @@ pub fn create_match_show_active_app_info() -> BuiltInMatch {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn create_match_show_logs() -> BuiltInMatch {
|
||||||
|
BuiltInMatch {
|
||||||
|
id: generate_next_builtin_id(),
|
||||||
|
label: "Show Espanso's logs",
|
||||||
|
triggers: vec!["#log#".to_string()],
|
||||||
|
action: |_| EventType::ShowLogs,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ pub fn get_builtin_matches(config: &dyn Config) -> Vec<BuiltInMatch> {
|
||||||
debug::create_match_paste_active_app_info(),
|
debug::create_match_paste_active_app_info(),
|
||||||
debug::create_match_show_active_config_info(),
|
debug::create_match_show_active_config_info(),
|
||||||
debug::create_match_show_active_app_info(),
|
debug::create_match_show_active_app_info(),
|
||||||
|
debug::create_match_show_logs(),
|
||||||
process::create_match_exit(),
|
process::create_match_exit(),
|
||||||
process::create_match_restart(),
|
process::create_match_restart(),
|
||||||
];
|
];
|
||||||
|
|
|
@ -18,16 +18,18 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use espanso_engine::dispatch::TextUIHandler;
|
use espanso_engine::dispatch::TextUIHandler;
|
||||||
|
use espanso_path::Paths;
|
||||||
|
|
||||||
use crate::gui::TextUI;
|
use crate::gui::TextUI;
|
||||||
|
|
||||||
pub struct TextUIHandlerAdapter<'a> {
|
pub struct TextUIHandlerAdapter<'a> {
|
||||||
text_ui: &'a dyn TextUI,
|
text_ui: &'a dyn TextUI,
|
||||||
|
paths: &'a Paths,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TextUIHandlerAdapter<'a> {
|
impl<'a> TextUIHandlerAdapter<'a> {
|
||||||
pub fn new(text_ui: &'a dyn TextUI) -> Self {
|
pub fn new(text_ui: &'a dyn TextUI, paths: &'a Paths) -> Self {
|
||||||
Self { text_ui }
|
Self { text_ui, paths }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,4 +38,11 @@ impl<'a> TextUIHandler for TextUIHandlerAdapter<'a> {
|
||||||
self.text_ui.show_text(title, text)?;
|
self.text_ui.show_text(title, text)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn show_logs(&self) -> anyhow::Result<()> {
|
||||||
|
self
|
||||||
|
.text_ui
|
||||||
|
.show_file("Espanso Logs", &self.paths.runtime.join("espanso.log"))?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,7 +243,7 @@ pub fn initialize_and_spawn(
|
||||||
let context_menu_adapter = ContextMenuHandlerAdapter::new(&*ui_remote);
|
let context_menu_adapter = ContextMenuHandlerAdapter::new(&*ui_remote);
|
||||||
let icon_adapter = IconHandlerAdapter::new(&*ui_remote);
|
let icon_adapter = IconHandlerAdapter::new(&*ui_remote);
|
||||||
let secure_input_adapter = SecureInputManagerAdapter::new();
|
let secure_input_adapter = SecureInputManagerAdapter::new();
|
||||||
let text_ui_adapter = TextUIHandlerAdapter::new(&modulo_text_ui);
|
let text_ui_adapter = TextUIHandlerAdapter::new(&modulo_text_ui, &paths);
|
||||||
let dispatcher = espanso_engine::dispatch::default(
|
let dispatcher = espanso_engine::dispatch::default(
|
||||||
&event_injector,
|
&event_injector,
|
||||||
&clipboard_injector,
|
&clipboard_injector,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user