this repo has no description
13
fork

Configure Feed

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

input: distinguish ctrl+j from enter (#149)

`\x0A` was being parsed as an enter keypress. Distinguish this explicitly as a ctrl+j press.

authored by

kuro337 and committed by
GitHub
91a310c9 8462b627

+8 -9
+1 -1
examples/cli.zig
··· 62 62 } else { 63 63 selected_option.? = selected_option.? -| 1; 64 64 } 65 - } else if (key.matches(vaxis.Key.enter, .{})) { 65 + } else if (key.matches(vaxis.Key.enter, .{}) or key.matches('j', .{ .ctrl = true })) { 66 66 if (selected_option) |i| { 67 67 log.err("enter", .{}); 68 68 try text_input.insertSliceAtCursor(options[i]);
+2 -2
examples/table.zig
··· 167 167 demo_tbl.sel_rows = try rows_list.toOwnedSlice(); 168 168 } 169 169 // See Row Content 170 - if (key.matches(vaxis.Key.enter, .{})) see_content = !see_content; 170 + if (key.matches(vaxis.Key.enter, .{}) or key.matches('j', .{ .ctrl = true })) see_content = !see_content; 171 171 }, 172 172 .btm => { 173 173 if (key.matchesAny(&.{ vaxis.Key.up, 'k' }, .{}) and moving) active = .mid 174 174 // Run Command and Clear Command Bar 175 - else if (key.matchExact(vaxis.Key.enter, .{})) { 175 + else if (key.matchExact(vaxis.Key.enter, .{}) or key.matchExact('j', .{ .ctrl = true })) { 176 176 const cmd = try cmd_input.toOwnedSlice(); 177 177 defer alloc.free(cmd); 178 178 if (mem.eql(u8, ":q", cmd) or
+1 -1
examples/text_input.zig
··· 99 99 try loop.start(); 100 100 try vx.enterAltScreen(tty.anyWriter()); 101 101 vx.queueRefresh(); 102 - } else if (key.matches(vaxis.Key.enter, .{})) { 102 + } else if (key.matches(vaxis.Key.enter, .{}) or key.matches('j', .{ .ctrl = true })) { 103 103 text_input.clearAndFree(); 104 104 } else { 105 105 try text_input.update(.{ .key_press = key });
+2 -3
src/Parser.zig
··· 94 94 0x00 => .{ .codepoint = '@', .mods = .{ .ctrl = true } }, 95 95 0x08 => .{ .codepoint = Key.backspace }, 96 96 0x09 => .{ .codepoint = Key.tab }, 97 - 0x0A, 98 - 0x0D, 99 - => .{ .codepoint = Key.enter }, 97 + 0x0A => .{ .codepoint = 'j', .mods = .{ .ctrl = true } }, 98 + 0x0D => .{ .codepoint = Key.enter }, 100 99 0x01...0x07, 101 100 0x0B...0x0C, 102 101 0x0E...0x1A,
+1 -1
src/vxfw/Button.zig
··· 44 44 pub fn handleEvent(self: *Button, ctx: *vxfw.EventContext, event: vxfw.Event) anyerror!void { 45 45 switch (event) { 46 46 .key_press => |key| { 47 - if (key.matches(vaxis.Key.enter, .{})) { 47 + if (key.matches(vaxis.Key.enter, .{}) or key.matches('j', .{ .ctrl = true })) { 48 48 return self.doClick(ctx); 49 49 } 50 50 },
+1 -1
src/vxfw/TextField.zig
··· 102 102 } else if (key.matches('d', .{ .alt = true })) { 103 103 self.deleteWordAfter(); 104 104 return self.checkChanged(ctx); 105 - } else if (key.matches(vaxis.Key.enter, .{})) { 105 + } else if (key.matches(vaxis.Key.enter, .{}) or key.matches('j', .{ .ctrl = true })) { 106 106 if (self.onSubmit) |onSubmit| { 107 107 try onSubmit(self.userdata, ctx, self.previous_val); 108 108 return ctx.consumeAndRedraw();