core: add binding to write screen to file

This commit is contained in:
Mitchell Hashimoto
2024-07-19 20:24:51 -07:00
parent 55657465a7
commit a62b76eda3
2 changed files with 21 additions and 2 deletions

View File

@ -3324,6 +3324,11 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
}, .unlocked);
},
.write_screen_file => |v| try self.writeScreenFile(
.screen,
v,
),
.write_scrollback_file => |v| try self.writeScreenFile(
.history,
v,
@ -3512,8 +3517,9 @@ fn closingAction(action: input.Binding.Action) bool {
/// The portion of the screen to write for writeScreenFile.
const WriteScreenLoc = enum {
history,
selection,
screen, // Full screen
history, // History (scrollback)
selection, // Selected text
};
fn writeScreenFile(
@ -3556,6 +3562,15 @@ fn writeScreenFile(
);
},
.screen => screen: {
break :screen terminal.Selection.init(
pages.getTopLeft(.screen),
pages.getBottomRight(.screen) orelse
break :screen null,
false,
);
},
.selection => self.io.terminal.screen.selection,
};

View File

@ -211,6 +211,10 @@ pub const Action = union(enum) {
///
write_scrollback_file: WriteScreenAction,
/// Same as write_scrollback_file but writes the full screen contents.
/// See write_scrollback_file for available values.
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