╭ changed ─╮ │src/ui.zig│ ╰──────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────╮ │← previous│ ╰──────────╯ ╭─────────────────────────────────────────────────╮ │1107 } │ │1108 │ │1109 pub fn getFocus(self: *Spacer) *Focus {│ │1098 - return &self.focus; │ │1110 + return self.focus; │ │1111 } │ │1112 }; │ │1113 │ ╰─────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────╮ │1114 // a single-child wrapper that builds the child at its natural size and│ │1115 // positions its grid in the middle of the area granted by the parent │ │1116 pub const Center = struct { │ │1105 - focus: Focus, │ │1117 + focus: *Focus, │ │1118 grid: ?Grid, │ │1119 child: *Widget, │ │1120 direction: Direction, │ ╰─────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────╮ │1126 errdefer allocator.destroy(child); │ │1127 child.* = child_widget; │ │1128 return .{ │ │1117 - .focus = Focus.init(.container), │ │1129 + .focus = try Focus.create(allocator, .container),│ │1130 .grid = null, │ │1131 .child = child, │ │1132 .direction = direction, │ ╰───────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────╮ │1134 } │ │1135 │ │1136 pub fn deinit(self: *Center, allocator: std.mem.Allocator) void {│ │1125 - self.focus.deinit(allocator); │ │1137 + self.focus.destroy(allocator); │ │1138 if (self.grid) |*grid| { │ │1139 grid.deinit(); │ │1140 self.grid = null; │ ╰───────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────╮ │1199 } │ │1200 │ │1201 pub fn getFocus(self: *Center) *Focus {│ │1190 - return &self.focus; │ │1202 + return self.focus; │ │1203 } │ │1204 }; │ │1205 │ ╰─────────────────────────────────────────────────╯ ╭───────────────────────────────────╮ │1206 // renders truecolor ANSI art│ │1207 pub const AnsiArt = struct { │ │1196 - focus: Focus, │ │1208 + focus: *Focus, │ │1209 grid: ?Grid, │ │1210 content: []const u8, │ │1211 │ ╰───────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────╮ │1200 - pub fn init(content: []const u8) AnsiArt { │ │1212 + pub fn init(allocator: std.mem.Allocator, content: []const u8) !AnsiArt {│ │1213 return .{ │ │1202 - .focus = Focus.init(.container), │ │1214 + .focus = try Focus.create(allocator, .container), │ │1215 .grid = null, │ │1216 .content = content, │ │1217 }; │ ╰───────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────╮ │1218 } │ │1219 │ │1220 pub fn deinit(self: *AnsiArt, allocator: std.mem.Allocator) void {│ │1209 - self.focus.deinit(allocator); │ │1221 + self.focus.destroy(allocator); │ │1222 if (self.grid) |*grid| { │ │1223 grid.deinit(); │ │1224 self.grid = null; │ ╰────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────╮ │1317 } │ │1318 │ │1319 pub fn getFocus(self: *AnsiArt) *Focus { │ │1308 - return &self.focus; │ │1320 + return self.focus; │ │1321 } │ │1322 │ │1323 fn applySgr(style: *Grid.Style, params: []const u8) void {│ ╰────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1374 return e; │ │1375 }; │ │1376 child.* = cw; │ │1365 - return .{ .grid = null, .child = child, .art = AnsiArt.init(art_content), .session = session }; │ │1377 + errdefer { │ │1378 + child.deinit(allocator); │ │1379 + allocator.destroy(child); │ │1380 + } │ │1381 + return .{ .grid = null, .child = child, .art = try AnsiArt.init(allocator, art_content), .session = session };│ │1382 } │ │1383 │ │1384 pub fn deinit(self: *AnsiBackground, allocator: std.mem.Allocator) void { │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯