-
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathmain.ml
More file actions
48 lines (44 loc) · 1.09 KB
/
main.ml
File metadata and controls
48 lines (44 loc) · 1.09 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
open Leaves
open Minttea
type msg = CursorUp | CursorDown | CursorLeft
let defaults =
let open Key_map in
make [
on
~help:{ key = "up"; desc = "↑/k" }
[ Minttea.Event.Up; Minttea.Event.Key "k" ]
CursorUp;
on
~help:{ key = "down"; desc = "↓/j" }
[ Minttea.Event.Down; Minttea.Event.Key "j" ]
CursorDown;
on ~disabled:true
~help:{ key = "left"; desc = "←/h" }
[ Minttea.Event.Left; Minttea.Event.Key "h" ]
CursorLeft;
]
let custom_key_map =
let open Key_map in
[
on
~help:{ key = "up"; desc = "↑/k" }
[ Minttea.Event.Up; Minttea.Event.Key "k"; Minttea.Event.Key "u" ]
CursorUp;
]
let () =
List.iter
(fun k ->
match Key_map.find_match ~custom_key_map k defaults with
| Some CursorUp -> print_endline "up"
| Some CursorDown -> print_endline "down"
| Some CursorLeft -> print_endline "left"
| None -> print_endline "Not Found")
[
Event.Up;
Event.Key "k";
Event.Key "u";
Event.Down;
Event.Key "j";
Event.Left;
Event.Enter;
]