summaryrefslogtreecommitdiff
path: root/lib/command.ml
diff options
context:
space:
mode:
authorFederico Igne <undyamon@disroot.org>2024-01-12 22:26:12 +0100
committerFederico Igne <undyamon@disroot.org>2024-01-12 22:26:12 +0100
commit6563ec106879b76e1b1e6fdfabf33587cefa9dc0 (patch)
treee4c775888d2f56209b527fae615ce6670eb36b27 /lib/command.ml
parent123ba3b46acd16d420b82d5a25c5a4c50135afe6 (diff)
downloadsandy-6563ec106879b76e1b1e6fdfabf33587cefa9dc0.tar.gz
sandy-6563ec106879b76e1b1e6fdfabf33587cefa9dc0.zip
feat: add '0' and '$' movements
Diffstat (limited to 'lib/command.ml')
-rw-r--r--lib/command.ml48
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
42let simple_movements = 42let 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
56let instant_operation =
57 [ Key 'C'; Key 'D'; Key 'J'; Key 'P'; Key 'X'; Key 'p'; Key 'x' ]
58
59let chord_operation = [ Key 'c'; Key 'd'; Key 'y' ]
60
61let to_scope = function 58let 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
67let is_simple_movement k = List.mem ~equal:Poly.equal simple_movements k
68
69let instant_operation =
70 [ Key 'C'; Key 'D'; Key 'J'; Key 'P'; Key 'X'; Key 'p'; Key 'x' ]
71
72let chord_operation = [ Key 'c'; Key 'd'; Key 'y' ]
73
74let 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
85let is_chord_operation k = List.mem ~equal:Poly.equal chord_operation k
86let is_instant_operation k = List.mem ~equal:Poly.equal instant_operation k
87
68let n_stream = 88let 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 *)