this repo has no description
13
fork

Configure Feed

Select the types of activity you want to include in your feed.

parser: parse 0x08 as backspace

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>

+21 -4
+4 -3
examples/text_input.zig
··· 50 50 255 => 0, 51 51 else => color_idx + 1, 52 52 }; 53 - try text_input.update(.{ .key_press = key }); 54 53 if (key.matches('c', .{ .ctrl = true })) { 55 54 break :outer; 56 - } 57 - if (key.matches('l', .{ .ctrl = true })) { 55 + } else if (key.matches('l', .{ .ctrl = true })) { 58 56 vx.queueRefresh(); 57 + } else { 58 + try text_input.update(.{ .key_press = key }); 59 59 } 60 60 }, 61 + 61 62 .winsize => |ws| { 62 63 try vx.resize(alloc, ws); 63 64 },
+17 -1
src/Parser.zig
··· 71 71 // ascii characters when we can 72 72 const key: Key = switch (b) { 73 73 0x00 => .{ .codepoint = '@', .mods = .{ .ctrl = true } }, 74 - 0x01...0x1A => .{ .codepoint = b + 0x60, .mods = .{ .ctrl = true } }, 74 + 0x08 => .{ .codepoint = Key.backspace }, 75 + 0x01...0x07, 76 + 0x09...0x1A, 77 + => .{ .codepoint = b + 0x60, .mods = .{ .ctrl = true } }, 75 78 0x1B => escape: { 76 79 // NOTE: This could be an errant escape at the end 77 80 // of a large read. That is _incredibly_ unlikely ··· 459 462 const expected_key: Key = .{ 460 463 .codepoint = 'a', 461 464 .text = "a", 465 + }; 466 + const expected_event: Event = .{ .key_press = expected_key }; 467 + 468 + try testing.expectEqual(1, result.n); 469 + try testing.expectEqual(expected_event, result.event); 470 + } 471 + 472 + test "parse: single xterm keypress backspace" { 473 + const input = "\x08"; 474 + var parser: Parser = .{}; 475 + const result = try parser.parse(input); 476 + const expected_key: Key = .{ 477 + .codepoint = Key.backspace, 462 478 }; 463 479 const expected_event: Event = .{ .key_press = expected_key }; 464 480