diff options
author | Federico Igne <undyamon@disroot.org> | 2024-01-28 23:42:12 +0100 |
---|---|---|
committer | Federico Igne <undyamon@disroot.org> | 2024-01-28 23:42:12 +0100 |
commit | f5c33507a74d83692c028d1e1659d3506399138e (patch) | |
tree | 15abadcda66931770003a7ec5b403695f4f81fd0 /lib/command.ml | |
parent | 633fb26ed21f7208517aa29dbaab9f0cf3bb2047 (diff) | |
download | sandy-master.tar.gz sandy-master.zip |
Diffstat (limited to 'lib/command.ml')
-rw-r--r-- | lib/command.ml | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/command.ml b/lib/command.ml index 2d7b51b..6439165 100644 --- a/lib/command.ml +++ b/lib/command.ml | |||
@@ -17,6 +17,10 @@ type operation = | |||
17 | | Search | 17 | | Search |
18 | | Search_rev | 18 | | Search_rev |
19 | | Goto | 19 | | Goto |
20 | | Undo | ||
21 | | Redo | ||
22 | | Earlier | ||
23 | | Later | ||
20 | 24 | ||
21 | type scope = Line | To_bol | To_eol | Down | Left | Right | Up | 25 | type scope = Line | To_bol | To_eol | Down | Left | Right | Up |
22 | 26 | ||
@@ -85,6 +89,8 @@ let instant_operation = | |||
85 | Key 'X'; | 89 | Key 'X'; |
86 | Key 'p'; | 90 | Key 'p'; |
87 | Key 'x'; | 91 | Key 'x'; |
92 | Key 'u'; | ||
93 | Ctrl 'R'; | ||
88 | ] | 94 | ] |
89 | 95 | ||
90 | let chord_operation = [ Key 'c'; Key 'd'; Key 'y' ] | 96 | let chord_operation = [ Key 'c'; Key 'd'; Key 'y' ] |
@@ -101,6 +107,8 @@ let to_op = function | |||
101 | | Key 'P' -> Paste_before | 107 | | Key 'P' -> Paste_before |
102 | | Key 'x' -> Erase_after | 108 | | Key 'x' -> Erase_after |
103 | | Key 'X' -> Erase_before | 109 | | Key 'X' -> Erase_before |
110 | | Key 'u' -> Undo | ||
111 | | Ctrl 'R' -> Redo | ||
104 | | _ -> failwith "Invalid operation in chord." | 112 | | _ -> failwith "Invalid operation in chord." |
105 | 113 | ||
106 | let is_chord_operation k = List.mem ~equal:Poly.equal chord_operation k | 114 | let is_chord_operation k = List.mem ~equal:Poly.equal chord_operation k |
@@ -129,6 +137,15 @@ let n_stream = | |||
129 | (`start, shortcut ~r (to_op k)) | 137 | (`start, shortcut ~r (to_op k)) |
130 | | `chord_fst_n (r, n), k when is_instant_operation k -> | 138 | | `chord_fst_n (r, n), k when is_instant_operation k -> |
131 | (`start, shortcut ?r ~n (to_op k)) | 139 | (`start, shortcut ?r ~n (to_op k)) |
140 | (* Special operations *) | ||
141 | | `start, Key 'g' -> (`special (None, None), Partial k) | ||
142 | | `chord_reg r, Key 'g' -> (`special (Some r, None), Partial k) | ||
143 | | `chord_fst_n (r, n), Key 'g' -> (`special (r, Some n), Partial k) | ||
144 | | `special (r, n), Key 'g' -> | ||
145 | let n = Option.value ~default:0 n in | ||
146 | (`start, shortcut ?r ~n Goto) | ||
147 | | `special (r, n), Key '-' -> (`start, shortcut ?r ?n Earlier) | ||
148 | | `special (r, n), Key '+' -> (`start, shortcut ?r ?n Later) | ||
132 | (* Chord operation (first) *) | 149 | (* Chord operation (first) *) |
133 | | `start, k when is_chord_operation k -> | 150 | | `start, k when is_chord_operation k -> |
134 | (`chord_cmd (None, None, to_op k), Partial k) | 151 | (`chord_cmd (None, None, to_op k), Partial k) |