Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action that writes both scrollback and active screen to file. #2040

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Surface.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3337,6 +3337,11 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
}, .unlocked);
},

.write_all_file => |v| try self.writeScreenFile(
.all,
v,
),

.write_screen_file => |v| try self.writeScreenFile(
.screen,
v,
Expand Down Expand Up @@ -3537,6 +3542,7 @@ fn closingAction(action: input.Binding.Action) bool {

/// The portion of the screen to write for writeScreenFile.
const WriteScreenLoc = enum {
all, // Full screen and history (scrollback)
screen, // Full screen
history, // History (scrollback)
selection, // Selected text
Expand Down Expand Up @@ -3591,6 +3597,14 @@ fn writeScreenFile(
);
},

.all => all: {
break :all terminal.Selection.init(
pages.getTopLeft(.history),
pages.getBottomRight(.screen) orelse break :all null,
false,
);
},

.selection => self.io.terminal.screen.selection,
};

Expand Down
29 changes: 21 additions & 8 deletions src/input/Binding.zig
Original file line number Diff line number Diff line change
Expand Up @@ -203,22 +203,35 @@ 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. The action
/// determines what to do with the filepath. Valid values are:
/// Write the entire scrollback _and_ the active screen 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_all_file: WriteScreenAction,

/// Write the entire scrollback into a temporary file. Note that this does
/// not include the contents of the active screen. 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,

/// Same as write_scrollback_file but writes the full screen contents.
/// See write_scrollback_file for available values.
/// Write the active screen 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_screen_file: WriteScreenAction,

/// Same as write_scrollback_file but writes the selected text.
/// If there is no selected text this does nothing (it doesn't
/// even create an empty file). See write_scrollback_file for
/// available values.
/// Write the selected text into a temporary file. If there is no selected
/// text this does nothing (it doesn't even create an empty 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_selection_file: WriteScreenAction,

/// Open a new window.
Expand Down