~rockorager/libvaxis

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH v1] Add home and end keybinds for the TextInput widget

Details
Message ID
<20240730183656.36189-1-tristan@partin.io>
DKIM signature
pass
Download raw message
Patch: +2 -2
readline accepts these an analogs for ctrl+z and ctrl+e.

Signed-off-by: Tristan Partin <tristan@partin.io>
---
 src/widgets/TextInput.zig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/widgets/TextInput.zig b/src/widgets/TextInput.zig
index bd08851..62f04e3 100644
--- a/src/widgets/TextInput.zig
+++ b/src/widgets/TextInput.zig
@@ -55,9 +55,9 @@ pub fn update(self: *TextInput, event: Event) !void {
                if (self.cursor_idx > 0) self.cursor_idx -= 1;
            } else if (key.matches(Key.right, .{}) or key.matches('f', .{ .ctrl = true })) {
                if (self.cursor_idx < self.grapheme_count) self.cursor_idx += 1;
            } else if (key.matches('a', .{ .ctrl = true })) {
            } else if (key.matches('a', .{ .ctrl = true }) || key.matches(Key.home, .{})) {
                self.cursor_idx = 0;
            } else if (key.matches('e', .{ .ctrl = true })) {
            } else if (key.matches('e', .{ .ctrl = true }) || key.matches(Key.end, .{})) {
                self.cursor_idx = self.grapheme_count;
            } else if (key.matches('k', .{ .ctrl = true })) {
                try self.deleteToEnd();
-- 
Tristan Partin
https://tristan.partin.io
Details
Message ID
<D333LJIQUE8I.15XG9I476574M@timculverhouse.com>
In-Reply-To
<20240730183656.36189-1-tristan@partin.io> (view parent)
DKIM signature
pass
Download raw message
On Tue Jul 30, 2024 at 1:37 PM CDT, Tristan Partin wrote:
> readline accepts these an analogs for ctrl+z and ctrl+e.
>
> Signed-off-by: Tristan Partin <tristan@partin.io>
> ---
>  src/widgets/TextInput.zig | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/widgets/TextInput.zig b/src/widgets/TextInput.zig
> index bd08851..62f04e3 100644
> --- a/src/widgets/TextInput.zig
> +++ b/src/widgets/TextInput.zig
> @@ -55,9 +55,9 @@ pub fn update(self: *TextInput, event: Event) !void {
>                  if (self.cursor_idx > 0) self.cursor_idx -= 1;
>              } else if (key.matches(Key.right, .{}) or key.matches('f', .{ .ctrl = true })) {
>                  if (self.cursor_idx < self.grapheme_count) self.cursor_idx += 1;
> -            } else if (key.matches('a', .{ .ctrl = true })) {
> +            } else if (key.matches('a', .{ .ctrl = true }) || key.matches(Key.home, .{})) {

zig does not use || as an or operator, instead they use the keyword "or".

>                  self.cursor_idx = 0;
> -            } else if (key.matches('e', .{ .ctrl = true })) {
> +            } else if (key.matches('e', .{ .ctrl = true }) || key.matches(Key.end, .{})) {

Same comment here.

>                  self.cursor_idx = self.grapheme_count;
>              } else if (key.matches('k', .{ .ctrl = true })) {
>                  try self.deleteToEnd();

-- 
Tim
Reply to thread Export thread (mbox)