mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
termio: get rid of manual backend
This commit is contained in:
@ -256,9 +256,7 @@ pub fn threadEnter(self: *Termio, thread: *termio.Thread, data: *ThreadData) !vo
|
|||||||
.renderer_state = self.renderer_state,
|
.renderer_state = self.renderer_state,
|
||||||
.surface_mailbox = self.surface_mailbox,
|
.surface_mailbox = self.surface_mailbox,
|
||||||
.mailbox = &self.mailbox,
|
.mailbox = &self.mailbox,
|
||||||
|
.backend = undefined, // Backend must replace this on threadEnter
|
||||||
// Placeholder until setup below
|
|
||||||
.backend = .{ .manual = {} },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Setup our backend
|
// Setup our backend
|
||||||
|
@ -19,17 +19,11 @@ const Pty = @import("../pty.zig").Pty;
|
|||||||
// enough to satisfy most write requests. It must be a power of 2.
|
// enough to satisfy most write requests. It must be a power of 2.
|
||||||
const WRITE_REQ_PREALLOC = std.math.pow(usize, 2, 5);
|
const WRITE_REQ_PREALLOC = std.math.pow(usize, 2, 5);
|
||||||
|
|
||||||
/// The kinds of readers.
|
/// The kinds of backends.
|
||||||
pub const Kind = enum { manual, exec };
|
pub const Kind = enum { exec };
|
||||||
|
|
||||||
/// Configuration for the various reader types.
|
/// Configuration for the various backend types.
|
||||||
pub const Config = union(Kind) {
|
pub const Config = union(Kind) {
|
||||||
/// Manual means that the termio caller will handle reading input
|
|
||||||
/// and passing it to the termio implementation. Note that even if you
|
|
||||||
/// select a different reader, you can always still manually provide input;
|
|
||||||
/// this config just makes it so that it is ONLY manual input.
|
|
||||||
manual: void,
|
|
||||||
|
|
||||||
/// Exec uses posix exec to run a command with a pty.
|
/// Exec uses posix exec to run a command with a pty.
|
||||||
exec: termio.Exec.Config,
|
exec: termio.Exec.Config,
|
||||||
};
|
};
|
||||||
@ -37,19 +31,16 @@ pub const Config = union(Kind) {
|
|||||||
/// Backend implementations. A backend is responsible for owning the pty
|
/// Backend implementations. A backend is responsible for owning the pty
|
||||||
/// behavior and providing read/write capabilities.
|
/// behavior and providing read/write capabilities.
|
||||||
pub const Backend = union(Kind) {
|
pub const Backend = union(Kind) {
|
||||||
manual: void,
|
|
||||||
exec: termio.Exec,
|
exec: termio.Exec,
|
||||||
|
|
||||||
pub fn deinit(self: *Backend) void {
|
pub fn deinit(self: *Backend) void {
|
||||||
switch (self.*) {
|
switch (self.*) {
|
||||||
.manual => {},
|
|
||||||
.exec => |*exec| exec.deinit(),
|
.exec => |*exec| exec.deinit(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn initTerminal(self: *Backend, t: *terminal.Terminal) void {
|
pub fn initTerminal(self: *Backend, t: *terminal.Terminal) void {
|
||||||
switch (self.*) {
|
switch (self.*) {
|
||||||
.manual => {},
|
|
||||||
.exec => |*exec| exec.initTerminal(t),
|
.exec => |*exec| exec.initTerminal(t),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,14 +52,12 @@ pub const Backend = union(Kind) {
|
|||||||
td: *termio.Termio.ThreadData,
|
td: *termio.Termio.ThreadData,
|
||||||
) !void {
|
) !void {
|
||||||
switch (self.*) {
|
switch (self.*) {
|
||||||
.manual => {},
|
|
||||||
.exec => |*exec| try exec.threadEnter(alloc, io, td),
|
.exec => |*exec| try exec.threadEnter(alloc, io, td),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn threadExit(self: *Backend, td: *termio.Termio.ThreadData) void {
|
pub fn threadExit(self: *Backend, td: *termio.Termio.ThreadData) void {
|
||||||
switch (self.*) {
|
switch (self.*) {
|
||||||
.manual => {},
|
|
||||||
.exec => |*exec| exec.threadExit(td),
|
.exec => |*exec| exec.threadExit(td),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,7 +68,6 @@ pub const Backend = union(Kind) {
|
|||||||
screen_size: renderer.ScreenSize,
|
screen_size: renderer.ScreenSize,
|
||||||
) !void {
|
) !void {
|
||||||
switch (self.*) {
|
switch (self.*) {
|
||||||
.manual => {},
|
|
||||||
.exec => |*exec| try exec.resize(grid_size, screen_size),
|
.exec => |*exec| try exec.resize(grid_size, screen_size),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,7 +80,6 @@ pub const Backend = union(Kind) {
|
|||||||
linefeed: bool,
|
linefeed: bool,
|
||||||
) !void {
|
) !void {
|
||||||
switch (self.*) {
|
switch (self.*) {
|
||||||
.manual => {},
|
|
||||||
.exec => |*exec| try exec.queueWrite(alloc, td, data, linefeed),
|
.exec => |*exec| try exec.queueWrite(alloc, td, data, linefeed),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,7 +92,6 @@ pub const Backend = union(Kind) {
|
|||||||
runtime_ms: u64,
|
runtime_ms: u64,
|
||||||
) !void {
|
) !void {
|
||||||
switch (self.*) {
|
switch (self.*) {
|
||||||
.manual => {},
|
|
||||||
.exec => |*exec| try exec.childExitedAbnormally(
|
.exec => |*exec| try exec.childExitedAbnormally(
|
||||||
gpa,
|
gpa,
|
||||||
t,
|
t,
|
||||||
@ -118,19 +104,16 @@ pub const Backend = union(Kind) {
|
|||||||
|
|
||||||
/// Termio thread data. See termio.ThreadData for docs.
|
/// Termio thread data. See termio.ThreadData for docs.
|
||||||
pub const ThreadData = union(Kind) {
|
pub const ThreadData = union(Kind) {
|
||||||
manual: void,
|
|
||||||
exec: termio.Exec.ThreadData,
|
exec: termio.Exec.ThreadData,
|
||||||
|
|
||||||
pub fn deinit(self: *ThreadData, alloc: Allocator) void {
|
pub fn deinit(self: *ThreadData, alloc: Allocator) void {
|
||||||
switch (self.*) {
|
switch (self.*) {
|
||||||
.manual => {},
|
|
||||||
.exec => |*exec| exec.deinit(alloc),
|
.exec => |*exec| exec.deinit(alloc),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn changeConfig(self: *ThreadData, config: *termio.DerivedConfig) void {
|
pub fn changeConfig(self: *ThreadData, config: *termio.DerivedConfig) void {
|
||||||
switch (self.*) {
|
switch (self.*) {
|
||||||
.manual => {},
|
|
||||||
.exec => |*exec| {
|
.exec => |*exec| {
|
||||||
exec.abnormal_runtime_threshold_ms = config.abnormal_runtime_threshold_ms;
|
exec.abnormal_runtime_threshold_ms = config.abnormal_runtime_threshold_ms;
|
||||||
exec.wait_after_command = config.wait_after_command;
|
exec.wait_after_command = config.wait_after_command;
|
||||||
|
Reference in New Issue
Block a user