feat(core): wire up extensions
This commit is contained in:
parent
4af0cde3ed
commit
a5fff067f7
|
@ -32,3 +32,4 @@ clap = "2.33.3"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
crossbeam = "0.8.0"
|
crossbeam = "0.8.0"
|
||||||
enum-as-inner = "0.3.3"
|
enum-as-inner = "0.3.3"
|
||||||
|
dirs = "3.0.1"
|
39
espanso/src/cli/worker/engine/render/clipboard.rs
Normal file
39
espanso/src/cli/worker/engine/render/clipboard.rs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* This file is part of espanso.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019-2021 Federico Terzi
|
||||||
|
*
|
||||||
|
* espanso is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* espanso is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use espanso_clipboard::Clipboard;
|
||||||
|
use espanso_render::extension::clipboard::ClipboardProvider;
|
||||||
|
|
||||||
|
pub struct ClipboardAdapter<'a> {
|
||||||
|
clipboard: &'a dyn Clipboard,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a> ClipboardAdapter<'a> {
|
||||||
|
pub fn new(clipboard: &'a dyn Clipboard) -> Self {
|
||||||
|
Self {
|
||||||
|
clipboard
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ClipboardProvider for ClipboardAdapter<'a> {
|
||||||
|
fn get_text(&self) -> Option<String> {
|
||||||
|
self.clipboard.get_text()
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,7 +17,9 @@
|
||||||
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use std::{cell::RefCell, collections::HashMap, convert::TryInto};
|
use std::{cell::RefCell, collections::HashMap};
|
||||||
|
|
||||||
|
pub mod clipboard;
|
||||||
|
|
||||||
use espanso_config::{
|
use espanso_config::{
|
||||||
config::Config,
|
config::Config,
|
|
@ -47,6 +47,8 @@ fn worker_main(args: CliModuleArgs) {
|
||||||
.match_store
|
.match_store
|
||||||
.expect("missing match store in worker main");
|
.expect("missing match store in worker main");
|
||||||
|
|
||||||
|
let paths = args.paths.expect("missing paths in worker main");
|
||||||
|
|
||||||
let app_info_provider =
|
let app_info_provider =
|
||||||
espanso_info::get_provider().expect("unable to initialize app info provider");
|
espanso_info::get_provider().expect("unable to initialize app info provider");
|
||||||
let config_manager =
|
let config_manager =
|
||||||
|
@ -66,8 +68,27 @@ fn worker_main(args: CliModuleArgs) {
|
||||||
let selector = MatchSelectorAdapter::new();
|
let selector = MatchSelectorAdapter::new();
|
||||||
let multiplexer = engine::multiplex::MultiplexAdapter::new(&match_cache);
|
let multiplexer = engine::multiplex::MultiplexAdapter::new(&match_cache);
|
||||||
|
|
||||||
// TODO: add extensions
|
let injector =
|
||||||
let renderer = espanso_render::create(Vec::new());
|
espanso_inject::get_injector(Default::default()).expect("failed to initialize injector module"); // TODO: handle the options
|
||||||
|
let clipboard = espanso_clipboard::get_clipboard(Default::default())
|
||||||
|
.expect("failed to initialize clipboard module"); // TODO: handle options
|
||||||
|
|
||||||
|
let clipboard_adapter = engine::render::clipboard::ClipboardAdapter::new(&*clipboard);
|
||||||
|
let clipboard_extension = espanso_render::extension::clipboard::ClipboardExtension::new(&clipboard_adapter);
|
||||||
|
let date_extension = espanso_render::extension::date::DateExtension::new();
|
||||||
|
let echo_extension = espanso_render::extension::echo::EchoExtension::new();
|
||||||
|
let random_extension = espanso_render::extension::random::RandomExtension::new();
|
||||||
|
let home_path = dirs::home_dir().expect("unable to obtain home dir path");
|
||||||
|
let script_extension = espanso_render::extension::script::ScriptExtension::new(&paths.config, &home_path, &paths.packages);
|
||||||
|
let shell_extension = espanso_render::extension::shell::ShellExtension::new(&paths.config);
|
||||||
|
let renderer = espanso_render::create(vec![
|
||||||
|
&clipboard_extension,
|
||||||
|
&date_extension,
|
||||||
|
&echo_extension,
|
||||||
|
&random_extension,
|
||||||
|
&script_extension,
|
||||||
|
&shell_extension,
|
||||||
|
]);
|
||||||
let renderer_adapter =
|
let renderer_adapter =
|
||||||
engine::render::RendererAdapter::new(&match_cache, &config_manager, &renderer);
|
engine::render::RendererAdapter::new(&match_cache, &config_manager, &renderer);
|
||||||
|
|
||||||
|
@ -80,10 +101,6 @@ fn worker_main(args: CliModuleArgs) {
|
||||||
&match_cache,
|
&match_cache,
|
||||||
);
|
);
|
||||||
|
|
||||||
let injector =
|
|
||||||
espanso_inject::get_injector(Default::default()).expect("failed to initialize injector module"); // TODO: handle the options
|
|
||||||
let clipboard = espanso_clipboard::get_clipboard(Default::default())
|
|
||||||
.expect("failed to initialize clipboard module"); // TODO: handle options
|
|
||||||
|
|
||||||
let event_injector = engine::executor::event_injector::EventInjectorAdapter::new(&*injector);
|
let event_injector = engine::executor::event_injector::EventInjectorAdapter::new(&*injector);
|
||||||
let clipboard_injector =
|
let clipboard_injector =
|
||||||
|
|
Loading…
Reference in New Issue
Block a user