add more vim bindings

This commit is contained in:
Robert Burnett 2024-11-20 15:18:17 -06:00 committed by CJ van den Berg
parent ba82922ce9
commit ae91afe255
2 changed files with 94 additions and 8 deletions

View file

@ -15,6 +15,7 @@ pub const ParseError = error{
InvalidStartOfControlBinding,
InvalidStartOfShiftBinding,
InvalidStartOfDelBinding,
InvalidStartOfEscBinding,
InvalidStartOfHomeBinding,
InvalidCRBinding,
InvalidSpaceBinding,
@ -117,7 +118,11 @@ pub fn parse_key_events(allocator: std.mem.Allocator, event: input.Event, str: [
'-' => {
state = .modifier;
},
else => return parse_error(error.InvalidStartOfControlBinding, "str: {s}, i: {} c: {c}", .{ str, i, str[i] }),
else => return parse_error(
error.InvalidStartOfControlBinding,
"str: {s}, i: {} c: {c}",
.{ str, i, str[i] },
),
}
},
'S' => {
@ -128,7 +133,11 @@ pub fn parse_key_events(allocator: std.mem.Allocator, event: input.Event, str: [
'p' => {
state = .space;
},
else => return parse_error(error.InvalidStartOfShiftBinding, "str: {s}, i: {} c: {c}", .{ str, i, str[i] }),
else => return parse_error(
error.InvalidStartOfShiftBinding,
"str: {s}, i: {} c: {c}",
.{ str, i, str[i] },
),
}
},
'F' => {
@ -154,7 +163,15 @@ pub fn parse_key_events(allocator: std.mem.Allocator, event: input.Event, str: [
state = .bs;
},
'E' => {
state = .esc;
state = switch (try peek(str, i)) {
's' => .esc,
'n' => .end,
else => return parse_error(
error.InvalidStartOfEscBinding,
"str: {s}, i: {} c: {c}",
.{ str, i, str[i] },
),
};
},
'D' => {
switch (try peek(str, i)) {
@ -167,13 +184,21 @@ pub fn parse_key_events(allocator: std.mem.Allocator, event: input.Event, str: [
'e' => {
state = .del;
},
else => return parse_error(error.InvalidStartOfDelBinding, "str: {s}, i: {} c: {c}", .{ str, i, str[i] }),
else => return parse_error(
error.InvalidStartOfDelBinding,
"str: {s}, i: {} c: {c}",
.{ str, i, str[i] },
),
}
},
'H' => {
state = .home;
},
else => return parse_error(error.InvalidStartOfHomeBinding, "str: {s}, i: {} c: {c}", .{ str, i, str[i] }),
else => return parse_error(
error.InvalidStartOfHomeBinding,
"str: {s}, i: {} c: {c}",
.{ str, i, str[i] },
),
}
},
.insert => {