diff --git a/src/Surface.zig b/src/Surface.zig index 24100544a..37b45df3d 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -3324,7 +3324,7 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool }, .unlocked); }, - .write_scrollback_file => write_scrollback_file: { + .write_scrollback_file => |scrollback_action| write_scrollback_file: { // Create a temporary directory to store our scrollback. var tmp_dir = try internal_os.TempDir.init(); errdefer tmp_dir.deinit(); @@ -3365,10 +3365,18 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; const path = try tmp_dir.dir.realpath("scrollback", &path_buf); - self.io.queueMessage(try termio.Message.writeReq( - self.alloc, - path, - ), .unlocked); + switch (scrollback_action) { + .paste => { + self.io.queueMessage(try termio.Message.writeReq( + self.alloc, + path, + ), .unlocked); + }, + .open => { + log.debug("opening scrollback file: {s}", .{path}); + try internal_os.open(self.alloc, path); + }, + } }, .new_window => try self.app.newWindow(self.rt_app, .{ .parent = self }), diff --git a/src/config/Config.zig b/src/config/Config.zig index 72a3cb909..b2cd2f447 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -1322,7 +1322,13 @@ pub fn default(alloc_gpa: Allocator) Allocator.Error!Config { try result.keybind.set.put( alloc, .{ .key = .{ .translated = .j }, .mods = inputpkg.ctrlOrSuper(.{ .shift = true }) }, - .{ .write_scrollback_file = {} }, + .{ .write_scrollback_file = .paste }, + ); + + try result.keybind.set.put( + alloc, + .{ .key = .{ .translated = .j }, .mods = inputpkg.ctrlOrSuper(.{ .shift = true, .alt = true }) }, + .{ .write_scrollback_file = .open }, ); // Expand Selection diff --git a/src/input/Binding.zig b/src/input/Binding.zig index 4232ea252..f5c2d1cdc 100644 --- a/src/input/Binding.zig +++ b/src/input/Binding.zig @@ -205,7 +205,7 @@ pub const Action = union(enum) { /// Write the entire scrollback into a temporary file and write the path to /// the file to the tty. - write_scrollback_file: void, + write_scrollback_file: WriteScrollbackAction, /// Open a new window. new_window: void, @@ -292,6 +292,11 @@ pub const Action = union(enum) { end, }; + pub const WriteScrollbackAction = enum { + paste, + open, + }; + pub const SplitDirection = enum { right, down,