1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use crate::env;
use std::io;
pub enum Mode {
Normal,
Insert,
Caret,
Passthrough,
}
pub fn enter_mode(mode: Mode) -> Result<(), io::Error> {
let mode_str = match mode {
Mode::Normal => "normal",
Mode::Insert => "insert",
Mode::Caret => "caret",
Mode::Passthrough => "passthrough",
};
let message = format!("enter-mode {}", mode_str);
send_command(&message)
}
pub fn fake_key(s: &str) -> Result<(), io::Error> {
let message = format!("fake-key {}", s);
send_command(&message)
}
pub fn send_command(cmd: &str) -> Result<(), io::Error> {
let fifo = env::fifo();
fifo.write(cmd)
}