Solve some TODOs
This commit is contained in:
parent
fbee38d5b8
commit
29629afa52
|
@ -121,6 +121,8 @@ int32_t initialize(void * _context_instance) {
|
|||
}
|
||||
|
||||
xdo_context = xdo_new(NULL);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32_t eventloop() {
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::os::raw::{c_void, c_char};
|
|||
#[allow(improper_ctypes)]
|
||||
#[link(name="linuxbridge", kind="static")]
|
||||
extern {
|
||||
pub fn initialize(s: *const c_void);
|
||||
pub fn initialize(s: *const c_void) -> i32;
|
||||
pub fn eventloop();
|
||||
pub fn cleanup();
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ use std::os::raw::c_void;
|
|||
use crate::event::*;
|
||||
use crate::event::KeyModifier::*;
|
||||
use crate::bridge::linux::*;
|
||||
use std::process::exit;
|
||||
use log::error;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct LinuxContext {
|
||||
|
@ -20,7 +22,11 @@ impl LinuxContext {
|
|||
|
||||
register_keypress_callback(keypress_callback);
|
||||
|
||||
initialize(context_ptr); // TODO: check initialization return codes
|
||||
let res = initialize(context_ptr);
|
||||
if res <= 0 {
|
||||
error!("Could not initialize linux context, error: {}", res);
|
||||
exit(10);
|
||||
}
|
||||
}
|
||||
|
||||
context
|
||||
|
|
|
@ -10,7 +10,6 @@ use crate::extension::Extension;
|
|||
use std::cell::RefCell;
|
||||
use std::process::exit;
|
||||
use std::collections::HashMap;
|
||||
use serde_yaml::Mapping;
|
||||
use regex::{Regex, Captures};
|
||||
|
||||
pub struct Engine<'a, S: KeyboardManager, C: ClipboardManager, M: ConfigManager<'a>,
|
||||
|
@ -79,7 +78,7 @@ impl <'a, S: KeyboardManager, C: ClipboardManager, M: ConfigManager<'a>, U: UIMa
|
|||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref VarRegex: Regex = Regex::new("\\{\\{\\s*(?P<name>\\w+)\\s*\\}\\}").unwrap();
|
||||
static ref VAR_REGEX: Regex = Regex::new("\\{\\{\\s*(?P<name>\\w+)\\s*\\}\\}").unwrap();
|
||||
}
|
||||
|
||||
impl <'a, S: KeyboardManager, C: ClipboardManager, M: ConfigManager<'a>, U: UIManager>
|
||||
|
@ -95,7 +94,6 @@ impl <'a, S: KeyboardManager, C: ClipboardManager, M: ConfigManager<'a>, U: UIMa
|
|||
self.keyboard_manager.delete_string(m.trigger.len() as i32);
|
||||
|
||||
let target_string = if m._has_vars {
|
||||
//self.extension_map.get("date").unwrap().calculate(Mapping::new()).unwrap()
|
||||
let mut output_map = HashMap::new();
|
||||
|
||||
for variable in m.vars.iter() {
|
||||
|
@ -114,7 +112,7 @@ impl <'a, S: KeyboardManager, C: ClipboardManager, M: ConfigManager<'a>, U: UIMa
|
|||
}
|
||||
|
||||
// Replace the variables
|
||||
let result = VarRegex.replace_all(&m.replace, |caps: &Captures| {
|
||||
let result = VAR_REGEX.replace_all(&m.replace, |caps: &Captures| {
|
||||
let var_name = caps.name("name").unwrap().as_str();
|
||||
let output = output_map.get(var_name);
|
||||
output.unwrap()
|
||||
|
|
|
@ -28,11 +28,11 @@ impl <'de> serde::Deserialize<'de> for Match {
|
|||
impl<'a> From<&'a AutoMatch> for Match{
|
||||
fn from(other: &'a AutoMatch) -> Self {
|
||||
lazy_static! {
|
||||
static ref VarRegex: Regex = Regex::new("\\{\\{\\s*(\\w+)\\s*\\}\\}").unwrap();
|
||||
static ref VAR_REGEX: Regex = Regex::new("\\{\\{\\s*(\\w+)\\s*\\}\\}").unwrap();
|
||||
}
|
||||
|
||||
// Check if the match contains variables
|
||||
let has_vars = VarRegex.is_match(&other.replace);
|
||||
let has_vars = VAR_REGEX.is_match(&other.replace);
|
||||
|
||||
Self {
|
||||
trigger: other.trigger.clone(),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use std::process::Command;
|
||||
use super::MenuItem;
|
||||
use log::error;
|
||||
|
||||
pub struct LinuxUIManager {}
|
||||
|
||||
|
@ -9,8 +10,8 @@ impl super::UIManager for LinuxUIManager {
|
|||
.args(&["-t", "2000", "espanso", message])
|
||||
.output();
|
||||
|
||||
if let Err(_) = res {
|
||||
// TODO: print error log
|
||||
if let Err(e) = res {
|
||||
error!("Could not send a notification, error: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,8 +22,6 @@ impl super::UIManager for LinuxUIManager {
|
|||
|
||||
impl LinuxUIManager {
|
||||
pub fn new() -> LinuxUIManager {
|
||||
// TODO: check if notify-send is present and log an error otherwise.
|
||||
|
||||
LinuxUIManager{}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user