From 25d844702f2d05560f50b56f56175b59668ea709 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Sun, 21 Jan 2024 13:19:18 -0600 Subject: [PATCH] tty: add events to parser handling, update comment Signed-off-by: Tim Culverhouse --- src/Tty.zig | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/Tty.zig b/src/Tty.zig index c2fa624..6244b33 100644 --- a/src/Tty.zig +++ b/src/Tty.zig @@ -134,7 +134,10 @@ pub fn run( const result = try parser.parse(buf[start..n]); start = result.n; // TODO: if we get 0 byte read, copy the remaining bytes to the - // beginning of the buffer and read mmore? + // beginning of the buffer and read mmore? this should only happen + // if we are in the middle of a grapheme at and filled our + // buffer. Probably can happen on large pastes so needs to be + // implemented but low priority const event = result.event orelse continue; switch (event) { @@ -143,8 +146,26 @@ pub fn run( vx.postEvent(.{ .key_press = key }); } }, - .focus_in => {}, - .focus_out => {}, + .focus_in => { + if (@hasField(EventType, "focus_in")) { + vx.postEvent(.focus_in); + } + }, + .focus_out => { + if (@hasField(EventType, "focus_out")) { + vx.postEvent(.focus_out); + } + }, + .paste_start => { + if (@hasField(EventType, "paste_start")) { + vx.postEvent(.paste_start); + } + }, + .paste_end => { + if (@hasField(EventType, "paste_end")) { + vx.postEvent(.paste_end); + } + }, } } }