fix: merge vaxis and win32 event handling interfaces
This commit is contained in:
		
							parent
							
								
									1fdb5f240b
								
							
						
					
					
						commit
						9047439315
					
				
					 3 changed files with 11 additions and 19 deletions
				
			
		| 
						 | 
				
			
			@ -146,7 +146,12 @@ pub fn leave_alternate_screen(self: *Self) void {
 | 
			
		|||
    self.vx.exitAltScreen() catch {};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub fn process_input_event(self: *Self, input_: []const u8, text: ?[]const u8) !void {
 | 
			
		||||
pub fn process_renderer_event(self: *Self, msg: []const u8) !void {
 | 
			
		||||
    var input_: []const u8 = undefined;
 | 
			
		||||
    var text_: []const u8 = undefined;
 | 
			
		||||
    if (!try cbor.match(msg, .{ "RDR", cbor.extract(&input_), cbor.extract(&text_) }))
 | 
			
		||||
        return error.InvalidRendererEvent;
 | 
			
		||||
    const text = if (text_.len > 0) text_ else null;
 | 
			
		||||
    const event = std.mem.bytesAsValue(vaxis.Event, input_);
 | 
			
		||||
    switch (event.*) {
 | 
			
		||||
        .key_press => |key__| {
 | 
			
		||||
| 
						 | 
				
			
			@ -493,7 +498,7 @@ const Loop = struct {
 | 
			
		|||
            },
 | 
			
		||||
            else => {},
 | 
			
		||||
        }
 | 
			
		||||
        self.pid.send(.{ "VXS", std.mem.asBytes(&event), text }) catch @panic("send VXS event failed");
 | 
			
		||||
        self.pid.send(.{ "RDR", std.mem.asBytes(&event), text }) catch @panic("send RDR event failed");
 | 
			
		||||
        if (free_text)
 | 
			
		||||
            self.vaxis.opts.system_clipboard_allocator.?.free(text);
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -149,7 +149,7 @@ pub fn leave_alternate_screen(self: *Self) void {
 | 
			
		|||
    _ = self;
 | 
			
		||||
    @panic("todo");
 | 
			
		||||
}
 | 
			
		||||
pub fn process_gui_event(self: *Self, m: thespian.message) !void {
 | 
			
		||||
pub fn process_renderer_event(self: *Self, m: thespian.message) !void {
 | 
			
		||||
    const Input = struct {
 | 
			
		||||
        kind: u8,
 | 
			
		||||
        codepoint: u21,
 | 
			
		||||
| 
						 | 
				
			
			@ -356,8 +356,3 @@ pub fn cursor_disable(self: *Self) void {
 | 
			
		|||
    _ = self;
 | 
			
		||||
    //@panic("todo");
 | 
			
		||||
}
 | 
			
		||||
pub fn ucs32_to_utf8(ucs32: []const u32, utf8: []u8) !usize {
 | 
			
		||||
    _ = ucs32;
 | 
			
		||||
    _ = utf8;
 | 
			
		||||
    @panic("todo");
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue