diff options
Diffstat (limited to 'src/dump.zig')
| -rw-r--r-- | src/dump.zig | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/dump.zig b/src/dump.zig index 93bf08cc..ff46205f 100644 --- a/src/dump.zig +++ b/src/dump.zig @@ -109,6 +109,7 @@ pub const Pane = struct { cols: u16 = 0, rows: u16 = 0, vweight: f32 = 1, + collapsed: bool = false, /// Exact editable tail when the user touched it. Null retains the live /// default; a present empty slice deliberately restores an empty tail. tag_tail: ?[]const u8 = null, @@ -118,6 +119,7 @@ pub const Pane = struct { }; pub const Column = struct { + tag: ?[]const u8 = null, weight: f32 = 1, panes: []const usize = &.{}, }; @@ -130,13 +132,20 @@ pub const State = struct { screen: Size, active: usize = 0, topbar: []const u8 = "", + topbar_custom: ?[]const u8 = null, theme: []const u8 = "dark", columns: []const Column = &.{}, panes: []const Pane = &.{}, mounts: []const Mount = &.{}, }; +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; +} + pub fn validate(state: State) !void { + if (state.topbar_custom) |bar| try validateTag(bar); + for (state.columns) |column| if (column.tag) |bar| try validateTag(bar); if (!std.mem.eql(u8, state.magic, magic)) return error.BadDumpMagic; if (state.version != version) return error.BadDumpVersion; if (state.panes.len == 0 or state.panes.len > max_panes) return error.BadDumpPanes; |
