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_after"]],
|
||||||
["O", ["enter_mode", "insert"], ["smart_insert_line_before"]],
|
["O", ["enter_mode", "insert"], ["smart_insert_line_before"]],
|
||||||
|
|
||||||
["<S-.><S-.>", "indent"],
|
["<GT><GT>", "indent"],
|
||||||
["<S-,><S-,>", "unindent"],
|
["<LT><LT>", "unindent"],
|
||||||
|
|
||||||
["v", "enter_mode", "visual"],
|
["v", "enter_mode", "visual"],
|
||||||
["V", ["enter_mode", "visual line"], ["select_line_vim"]],
|
["V", ["enter_mode", "visual line"], ["select_line_vim"]],
|
||||||
|
|
|
@ -15,6 +15,7 @@ pub const ParseError = error{
|
||||||
InvalidStartOfControlBinding,
|
InvalidStartOfControlBinding,
|
||||||
InvalidStartOfShiftBinding,
|
InvalidStartOfShiftBinding,
|
||||||
InvalidStartOfDelBinding,
|
InvalidStartOfDelBinding,
|
||||||
|
InvalidStartOfLeftBinding,
|
||||||
InvalidStartOfEscBinding,
|
InvalidStartOfEscBinding,
|
||||||
InvalidStartOfHomeBinding,
|
InvalidStartOfHomeBinding,
|
||||||
InvalidCRBinding,
|
InvalidCRBinding,
|
||||||
|
@ -74,6 +75,8 @@ pub fn parse_key_events(allocator: std.mem.Allocator, str: []const u8) ParseErro
|
||||||
end,
|
end,
|
||||||
insert,
|
insert,
|
||||||
bs,
|
bs,
|
||||||
|
less_than,
|
||||||
|
greater_than,
|
||||||
};
|
};
|
||||||
var state: State = .base;
|
var state: State = .base;
|
||||||
var function_key_number: u8 = 0;
|
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;
|
state = .up;
|
||||||
},
|
},
|
||||||
'L' => {
|
'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' => {
|
'R' => {
|
||||||
state = .right;
|
state = .right;
|
||||||
},
|
},
|
||||||
|
'G' => {
|
||||||
|
state = .greater_than;
|
||||||
|
},
|
||||||
'I' => {
|
'I' => {
|
||||||
state = .insert;
|
state = .insert;
|
||||||
},
|
},
|
||||||
|
@ -304,6 +318,22 @@ pub fn parse_key_events(allocator: std.mem.Allocator, str: []const u8) ParseErro
|
||||||
i += 5;
|
i += 5;
|
||||||
} else return parse_error(error.InvalidRightBinding, "str: {s}, i: {} c: {c}", .{ str, i, str[i] });
|
} 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 => {
|
.function_key => {
|
||||||
switch (str[i]) {
|
switch (str[i]) {
|
||||||
'0'...'9' => {
|
'0'...'9' => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue