╭ changed ────────╮ │src/ui/widget.zig│ ╰─────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │182 text_box.options.invert = selected; │ │183 } │ │184 │ │185 +// explanatory text atop a view's rows: a frame that takes focus like a row, so │ │186 +// the arrows scroll it into view, then a blank line │ │187 +pub fn initAbout(allocator: std.mem.Allocator, spans: []const RichText.Span) !wgt.Box(Widget) { │ │188 + var row = try wgt.Box(Widget).init(allocator, .{ .border = null, .direction = .vert }); │ │189 + errdefer row.deinit(allocator); │ │190 + { │ │191 + var frame = try wgt.Box(Widget).init(allocator, .{ .border = .single, .round_corners = true, .direction = .vert, .top_label = .{ .text = " note " } });│ │192 + errdefer frame.deinit(allocator); │ │193 + frame.getFocus().mode = .all; │ │194 + { │ │195 + var text = try RichText.init(allocator, spans); │ │196 + errdefer text.deinit(allocator); │ │197 + try frame.children.put(allocator, text.getFocus().id, .{ .widget = .{ .rich_text = text }, .rect = null, .min_size = null }); │ │198 + } │ │199 + row.getFocus().child_id = frame.getFocus().id; │ │200 + try row.children.put(allocator, frame.getFocus().id, .{ .widget = .{ .box = frame }, .rect = null, .min_size = null }); │ │201 + } │ │202 + { │ │203 + var blank = try wgt.Text.init(allocator, " "); │ │204 + errdefer blank.deinit(allocator); │ │205 + try row.children.put(allocator, blank.getFocus().id, .{ .widget = .{ .text = blank }, .rect = null, .min_size = null }); │ │206 + } │ │207 + return row; │ │208 +} │ │209 + │ │210 +// double the about frame's border while it has focus │ │211 +pub fn markAboutFocused(row: *wgt.Box(Widget), root_focus: *const Focus) void { │ │212 + const frame = &row.children.values()[0].widget.box; │ │213 + frame.options.border = if (root_focus.grandchild_id == frame.getFocus().id) .double else .single; │ │214 +} │ │215 + │ │216 pub fn addBackButton(allocator: std.mem.Allocator, box: *wgt.Box(Widget), session: *ui.Session) !void { │ │217 if (!session.is_terminal) return; │ │218 var back = try wgt.TextBox.init(allocator, "←", .{ .border = .hidden, .wrap_kind = .none }); │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯