diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/normal.zig | 2 | ||||
| -rw-r--r-- | src/pdf_view.zig | 14 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/normal.zig b/src/normal.zig index f214121a..25e2deec 100644 --- a/src/normal.zig +++ b/src/normal.zig @@ -1016,6 +1016,8 @@ pub fn handlePdfNormal(p: *Pardes, pane: *Pane, key: Key) void { if (result.page_changed) panes.Pdf.resetPageChrome(pane); switch (result.host) { .none => {}, + // typed again by a macro, Esc is only the page's + .last => if (p.macro.replaying == 0) exec.runBuiltin(p, .Last, p.active, "", null), .leader => { p.leader_on = true; p.leader_n = 0; diff --git a/src/pdf_view.zig b/src/pdf_view.zig index 4ddbf299..b2b9c5a3 100644 --- a/src/pdf_view.zig +++ b/src/pdf_view.zig @@ -906,12 +906,15 @@ pub const State = if (enabled) struct { if (page) |selected_page| state.invalidateRaster(selected_page); } - pub fn cancelChrome(state: *@This(), gpa: std.mem.Allocator) void { + /// Drops the selection and the search; true when there was one. + pub fn cancelChrome(state: *@This(), gpa: std.mem.Allocator) bool { + const had = state.selection != null or state.search_query.len > 0; state.clearDrag(); state.clearSelection(gpa); - if (state.search_query.len == 0) return; + if (state.search_query.len == 0) return had; state.dropSearchQuery(gpa); state.invalidateRaster(state.page); + return had; } fn invalidatePage(state: *@This(), gpa: std.mem.Allocator) void { @@ -1230,6 +1233,7 @@ pub const ScrollResult = struct { active_page: usize }; pub const CellPixels = struct { w: u16, h: u16 }; pub const NormalHost = enum { none, + last, leader, command_line, search, @@ -2476,7 +2480,11 @@ pub fn applyNormal( if (comptime !enabled) return .{}; var result: NormalResult = .{}; switch (semantic) { - .escape => state.cancelChrome(gpa), + // Esc drops a selection or a search the page shows, else goes back + // a pane (text-only, the page shows neither). + .escape => if (!state.cancelChrome(gpa) or !native_images) { + result.host = .last; + }, .move => |move| switch (move.motion) { .down => result.page_changed = moveRows( state, |
