Change way Inject backend handles multiline matches on Linux
This commit is contained in:
parent
23095d4394
commit
33cfb156db
|
@ -295,6 +295,10 @@ void send_string(const char * string) {
|
||||||
xdo_enter_text_window(xdo_context, CURRENTWINDOW, string, 1000);
|
xdo_enter_text_window(xdo_context, CURRENTWINDOW, string, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void send_enter() {
|
||||||
|
xdo_send_keysequence_window(xdo_context, CURRENTWINDOW, "Return", 1000);
|
||||||
|
}
|
||||||
|
|
||||||
void delete_string(int32_t count) {
|
void delete_string(int32_t count) {
|
||||||
for (int i = 0; i<count; i++) {
|
for (int i = 0; i<count; i++) {
|
||||||
xdo_send_keysequence_window(xdo_context, CURRENTWINDOW, "BackSpace", 1000);
|
xdo_send_keysequence_window(xdo_context, CURRENTWINDOW, "BackSpace", 1000);
|
||||||
|
|
|
@ -67,6 +67,11 @@ extern "C" void send_string(const char * string);
|
||||||
*/
|
*/
|
||||||
extern "C" void delete_string(int32_t count);
|
extern "C" void delete_string(int32_t count);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Send an Enter key press
|
||||||
|
*/
|
||||||
|
extern "C" void send_enter();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Send the left arrow keypress, *count* times.
|
* Send the left arrow keypress, *count* times.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -40,6 +40,7 @@ extern {
|
||||||
pub fn send_string(string: *const c_char);
|
pub fn send_string(string: *const c_char);
|
||||||
pub fn delete_string(count: i32);
|
pub fn delete_string(count: i32);
|
||||||
pub fn left_arrow(count: i32);
|
pub fn left_arrow(count: i32);
|
||||||
|
pub fn send_enter();
|
||||||
pub fn trigger_paste();
|
pub fn trigger_paste();
|
||||||
pub fn trigger_terminal_paste();
|
pub fn trigger_terminal_paste();
|
||||||
pub fn trigger_shift_ins_paste();
|
pub fn trigger_shift_ins_paste();
|
||||||
|
|
|
@ -209,22 +209,15 @@ impl <'a, S: KeyboardManager, C: ClipboardManager, M: ConfigManager<'a>, U: UIMa
|
||||||
|
|
||||||
match backend {
|
match backend {
|
||||||
BackendType::Inject => {
|
BackendType::Inject => {
|
||||||
// Send the expected string. On linux, newlines are managed automatically
|
// To handle newlines, substitute each "\n" char with an Enter key press.
|
||||||
// while on windows and macos, we need to emulate a Enter key press.
|
let splits = target_string.split('\n');
|
||||||
|
|
||||||
if cfg!(target_os = "linux") {
|
for (i, split) in splits.enumerate() {
|
||||||
self.keyboard_manager.send_string(&target_string);
|
if i > 0 {
|
||||||
}else{
|
self.keyboard_manager.send_enter();
|
||||||
// To handle newlines, substitute each "\n" char with an Enter key press.
|
|
||||||
let splits = target_string.split('\n');
|
|
||||||
|
|
||||||
for (i, split) in splits.enumerate() {
|
|
||||||
if i > 0 {
|
|
||||||
self.keyboard_manager.send_enter();
|
|
||||||
}
|
|
||||||
|
|
||||||
self.keyboard_manager.send_string(split);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.keyboard_manager.send_string(split);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
BackendType::Clipboard => {
|
BackendType::Clipboard => {
|
||||||
|
|
|
@ -35,7 +35,9 @@ impl super::KeyboardManager for LinuxKeyboardManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_enter(&self) {
|
fn send_enter(&self) {
|
||||||
// On linux this is not needed, so NOOP
|
unsafe {
|
||||||
|
send_enter();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn trigger_paste(&self, shortcut: &PasteShortcut) {
|
fn trigger_paste(&self, shortcut: &PasteShortcut) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user