From e3df08039aab17eb81e840d88d1047d63baa9d5f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 19 Jul 2024 20:03:20 -0700 Subject: [PATCH] some bikeshedding --- src/Surface.zig | 19 +++++++------------ src/input/Binding.zig | 20 ++++++++++++-------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/Surface.zig b/src/Surface.zig index 37b45df3d..351f61c5f 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 => |scrollback_action| write_scrollback_file: { + .write_scrollback_file => |write_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,17 +3365,12 @@ 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); - 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); - }, + switch (write_action) { + .open => try internal_os.open(self.alloc, path), + .paste => self.io.queueMessage(try termio.Message.writeReq( + self.alloc, + path, + ), .unlocked), } }, diff --git a/src/input/Binding.zig b/src/input/Binding.zig index f5c2d1cdc..02b9f79bf 100644 --- a/src/input/Binding.zig +++ b/src/input/Binding.zig @@ -203,9 +203,13 @@ pub const Action = union(enum) { /// number of prompts to jump forward, negative is backwards. jump_to_prompt: i16, - /// Write the entire scrollback into a temporary file and write the path to - /// the file to the tty. - write_scrollback_file: WriteScrollbackAction, + /// Write the entire scrollback into a temporary file. The action + /// determines what to do with the filepath. Valid values are: + /// + /// - "paste": Paste the file path into the terminal. + /// - "open": Open the file in the default OS editor for text files. + /// + write_scrollback_file: WriteScreenAction, /// Open a new window. new_window: void, @@ -292,11 +296,6 @@ pub const Action = union(enum) { end, }; - pub const WriteScrollbackAction = enum { - paste, - open, - }; - pub const SplitDirection = enum { right, down, @@ -329,6 +328,11 @@ pub const Action = union(enum) { u16, }; + pub const WriteScreenAction = enum { + paste, + open, + }; + // Extern because it is used in the embedded runtime ABI. pub const InspectorMode = enum(c_int) { toggle,