parent
6618a2d84d
commit
2cced4fbff
2 changed files with 33 additions and 3 deletions
|
@ -35,8 +35,8 @@
|
|||
["o", ["enter_mode", "insert"], ["smart_insert_line_after"]],
|
||||
["O", ["enter_mode", "insert"], ["smart_insert_line_before"]],
|
||||
|
||||
["<S-.><S-.>", "indent"],
|
||||
["<S-,><S-,>", "unindent"],
|
||||
["<GT><GT>", "indent"],
|
||||
["<LT><LT>", "unindent"],
|
||||
|
||||
["v", "enter_mode", "visual"],
|
||||
["V", ["enter_mode", "visual line"], ["select_line_vim"]],
|
||||
|
|
|
@ -15,6 +15,7 @@ pub const ParseError = error{
|
|||
InvalidStartOfControlBinding,
|
||||
InvalidStartOfShiftBinding,
|
||||
InvalidStartOfDelBinding,
|
||||
InvalidStartOfLeftBinding,
|
||||
InvalidStartOfEscBinding,
|
||||
InvalidStartOfHomeBinding,
|
||||
InvalidCRBinding,
|
||||
|
@ -74,6 +75,8 @@ pub fn parse_key_events(allocator: std.mem.Allocator, str: []const u8) ParseErro
|
|||
end,
|
||||
insert,
|
||||
bs,
|
||||
less_than,
|
||||
greater_than,
|
||||
};
|
||||
var state: State = .base;
|
||||
var function_key_number: u8 = 0;
|
||||
|
@ -150,11 +153,22 @@ pub fn parse_key_events(allocator: std.mem.Allocator, str: []const u8) ParseErro
|
|||
state = .up;
|
||||
},
|
||||
'L' => {
|
||||
state = .left;
|
||||
state = switch (try peek(str, i)) {
|
||||
'e' => .left,
|
||||
'T' => .less_than,
|
||||
else => return parse_error(
|
||||
error.InvalidStartOfLeftBinding,
|
||||
"str: {s}, i: {} c: {c}",
|
||||
.{ str, i, str[i] },
|
||||
),
|
||||
};
|
||||
},
|
||||
'R' => {
|
||||
state = .right;
|
||||
},
|
||||
'G' => {
|
||||
state = .greater_than;
|
||||
},
|
||||
'I' => {
|
||||
state = .insert;
|
||||
},
|
||||
|
@ -304,6 +318,22 @@ pub fn parse_key_events(allocator: std.mem.Allocator, str: []const u8) ParseErro
|
|||
i += 5;
|
||||
} else return parse_error(error.InvalidRightBinding, "str: {s}, i: {} c: {c}", .{ str, i, str[i] });
|
||||
},
|
||||
.less_than => {
|
||||
if (std.mem.indexOf(u8, str[i..], "LT") == 0) {
|
||||
try result.append(from_key_mods('<', modifiers));
|
||||
modifiers = 0;
|
||||
state = .escape_sequence_end;
|
||||
i += 2;
|
||||
} else return parse_error(error.InvalidLeftBinding, "str: {s}, i: {} c: {c}", .{ str, i, str[i] });
|
||||
},
|
||||
.greater_than => {
|
||||
if (std.mem.indexOf(u8, str[i..], "GT") == 0) {
|
||||
try result.append(from_key_mods('>', modifiers));
|
||||
modifiers = 0;
|
||||
state = .escape_sequence_end;
|
||||
i += 2;
|
||||
} else return parse_error(error.InvalidLeftBinding, "str: {s}, i: {} c: {c}", .{ str, i, str[i] });
|
||||
},
|
||||
.function_key => {
|
||||
switch (str[i]) {
|
||||
'0'...'9' => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue