summaryrefslogtreecommitdiff
path: root/src/pdf_view.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/pdf_view.zig')
-rw-r--r--src/pdf_view.zig14
1 files changed, 11 insertions, 3 deletions
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,