summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-29 20:51:15 -0300
committerGabriel Schneider <[email protected]>2026-10-29 21:03:37 -0300
commitfdf59131f68db19fc4818b6e5db7c9fe4cc609fd (patch)
tree1d3296044f387ec55f66a8d188279ce3eaaa63dc /src
parenta8d9eb9e5051521aaeb1a95584729794059b5d83 (diff)
downloadpardes-fdf59131f68db19fc4818b6e5db7c9fe4cc609fd.tar.gz
pardes-fdf59131f68db19fc4818b6e5db7c9fe4cc609fd.zip
pdf: Esc in a PDF pane drops the selection or the search highlights the page shows, and with none goes back a pane as Esc does everywhere else; Shift-Esc still goes at once
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/normal.zig2
-rw-r--r--src/pdf_view.zig14
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,