mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-06 18:06:33 +00:00
rename to expand_selection
This commit is contained in:
@@ -3488,23 +3488,23 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
|
||||
|
||||
.quit => try self.app.setQuit(),
|
||||
|
||||
.selection_navigation_left, .selection_navigation_right, .selection_navigation_up, .selection_navigation_down => {
|
||||
alter_navigation: {
|
||||
.expand_selection => |direction| expand_selection: {
|
||||
self.renderer_state.mutex.lock();
|
||||
defer self.renderer_state.mutex.unlock();
|
||||
var screen = &self.io.terminal.screen;
|
||||
const sel = if (screen.selection) |*sel| sel else break :alter_navigation;
|
||||
sel.adjust(screen, switch (action) {
|
||||
.selection_navigation_left => .left,
|
||||
.selection_navigation_right => .right,
|
||||
.selection_navigation_up => .up,
|
||||
.selection_navigation_down => .down,
|
||||
.selection_navigation_page_up => .page_up,
|
||||
.selection_navigation_page_down => .page_down,
|
||||
.selection_natigation_home => .home,
|
||||
.selection_natigation_end => .end,
|
||||
else => break :alter_navigation,
|
||||
|
||||
const screen = &self.io.terminal.screen;
|
||||
const sel = if (screen.selection) |*sel| sel else break :expand_selection;
|
||||
sel.adjust(screen, switch (direction) {
|
||||
.left => .left,
|
||||
.right => .right,
|
||||
.up => .up,
|
||||
.down => .down,
|
||||
.page_up => .page_up,
|
||||
.page_down => .page_down,
|
||||
.home => .home,
|
||||
.end => .end,
|
||||
});
|
||||
|
||||
// If the selection endpoint is outside of the current viewpoint,
|
||||
// scroll it in to view. Note we always specifically use sel.end
|
||||
// because that is what adjust modifies.
|
||||
@@ -3524,8 +3524,9 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
|
||||
|
||||
screen.scroll(.{ .pin = target });
|
||||
}
|
||||
}
|
||||
|
||||
// Queue a render so its shown
|
||||
screen.dirty.selection = true;
|
||||
try self.queueRender();
|
||||
},
|
||||
}
|
||||
|
@@ -1325,6 +1325,48 @@ pub fn default(alloc_gpa: Allocator) Allocator.Error!Config {
|
||||
.{ .write_scrollback_file = {} },
|
||||
);
|
||||
|
||||
// Expand Selection
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .left }, .mods = .{ .shift = true } },
|
||||
.{ .expand_selection = .left },
|
||||
);
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .right }, .mods = .{ .shift = true } },
|
||||
.{ .expand_selection = .right },
|
||||
);
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .up }, .mods = .{ .shift = true } },
|
||||
.{ .expand_selection = .up },
|
||||
);
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .down }, .mods = .{ .shift = true } },
|
||||
.{ .expand_selection = .down },
|
||||
);
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .page_up }, .mods = .{ .shift = true } },
|
||||
.{ .expand_selection = .page_up },
|
||||
);
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .page_down }, .mods = .{ .shift = true } },
|
||||
.{ .expand_selection = .page_down },
|
||||
);
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .home }, .mods = .{ .shift = true } },
|
||||
.{ .expand_selection = .home },
|
||||
);
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .end }, .mods = .{ .shift = true } },
|
||||
.{ .expand_selection = .end },
|
||||
);
|
||||
|
||||
// Windowing
|
||||
if (comptime !builtin.target.isDarwin()) {
|
||||
try result.keybind.set.put(
|
||||
@@ -1494,48 +1536,6 @@ pub fn default(alloc_gpa: Allocator) Allocator.Error!Config {
|
||||
.{ .key = .{ .translated = .insert }, .mods = .{ .shift = true } },
|
||||
.{ .paste_from_selection = {} },
|
||||
);
|
||||
|
||||
// Selection Navigation
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .left }, .mods = .{ .shift = true } },
|
||||
.{ .selection_navigation_left = {} },
|
||||
);
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .right }, .mods = .{ .shift = true } },
|
||||
.{ .selection_navigation_right = {} },
|
||||
);
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .up }, .mods = .{ .shift = true } },
|
||||
.{ .selection_navigation_up = {} },
|
||||
);
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .down }, .mods = .{ .shift = true } },
|
||||
.{ .selection_navigation_down = {} },
|
||||
);
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .page_up }, .mods = .{ .shift = true } },
|
||||
.{ .selection_navigation_page_up = {} },
|
||||
);
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .page_down }, .mods = .{ .shift = true } },
|
||||
.{ .selection_navigation_page_down = {} },
|
||||
);
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .home }, .mods = .{ .shift = true } },
|
||||
.{ .selection_navigation_home = {} },
|
||||
);
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .end }, .mods = .{ .shift = true } },
|
||||
.{ .selection_navigation_end = {} },
|
||||
);
|
||||
}
|
||||
{
|
||||
// Cmd+N for goto tab N
|
||||
|
@@ -169,15 +169,6 @@ pub const Action = union(enum) {
|
||||
/// enter after to get a new prompt.
|
||||
reset: void,
|
||||
|
||||
selection_navigation_left: void,
|
||||
selection_navigation_right: void,
|
||||
selection_navigation_up: void,
|
||||
selection_navigation_down: void,
|
||||
selection_navigation_page_up: void,
|
||||
selection_navigation_page_down: void,
|
||||
selection_natigation_home: void,
|
||||
selection_natigation_end: void,
|
||||
|
||||
/// Copy and paste.
|
||||
copy_to_clipboard: void,
|
||||
paste_from_clipboard: void,
|
||||
@@ -204,6 +195,10 @@ pub const Action = union(enum) {
|
||||
scroll_page_fractional: f32,
|
||||
scroll_page_lines: i16,
|
||||
|
||||
/// Expand an existing selection in a given direction. This action
|
||||
/// does nothing if there is no active selection.
|
||||
expand_selection: ExpandSelection,
|
||||
|
||||
/// Jump the viewport forward or back by prompt. Positive number is the
|
||||
/// number of prompts to jump forward, negative is backwards.
|
||||
jump_to_prompt: i16,
|
||||
@@ -286,6 +281,17 @@ pub const Action = union(enum) {
|
||||
application: []const u8,
|
||||
};
|
||||
|
||||
pub const ExpandSelection = enum {
|
||||
left,
|
||||
right,
|
||||
up,
|
||||
down,
|
||||
page_up,
|
||||
page_down,
|
||||
home,
|
||||
end,
|
||||
};
|
||||
|
||||
pub const SplitDirection = enum {
|
||||
right,
|
||||
down,
|
||||
|
Reference in New Issue
Block a user