summaryrefslogtreecommitdiff
path: root/core/Core.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Core.zig')
-rw-r--r--core/Core.zig25
1 files changed, 12 insertions, 13 deletions
diff --git a/core/Core.zig b/core/Core.zig
index 39d09f21..a19453af 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -523,8 +523,6 @@ pub fn init(gpa: std.mem.Allocator, opts: Options) !*Pardes {
}
fn initSession(gpa: std.mem.Allocator, opts: Options) !*Pardes {
- // A new session draws a tab at the default until `Tab` says otherwise.
- config.tab_now = config.tab_width;
const p = try create(gpa, opts);
errdefer p.deinit();
p.boot = Boot.of(opts);
@@ -1604,7 +1602,7 @@ pub fn update(p: *Pardes, ev: Event) void {
.tick => {
Stream.step(p);
Messages.advanceMessages(p);
- for (p.panes) |slot| if (slot) |pane| if (pane.file) |*f| f.tables.step(pane.gpa, f);
+ for (p.panes) |slot| if (slot) |pane| if (pane.file) |*f| f.tables.step(p.settings.tab, pane.gpa, f);
for (0..p.panes.len) |id| exec.flushReplEnter(p, id, false);
},
else => {},
@@ -1858,7 +1856,7 @@ pub fn sync(p: *Pardes) void {
var caret_row: usize = @intCast(@max(0, pane.tag.cur_row));
if (prefix) |made| wrap: {
const whole = std.mem.concat(wa, u8, &.{ made, tagline.curTail(pane) }) catch break :wrap;
- const shown = tagline.wrapTag(wa, whole, tagline.tagWidth(p, id)) catch break :wrap;
+ const shown = tagline.wrapTag(p.settings.tab, wa, whole, tagline.tagWidth(p, id)) catch break :wrap;
lines = shown.rows();
// Collapsed, one row, as acme's Tagup sets taglines to 1
// (plan9port text.c:786).
@@ -2174,6 +2172,7 @@ pub const Boot = enum {
};
pub const Options = struct {
+ pub const replica = .{ .local = .{"distrusted"} };
tty_only: bool = false,
/// The first view's frontend is a window (`Pardes.frontend`), as a
/// window's build says: an option, taped with the rest, so that a
@@ -2215,6 +2214,9 @@ pub const Options = struct {
recent_import: ?[]const u8 = null,
startup_config_path: ?[]const u8 = null,
image_allocator: ?std.mem.Allocator = null,
+ /// A client's: the kinds it caught breaking PA_PLAIN, its frontend's
+ /// list, which outlives each core it joins with. In no tape and no dump.
+ distrusted: ?*pardes.Addon.Distrusted = null,
/// What the host's scan of the addon directories found (Addon.scan).
addons: []const pardes.Kind.Loaded = &.{},
tree_sitter_allocator: ?std.mem.Allocator = null,
@@ -2923,7 +2925,7 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe
// Several selections executed at once: each is sent, not the first.
{
const text = try edit.flatSurface(p.editor(), &file.body);
- file.body.setRanges(text, &.{ .{ .anchor = 0, .head = 8 }, .{ .anchor = 9, .head = 11 } }, &.{}, 0, true);
+ file.body.setRanges(config.tab_width, text, &.{ .{ .anchor = 0, .head = 8 }, .{ .anchor = 9, .head = 11 } }, &.{}, 0, true);
try std.testing.expect(exec.chordEachSel(p, file, .Exec));
Sent.drain(p);
try std.testing.expectEqualStrings("print(1)\rls\r", Sent.said(1));
@@ -3438,11 +3440,9 @@ test "Tab N draws every pane's tab N cells wide and clicks count past it; bare T
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{ .cols = 60, .rows = 12 });
defer p.deinit();
- // The width is the process's: the next test starts from the default.
- defer config.tab_now = config.tab_width;
const pane = try p.setTestFile("\tx = 1\n");
try std.testing.expect(p.executeBuiltinLine(0, "Tab 8"));
- try std.testing.expectEqual(@as(u16, 8), config.tab_now);
+ try std.testing.expectEqual(@as(u16, 8), p.settings.tab);
var frame = std.heap.ArenaAllocator.init(gpa);
defer frame.deinit();
const surface = try p.render(frame.allocator());
@@ -3459,7 +3459,7 @@ test "Tab N draws every pane's tab N cells wide and clicks count past it; bare T
try std.testing.expectEqualStrings("Tab 8", pane.msg[0..pane.msg_len]);
// Out of range: refused, the width kept.
try std.testing.expect(p.executeBuiltinLine(0, "Tab 0"));
- try std.testing.expectEqual(@as(u16, 8), config.tab_now);
+ try std.testing.expectEqual(@as(u16, 8), p.settings.tab);
// The ctl read's tab column, and a Dump's settings.
const ctl_text = @import("ninep/testing.zig").rd(p, ctlfs.Node.of(pane.serial, .ctl), 0, 4096).bytes;
try std.testing.expect(std.mem.indexOf(u8, ctl_text, " 8 ") != null);
@@ -3467,7 +3467,6 @@ test "Tab N draws every pane's tab N cells wide and clicks count past it; bare T
const restored = try dump.restore(p, p.dump_out.?, "/tmp/pardes.dump.zon");
defer restored.deinit();
try std.testing.expectEqual(@as(u16, 8), restored.settings.tab);
- try std.testing.expectEqual(@as(u16, 8), config.tab_now);
}
test "tabbed file aligns syntax cursor and mouse at the nearest insertion gap" {
@@ -3504,7 +3503,7 @@ test "tabbed file aligns syntax cursor and mouse at the nearest insertion gap" {
const line = modal.lineSlice(f.content, 0);
const virtual: u16 = 3;
- const blank_x = text_x + @as(u16, @intCast(pardes.panes.File.displayWidth(line))) + virtual;
+ const blank_x = text_x + @as(u16, @intCast(pardes.panes.File.displayWidth(config.tab_width, line))) + virtual;
p.update(.{ .mouse = .{ .button = config.select_button, .kind = .press, .col = blank_x, .row = body_y } });
p.update(.{ .mouse = .{ .button = config.select_button, .kind = .release, .col = blank_x, .row = body_y } });
try std.testing.expectEqual(@as(i32, @intCast(line.len)), pane.body.cur_col);
@@ -3518,7 +3517,7 @@ test "tabbed file aligns syntax cursor and mouse at the nearest insertion gap" {
// The immediately-adjacent EOL cell and an in-line separator are blank
// too. Pointer expansion must not lean left into the preceding word.
- const adjacent: i32 = @intCast(config.PREFIX_W + pardes.panes.File.displayWidth(line));
+ const adjacent: i32 = @intCast(config.PREFIX_W + pardes.panes.File.displayWidth(config.tab_width, line));
try std.testing.expect(look.expandedSel(p, pane, .{ .state = .dragging, .c0 = adjacent, .c1 = adjacent, .r0 = BOX_H, .r1 = BOX_H }) == null);
const separator: i32 = @intCast(config.PREFIX_W + config.tab_width + "return".len);
try std.testing.expect(look.expandedSel(p, pane, .{ .state = .dragging, .c0 = separator, .c1 = separator, .r0 = BOX_H, .r1 = BOX_H }) == null);
@@ -3986,7 +3985,7 @@ test "leaving tty hides the prompt and keeps the command typed at it" {
}.at;
const bodyRowOf = struct {
fn at(pp: *Pardes, pane: *Pane, needle: []const u8) ?[]const u8 {
- const body = @import("body_layer.zig").bodyText(pp.scratch.allocator(), pane) catch return null;
+ const body = @import("body_layer.zig").bodyText(pp.settings.tab, pp.scratch.allocator(), pane) catch return null;
var it = std.mem.splitScalar(u8, body, '\n');
while (it.next()) |r| if (std.mem.indexOf(u8, r, needle) != null) return r;
return null;