Add cursor position implementation on Linux

This commit is contained in:
Federico Terzi 2019-10-25 22:34:31 +02:00
parent 8afacf4efb
commit b63e2b2592
4 changed files with 19 additions and 1 deletions

View File

@ -278,6 +278,12 @@ void delete_string(int32_t count) {
} }
} }
void left_arrow(int32_t count) {
for (int i = 0; i<count; i++) {
xdo_send_keysequence_window(xdo_context, CURRENTWINDOW, "Left", 8000);
}
}
void trigger_paste() { void trigger_paste() {
xdo_send_keysequence_window(xdo_context, CURRENTWINDOW, "Control_L+v", 8000); xdo_send_keysequence_window(xdo_context, CURRENTWINDOW, "Control_L+v", 8000);
} }
@ -450,4 +456,4 @@ int32_t is_current_window_terminal() {
} }
return 0; return 0;
} }

View File

@ -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 the left arrow keypress, *count* times.
*/
extern "C" void left_arrow(int32_t count);
/* /*
* Trigger normal paste ( Pressing CTRL+V ) * Trigger normal paste ( Pressing CTRL+V )
*/ */

View File

@ -39,6 +39,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 trigger_paste(); pub fn trigger_paste();
pub fn trigger_terminal_paste(); pub fn trigger_terminal_paste();
} }

View File

@ -53,4 +53,10 @@ impl super::KeyboardManager for LinuxKeyboardManager {
fn delete_string(&self, count: i32) { fn delete_string(&self, count: i32) {
unsafe {delete_string(count)} unsafe {delete_string(count)}
} }
fn move_cursor_left(&self, count: i32) {
unsafe {
left_arrow(count);
}
}
} }