From 0368bb15a68b8700e503f8466687a9d60d6b1935 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Wed, 22 Jan 2025 15:28:03 +0100 Subject: [PATCH] feat(keybind): simplify and clean-up a little --- src/tui/editor.zig | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 254fe0e..d7c05ac 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -149,29 +149,11 @@ pub const CurSel = struct { } fn check_selection(self: *Self, root: Buffer.Root, metrics: Buffer.Metrics) void { - switch (tui.current().get_selection_style()) { - .normal => self.check_selection_normal(), - .inclusive => self.check_selection_inclusive(root, metrics), - } - } - - fn check_selection_normal(self: *Self) void { if (self.selection) |sel| if (sel.empty()) { - self.disable_selection_normal(); + self.disable_selection(root, metrics); }; } - fn check_selection_inclusive(self: *Self, root: Buffer.Root, metrics: Buffer.Metrics) void { - if (self.selection) |sel| if (sel.empty()) { - self.disable_selection_inclusive(root, metrics); - }; - // if (self.selection) |*sel| { - // var temp = sel; - // if (!temp.is_reversed()) temp.end.move_left(root, metrics) catch {}; - // if (temp.empty()) self.disable_selection_inclusive(root, metrics); - // } - } - fn expand_selection_to_line(self: *Self, root: Buffer.Root, metrics: Buffer.Metrics) !*Selection { const sel = try self.enable_selection(root, metrics); sel.normalize(); @@ -1704,16 +1686,6 @@ pub const Editor = struct { return try move(root, &cursel.cursor, allocator); } - fn with_cursors(self: *Self, root_: Buffer.Root, move: cursor_operator, allocator: Allocator) error{Stop}!Buffer.Root { - var root = root_; - for (self.cursels.items) |*cursel| { - self.selection(root, self.metrics); - root = try with_cursor(root, move, cursel, allocator); - } - self.collapse_cursors(); - return root; - } - fn with_selection_const(root: Buffer.Root, move: cursor_operator_const, cursel: *CurSel, metrics: Buffer.Metrics) error{Stop}!void { const sel = try cursel.enable_selection(root, metrics); try move(root, &sel.end, metrics);