summaryrefslogtreecommitdiff
path: root/dev/Host.zig
blob: 1834e52ecec9a5815e4feef4037caaac99d49f3f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const pardes = @import("core");
const host_io = @import("host_io.zig");
const Lsp = host_io.Lsp;

ctx: ?*anyopaque = null,
vtable: *const VTable = &.{},

pub const VTable = struct {
    wait_input: ?*const fn (ctx: ?*anyopaque, timeout_ms: u32) void = null,
    /// The shell's monotonic clock in ns: the only time the core sees.
    /// Without one, core animation moves only by `.tick` events.
    now: ?*const fn (ctx: ?*anyopaque) u64 = null,
    /// The frame drawn on the frontend: false when it could not show it
    /// now (no image to draw into, the terminal still answering the last),
    /// which owes the next frame.
    present: ?*const fn (ctx: ?*anyopaque, surface: *const pardes.Surface) bool = null,
    post_present: ?*const fn (ctx: ?*anyopaque) void = null,
    poll_frame: ?*const fn (ctx: ?*anyopaque) void = null,
    /// Whether anyone sees a frame drawn now. A detached session with no
    /// client attached draws none (a /screen read draws its own), and
    /// the frame owed is drawn when one attaches. Absent: always.
    watched: ?*const fn (ctx: ?*anyopaque) bool = null,
    /// Detach: the terminal or window let go, the session left running
    /// for the daemon to attach again (daemon.zig).
    detach: ?*const fn (ctx: ?*anyopaque) void = null,
    /// Adopt: the shells a dead session left, asked of the daemon.
    adopt: ?*const fn (ctx: ?*anyopaque, pane: u8) void = null,
    /// Upgrade: this process exec'd as the pardes installed since, at
    /// the step's end (upgrade.zig); `pane` hears why if it cannot be.
    upgrade: ?*const fn (ctx: ?*anyopaque, pane: u8) void = null,
    /// Whether a newer pardes is installed at the path this process
    /// started from, to be said once (upgrade.zig): asked at a focus-in.
    newer_build: ?*const fn (ctx: ?*anyopaque) bool = null,
    spawn: ?*const fn (ctx: ?*anyopaque, pane: u8, cwd: []const u8) void = null,
    pty_write: ?*const fn (ctx: ?*anyopaque, pane: u8, bytes: []const u8) void = null,
    pty_resize: ?*const fn (ctx: ?*anyopaque, pane: u8, cols: u16, rows: u16) void = null,
    pty_signal: ?*const fn (ctx: ?*anyopaque, pane: u8, sig: pardes.PtySignal) void = null,
    close_pty: ?*const fn (ctx: ?*anyopaque, pane: u8) void = null,
    tty_taken: ?*const fn (ctx: ?*anyopaque, pane: u8) bool = null,
    /// The name of the program holding the tty, when it is not the
    /// shell (host_io.foregroundName), in `buf`.
    fg_name: ?*const fn (ctx: ?*anyopaque, pane: u8, buf: []u8) ?[]const u8 = null,
    /// Answered at once, not queued as an effect: Kill asks while the
    /// job it saw running is still the one in the tty (host_io.killJob).
    kill_job: ?*const fn (ctx: ?*anyopaque, pane: u8) bool = null,
    write_file: ?*const fn (ctx: ?*anyopaque, pane: u8, path: []const u8, bytes: []const u8) void = null,
    write_dump: ?*const fn (ctx: ?*anyopaque, bytes: []const u8) void = null,
    watch_file: ?*const fn (ctx: ?*anyopaque, pane: u8, path: []const u8, on: bool, mode: pardes.WatchMode) void = null,
    watch_theme: ?*const fn (ctx: ?*anyopaque, generation: u32, on: bool) void = null,
    dump_themes: ?*const fn (ctx: ?*anyopaque, pane: u8) void = null,
    set_clipboard: ?*const fn (ctx: ?*anyopaque, text: []const u8) void = null,
    read_clipboard: ?*const fn (ctx: ?*anyopaque) void = null,
    open_link: ?*const fn (ctx: ?*anyopaque, url: []const u8) void = null,
    /// A plumbing rule's program (Effect.start): every host's is
    /// startDetached. Null once it runs, else why not.
    start: ?*const fn (ctx: ?*anyopaque, line: []const u8, why: []u8) ?[]const u8 = null,
    lsp: ?*const fn (ctx: ?*anyopaque, req: Lsp.Request) void = null,
    pipe: ?*const fn (ctx: ?*anyopaque, id: u32) void = null,
    /// Start the streaming search of this generation on a worker
    /// (pardes.Stream.start); absent, it runs on the loop.
    search: ?*const fn (ctx: ?*anyopaque, gen: u32) void = null,
    /// Carry the dump of handover `seq` to another window on a worker
    /// (Handover.start), which answers through the inbox's `handed`.
    hand_over: ?*const fn (ctx: ?*anyopaque, seq: u32, bytes: []const u8) void = null,
    /// Run job `token` of the pane in slot `pane` (whose serial is
    /// `serial`) on a worker (`KindJob`), answering with the `job` event;
    /// absent, it runs on the loop.
    job: ?*const fn (ctx: ?*anyopaque, pane: u8, serial: u32, token: u32) void = null,
};