diff options
Diffstat (limited to 'lib/editor.ml')
-rw-r--r-- | lib/editor.ml | 56 |
1 files changed, 41 insertions, 15 deletions
diff --git a/lib/editor.ml b/lib/editor.ml index adc9994..96623f2 100644 --- a/lib/editor.ml +++ b/lib/editor.ml | |||
@@ -213,21 +213,12 @@ let handle_normal_command = | |||
213 | | Chord (_, n, Noop, _, Right) -> | 213 | | Chord (_, n, Noop, _, Right) -> |
214 | Buffer.Action.move_right ?n |> on_focused_buffer | 214 | Buffer.Action.move_right ?n |> on_focused_buffer |
215 | | Chord (_, n, Noop, _, Up) -> Buffer.Action.move_up ?n |> on_focused_buffer | 215 | | Chord (_, n, Noop, _, Up) -> Buffer.Action.move_up ?n |> on_focused_buffer |
216 | | Simple (Ctrl 'Q') -> quit 0 | 216 | | Chord (_, n, Noop, _, To_bol) -> |
217 | (* | Key '0' -> Buffer.Action.bol |> on_focused_buffer_or_new *) | 217 | let n = Option.value ~default:1 n - 1 in |
218 | | Simple (Key 'A') -> | 218 | Buffer.Action.(move_down ~n &> bol) |> on_focused_buffer |
219 | (Buffer.Action.eol |> on_focused_buffer_or_new) *> set_mode Insert | 219 | | Chord (_, n, Noop, _, To_eol) -> |
220 | | Simple (Key 'a') -> | 220 | let n = Option.value ~default:1 n - 1 in |
221 | (Buffer.Action.move_right |> on_focused_buffer_or_new) *> set_mode Insert | 221 | Buffer.Action.(move_down ~n &> eol) |> on_focused_buffer |
222 | (* | Key 'G' -> Buffer.Action.eof |> on_focused_buffer_or_new *) | ||
223 | (* | Key 'I' -> noop *) | ||
224 | | Simple (Key 'i') -> (Fn.id |> on_focused_buffer_or_new) *> set_mode Insert | ||
225 | (* | Key 's' -> *) | ||
226 | (* (Buffer.Action.delete_after |> on_focused_buffer_or_new) *) | ||
227 | (* *> set_mode Insert *) | ||
228 | (* | Key 'x' | Delete -> Buffer.Action.delete_after |> on_focused_buffer_or_new *) | ||
229 | (* | Key 'X' -> Buffer.Action.delete_before |> on_focused_buffer_or_new *) | ||
230 | (* | Key '$' -> Buffer.Action.eol |> on_focused_buffer_or_new *) | ||
231 | (* Change *) | 222 | (* Change *) |
232 | | Shortcut (_, n, Change) -> | 223 | | Shortcut (_, n, Change) -> |
233 | let n = Option.value ~default:1 n - 1 in | 224 | let n = Option.value ~default:1 n - 1 in |
@@ -258,6 +249,18 @@ let handle_normal_command = | |||
258 | (Buffer.Action.(bol &> delete_to_eol &> delete_lines_before ~n) | 249 | (Buffer.Action.(bol &> delete_to_eol &> delete_lines_before ~n) |
259 | |> on_focused_buffer_or_new) | 250 | |> on_focused_buffer_or_new) |
260 | *> set_mode Insert | 251 | *> set_mode Insert |
252 | | Chord (_, n1, Change, n2, To_bol) -> | ||
253 | let n = Option.((value ~default:1 n1 * value ~default:1 n2) - 1) in | ||
254 | (Buffer.Action.( | ||
255 | delete_to_bol &> move_down &> delete_lines ~n &> move_up &> bol) | ||
256 | |> on_focused_buffer_or_new) | ||
257 | *> set_mode Insert | ||
258 | | Chord (_, n1, Change, n2, To_eol) -> | ||
259 | let n = Option.((value ~default:1 n1 * value ~default:1 n2) - 1) in | ||
260 | (Buffer.Action.( | ||
261 | delete_to_eol &> move_down &> delete_lines ~n &> move_up &> eol) | ||
262 | |> on_focused_buffer_or_new) | ||
263 | *> set_mode Insert | ||
261 | (* Delete *) | 264 | (* Delete *) |
262 | | Shortcut (_, n, Delete) -> | 265 | | Shortcut (_, n, Delete) -> |
263 | let n = Option.value ~default:1 n - 1 in | 266 | let n = Option.value ~default:1 n - 1 in |
@@ -286,10 +289,33 @@ let handle_normal_command = | |||
286 | let n = Option.(value ~default:1 n1 * value ~default:1 n2) in | 289 | let n = Option.(value ~default:1 n1 * value ~default:1 n2) in |
287 | Buffer.Action.(delete_lines ~n:1 &> delete_lines_before ~n) | 290 | Buffer.Action.(delete_lines ~n:1 &> delete_lines_before ~n) |
288 | |> on_focused_buffer_or_new | 291 | |> on_focused_buffer_or_new |
292 | | Chord (_, n1, Delete, n2, To_bol) -> | ||
293 | let n = Option.((value ~default:1 n1 * value ~default:1 n2) - 1) in | ||
294 | Buffer.Action.( | ||
295 | delete_to_bol &> move_down &> delete_lines ~n &> move_up &> bol) | ||
296 | |> on_focused_buffer_or_new | ||
297 | | Chord (_, n1, Delete, n2, To_eol) -> | ||
298 | let n = Option.((value ~default:1 n1 * value ~default:1 n2) - 1) in | ||
299 | Buffer.Action.( | ||
300 | delete_to_eol &> move_down &> delete_lines ~n &> move_up &> eol) | ||
301 | |> on_focused_buffer_or_new | ||
289 | (* Join *) | 302 | (* Join *) |
290 | | Shortcut (_, n, Join) -> | 303 | | Shortcut (_, n, Join) -> |
291 | let n = Option.(value ~default:1 n) in | 304 | let n = Option.(value ~default:1 n) in |
292 | Buffer.Action.join_lines ~n |> on_focused_buffer_or_new | 305 | Buffer.Action.join_lines ~n |> on_focused_buffer_or_new |
306 | (* Quit *) | ||
307 | | Simple (Ctrl 'Q') -> quit 0 | ||
308 | (* Misc *) | ||
309 | | Simple (Key 'A') -> | ||
310 | (Buffer.Action.eol |> on_focused_buffer_or_new) *> set_mode Insert | ||
311 | | Simple (Key 'a') -> | ||
312 | (Buffer.Action.move_right |> on_focused_buffer_or_new) *> set_mode Insert | ||
313 | (* | Key 'G' -> Buffer.Action.eof |> on_focused_buffer_or_new *) | ||
314 | (* | Key 'I' -> noop *) | ||
315 | | Simple (Key 'i') -> (Fn.id |> on_focused_buffer_or_new) *> set_mode Insert | ||
316 | (* | Key 's' -> *) | ||
317 | (* (Buffer.Action.delete_after |> on_focused_buffer_or_new) *) | ||
318 | (* *> set_mode Insert *) | ||
293 | | _ -> noop | 319 | | _ -> noop |
294 | 320 | ||
295 | let handle_next_command m e = | 321 | let handle_next_command m e = |