2019-09-01 12:58:39 +00:00
|
|
|
use std::sync::mpsc;
|
2019-09-07 14:13:13 +00:00
|
|
|
use std::os::raw::{c_void};
|
2019-09-01 14:50:20 +00:00
|
|
|
use std::ffi::CString;
|
2019-09-07 11:35:45 +00:00
|
|
|
use crate::bridge::linux::*;
|
|
|
|
|
2019-09-13 13:03:03 +00:00
|
|
|
pub struct LinuxKeyboardManager {
|
2019-09-01 12:58:39 +00:00
|
|
|
}
|
|
|
|
|
2019-09-13 13:03:03 +00:00
|
|
|
impl super::KeyboardManager for LinuxKeyboardManager {
|
2019-09-01 12:58:39 +00:00
|
|
|
fn send_string(&self, s: &str) {
|
2019-09-01 14:50:20 +00:00
|
|
|
let res = CString::new(s);
|
|
|
|
match res {
|
|
|
|
Ok(cstr) => unsafe { send_string(cstr.as_ptr()); }
|
|
|
|
Err(e) => panic!(e.to_string())
|
|
|
|
}
|
2019-09-01 12:58:39 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 20:19:28 +00:00
|
|
|
fn send_enter(&self) {
|
|
|
|
// On linux this is not needed, so NOOP
|
|
|
|
}
|
|
|
|
|
2019-09-06 22:38:13 +00:00
|
|
|
fn trigger_paste(&self) {
|
|
|
|
unsafe { trigger_paste(); }
|
|
|
|
|
|
|
|
// TODO: detect when in terminal and use trigger_terminal_paste() instead
|
|
|
|
}
|
|
|
|
|
2019-09-01 12:58:39 +00:00
|
|
|
fn delete_string(&self, count: i32) {
|
2019-09-01 14:50:20 +00:00
|
|
|
unsafe {delete_string(count)}
|
2019-09-01 12:58:39 +00:00
|
|
|
}
|
|
|
|
}
|