mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
feat: add basic text content retrieve
This commit is contained in:
@ -731,10 +731,14 @@ pub fn close(self: *Surface) void {
|
|||||||
const title = self.rt_surface.getTitle();
|
const title = self.rt_surface.getTitle();
|
||||||
const title_copy = if (title) |t| self.alloc.dupe(u8, t) catch null else null;
|
const title_copy = if (title) |t| self.alloc.dupe(u8, t) catch null else null;
|
||||||
|
|
||||||
|
// Save terminal contents including scrollback buffer
|
||||||
|
const contents = self.io.terminal.screen.dumpStringAlloc(self.alloc, .{ .screen = .{} }) catch null;
|
||||||
|
|
||||||
// Save to last closed tabs
|
// Save to last closed tabs
|
||||||
self.app.last_closed_tabs.push(.{
|
self.app.last_closed_tabs.push(.{
|
||||||
.title = title_copy,
|
.title = title_copy,
|
||||||
.cwd = cwd_copy,
|
.cwd = cwd_copy,
|
||||||
|
.contents = contents,
|
||||||
}, self.alloc);
|
}, self.alloc);
|
||||||
|
|
||||||
log.debug("closing tab - pwd: {s}, title: {s}", .{
|
log.debug("closing tab - pwd: {s}, title: {s}", .{
|
||||||
|
@ -23,6 +23,7 @@ const CoreSurface = @import("../Surface.zig");
|
|||||||
const configpkg = @import("../config.zig");
|
const configpkg = @import("../config.zig");
|
||||||
const Config = @import("../config.zig").Config;
|
const Config = @import("../config.zig").Config;
|
||||||
const LastClosedTab = @import("../terminal/closedtabs.zig").LastClosedTab;
|
const LastClosedTab = @import("../terminal/closedtabs.zig").LastClosedTab;
|
||||||
|
const sgr = @import("../terminal/sgr.zig");
|
||||||
|
|
||||||
// Get native API access on certain platforms so we can do more customization.
|
// Get native API access on certain platforms so we can do more customization.
|
||||||
const glfwNative = glfw.Native(.{
|
const glfwNative = glfw.Native(.{
|
||||||
@ -382,6 +383,11 @@ pub const App = struct {
|
|||||||
try window.core_surface.rt_surface.setTitle(title_z);
|
try window.core_surface.rt_surface.setTitle(title_z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Restore terminal contents if available
|
||||||
|
if (last_tab.contents) |contents| {
|
||||||
|
try window.core_surface.io.terminal.printString(contents);
|
||||||
|
}
|
||||||
|
|
||||||
log.debug("Reopening last tab - pwd: {s}, title: {s}", .{
|
log.debug("Reopening last tab - pwd: {s}, title: {s}", .{
|
||||||
last_tab.cwd orelse "(null)",
|
last_tab.cwd orelse "(null)",
|
||||||
last_tab.title orelse "(null)",
|
last_tab.title orelse "(null)",
|
||||||
|
@ -6,10 +6,12 @@ const max_closed_tabs = 10;
|
|||||||
pub const LastClosedTab = struct {
|
pub const LastClosedTab = struct {
|
||||||
title: ?[]const u8,
|
title: ?[]const u8,
|
||||||
cwd: ?[]const u8,
|
cwd: ?[]const u8,
|
||||||
|
contents: ?[]const u8,
|
||||||
|
|
||||||
pub fn deinit(self: *LastClosedTab, alloc: Allocator) void {
|
pub fn deinit(self: *LastClosedTab, alloc: Allocator) void {
|
||||||
if (self.title) |t| alloc.free(t);
|
if (self.title) |t| alloc.free(t);
|
||||||
if (self.cwd) |c| alloc.free(c);
|
if (self.cwd) |c| alloc.free(c);
|
||||||
|
if (self.contents) |c| alloc.free(c);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user