mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-22 19:56:08 +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);
|
}, .unlocked);
|
||||||
},
|
},
|
||||||
|
|
||||||
.write_scrollback_file => write_scrollback_file: {
|
.write_scrollback_file => |scrollback_action| write_scrollback_file: {
|
||||||
// Create a temporary directory to store our scrollback.
|
// Create a temporary directory to store our scrollback.
|
||||||
var tmp_dir = try internal_os.TempDir.init();
|
var tmp_dir = try internal_os.TempDir.init();
|
||||||
errdefer tmp_dir.deinit();
|
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;
|
var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
||||||
const path = try tmp_dir.dir.realpath("scrollback", &path_buf);
|
const path = try tmp_dir.dir.realpath("scrollback", &path_buf);
|
||||||
|
|
||||||
self.io.queueMessage(try termio.Message.writeReq(
|
switch (scrollback_action) {
|
||||||
self.alloc,
|
.paste => {
|
||||||
path,
|
self.io.queueMessage(try termio.Message.writeReq(
|
||||||
), .unlocked);
|
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 }),
|
.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(
|
try result.keybind.set.put(
|
||||||
alloc,
|
alloc,
|
||||||
.{ .key = .{ .translated = .j }, .mods = inputpkg.ctrlOrSuper(.{ .shift = true }) },
|
.{ .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
|
// Expand Selection
|
||||||
|
@ -205,7 +205,7 @@ pub const Action = union(enum) {
|
|||||||
|
|
||||||
/// Write the entire scrollback into a temporary file and write the path to
|
/// Write the entire scrollback into a temporary file and write the path to
|
||||||
/// the file to the tty.
|
/// the file to the tty.
|
||||||
write_scrollback_file: void,
|
write_scrollback_file: WriteScrollbackAction,
|
||||||
|
|
||||||
/// Open a new window.
|
/// Open a new window.
|
||||||
new_window: void,
|
new_window: void,
|
||||||
@ -292,6 +292,11 @@ pub const Action = union(enum) {
|
|||||||
end,
|
end,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const WriteScrollbackAction = enum {
|
||||||
|
paste,
|
||||||
|
open,
|
||||||
|
};
|
||||||
|
|
||||||
pub const SplitDirection = enum {
|
pub const SplitDirection = enum {
|
||||||
right,
|
right,
|
||||||
down,
|
down,
|
||||||
|
Reference in New Issue
Block a user