mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-05 19:08:17 +00:00
Add "Scroll to Selection" command
This commit is contained in:

committed by
Mitchell Hashimoto

parent
eb7368699b
commit
071531c5c5
@@ -4119,6 +4119,14 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
|
||||
}, .unlocked);
|
||||
},
|
||||
|
||||
.scroll_to_selection => {
|
||||
self.renderer_state.mutex.lock();
|
||||
defer self.renderer_state.mutex.unlock();
|
||||
const sel = self.io.terminal.screen.selection orelse return false;
|
||||
const tl = sel.topLeft(&self.io.terminal.screen);
|
||||
self.io.terminal.screen.scroll(.{ .pin = tl });
|
||||
},
|
||||
|
||||
.scroll_page_up => {
|
||||
const rows: isize = @intCast(self.size.grid().rows);
|
||||
self.io.queueMessage(.{
|
||||
|
@@ -279,6 +279,7 @@ pub const Action = union(enum) {
|
||||
/// Scroll the screen varying amounts.
|
||||
scroll_to_top,
|
||||
scroll_to_bottom,
|
||||
scroll_to_selection,
|
||||
scroll_page_up,
|
||||
scroll_page_down,
|
||||
scroll_page_fractional: f32,
|
||||
@@ -789,6 +790,7 @@ pub const Action = union(enum) {
|
||||
.select_all,
|
||||
.scroll_to_top,
|
||||
.scroll_to_bottom,
|
||||
.scroll_to_selection,
|
||||
.scroll_page_up,
|
||||
.scroll_page_down,
|
||||
.scroll_page_fractional,
|
||||
|
@@ -170,6 +170,12 @@ fn actionCommands(action: Action.Key) []const Command {
|
||||
.description = "Scroll to the bottom of the screen.",
|
||||
}},
|
||||
|
||||
.scroll_to_selection => comptime &.{.{
|
||||
.action = .scroll_to_selection,
|
||||
.title = "Scroll to Selection",
|
||||
.description = "Scroll to the selected text.",
|
||||
}},
|
||||
|
||||
.scroll_page_up => comptime &.{.{
|
||||
.action = .scroll_page_up,
|
||||
.title = "Scroll Page Up",
|
||||
|
Reference in New Issue
Block a user