adjust selection

This commit is contained in:
Mitchell Hashimoto
2024-07-19 14:20:28 -07:00
parent 72d8af5d0b
commit 72c0f9dd32
3 changed files with 13 additions and 13 deletions

View File

@@ -3488,12 +3488,12 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
.quit => try self.app.setQuit(), .quit => try self.app.setQuit(),
.expand_selection => |direction| expand_selection: { .adjust_selection => |direction| adjust_selection: {
self.renderer_state.mutex.lock(); self.renderer_state.mutex.lock();
defer self.renderer_state.mutex.unlock(); defer self.renderer_state.mutex.unlock();
const screen = &self.io.terminal.screen; const screen = &self.io.terminal.screen;
const sel = if (screen.selection) |*sel| sel else break :expand_selection; const sel = if (screen.selection) |*sel| sel else break :adjust_selection;
sel.adjust(screen, switch (direction) { sel.adjust(screen, switch (direction) {
.left => .left, .left => .left,
.right => .right, .right => .right,

View File

@@ -1329,42 +1329,42 @@ pub fn default(alloc_gpa: Allocator) Allocator.Error!Config {
try result.keybind.set.put( try result.keybind.set.put(
alloc, alloc,
.{ .key = .{ .translated = .left }, .mods = .{ .shift = true } }, .{ .key = .{ .translated = .left }, .mods = .{ .shift = true } },
.{ .expand_selection = .left }, .{ .adjust_selection = .left },
); );
try result.keybind.set.put( try result.keybind.set.put(
alloc, alloc,
.{ .key = .{ .translated = .right }, .mods = .{ .shift = true } }, .{ .key = .{ .translated = .right }, .mods = .{ .shift = true } },
.{ .expand_selection = .right }, .{ .adjust_selection = .right },
); );
try result.keybind.set.put( try result.keybind.set.put(
alloc, alloc,
.{ .key = .{ .translated = .up }, .mods = .{ .shift = true } }, .{ .key = .{ .translated = .up }, .mods = .{ .shift = true } },
.{ .expand_selection = .up }, .{ .adjust_selection = .up },
); );
try result.keybind.set.put( try result.keybind.set.put(
alloc, alloc,
.{ .key = .{ .translated = .down }, .mods = .{ .shift = true } }, .{ .key = .{ .translated = .down }, .mods = .{ .shift = true } },
.{ .expand_selection = .down }, .{ .adjust_selection = .down },
); );
try result.keybind.set.put( try result.keybind.set.put(
alloc, alloc,
.{ .key = .{ .translated = .page_up }, .mods = .{ .shift = true } }, .{ .key = .{ .translated = .page_up }, .mods = .{ .shift = true } },
.{ .expand_selection = .page_up }, .{ .adjust_selection = .page_up },
); );
try result.keybind.set.put( try result.keybind.set.put(
alloc, alloc,
.{ .key = .{ .translated = .page_down }, .mods = .{ .shift = true } }, .{ .key = .{ .translated = .page_down }, .mods = .{ .shift = true } },
.{ .expand_selection = .page_down }, .{ .adjust_selection = .page_down },
); );
try result.keybind.set.put( try result.keybind.set.put(
alloc, alloc,
.{ .key = .{ .translated = .home }, .mods = .{ .shift = true } }, .{ .key = .{ .translated = .home }, .mods = .{ .shift = true } },
.{ .expand_selection = .home }, .{ .adjust_selection = .home },
); );
try result.keybind.set.put( try result.keybind.set.put(
alloc, alloc,
.{ .key = .{ .translated = .end }, .mods = .{ .shift = true } }, .{ .key = .{ .translated = .end }, .mods = .{ .shift = true } },
.{ .expand_selection = .end }, .{ .adjust_selection = .end },
); );
// Windowing // Windowing

View File

@@ -195,9 +195,9 @@ pub const Action = union(enum) {
scroll_page_fractional: f32, scroll_page_fractional: f32,
scroll_page_lines: i16, scroll_page_lines: i16,
/// Expand an existing selection in a given direction. This action /// Adjust an existing selection in a given direction. This action
/// does nothing if there is no active selection. /// does nothing if there is no active selection.
expand_selection: ExpandSelection, adjust_selection: AdjustSelection,
/// Jump the viewport forward or back by prompt. Positive number is the /// Jump the viewport forward or back by prompt. Positive number is the
/// number of prompts to jump forward, negative is backwards. /// number of prompts to jump forward, negative is backwards.
@@ -281,7 +281,7 @@ pub const Action = union(enum) {
application: []const u8, application: []const u8,
}; };
pub const ExpandSelection = enum { pub const AdjustSelection = enum {
left, left,
right, right,
up, up,