send a utf-8 string to the host all characters are converted into unicode input!
(&mut self, s: &str)
| 381 | /// send a utf-8 string to the host |
| 382 | /// all characters are converted into unicode input! |
| 383 | fn send_string(&mut self, s: &str) { |
| 384 | for c in s.chars() { |
| 385 | /* the problem with this approach: it is dependant on the shift/caps lock state |
| 386 | match c { |
| 387 | 'a'..='z' => {self.send_keys(&[ascii_to_keycode(c, 97, KeyCode::A)]); self.send_empty()}, |
| 388 | '1'..='9' => {self.send_keys(&[ascii_to_keycode(c, 49, KeyCode::Kb1)]); self.send_empty()}, |
| 389 | '0' => {self.send_keys(&[KeyCode::Kb0]); self.send_empty()}, |
| 390 | 'A'..='Z' => {self.send_keys(&[ascii_to_keycode(c, 65, KeyCode::A), KeyCode::LShift]); self.send_empty()}, |
| 391 | _ => self.send_unicode(c), |
| 392 | } |
| 393 | */ |
| 394 | //probably best to unicode everything |
| 395 | self.send_unicode(c); |
| 396 | |
| 397 | // option: send simple ones directly? |
| 398 | /* |
| 399 | if 'a' <= c && c <= 'z' { |
| 400 | } |
| 401 | */ |
| 402 | } |
| 403 | } |
| 404 | } |
| 405 | fn ascii_to_keycode(c: char, ascii_offset: u8, keycode_offset: KeyCode) -> KeyCode { |
| 406 | let mut ascii = [0 as u8]; // buffer |
no test coverage detected