diff options
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 59 |
1 files changed, 12 insertions, 47 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index c3d12932..db5c0c25 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -80,8 +80,6 @@ pub const isolated = @import("pardes_isolation").isolated; pub const font_picker = platform == .gui or platform == .macos; -pub const hosted = platform == .tui or platform == .gui or platform == .macos; - /// Whose turn it is with the core. The core is single-threaded: the editor's /// thread has it, and lets go of it in two kinds of gap -- while it waits for /// input (`rest`, `wake`), and while it is out in the host filesystem in the @@ -102,7 +100,7 @@ pub const hosted = platform == .tui or platform == .gui or platform == .macos; /// is never the syscall's own. /// /// One per process, like the editor it belongs to. A process that never -/// starts it -- a test, the browser -- has no second thread, and +/// starts it -- a test -- has no second thread, and /// every yield is a no-op. pub var turn: Turn = .{}; @@ -248,9 +246,6 @@ pub const pdf_raster_policy: PdfRasterPolicy = switch (platform) { // Both pixel shells rasterize for a real display and can afford it; the // wire-bandwidth argument that shapes the Kitty policy does not apply. .gui, .macos => sdl_pdf_raster_policy, - // The web rasterizes no PDF at all (mupdf is compiled out), so the - // cheaper policy is the honest placeholder. - .web => kitty_pdf_raster_policy, }; pub const Pane = panes.Pane; @@ -395,7 +390,6 @@ fn colFromSpan(x: f32, span: f32) u16 { } test "a compact tagline anchors at its own pane, and both shells step from the same origin" { - if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 24 }); defer p.deinit(); _ = try p.newShell(1, ""); @@ -2388,7 +2382,7 @@ test "a host with no methods at all is a complete in-process pardes" { } test "Font keeps requested and acknowledged faces as separate plain state" { - if (comptime !font_picker) return; // there is no Font builtin on tty or web + if (comptime !font_picker) return; // there is no Font builtin on the tty const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24 }); defer p.deinit(); var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); @@ -2495,7 +2489,6 @@ test "startup config overrides restored styling before initFromDump returns" { } test "restored sessions animate layout changes after bootstrap" { - if (platform == .web) return; const source = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 16 }); defer source.deinit(); try dump.dumpState(source); @@ -3113,7 +3106,6 @@ comptime { } test "a new column takes width only from the column that created it" { - if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .cols = 124, .rows = 24 }); defer p.deinit(); @@ -3181,7 +3173,6 @@ test "a new column takes width only from the column that created it" { } test "Newcol refuses an unsplittable restored weight before spawning" { - if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .cols = 200, .rows = 20 }); defer p.deinit(); @@ -3578,7 +3569,6 @@ test "core composes character motion out of the new grid, not a fade" { } test "repeated non-dyadic column splits preserve every unrelated boundary" { - if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .cols = 979, .rows = 20 }); defer p.deinit(); @@ -4264,9 +4254,9 @@ pub const Pardes = struct { /// remembered for want of memory is no failure of what opened it), so /// on a host it takes from the process heap, not the editor's, whose /// every failure must be answered. - // ponytail: a host heap for a best-effort list; the browser's gpa there. - pub fn recentGpa(p: *const Pardes) std.mem.Allocator { - return if (comptime hosted) std.heap.smp_allocator else p.gpa; + // ponytail: a host heap for a best-effort list. + pub fn recentGpa(_: *const Pardes) std.mem.Allocator { + return std.heap.smp_allocator; } /// Recent's file read once at start: a new session's. @@ -4286,7 +4276,6 @@ pub const Pardes = struct { /// the served tree's (`/virtual/`) nor a name never saved. pub fn recentKeeps(path: []const u8) bool { const local = filesystem.localPath(path) orelse return false; - if (comptime !hosted) return true; return exec.kindOf(local) == .file; } @@ -4372,7 +4361,7 @@ pub const Pardes = struct { const taped = tape.enter(p, .{ .deinit = tape.current(p) }); tape.forget(p); defer tape.leave(null, taped); - if (comptime hosted) if (std.c.getenv("PARDES_FRAMES")) |path| p.frames.dump(std.mem.span(path)); + if (std.c.getenv("PARDES_FRAMES")) |path| p.frames.dump(std.mem.span(path)); // Every file open now is closed with its dot, and the list kept. for (p.panes) |slot| if (slot) |pane| p.noteClosed(pane); p.store.flush(p, true); @@ -4896,11 +4885,10 @@ pub const Pardes = struct { } /// A window's font, asked and told (this and the three below): in every - /// hosted build, not only a window's, as only a window's host calls + /// build, not only a window's, as only a window's host calls /// them and a terminal's replica of a window's session must step as /// the window does. pub fn takeFontRequest(p: *Pardes) ?[]const u8 { - if (comptime !hosted) return null; const taped = tape.enter(p, .take_font_request); defer tape.leave(p, taped); if (!p.settings.font.pending or p.font_request_taken) return null; @@ -4916,7 +4904,6 @@ pub const Pardes = struct { effective_size_hundredths: u16, unit: config.Runtime.FontSizeUnit, ) bool { - if (comptime !hosted) return false; const taped = tape.enter(p, .{ .observe_font = .{ .name = effective_name, .size = effective_size_hundredths, .unit = unit } }); defer tape.leave(p, taped); if (!p.settings.font.effective_name.set(effective_name)) return false; @@ -4933,7 +4920,6 @@ pub const Pardes = struct { effective_size_hundredths: u16, unit: config.Runtime.FontSizeUnit, ) bool { - if (comptime !hosted) return false; const taped = tape.enter(p, .{ .acknowledge_font = .{ .name = effective_name, .size = effective_size_hundredths, .unit = unit } }); defer tape.leave(p, taped); if (!p.settings.font.pending or !p.font_request_taken) return false; @@ -4951,7 +4937,6 @@ pub const Pardes = struct { } pub fn rejectFont(p: *Pardes) void { - if (comptime !hosted) return; const taped = tape.enter(p, .reject_font); defer tape.leave(p, taped); if (!p.settings.font.pending or !p.font_request_taken) return; @@ -5179,7 +5164,7 @@ pub const Pardes = struct { // A Save makes the directories its file goes in, and any above them, // first: one rule, for the pane's own name and `Save path` alike. A // directory it cannot make leaves the write to fail and say why. - if (comptime hosted) if (filesystem.localPath(path)) |local| filesystem.makeDirs(std.fs.path.dirname(local) orelse "/"); + if (filesystem.localPath(path)) |local| filesystem.makeDirs(std.fs.path.dirname(local) orelse "/"); // The in-process filesystem reports the same way a real host does, // so an OOM there leaves the pane dirty rather than looking saved. if (p.host.vtable.write_file) |f| f(p.host.ctx, id, path, bytes) else if (!p.fallback.writeFile(path, bytes)) p.saveFailed(id, path, error.OutOfMemory); @@ -5255,7 +5240,7 @@ pub const Pardes = struct { // The script is there; the program its `#!` names is not. var said: [320]u8 = undefined; var interp: [256]u8 = undefined; - const name: ?[]const u8 = if (comptime hosted) tape.value(.interpreter, missingInterpreter, .{ pane.shell orelse p.shellBin(), &interp }) else null; + const name = tape.value(.interpreter, missingInterpreter, .{ pane.shell orelse p.shellBin(), &interp }); p.reportFailure(id, if (name) |n| std.fmt.bufPrint(&said, "shell: interpreter {s} not found", .{n}) catch "shell: interpreter not found" else "shell: interpreter not found"); } else { p.reportError(id, "shell", err); @@ -5277,10 +5262,10 @@ pub const Pardes = struct { /// missing, and whether that is because one above refuses (EACCES). fn parentTrouble(path: []const u8, err: anyerror) struct { dir: []const u8, kind: ?std.Io.File.Kind, missing: bool, denied: bool } { const dir = std.fs.path.dirname(path) orelse "/"; - const local = if (comptime hosted) filesystem.localPath(dir) else null; - const kind: ?std.Io.File.Kind = if (comptime hosted) (if (local) |l| exec.kindOf(l) else .directory) else .directory; + const local = filesystem.localPath(dir); + const kind: ?std.Io.File.Kind = if (local) |l| exec.kindOf(l) else .directory; const missing = err == error.FileNotFound or err == error.NotDir or kind != .directory; - const denied = missing and (if (comptime hosted) (if (local) |l| tape.value(.denied, filesystem.deniedAbove, .{l}) else false) else false); + const denied = missing and (if (local) |l| tape.value(.denied, filesystem.deniedAbove, .{l}) else false); return .{ .dir = dir, .kind = kind, .missing = missing, .denied = denied }; } @@ -6241,7 +6226,6 @@ pub const Pardes = struct { /// Where pardes started: the directory of what runs from a header. pub fn sessionDir(p: *Pardes) []const u8 { if (p.session_dir_len) |n| return p.session_dir[0..n]; - if (comptime !hosted) return "/"; // The directory the session that recorded was started in. const dir = tape.value(.cwd, processDir, .{&p.session_dir}) orelse return "/"; std.mem.copyForwards(u8, &p.session_dir, dir); @@ -7499,7 +7483,6 @@ pub const Pardes = struct { }; test "a boot file that will not open boots an errors pane rather than failing the launch" { - if (platform == .web) return; const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .cols = 80, @@ -7625,7 +7608,6 @@ test "raw terminal cursor follows its active row only while that row is visible" } test "Esc back into a tty leaves its view at the prompt" { - if (platform == .web) return; const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }); defer p.deinit(); @@ -7665,7 +7647,6 @@ test "Esc back into a tty leaves its view at the prompt" { } test "a prompt chip is a band with its caret, still on the grid, and only the chip swallows a click" { - if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); defer p.deinit(); const id = p.active; @@ -7722,7 +7703,6 @@ test "a prompt chip is a band with its caret, still on the grid, and only the ch } test "a prompt is typed on its own line in the notice band and leaves the tag row alone" { - if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); defer p.deinit(); const pane = try p.setTestFile("one two\n"); @@ -7761,7 +7741,6 @@ test "a prompt is typed on its own line in the notice band and leaves the tag ro } test "Del from a key asks which neighbour takes the rows; nothing else asks" { - if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 40 }); defer p.deinit(); var frame = std.heap.ArenaAllocator.init(std.testing.allocator); @@ -7878,7 +7857,6 @@ test "Del from a key asks which neighbour takes the rows; nothing else asks" { } test "the bare tty startup opens a text pane under the shell, unfocused" { - if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .boot = .tty }); defer p.deinit(); try std.testing.expectEqual(Boot.tty, p.boot); @@ -7904,7 +7882,6 @@ test "the bare tty startup opens a text pane under the shell, unfocused" { } test "tty output follows only from the bottom" { - if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24, .file = "mise.toml" }); defer p.deinit(); p.update(.{ .resize = .{ .cols = 80, .rows = 24 } }); @@ -7947,7 +7924,6 @@ test "tty output follows only from the bottom" { } test "raw tty Esc backs out and Shift-Esc is the program's Esc" { - if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24, .file = "mise.toml" }); defer p.deinit(); _ = exec.spawnTty(p, 0); @@ -7972,7 +7948,6 @@ test "raw tty Esc backs out and Shift-Esc is the program's Esc" { } test "with ProgramEsc raw tty Escape only leaves at a shell prompt" { - if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24, .file = "mise.toml" }); defer p.deinit(); p.settings.program_esc = true; @@ -8004,7 +7979,6 @@ test "with ProgramEsc raw tty Escape only leaves at a shell prompt" { } test "the Del question shows only once its delay is up: a quick SPC d j never sees it" { - if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 40 }); defer p.deinit(); var frame = std.heap.ArenaAllocator.init(std.testing.allocator); @@ -8053,7 +8027,6 @@ test "the Del question shows only once its delay is up: a quick SPC d j never se } test "raw tty Ctrl-B switches to editor mode without sending child input" { - if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .file = "mise.toml" }); defer p.deinit(); _ = exec.spawnTty(p, 0); @@ -8150,7 +8123,6 @@ test "a Rename the language server finds nothing for says so, and changes nothin } test "raw tty forwards Ctrl letters and former global shortcuts to the child" { - if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); var buf: [256]u8 = undefined; @@ -8198,7 +8170,6 @@ test "raw tty forwards Ctrl letters and former global shortcuts to the child" { } test "an unasked desktop paste reaches a tty pane's program, not its buffer" { - if (platform == .web) return; const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); defer p.deinit(); @@ -8217,7 +8188,6 @@ test "an unasked desktop paste reaches a tty pane's program, not its buffer" { } test "a paste larger than the effect ring reaches the program whole and in order" { - if (platform == .web) return; const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); defer p.deinit(); @@ -8237,7 +8207,6 @@ test "a paste larger than the effect ring reaches the program whole and in order } test "a bracketed paste larger than the ring still closes its bracket" { - if (platform == .web) return; const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); defer p.deinit(); @@ -8260,7 +8229,6 @@ test "a bracketed paste larger than the ring still closes its bracket" { } test "a terminal's answer to its program waits behind the paste still queued for its pty" { - if (platform == .web) return; const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); defer p.deinit(); @@ -8287,7 +8255,6 @@ test "a terminal's answer to its program waits behind the paste still queued for } test "pasted bytes still queued at shutdown are freed, not leaked" { - if (platform == .web) return; const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); defer p.deinit(); @@ -8305,7 +8272,6 @@ test "pasted bytes still queued at shutdown are freed, not leaked" { } test "leaving tty hides the prompt and keeps the command typed at it" { - if (platform == .web) return; const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }); defer p.deinit(); @@ -8371,7 +8337,6 @@ test "leaving tty hides the prompt and keeps the command typed at it" { } test "entering tty walks the shell cursor to the column clicked past the prompt" { - if (platform == .web) return; const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }); defer p.deinit(); |
