diff options
Diffstat (limited to 'lib/command.ml')
-rw-r--r-- | lib/command.ml | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/lib/command.ml b/lib/command.ml index 97c1fdf..a68c723 100644 --- a/lib/command.ml +++ b/lib/command.ml | |||
@@ -41,11 +41,13 @@ let i_stream = | |||
41 | 41 | ||
42 | let simple_movements = | 42 | let simple_movements = |
43 | [ | 43 | [ |
44 | Key ' '; | ||
45 | Key '0'; | ||
44 | Key 'h'; | 46 | Key 'h'; |
45 | Key 'j'; | 47 | Key 'j'; |
46 | Key 'k'; | 48 | Key 'k'; |
47 | Key 'l'; | 49 | Key 'l'; |
48 | Key ' '; | 50 | Key '$'; |
49 | Arrow_up; | 51 | Arrow_up; |
50 | Arrow_down; | 52 | Arrow_down; |
51 | Arrow_left; | 53 | Arrow_left; |
@@ -53,37 +55,39 @@ let simple_movements = | |||
53 | Backspace; | 55 | Backspace; |
54 | ] | 56 | ] |
55 | 57 | ||
56 | let instant_operation = | ||
57 | [ Key 'C'; Key 'D'; Key 'J'; Key 'P'; Key 'X'; Key 'p'; Key 'x' ] | ||
58 | |||
59 | let chord_operation = [ Key 'c'; Key 'd'; Key 'y' ] | ||
60 | |||
61 | let to_scope = function | 58 | let to_scope = function |
62 | | Key 'j' | Arrow_down -> Down | 59 | | Key 'j' | Arrow_down -> Down |
63 | | Key 'h' | Arrow_left | Backspace -> Left | 60 | | Key 'h' | Arrow_left | Backspace -> Left |
64 | | Key 'l' | Key ' ' | Arrow_right -> Right | 61 | | Key 'l' | Key ' ' | Arrow_right -> Right |
65 | | Key 'k' | Arrow_up -> Up | 62 | | Key 'k' | Arrow_up -> Up |
63 | | Key '0' -> To_bol | ||
64 | | Key '$' -> To_eol | ||
66 | | _ -> failwith "Invalid motion." | 65 | | _ -> failwith "Invalid motion." |
67 | 66 | ||
67 | let is_simple_movement k = List.mem ~equal:Poly.equal simple_movements k | ||
68 | |||
69 | let instant_operation = | ||
70 | [ Key 'C'; Key 'D'; Key 'J'; Key 'P'; Key 'X'; Key 'p'; Key 'x' ] | ||
71 | |||
72 | let chord_operation = [ Key 'c'; Key 'd'; Key 'y' ] | ||
73 | |||
74 | let to_op = function | ||
75 | | Key 'J' -> Join | ||
76 | | Key 'c' | Key 'C' -> Change | ||
77 | | Key 'd' | Key 'D' -> Delete | ||
78 | | Key 'y' | Key 'Y' -> Yank | ||
79 | | Key 'p' -> Paste_after | ||
80 | | Key 'P' -> Paste_before | ||
81 | | Key 'x' -> Erase_after | ||
82 | | Key 'X' -> Erase_before | ||
83 | | _ -> failwith "Invalid operation in chord." | ||
84 | |||
85 | let is_chord_operation k = List.mem ~equal:Poly.equal chord_operation k | ||
86 | let is_instant_operation k = List.mem ~equal:Poly.equal instant_operation k | ||
87 | |||
68 | let n_stream = | 88 | let n_stream = |
69 | let step s k = | 89 | let step s k = |
70 | let open Sequence.Step in | 90 | let open Sequence.Step in |
71 | let is_chord_operation k = List.mem ~equal:Poly.equal chord_operation k in | ||
72 | let is_simple_movement k = List.mem ~equal:Poly.equal simple_movements k in | ||
73 | let is_instant_operation k = | ||
74 | List.mem ~equal:Poly.equal instant_operation k | ||
75 | in | ||
76 | let to_op = function | ||
77 | | Key 'J' -> Join | ||
78 | | Key 'c' | Key 'C' -> Change | ||
79 | | Key 'd' | Key 'D' -> Delete | ||
80 | | Key 'y' | Key 'Y' -> Yank | ||
81 | | Key 'p' -> Paste_after | ||
82 | | Key 'P' -> Paste_before | ||
83 | | Key 'x' -> Erase_after | ||
84 | | Key 'X' -> Erase_before | ||
85 | | _ -> failwith "Invalid operation in chord." | ||
86 | in | ||
87 | match (s, k) with | 91 | match (s, k) with |
88 | | `start, Key '"' -> Yield { value = Partial k; state = `chord_reg_pre } | 92 | | `start, Key '"' -> Yield { value = Partial k; state = `chord_reg_pre } |
89 | (* Register *) | 93 | (* Register *) |