summaryrefslogtreecommitdiff
path: root/src/key_state.zig
diff options
context:
space:
mode:
authorGravatar Uko Kokņevičs2022-01-02 05:25:20 +0200
committerGravatar Uko Kokņevičs2022-01-02 05:25:20 +0200
commit963d1fa7bd2d74c951859f27e4fb01eb71a77e8d (patch)
treef8f0d360a2ad48e76531668ae12378652d03affb /src/key_state.zig
parenthierarchy changes (diff)
downloades-963d1fa7bd2d74c951859f27e4fb01eb71a77e8d.tar.gz
es-963d1fa7bd2d74c951859f27e4fb01eb71a77e8d.tar.xz
es-963d1fa7bd2d74c951859f27e4fb01eb71a77e8d.zip
Improved input
Diffstat (limited to 'src/key_state.zig')
-rw-r--r--src/key_state.zig23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/key_state.zig b/src/key_state.zig
index ce20071..2cb9988 100644
--- a/src/key_state.zig
+++ b/src/key_state.zig
@@ -19,7 +19,7 @@ pub const Error = error{
19 std.os.RealPathError; 19 std.os.RealPathError;
20pub const KeyState = fn (*Editor, *Buffer, Key) Error!void; 20pub const KeyState = fn (*Editor, *Buffer, Key) Error!void;
21 21
22pub fn mgState(editor: *Editor, buf: *Buffer, key: Key) Error!void { 22fn mgState(editor: *Editor, buf: *Buffer, key: Key) Error!void {
23 editor.current_state = defaultState; 23 editor.current_state = defaultState;
24 editor.clearStatusMessage(); 24 editor.clearStatusMessage();
25 25
@@ -34,7 +34,23 @@ pub fn mgState(editor: *Editor, buf: *Buffer, key: Key) Error!void {
34 } 34 }
35} 35}
36 36
37pub fn cxState(editor: *Editor, buf: *Buffer, key: Key) Error!void { 37fn mOState(editor: *Editor, buf: *Buffer, key: Key) Error!void {
38 editor.current_state = defaultState;
39 editor.clearStatusMessage();
40
41 switch (key) {
42 // ========== <*> ==========
43 Key.char('F') => buf.moveEndOfLine(),
44 Key.char('H') => buf.moveBeginningOfLine(),
45
46 else => {
47 std.log.debug("Unknown chord: M-O {}", .{key});
48 try editor.setStatusMessage("Unknown chord: M-O {}", .{key});
49 },
50 }
51}
52
53fn cxState(editor: *Editor, buf: *Buffer, key: Key) Error!void {
38 editor.current_state = defaultState; 54 editor.current_state = defaultState;
39 editor.clearStatusMessage(); 55 editor.clearStatusMessage();
40 56
@@ -59,13 +75,14 @@ pub fn cxState(editor: *Editor, buf: *Buffer, key: Key) Error!void {
59pub fn defaultState(editor: *Editor, buf: *Buffer, key: Key) Error!void { 75pub fn defaultState(editor: *Editor, buf: *Buffer, key: Key) Error!void {
60 switch (key) { 76 switch (key) {
61 // ========== M-C-<*> ========== 77 // ========== M-C-<*> ==========
62 Key.metaCtrl('d'), Key.backspace => try buf.backwardDeleteChar(), 78 Key.meta(Key.ctrl('d')), Key.backspace => try buf.backwardDeleteChar(),
63 79
64 // ========== M-<*> ========== 80 // ========== M-<*> ==========
65 Key.meta('g') => { 81 Key.meta('g') => {
66 editor.current_state = mgState; 82 editor.current_state = mgState;
67 try editor.setStatusMessage("M-g-", .{}); 83 try editor.setStatusMessage("M-g-", .{});
68 }, 84 },
85 Key.meta('O') => editor.current_state = mOState,
69 Key.meta('v'), Key.page_up => buf.pageUp(editor.screenrows), 86 Key.meta('v'), Key.page_up => buf.pageUp(editor.screenrows),
70 87
71 // ========== C-<*> ========== 88 // ========== C-<*> ==========