feat: add Button widget and use it to build a menu with mouse support on the home screen

This commit is contained in:
CJ van den Berg 2024-03-06 00:44:43 +01:00
parent 45307e3636
commit 8f360c8f28
6 changed files with 206 additions and 65 deletions

View file

@ -690,7 +690,7 @@ const cmds = struct {
var mode: []const u8 = undefined;
if (!try ctx.args.match(.{tp.extract(&mode)}))
return tp.exit_error(error.InvalidArgument);
if (self.mini_mode) |_| std.debug.panic("attempted to switch mode to {s} while in mini mode {s}", .{ mode, self.input_mode.?.name });
if (self.mini_mode) |_| try cmds.exit_mini_mode(self, .{});
if (self.input_mode) |*m| m.deinit();
self.input_mode = if (std.mem.eql(u8, mode, "vim/normal"))
@import("mode/input/vim/normal.zig").create(self.a) catch |e| return tp.exit_error(e)
@ -831,6 +831,10 @@ pub fn request_mouse_cursor_pointer(self: *const Self, push_or_pop: bool) void {
if (push_or_pop) self.mouse_cursor_push("pointer") else self.mouse_cursor_pop();
}
pub fn request_mouse_cursor_default(self: *const Self, push_or_pop: bool) void {
if (push_or_pop) self.mouse_cursor_push("default") else self.mouse_cursor_pop();
}
fn mouse_cursor_push(self: *const Self, comptime name: []const u8) void {
self.write_stdout(OSC22_cursor ++ name ++ ST);
}