mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-21 11:16:08 +03:00
termio: remove more state
This commit is contained in:
@ -426,51 +426,50 @@ pub fn init(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Start our IO implementation
|
// Start our IO implementation
|
||||||
var io_exec = try termio.Exec.init(alloc, .{
|
// This separate block ({}) is important because our errdefers must
|
||||||
.command = config.command,
|
// be scoped here to be valid.
|
||||||
.shell_integration = config.@"shell-integration",
|
{
|
||||||
.shell_integration_features = config.@"shell-integration-features",
|
// Initialize our IO backend
|
||||||
.working_directory = config.@"working-directory",
|
var io_exec = try termio.Exec.init(alloc, .{
|
||||||
.resources_dir = main.state.resources_dir,
|
.command = config.command,
|
||||||
.term = config.term,
|
.shell_integration = config.@"shell-integration",
|
||||||
|
.shell_integration_features = config.@"shell-integration-features",
|
||||||
|
.working_directory = config.@"working-directory",
|
||||||
|
.resources_dir = main.state.resources_dir,
|
||||||
|
.term = config.term,
|
||||||
|
|
||||||
// Get the cgroup if we're on linux and have the decl. I'd love
|
// Get the cgroup if we're on linux and have the decl. I'd love
|
||||||
// to change this from a decl to a surface options struct because
|
// to change this from a decl to a surface options struct because
|
||||||
// then we can do memory management better (don't need to retain
|
// then we can do memory management better (don't need to retain
|
||||||
// the string around).
|
// the string around).
|
||||||
.linux_cgroup = if (comptime builtin.os.tag == .linux and
|
.linux_cgroup = if (comptime builtin.os.tag == .linux and
|
||||||
@hasDecl(apprt.runtime.Surface, "cgroup"))
|
@hasDecl(apprt.runtime.Surface, "cgroup"))
|
||||||
rt_surface.cgroup()
|
rt_surface.cgroup()
|
||||||
else
|
else
|
||||||
Command.linux_cgroup_default,
|
Command.linux_cgroup_default,
|
||||||
});
|
});
|
||||||
errdefer io_exec.deinit();
|
errdefer io_exec.deinit();
|
||||||
var io_writer = try termio.Writer.initMailbox(alloc);
|
|
||||||
errdefer io_writer.deinit(alloc);
|
|
||||||
try termio.Termio.init(&self.io, alloc, .{
|
|
||||||
.grid_size = grid_size,
|
|
||||||
.screen_size = screen_size,
|
|
||||||
.padding = padding,
|
|
||||||
.full_config = config,
|
|
||||||
.config = try termio.Termio.DerivedConfig.init(alloc, config),
|
|
||||||
.reader = .{ .exec = io_exec },
|
|
||||||
.writer = io_writer,
|
|
||||||
.resources_dir = main.state.resources_dir,
|
|
||||||
.renderer_state = &self.renderer_state,
|
|
||||||
.renderer_wakeup = render_thread.wakeup,
|
|
||||||
.renderer_mailbox = render_thread.mailbox,
|
|
||||||
.surface_mailbox = .{ .surface = self, .app = app_mailbox },
|
|
||||||
|
|
||||||
// Get the cgroup if we're on linux and have the decl. I'd love
|
// Initialize our IO writer
|
||||||
// to change this from a decl to a surface options struct because
|
var io_writer = try termio.Writer.initMailbox(alloc);
|
||||||
// then we can do memory management better (don't need to retain
|
errdefer io_writer.deinit(alloc);
|
||||||
// the string around).
|
|
||||||
.linux_cgroup = if (comptime builtin.os.tag == .linux and
|
try termio.Termio.init(&self.io, alloc, .{
|
||||||
@hasDecl(apprt.runtime.Surface, "cgroup"))
|
.grid_size = grid_size,
|
||||||
rt_surface.cgroup()
|
.screen_size = screen_size,
|
||||||
else
|
.padding = padding,
|
||||||
Command.linux_cgroup_default,
|
.full_config = config,
|
||||||
});
|
.config = try termio.Termio.DerivedConfig.init(alloc, config),
|
||||||
|
.reader = .{ .exec = io_exec },
|
||||||
|
.writer = io_writer,
|
||||||
|
.renderer_state = &self.renderer_state,
|
||||||
|
.renderer_wakeup = render_thread.wakeup,
|
||||||
|
.renderer_mailbox = render_thread.mailbox,
|
||||||
|
.surface_mailbox = .{ .surface = self, .app = app_mailbox },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Outside the block, IO has now taken ownership of our temporary state
|
||||||
|
// so we can just defer this and not the subcomponents.
|
||||||
errdefer self.io.deinit();
|
errdefer self.io.deinit();
|
||||||
|
|
||||||
// Report initial cell size on surface creation
|
// Report initial cell size on surface creation
|
||||||
|
@ -32,9 +32,6 @@ reader: termio.Reader,
|
|||||||
/// If you're using termio.Thread this MUST be "mailbox".
|
/// If you're using termio.Thread this MUST be "mailbox".
|
||||||
writer: termio.Writer,
|
writer: termio.Writer,
|
||||||
|
|
||||||
/// The application resources directory.
|
|
||||||
resources_dir: ?[]const u8,
|
|
||||||
|
|
||||||
/// The render state. The IO implementation can modify anything here. The
|
/// The render state. The IO implementation can modify anything here. The
|
||||||
/// surface thread will setup the initial "terminal" pointer but the IO impl
|
/// surface thread will setup the initial "terminal" pointer but the IO impl
|
||||||
/// is free to change that if that is useful (i.e. doing some sort of dual
|
/// is free to change that if that is useful (i.e. doing some sort of dual
|
||||||
@ -50,7 +47,3 @@ renderer_mailbox: *renderer.Thread.Mailbox,
|
|||||||
|
|
||||||
/// The mailbox for sending the surface messages.
|
/// The mailbox for sending the surface messages.
|
||||||
surface_mailbox: apprt.surface.Mailbox,
|
surface_mailbox: apprt.surface.Mailbox,
|
||||||
|
|
||||||
/// The cgroup to apply to the started termio process, if able by
|
|
||||||
/// the termio implementation. This only applies to Linux.
|
|
||||||
linux_cgroup: Command.LinuxCgroup = Command.linux_cgroup_default,
|
|
||||||
|
Reference in New Issue
Block a user