diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-28 16:43:59 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:15 -0300 |
| commit | 71c5b400ced873cddd77497b7a9fd06184954813 (patch) | |
| tree | 76e0d64e9e73f55aa1eea5a357c3cc2c8345a253 /src/normal.zig | |
| parent | 78daa25e5c99cc0d71da36b6e0dcdd362b0cb284 (diff) | |
| download | pardes-71c5b400ced873cddd77497b7a9fd06184954813.tar.gz pardes-71c5b400ced873cddd77497b7a9fd06184954813.zip | |
Z arms the view keys until Esc, and zm puts the cursor's column mid-view
Z is helix's sticky view mode: the z keys stay armed after each until Esc,
which leaves the mode and does nothing else (no pane hop). zm is
align_view_middle: an unwrapped view scrolls sideways so the cursor's column
is in its middle.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/normal.zig')
| -rw-r--r-- | src/normal.zig | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/normal.zig b/src/normal.zig index f9d7cf25..f7ba3810 100644 --- a/src/normal.zig +++ b/src/normal.zig @@ -29,6 +29,7 @@ fn roleBindingName(comptime role: modal.Normal.Role) []const u8 { return switch (role) { .prefix_goto => "goto_prefix", .prefix_view => "view_prefix", + .prefix_view_sticky => "view_prefix_sticky", .prefix_match => "match_prefix", .prefix_find_fwd => "find_char_fwd", .prefix_find_back => "find_char_back", @@ -478,6 +479,15 @@ fn executeNormalAction(p: *Pardes, t: *Text, semantic: modal.Normal.Action) void pane.scrollBy(t.cur_row - (pane.scroll() + @as(i32, pane.rows) - 1)); pane.ensureCursorVisible(); }, + .middle => { + // helix align_view_middle: the cursor's column to the middle + // of an unwrapped view + if (pane.body_wrapped) return; + const line = text[modal.lineStartOffset(text, modal.lineAtOffset(text, cur))..modal.lineEndOffset(text, modal.lineAtOffset(text, cur))]; + const w: usize = @intCast(@max(1, @as(i32, pane.cols) - @as(i32, panes.File.gutterWidth(pane)))); + const col = panes.File.rawDisplayCol(line, @intCast(@max(0, t.cur_col))); + pane.hscroll = @intCast(panes.File.rawAtDisplay(line, col -| w / 2)); + }, .scroll_down => return t.scrollViewMove(text, range, 1), .scroll_up => return t.scrollViewMove(text, range, -1), }, |
