mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-22 11:46:11 +03:00
core: support opening scrollback file in default text editor
This commit is contained in:

committed by
Mitchell Hashimoto

parent
5ed0bcc4ac
commit
6fde429728
@ -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 }),
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user