fix: store button click locations as signed values
This commit is contained in:
parent
e6cc1c35f9
commit
25a719382f
22 changed files with 36 additions and 36 deletions
|
|
@ -58,7 +58,7 @@ pub fn on_render_menu(_: *Type, button: *Type.ButtonType, theme: *const Widget.T
|
|||
return tui.render_file_item_cbor(&button.plane, button.opts.label, button.active, selected, button.hover, theme);
|
||||
}
|
||||
|
||||
fn select(menu: **Type.MenuType, button: *Type.ButtonType, _: Type.Cursor) void {
|
||||
fn select(menu: **Type.MenuType, button: *Type.ButtonType, _: Type.Pos) void {
|
||||
var file_path: []const u8 = undefined;
|
||||
var iter = button.opts.label;
|
||||
if (!(cbor.matchString(&iter, &file_path) catch false)) return;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ pub fn add_menu_entry(palette: *Type, entry: *Entry, matches: ?[]const usize) !v
|
|||
palette.items += 1;
|
||||
}
|
||||
|
||||
fn select(menu: **Type.MenuType, button: *Type.ButtonType, _: Type.Cursor) void {
|
||||
fn select(menu: **Type.MenuType, button: *Type.ButtonType, _: Type.Pos) void {
|
||||
var unused: []const u8 = undefined;
|
||||
var command_id: command.ID = undefined;
|
||||
var iter = button.opts.label;
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ fn get_replace_selection(replace: Buffer.Selection) ?Buffer.Selection {
|
|||
replace;
|
||||
}
|
||||
|
||||
fn select(menu: **Type.MenuType, button: *Type.ButtonType, _: Type.Cursor) void {
|
||||
fn select(menu: **Type.MenuType, button: *Type.ButtonType, _: Type.Pos) void {
|
||||
const label_, _, _, _, _ = get_values(button.opts.label);
|
||||
tp.self_pid().send(.{ "cmd", "exit_overlay_mode" }) catch |e| menu.*.opts.ctx.logger.err(module_name, e);
|
||||
tp.self_pid().send(.{ "cmd", "insert_chars", .{label_} }) catch |e| menu.*.opts.ctx.logger.err(module_name, e);
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ pub fn Variant(comptime command: []const u8, comptime label_: []const u8, allow_
|
|||
return false;
|
||||
}
|
||||
|
||||
fn select(menu: **Type.MenuType, button: *Type.ButtonType, _: Type.Cursor) void {
|
||||
fn select(menu: **Type.MenuType, button: *Type.ButtonType, _: Type.Pos) void {
|
||||
var description_: []const u8 = undefined;
|
||||
var icon_: []const u8 = undefined;
|
||||
var color: u24 = undefined;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ pub fn add_menu_entry(palette: *Type, entry: *Entry, matches: ?[]const usize) !v
|
|||
palette.items += 1;
|
||||
}
|
||||
|
||||
fn select(menu: **Type.MenuType, button: *Type.ButtonType, _: Type.Cursor) void {
|
||||
fn select(menu: **Type.MenuType, button: *Type.ButtonType, _: Type.Pos) void {
|
||||
var label_: []const u8 = undefined;
|
||||
var iter = button.opts.label;
|
||||
if (!(cbor.matchString(&iter, &label_) catch false)) return;
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ pub fn add_menu_entry(palette: *Type, entry: *Entry, matches: ?[]const usize) !v
|
|||
palette.items += 1;
|
||||
}
|
||||
|
||||
fn select(menu: **Type.MenuType, button: *Type.ButtonType, _: Type.Cursor) void {
|
||||
fn select(menu: **Type.MenuType, button: *Type.ButtonType, _: Type.Pos) void {
|
||||
var unused: []const u8 = undefined;
|
||||
var command_id: command.ID = undefined;
|
||||
var iter = button.opts.label;
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ fn do_resize(self: *Self) void {
|
|||
self.menu.resize(self.prepare_resize());
|
||||
}
|
||||
|
||||
fn menu_action_open_file(menu: **MenuType, button: *ButtonType, _: Button.Cursor) void {
|
||||
fn menu_action_open_file(menu: **MenuType, button: *ButtonType, _: Widget.Pos) void {
|
||||
var file_path: []const u8 = undefined;
|
||||
var iter = button.opts.label;
|
||||
if (!(cbor.matchString(&iter, &file_path) catch false)) return;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ pub fn add_menu_entry(palette: *Type, entry: *Entry, matches: ?[]const usize) !v
|
|||
palette.items += 1;
|
||||
}
|
||||
|
||||
fn select(menu: **Type.MenuType, button: *Type.ButtonType, _: Type.Cursor) void {
|
||||
fn select(menu: **Type.MenuType, button: *Type.ButtonType, _: Type.Pos) void {
|
||||
var name_: []const u8 = undefined;
|
||||
var iter = button.opts.label;
|
||||
if (!(cbor.matchString(&iter, &name_) catch false)) return;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ pub fn Create(options: type) type {
|
|||
|
||||
pub const MenuType = Menu.Options(*Self).MenuType;
|
||||
pub const ButtonType = MenuType.ButtonType;
|
||||
pub const Cursor = Button.Cursor;
|
||||
pub const Pos = Widget.Pos;
|
||||
|
||||
pub fn create(allocator: std.mem.Allocator) !tui.Mode {
|
||||
return create_with_args(allocator, .{});
|
||||
|
|
@ -212,7 +212,7 @@ pub fn Create(options: type) type {
|
|||
scrollbar.set(@intCast(@max(self.total_items, 1) - 1), @intCast(self.view_rows), @intCast(self.view_pos));
|
||||
}
|
||||
|
||||
fn mouse_click_button4(menu: **Menu.State(*Self), _: *ButtonType, _: Button.Cursor) void {
|
||||
fn mouse_click_button4(menu: **Menu.State(*Self), _: *ButtonType, _: Widget.Pos) void {
|
||||
const self = &menu.*.opts.ctx.*;
|
||||
if (self.view_pos < Menu.scroll_lines) {
|
||||
self.view_pos = 0;
|
||||
|
|
@ -223,7 +223,7 @@ pub fn Create(options: type) type {
|
|||
self.start_query(0) catch {};
|
||||
}
|
||||
|
||||
fn mouse_click_button5(menu: **Menu.State(*Self), _: *ButtonType, _: Button.Cursor) void {
|
||||
fn mouse_click_button5(menu: **Menu.State(*Self), _: *ButtonType, _: Widget.Pos) void {
|
||||
const self = &menu.*.opts.ctx.*;
|
||||
if (self.view_pos < @max(self.total_items, self.view_rows) - self.view_rows)
|
||||
self.view_pos += Menu.scroll_lines;
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ pub fn on_render_menu(palette: *Type, button: *Type.ButtonType, theme: *const Wi
|
|||
return false;
|
||||
}
|
||||
|
||||
fn select(menu: **Type.MenuType, button: *Type.ButtonType, _: Type.Cursor) void {
|
||||
fn select(menu: **Type.MenuType, button: *Type.ButtonType, _: Type.Pos) void {
|
||||
var entry: Entry = undefined;
|
||||
var iter = button.opts.label;
|
||||
if (!(cbor.matchValue(&iter, cbor.extract(&entry)) catch false)) return;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ pub fn add_menu_entry(palette: *Type, entry: *Entry, matches: ?[]const usize) !v
|
|||
palette.items += 1;
|
||||
}
|
||||
|
||||
fn select(menu: **Type.MenuType, button: *Type.ButtonType, _: Type.Cursor) void {
|
||||
fn select(menu: **Type.MenuType, button: *Type.ButtonType, _: Type.Pos) void {
|
||||
var description_: []const u8 = undefined;
|
||||
var name_: []const u8 = undefined;
|
||||
var iter = button.opts.label;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue