summaryrefslogtreecommitdiff
path: root/src/dump.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/dump.zig')
-rw-r--r--src/dump.zig12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/dump.zig b/src/dump.zig
index 7112e1f0..aeb25a90 100644
--- a/src/dump.zig
+++ b/src/dump.zig
@@ -191,8 +191,10 @@ pub const State = struct {
mounts: []const Mount = &.{},
};
+/// A header is a text like any other: it may hold newlines, but not a
+/// carriage return or a NUL.
fn validateTag(bar: []const u8) !void {
- if (bar.len > limits.max_tag_tail or std.mem.indexOfAny(u8, bar, "\r\n\x00") != null or !std.unicode.utf8ValidateSlice(bar)) return error.BadDumpTag;
+ if (bar.len > limits.max_tag_tail or std.mem.indexOfAny(u8, bar, "\r\x00") != null or !std.unicode.utf8ValidateSlice(bar)) return error.BadDumpTag;
}
pub fn validate(state: State) !void {
@@ -637,7 +639,7 @@ pub fn dumpState(p: *Pardes) !void {
};
if (ids_len > 0) {
columns[columns_len] = .{
- .tag = if (p.col_tags[c].custom) p.columnTag(c) else null,
+ .tag = p.col_tags[c].own,
.weight = @as(f32, @floatFromInt(p.col_weight[c])) / @as(f32, @floatFromInt(column_weight_unit)),
.panes = column_ids[c][0..ids_len],
};
@@ -651,7 +653,7 @@ pub fn dumpState(p: *Pardes) !void {
.screen = .{ .cols = p.screen_w, .rows = p.screen_h },
.active = slot_to_pane[p.active] orelse 0,
.topbar = config.topbar_str,
- .topbar_custom = if (p.global_tag.custom) p.global_tag.slice("") else null,
+ .topbar_custom = p.global_tag.own,
.theme = p.theme().name,
.locations_config = p.locations_config,
.tree_context_tag_style = p.settings.tree_context_tag_style,
@@ -788,9 +790,9 @@ fn initDump(gpa: std.mem.Allocator, opts: Options, zon_bytes: []const u8, previo
}
p.ncol = @min(st.columns.len, MAX_COLS);
p.col_serial = @splat(0);
- if (st.topbar_custom) |bar| _ = p.global_tag.set(bar);
+ if (st.topbar_custom) |bar| p.global_tag.own = try p.gpa.dupe(u8, bar);
for (st.columns[0..p.ncol], 0..) |col, c| {
- if (col.tag) |bar| _ = p.col_tags[c].set(bar);
+ if (col.tag) |bar| p.col_tags[c].own = try p.gpa.dupe(u8, bar);
const scaled = @as(f64, @floatCast(col.weight)) * @as(f64, @floatFromInt(column_weight_unit));
const bounded = @min(scaled, @as(f64, @floatFromInt(max_column_weight)));
p.col_weight[c] = @max(1, @as(u64, @intFromFloat(@round(bounded))));