input: scroll_to_row action

pull/9232/head
Mitchell Hashimoto 2025-10-16 08:22:52 -07:00
parent 135136f733
commit c86266cd90
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
3 changed files with 26 additions and 5 deletions

View File

@ -4827,12 +4827,27 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
}, .unlocked);
},
.scroll_to_row => |n| {
{
self.renderer_state.mutex.lock();
defer self.renderer_state.mutex.unlock();
const t: *terminal.Terminal = self.renderer_state.terminal;
t.screen.scroll(.{ .row = n });
}
try self.queueRender();
},
.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 });
{
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 });
}
try self.queueRender();
},
.scroll_page_up => {

View File

@ -347,6 +347,10 @@ pub const Action = union(enum) {
/// Scroll to the selected text.
scroll_to_selection,
/// Scroll to the given absolute row in the screen with 0 being
/// the first row.
scroll_to_row: usize,
/// Scroll the screen up by one page.
scroll_page_up,
@ -1077,6 +1081,7 @@ pub const Action = union(enum) {
.scroll_to_top,
.scroll_to_bottom,
.scroll_to_selection,
.scroll_to_row,
.scroll_page_up,
.scroll_page_down,
.scroll_page_fractional,

View File

@ -487,6 +487,7 @@ fn actionCommands(action: Action.Key) []const Command {
.esc,
.cursor_key,
.set_font_size,
.scroll_to_row,
.scroll_page_fractional,
.scroll_page_lines,
.adjust_selection,