fix: store button click locations as signed values

This commit is contained in:
CJ van den Berg 2025-10-10 16:05:50 +02:00
parent e6cc1c35f9
commit 25a719382f
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
22 changed files with 36 additions and 36 deletions

View file

@ -62,7 +62,7 @@ pub fn ctx_deinit(self: *Self) void {
if (self.behind) |p| self.allocator.free(p);
}
fn on_click(self: *Self, _: *ButtonType, _: Button.Cursor) void {
fn on_click(self: *Self, _: *ButtonType, _: Widget.Pos) void {
self.refresh_git_status();
command.executeName("show_git_status", .{}) catch {};
}

View file

@ -31,7 +31,7 @@ pub fn create(allocator: Allocator, parent: Plane, event_handler: ?EventHandler,
});
}
fn on_click(_: *Self, _: *ButtonType, _: Button.Cursor) void {
fn on_click(_: *Self, _: *ButtonType, _: Widget.Pos) void {
command.executeName("show_diagnostics", .{}) catch {};
}

View file

@ -65,15 +65,15 @@ pub fn create(allocator: Allocator, parent: Plane, event_handler: ?EventHandler,
return Widget.to(btn);
}
fn on_click(_: *Self, _: *ButtonType, _: Button.Cursor) void {
fn on_click(_: *Self, _: *ButtonType, _: Widget.Pos) void {
command.executeName("open_recent", .{}) catch {};
}
fn on_click2(_: *Self, _: *ButtonType, _: Button.Cursor) void {
fn on_click2(_: *Self, _: *ButtonType, _: Widget.Pos) void {
command.executeName("close_file", .{}) catch {};
}
fn on_click3(self: *Self, _: *ButtonType, _: Button.Cursor) void {
fn on_click3(self: *Self, _: *ButtonType, _: Widget.Pos) void {
self.detailed = !self.detailed;
}

View file

@ -60,7 +60,7 @@ pub fn create(allocator: Allocator, parent: Plane, event_handler: ?EventHandler,
});
}
fn on_click(_: *Self, _: *ButtonType, _: Button.Cursor) void {
fn on_click(_: *Self, _: *ButtonType, _: Widget.Pos) void {
command.executeName("goto", .{}) catch {};
}

View file

@ -105,7 +105,7 @@ fn render_logo(self: *ButtonType, theme: *const Widget.Theme, style_label: Widge
}
}
fn on_click(_: *Style, _: *ButtonType, _: Button.Cursor) void {
fn on_click(_: *Style, _: *ButtonType, _: Widget.Pos) void {
if (is_mini_mode()) {
command.executeName("exit_mini_mode", .{}) catch {};
} else if (is_overlay_mode()) {
@ -115,6 +115,6 @@ fn on_click(_: *Style, _: *ButtonType, _: Button.Cursor) void {
}
}
fn toggle_panel(_: *Style, _: *ButtonType, _: Button.Cursor) void {
fn toggle_panel(_: *Style, _: *ButtonType, _: Widget.Pos) void {
command.executeName("toggle_panel", .{}) catch {};
}

View file

@ -353,14 +353,14 @@ const Tab = struct {
});
}
fn on_click(self: *@This(), _: *ButtonType, pos: Button.Cursor) void {
fn on_click(self: *@This(), _: *ButtonType, pos: Widget.Pos) void {
const buffer_manager = tui.get_buffer_manager() orelse @panic("tabs no buffer manager");
if (buffer_manager.buffer_from_ref(self.buffer_ref)) |buffer| {
if (self.close_pos) |close_pos| if (pos.col == close_pos) {
if (self.close_pos) |close_pos| if (pos.x == close_pos) {
tp.self_pid().send(.{ "cmd", "close_buffer", .{buffer.get_file_path()} }) catch {};
return;
};
if (self.save_pos) |save_pos| if (pos.col == save_pos) {
if (self.save_pos) |save_pos| if (pos.x == save_pos) {
tp.self_pid().send(.{ "cmd", "save_buffer", .{buffer.get_file_path()} }) catch {};
return;
};
@ -368,7 +368,7 @@ const Tab = struct {
}
}
fn on_click2(self: *@This(), _: *ButtonType, _: Button.Cursor) void {
fn on_click2(self: *@This(), _: *ButtonType, _: Widget.Pos) void {
const buffer_manager = tui.get_buffer_manager() orelse @panic("tabs no buffer manager");
if (buffer_manager.buffer_from_ref(self.buffer_ref)) |buffer|
tp.self_pid().send(.{ "cmd", "close_buffer", .{buffer.get_file_path()} }) catch {};