Skip to documentation
SLOP

tiny.ui.View

Reference tiny.ui View

Defined in tiny.ui.

View holds typed slices over one publish buffer.

API (22)

Actions

Public operations.

Fields and members

Public fields and members.

No direct callersNo direct callstiny.uiView
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/ui/src/tree/view.zig:30

zig
/// `View` holds typed slices over one publish buffer. In a view from `bind`, every nonempty/// table field is a slice into `bytes`, so the view owns no memory. The default `View` is empty.pub const View = struct {    /// `View.bytes` is the whole buffer.    bytes: []align(8) const u8 = &.{},    /// `View.header` is a copy of its 152 byte header.    header: Header = .{},    nodes: []const Node = &.{},    /// `View.identity` points to the `Store`'s current id-to-index map. `View.prior` points to the    /// packed correspondence from the most recent publish. A `View` made by `bind` or by a caller    /// can omit identity and prior: their defaults are null and empty. The correspondence describes    /// only the immediately preceding retained tree, and remains valid until the next publish    /// modifies the scratch arrays.    identity: ?*const map.Map = null,    prior: []const u32 = &.{},    declarations: []const Declaration = &.{},    classes: []const u32 = &.{},    texts: []const TextRecord = &.{},    runs: []const TextRun = &.{},    relations: []const Relation = &.{},    atoms: []const Atom = &.{},    strings: []const u8 = &.{},    solved_roots: []const SolvedRoot = &.{},    solved_rects: []const Rect = &.{},    /// `View.text` returns the bytes of one atom from the string table. It returns an    /// empty slice for `atom_absent`.    pub fn text(self: View, atom: u32) []const u8 {        if (atom == abi.atom_absent) return &.{};        std.debug.assert(atom < self.atoms.len);        const record = self.atoms[atom];        std.debug.assert(record.offset + record.len <= self.strings.len);        return self.strings[record.offset..][0..record.len];    }    /// `View.declarationsOf` returns the declarations of node `node`, as a slice into    /// the buffer.    pub fn declarationsOf(self: View, node: u32) []const Declaration {        std.debug.assert(node < self.nodes.len);        const record = self.nodes[node];        const first = record.declaration_first;        std.debug.assert(first + record.declaration_count <= self.declarations.len);        return self.declarations[first..][0..record.declaration_count];    }    /// `View.classesOf` returns the class entries of node `node`.    pub fn classesOf(self: View, node: u32) []const u32 {        std.debug.assert(node < self.nodes.len);        const record = self.nodes[node];        std.debug.assert(record.class_first + record.class_count <= self.classes.len);        return self.classes[record.class_first..][0..record.class_count];    }    /// `View.textOf` returns a pointer to the text record of node `node`, or null    /// when the node has no text.    pub fn textOf(self: View, node: u32) ?*const TextRecord {        std.debug.assert(node < self.nodes.len);        const index = self.nodes[node].text;        if (index == abi.text_absent) return null;        std.debug.assert(index < self.texts.len);        return &self.texts[index];    }    /// `View.runsOf` returns the runs of one text record, as a slice into the buffer.    pub fn runsOf(self: View, record: *const TextRecord) []const TextRun {        std.debug.assert(record.run_first + record.run_count <= self.runs.len);        return self.runs[record.run_first..][0..record.run_count];    }    /// `View.children` returns an iterator over the direct children of node `node`.    pub fn children(self: View, node: u32) walk.Children {        return walk.children(self.nodes, node);    }    /// `View.subtree` returns node `node` followed by all of its descendants.    pub fn subtree(self: View, node: u32) []const Node {        return walk.subtree(self.nodes, node);    }    /// `View.solvedRectsOf` returns the `subtree_count + 1` rects of one solved root,    /// starting at its `rect_first`.    pub fn solvedRectsOf(self: View, root: SolvedRoot) []const Rect {        std.debug.assert(root.node < self.nodes.len);        const span = self.nodes[root.node].subtree_count + 1;        std.debug.assert(root.rect_first + span <= self.solved_rects.len);        return self.solved_rects[root.rect_first..][0..span];    }};

Source: lib/ui/src/root.zig:32

zig
pub const View = tree.View;
Called byCallsNo direct callerstreechildrenViewchildren
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callerstreesubtreeViewsubtree
Static calls · unresolved targets: 0 · external targets: 0.

Also reachable as

tree.View.

Audit

Definitions9
Public names18
Members14
Version26.7.0
Revisiondaab053ee433