~leon_plickat/nfm

d3428e103b3c7f9c6c700db935012c6ae982dfa6 — Leon Henrik Plickat 4 months ago aac4a46
Use @setEvalBranchQuota() to allow all escape sequences in the ComptimeStringMap
1 files changed, 122 insertions(+), 122 deletions(-)

M src/UserInterface.zig
M src/UserInterface.zig => src/UserInterface.zig +122 -122
@@ 56,128 56,128 @@ pub const Event = union(enum) {
};

/// The various escape sequences that represent special keys.
/// TODO[zig] This currently exceeds the operation limit for comptime, so unused
///           values are commented out. Hopefully in the future comptime can
///           handle this completely.
const escape_key_codes = std.ComptimeStringMap(
    Event,
    .{
        // Legacy
        .{ "[A", .arrow_up },
        .{ "OA", .arrow_up },
        .{ "[B", .arrow_down },
        .{ "OB", .arrow_down },
        .{ "[C", .arrow_right },
        .{ "OC", .arrow_right },
        .{ "[D", .arrow_left },
        .{ "OD", .arrow_left },
        .{ "[2~", .insert },
        .{ "[3~", .delete },
        .{ "[5~", .page_up },
        .{ "[6~", .page_down },
        .{ "[F", .end },
        .{ "OF", .end },
        .{ "[4~", .home },
        .{ "[8~", .home },
        .{ "[H", .home },
        .{ "[1~", .home },
        .{ "[7~", .home },
        .{ "[H~", .home },
        //.{ "OP", .{ .function = 1 } },
        //.{ "OQ", .{ .function = 2 } },
        //.{ "OR", .{ .function = 3 } },
        //.{ "OS", .{ .function = 4 } },
        //.{ "[15~", .{ .function = 5 } },
        //.{ "[17~", .{ .function = 6 } },
        //.{ "[18~", .{ .function = 7 } },
        //.{ "[19~", .{ .function = 8 } },
        //.{ "[20~", .{ .function = 9 } },
        //.{ "[21~", .{ .function = 10 } },
        //.{ "[23~", .{ .function = 11 } },
        //.{ "[24~", .{ .function = 12 } },
        //.{ "a", .{ .alt = 'a' } },
        .{ "b", .{ .alt = 'b' } },
        //.{ "c", .{ .alt = 'c' } },
        //.{ "d", .{ .alt = 'd' } },
        //.{ "e", .{ .alt = 'e' } },
        .{ "f", .{ .alt = 'f' } },
        //.{ "g", .{ .alt = 'g' } },
        //.{ "h", .{ .alt = 'h' } },
        //.{ "i", .{ .alt = 'i' } },
        //.{ "j", .{ .alt = 'j' } },
        //.{ "k", .{ .alt = 'k' } },
        //.{ "l", .{ .alt = 'l' } },
        //.{ "m", .{ .alt = 'm' } },
        //.{ "n", .{ .alt = 'n' } },
        //.{ "o", .{ .alt = 'o' } },
        //.{ "p", .{ .alt = 'p' } },
        //.{ "q", .{ .alt = 'q' } },
        //.{ "r", .{ .alt = 'r' } },
        //.{ "s", .{ .alt = 's' } },
        //.{ "t", .{ .alt = 't' } },
        //.{ "u", .{ .alt = 'u' } },
        //.{ "v", .{ .alt = 'v' } },
        //.{ "w", .{ .alt = 'w' } },
        //.{ "x", .{ .alt = 'x' } },
        //.{ "y", .{ .alt = 'y' } },
        //.{ "z", .{ .alt = 'z' } },

        // Kitty
        .{ "[27u", .escape },
        .{ "[97;5u", .{ .ctrl = 'a' } },
        //.{ "[98;5u", .{ .ctrl = 'b' } },
        .{ "[99;5u", .{ .ctrl = 'c' } },
        //.{ "[100;5u", .{ .ctrl = 'd' } },
        .{ "[101;5u", .{ .ctrl = 'e' } },
        //.{ "[102;5u", .{ .ctrl = 'f' } },
        .{ "[103;5u", .{ .ctrl = 'g' } },
        //.{ "[104;5u", .{ .ctrl = 'h' } },
        .{ "[105;5u", .{ .ctrl = 'i' } },
        //.{ "[106;5u", .{ .ctrl = 'j' } },
        .{ "[107;5u", .{ .ctrl = 'k' } },
        //.{ "[108;5u", .{ .ctrl = 'l' } },
        //.{ "[109;5u", .{ .ctrl = 'm' } },
        //.{ "[110;5u", .{ .ctrl = 'n' } },
        //.{ "[111;5u", .{ .ctrl = 'o' } },
        //.{ "[112;5u", .{ .ctrl = 'p' } },
        //.{ "[113;5u", .{ .ctrl = 'q' } },
        //.{ "[114;5u", .{ .ctrl = 'r' } },
        .{ "[115;5u", .{ .ctrl = 's' } },
        //.{ "[116;5u", .{ .ctrl = 't' } },
        //.{ "[117;5u", .{ .ctrl = 'u' } },
        //.{ "[118;5u", .{ .ctrl = 'v' } },
        .{ "[119;5u", .{ .ctrl = 'w' } },
        //.{ "[120;5u", .{ .ctrl = 'x' } },
        //.{ "[121;5u", .{ .ctrl = 'y' } },
        //.{ "[122;5u", .{ .ctrl = 'z' } },
        //.{ "[97;3u", .{ .alt = 'a' } },
        .{ "[98;3u", .{ .alt = 'b' } },
        //.{ "[99;3u", .{ .alt = 'c' } },
        //.{ "[100;3u", .{ .alt = 'd' } },
        //.{ "[101;3u", .{ .alt = 'e' } },
        .{ "[102;3u", .{ .alt = 'f' } },
        //.{ "[103;3u", .{ .alt = 'g' } },
        //.{ "[104;3u", .{ .alt = 'h' } },
        //.{ "[105;3u", .{ .alt = 'i' } },
        //.{ "[106;3u", .{ .alt = 'j' } },
        //.{ "[107;3u", .{ .alt = 'k' } },
        //.{ "[108;3u", .{ .alt = 'l' } },
        //.{ "[109;3u", .{ .alt = 'm' } },
        //.{ "[110;3u", .{ .alt = 'n' } },
        //.{ "[111;3u", .{ .alt = 'o' } },
        //.{ "[112;3u", .{ .alt = 'p' } },
        //.{ "[113;3u", .{ .alt = 'q' } },
        //.{ "[114;3u", .{ .alt = 'r' } },
        //.{ "[115;3u", .{ .alt = 's' } },
        //.{ "[116;3u", .{ .alt = 't' } },
        //.{ "[117;3u", .{ .alt = 'u' } },
        //.{ "[118;3u", .{ .alt = 'v' } },
        //.{ "[119;3u", .{ .alt = 'w' } },
        //.{ "[120;3u", .{ .alt = 'x' } },
        //.{ "[121;3u", .{ .alt = 'y' } },
        //.{ "[122;3u", .{ .alt = 'z' } },
    },
);
const escape_key_codes = blk: {
    @setEvalBranchQuota(5000);
    break :blk std.ComptimeStringMap(
        Event,
        .{
            // Legacy
            .{ "[A", .arrow_up },
            .{ "OA", .arrow_up },
            .{ "[B", .arrow_down },
            .{ "OB", .arrow_down },
            .{ "[C", .arrow_right },
            .{ "OC", .arrow_right },
            .{ "[D", .arrow_left },
            .{ "OD", .arrow_left },
            .{ "[2~", .insert },
            .{ "[3~", .delete },
            .{ "[5~", .page_up },
            .{ "[6~", .page_down },
            .{ "[F", .end },
            .{ "OF", .end },
            .{ "[4~", .home },
            .{ "[8~", .home },
            .{ "[H", .home },
            .{ "[1~", .home },
            .{ "[7~", .home },
            .{ "[H~", .home },
            //.{ "OP", .{ .function = 1 } },
            //.{ "OQ", .{ .function = 2 } },
            //.{ "OR", .{ .function = 3 } },
            //.{ "OS", .{ .function = 4 } },
            //.{ "[15~", .{ .function = 5 } },
            //.{ "[17~", .{ .function = 6 } },
            //.{ "[18~", .{ .function = 7 } },
            //.{ "[19~", .{ .function = 8 } },
            //.{ "[20~", .{ .function = 9 } },
            //.{ "[21~", .{ .function = 10 } },
            //.{ "[23~", .{ .function = 11 } },
            //.{ "[24~", .{ .function = 12 } },
            //.{ "a", .{ .alt = 'a' } },
            .{ "b", .{ .alt = 'b' } },
            //.{ "c", .{ .alt = 'c' } },
            //.{ "d", .{ .alt = 'd' } },
            //.{ "e", .{ .alt = 'e' } },
            .{ "f", .{ .alt = 'f' } },
            //.{ "g", .{ .alt = 'g' } },
            //.{ "h", .{ .alt = 'h' } },
            //.{ "i", .{ .alt = 'i' } },
            //.{ "j", .{ .alt = 'j' } },
            //.{ "k", .{ .alt = 'k' } },
            //.{ "l", .{ .alt = 'l' } },
            //.{ "m", .{ .alt = 'm' } },
            //.{ "n", .{ .alt = 'n' } },
            //.{ "o", .{ .alt = 'o' } },
            //.{ "p", .{ .alt = 'p' } },
            //.{ "q", .{ .alt = 'q' } },
            //.{ "r", .{ .alt = 'r' } },
            //.{ "s", .{ .alt = 's' } },
            //.{ "t", .{ .alt = 't' } },
            //.{ "u", .{ .alt = 'u' } },
            //.{ "v", .{ .alt = 'v' } },
            //.{ "w", .{ .alt = 'w' } },
            //.{ "x", .{ .alt = 'x' } },
            //.{ "y", .{ .alt = 'y' } },
            //.{ "z", .{ .alt = 'z' } },

            // Kitty
            .{ "[27u", .escape },
            .{ "[97;5u", .{ .ctrl = 'a' } },
            //.{ "[98;5u", .{ .ctrl = 'b' } },
            .{ "[99;5u", .{ .ctrl = 'c' } },
            //.{ "[100;5u", .{ .ctrl = 'd' } },
            .{ "[101;5u", .{ .ctrl = 'e' } },
            //.{ "[102;5u", .{ .ctrl = 'f' } },
            .{ "[103;5u", .{ .ctrl = 'g' } },
            //.{ "[104;5u", .{ .ctrl = 'h' } },
            .{ "[105;5u", .{ .ctrl = 'i' } },
            //.{ "[106;5u", .{ .ctrl = 'j' } },
            .{ "[107;5u", .{ .ctrl = 'k' } },
            //.{ "[108;5u", .{ .ctrl = 'l' } },
            //.{ "[109;5u", .{ .ctrl = 'm' } },
            //.{ "[110;5u", .{ .ctrl = 'n' } },
            //.{ "[111;5u", .{ .ctrl = 'o' } },
            //.{ "[112;5u", .{ .ctrl = 'p' } },
            //.{ "[113;5u", .{ .ctrl = 'q' } },
            //.{ "[114;5u", .{ .ctrl = 'r' } },
            .{ "[115;5u", .{ .ctrl = 's' } },
            //.{ "[116;5u", .{ .ctrl = 't' } },
            //.{ "[117;5u", .{ .ctrl = 'u' } },
            //.{ "[118;5u", .{ .ctrl = 'v' } },
            .{ "[119;5u", .{ .ctrl = 'w' } },
            //.{ "[120;5u", .{ .ctrl = 'x' } },
            //.{ "[121;5u", .{ .ctrl = 'y' } },
            //.{ "[122;5u", .{ .ctrl = 'z' } },
            //.{ "[97;3u", .{ .alt = 'a' } },
            .{ "[98;3u", .{ .alt = 'b' } },
            //.{ "[99;3u", .{ .alt = 'c' } },
            //.{ "[100;3u", .{ .alt = 'd' } },
            //.{ "[101;3u", .{ .alt = 'e' } },
            .{ "[102;3u", .{ .alt = 'f' } },
            //.{ "[103;3u", .{ .alt = 'g' } },
            //.{ "[104;3u", .{ .alt = 'h' } },
            //.{ "[105;3u", .{ .alt = 'i' } },
            //.{ "[106;3u", .{ .alt = 'j' } },
            //.{ "[107;3u", .{ .alt = 'k' } },
            //.{ "[108;3u", .{ .alt = 'l' } },
            //.{ "[109;3u", .{ .alt = 'm' } },
            //.{ "[110;3u", .{ .alt = 'n' } },
            //.{ "[111;3u", .{ .alt = 'o' } },
            //.{ "[112;3u", .{ .alt = 'p' } },
            //.{ "[113;3u", .{ .alt = 'q' } },
            //.{ "[114;3u", .{ .alt = 'r' } },
            //.{ "[115;3u", .{ .alt = 's' } },
            //.{ "[116;3u", .{ .alt = 't' } },
            //.{ "[117;3u", .{ .alt = 'u' } },
            //.{ "[118;3u", .{ .alt = 'v' } },
            //.{ "[119;3u", .{ .alt = 'w' } },
            //.{ "[120;3u", .{ .alt = 'x' } },
            //.{ "[121;3u", .{ .alt = 'y' } },
            //.{ "[122;3u", .{ .alt = 'z' } },
        },
    );
};

const Colour = enum {
    none,