mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
fix: +list-themes crashing when there's search result is empty
This commit is contained in:
@ -256,7 +256,10 @@ const Preview = struct {
|
|||||||
|
|
||||||
fn updateFiltered(self: *Preview) !void {
|
fn updateFiltered(self: *Preview) !void {
|
||||||
const relative = self.current -| self.window;
|
const relative = self.current -| self.window;
|
||||||
const selected = self.themes[self.filtered.items[self.current]].theme;
|
var selected: []const u8 = undefined;
|
||||||
|
if (self.filtered.items.len > 0) {
|
||||||
|
selected = self.themes[self.filtered.items[self.current]].theme;
|
||||||
|
}
|
||||||
|
|
||||||
const hash_algorithm = std.hash.Wyhash;
|
const hash_algorithm = std.hash.Wyhash;
|
||||||
|
|
||||||
@ -714,41 +717,41 @@ const Preview = struct {
|
|||||||
const x_off: u16 = @intCast(x_off_unconverted);
|
const x_off: u16 = @intCast(x_off_unconverted);
|
||||||
const width: u16 = win.width - x_off;
|
const width: u16 = win.width - x_off;
|
||||||
|
|
||||||
|
if (self.filtered.items.len > 0) {
|
||||||
const theme = self.themes[self.filtered.items[self.current]];
|
const theme = self.themes[self.filtered.items[self.current]];
|
||||||
|
|
||||||
var config = try Config.default(alloc);
|
var config = try Config.default(alloc);
|
||||||
defer config.deinit();
|
defer config.deinit();
|
||||||
|
|
||||||
config.loadFile(config._arena.?.allocator(), theme.path) catch |err| {
|
config.loadFile(config._arena.?.allocator(), theme.path) catch |err| {
|
||||||
|
const theme_path_len: u16 = @intCast(theme.path.len);
|
||||||
|
|
||||||
const child = win.child(
|
const child = win.child(
|
||||||
.{
|
.{
|
||||||
.x_off = x_off,
|
.x_off = x_off,
|
||||||
.y_off = 0,
|
.y_off = 0,
|
||||||
.width = .{
|
.width = width,
|
||||||
.limit = width,
|
.height = win.height,
|
||||||
},
|
|
||||||
.height = .{
|
|
||||||
.limit = win.height,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
child.fill(.{ .style = self.ui_standard() });
|
child.fill(.{ .style = self.ui_standard() });
|
||||||
const middle = child.height / 2;
|
const middle = child.height / 2;
|
||||||
{
|
{
|
||||||
const text = try std.fmt.allocPrint(alloc, "Unable to open {s} from:", .{theme.theme});
|
const text = try std.fmt.allocPrint(alloc, "Unable to open {s} from:", .{theme.theme});
|
||||||
_ = try child.printSegment(
|
const text_len: u16 = @intCast(text.len);
|
||||||
|
_ = child.printSegment(
|
||||||
.{
|
.{
|
||||||
.text = text,
|
.text = text,
|
||||||
.style = self.ui_err(),
|
.style = self.ui_err(),
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.row_offset = middle -| 1,
|
.row_offset = middle -| 1,
|
||||||
.col_offset = child.width / 2 -| text.len / 2,
|
.col_offset = child.width / 2 -| text_len / 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
_ = try child.printSegment(
|
_ = child.printSegment(
|
||||||
.{
|
.{
|
||||||
.text = theme.path,
|
.text = theme.path,
|
||||||
.style = self.ui_err(),
|
.style = self.ui_err(),
|
||||||
@ -758,27 +761,28 @@ const Preview = struct {
|
|||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.row_offset = middle,
|
.row_offset = middle,
|
||||||
.col_offset = child.width / 2 -| theme.path.len / 2,
|
.col_offset = child.width / 2 -| theme_path_len / 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const text = try std.fmt.allocPrint(alloc, "{}", .{err});
|
const text = try std.fmt.allocPrint(alloc, "{}", .{err});
|
||||||
_ = try child.printSegment(
|
const text_len: u16 = @intCast(text.len);
|
||||||
|
_ = child.printSegment(
|
||||||
.{
|
.{
|
||||||
.text = text,
|
.text = text,
|
||||||
.style = self.ui_err(),
|
.style = self.ui_err(),
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.row_offset = middle + 1,
|
.row_offset = middle + 1,
|
||||||
.col_offset = child.width / 2 -| text.len / 2,
|
.col_offset = child.width / 2 -| text_len / 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
var next_start: usize = 0;
|
var next_start: u16 = 0;
|
||||||
|
|
||||||
const fg: vaxis.Color = .{
|
const fg: vaxis.Color = .{
|
||||||
.rgb = [_]u8{
|
.rgb = [_]u8{
|
||||||
@ -841,20 +845,18 @@ const Preview = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
|
const theme_len: u16 = @intCast(theme.theme.len);
|
||||||
|
const theme_path_len: u16 = @intCast(theme.path.len);
|
||||||
const child = win.child(
|
const child = win.child(
|
||||||
.{
|
.{
|
||||||
.x_off = x_off,
|
.x_off = x_off,
|
||||||
.y_off = next_start,
|
.y_off = next_start,
|
||||||
.width = .{
|
.width = width,
|
||||||
.limit = width,
|
.height = 4,
|
||||||
},
|
|
||||||
.height = .{
|
|
||||||
.limit = 4,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
child.fill(.{ .style = standard });
|
child.fill(.{ .style = standard });
|
||||||
_ = try child.printSegment(
|
_ = child.printSegment(
|
||||||
.{
|
.{
|
||||||
.text = theme.theme,
|
.text = theme.theme,
|
||||||
.style = standard_bold_italic,
|
.style = standard_bold_italic,
|
||||||
@ -864,10 +866,10 @@ const Preview = struct {
|
|||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.row_offset = 1,
|
.row_offset = 1,
|
||||||
.col_offset = child.width / 2 -| theme.theme.len / 2,
|
.col_offset = child.width / 2 -| theme_len / 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.printSegment(
|
_ = child.printSegment(
|
||||||
.{
|
.{
|
||||||
.text = theme.path,
|
.text = theme.path,
|
||||||
.style = standard,
|
.style = standard,
|
||||||
@ -877,7 +879,7 @@ const Preview = struct {
|
|||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.row_offset = 2,
|
.row_offset = 2,
|
||||||
.col_offset = child.width / 2 -| theme.path.len / 2,
|
.col_offset = child.width / 2 -| theme_path_len / 2,
|
||||||
.wrap = .none,
|
.wrap = .none,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -885,37 +887,36 @@ const Preview = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (config._diagnostics.items().len > 0) {
|
if (config._diagnostics.items().len > 0) {
|
||||||
|
const diagnostic_items_len: u16 = @intCast(config._diagnostics.items().len);
|
||||||
const child = win.child(
|
const child = win.child(
|
||||||
.{
|
.{
|
||||||
.x_off = x_off,
|
.x_off = x_off,
|
||||||
.y_off = next_start,
|
.y_off = next_start,
|
||||||
.width = .{
|
.width = width,
|
||||||
.limit = width,
|
.height = if (config._diagnostics.items().len == 0) 0 else 2 + diagnostic_items_len,
|
||||||
},
|
|
||||||
.height = .{
|
|
||||||
.limit = if (config._diagnostics.items().len == 0) 0 else 2 + config._diagnostics.items().len,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
{
|
{
|
||||||
const text = "Problems were encountered trying to load the theme:";
|
const text = "Problems were encountered trying to load the theme:";
|
||||||
_ = try child.printSegment(
|
const text_len: u16 = @intCast(text.len);
|
||||||
|
_ = child.printSegment(
|
||||||
.{
|
.{
|
||||||
.text = text,
|
.text = text,
|
||||||
.style = self.ui_err(),
|
.style = self.ui_err(),
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.row_offset = 0,
|
.row_offset = 0,
|
||||||
.col_offset = child.width / 2 -| (text.len / 2),
|
.col_offset = child.width / 2 -| (text_len / 2),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var buf = std.ArrayList(u8).init(alloc);
|
var buf = std.ArrayList(u8).init(alloc);
|
||||||
defer buf.deinit();
|
defer buf.deinit();
|
||||||
for (config._diagnostics.items(), 0..) |diag, i| {
|
for (config._diagnostics.items(), 0..) |diag, captured_i| {
|
||||||
|
const i: u16 = @intCast(captured_i);
|
||||||
try diag.write(buf.writer());
|
try diag.write(buf.writer());
|
||||||
_ = try child.printSegment(
|
_ = child.printSegment(
|
||||||
.{
|
.{
|
||||||
.text = buf.items,
|
.text = buf.items,
|
||||||
.style = self.ui_err(),
|
.style = self.ui_err(),
|
||||||
@ -933,24 +934,21 @@ const Preview = struct {
|
|||||||
const child = win.child(.{
|
const child = win.child(.{
|
||||||
.x_off = x_off,
|
.x_off = x_off,
|
||||||
.y_off = next_start,
|
.y_off = next_start,
|
||||||
.width = .{
|
.width = width,
|
||||||
.limit = width,
|
.height = 6,
|
||||||
},
|
|
||||||
.height = .{
|
|
||||||
.limit = 6,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
child.fill(.{ .style = standard });
|
child.fill(.{ .style = standard });
|
||||||
|
|
||||||
for (0..16) |i| {
|
for (0..16) |captured_i| {
|
||||||
|
const i: u16 = @intCast(captured_i);
|
||||||
const r = i / 8;
|
const r = i / 8;
|
||||||
const c = i % 8;
|
const c = i % 8;
|
||||||
const text = if (self.hex)
|
const text = if (self.hex)
|
||||||
try std.fmt.allocPrint(alloc, " {x:0>2}", .{i})
|
try std.fmt.allocPrint(alloc, " {x:0>2}", .{i})
|
||||||
else
|
else
|
||||||
try std.fmt.allocPrint(alloc, "{d:3}", .{i});
|
try std.fmt.allocPrint(alloc, "{d:3}", .{i});
|
||||||
_ = try child.printSegment(
|
_ = child.printSegment(
|
||||||
.{
|
.{
|
||||||
.text = text,
|
.text = text,
|
||||||
.style = standard,
|
.style = standard,
|
||||||
@ -960,7 +958,7 @@ const Preview = struct {
|
|||||||
.col_offset = c * 8,
|
.col_offset = c * 8,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.printSegment(
|
_ = child.printSegment(
|
||||||
.{
|
.{
|
||||||
.text = "████",
|
.text = "████",
|
||||||
.style = .{
|
.style = .{
|
||||||
@ -973,7 +971,7 @@ const Preview = struct {
|
|||||||
.col_offset = 4 + c * 8,
|
.col_offset = 4 + c * 8,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.printSegment(
|
_ = child.printSegment(
|
||||||
.{
|
.{
|
||||||
.text = "████",
|
.text = "████",
|
||||||
.style = .{
|
.style = .{
|
||||||
@ -994,12 +992,8 @@ const Preview = struct {
|
|||||||
.{
|
.{
|
||||||
.x_off = x_off,
|
.x_off = x_off,
|
||||||
.y_off = next_start,
|
.y_off = next_start,
|
||||||
.width = .{
|
.width = width,
|
||||||
.limit = width,
|
.height = 24,
|
||||||
},
|
|
||||||
.height = .{
|
|
||||||
.limit = 24,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const bold: vaxis.Style = .{
|
const bold: vaxis.Style = .{
|
||||||
@ -1049,7 +1043,7 @@ const Preview = struct {
|
|||||||
.bg = bg,
|
.bg = bg,
|
||||||
};
|
};
|
||||||
child.fill(.{ .style = standard });
|
child.fill(.{ .style = standard });
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = "→", .style = color2 },
|
.{ .text = "→", .style = color2 },
|
||||||
.{ .text = " ", .style = standard },
|
.{ .text = " ", .style = standard },
|
||||||
@ -1063,7 +1057,7 @@ const Preview = struct {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
{
|
{
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{
|
.{
|
||||||
.text = "───────┬",
|
.text = "───────┬",
|
||||||
@ -1076,8 +1070,9 @@ const Preview = struct {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (child.width > 10) {
|
if (child.width > 10) {
|
||||||
for (10..child.width) |col| {
|
for (10..child.width) |captured_col| {
|
||||||
_ = try child.print(
|
const col: u16 = @intCast(captured_col);
|
||||||
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{
|
.{
|
||||||
.text = "─",
|
.text = "─",
|
||||||
@ -1092,7 +1087,7 @@ const Preview = struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{
|
.{
|
||||||
.text = " │ ",
|
.text = " │ ",
|
||||||
@ -1115,7 +1110,7 @@ const Preview = struct {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
{
|
{
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{
|
.{
|
||||||
.text = "───────┼",
|
.text = "───────┼",
|
||||||
@ -1128,8 +1123,9 @@ const Preview = struct {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (child.width > 10) {
|
if (child.width > 10) {
|
||||||
for (10..child.width) |col| {
|
for (10..child.width) |captured_col| {
|
||||||
_ = try child.print(
|
const col: u16 = @intCast(captured_col);
|
||||||
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{
|
.{
|
||||||
.text = "─",
|
.text = "─",
|
||||||
@ -1144,7 +1140,7 @@ const Preview = struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = " 1 │ ", .style = color238 },
|
.{ .text = " 1 │ ", .style = color238 },
|
||||||
.{ .text = "const", .style = color5 },
|
.{ .text = "const", .style = color5 },
|
||||||
@ -1159,7 +1155,7 @@ const Preview = struct {
|
|||||||
.col_offset = 2,
|
.col_offset = 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = " 2 │", .style = color238 },
|
.{ .text = " 2 │", .style = color238 },
|
||||||
},
|
},
|
||||||
@ -1168,7 +1164,7 @@ const Preview = struct {
|
|||||||
.col_offset = 2,
|
.col_offset = 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = " 3 │ ", .style = color238 },
|
.{ .text = " 3 │ ", .style = color238 },
|
||||||
.{ .text = "pub ", .style = color5 },
|
.{ .text = "pub ", .style = color5 },
|
||||||
@ -1184,7 +1180,7 @@ const Preview = struct {
|
|||||||
.col_offset = 2,
|
.col_offset = 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = " 4 │ ", .style = color238 },
|
.{ .text = " 4 │ ", .style = color238 },
|
||||||
.{ .text = "const ", .style = color5 },
|
.{ .text = "const ", .style = color5 },
|
||||||
@ -1197,7 +1193,7 @@ const Preview = struct {
|
|||||||
.col_offset = 2,
|
.col_offset = 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = " 5 │ ", .style = color238 },
|
.{ .text = " 5 │ ", .style = color238 },
|
||||||
.{ .text = "var ", .style = color5 },
|
.{ .text = "var ", .style = color5 },
|
||||||
@ -1212,7 +1208,7 @@ const Preview = struct {
|
|||||||
.col_offset = 2,
|
.col_offset = 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = " 6 │ ", .style = color238 },
|
.{ .text = " 6 │ ", .style = color238 },
|
||||||
.{ .text = "while ", .style = color5 },
|
.{ .text = "while ", .style = color5 },
|
||||||
@ -1229,7 +1225,7 @@ const Preview = struct {
|
|||||||
.col_offset = 2,
|
.col_offset = 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = " 7 │ ", .style = color238 },
|
.{ .text = " 7 │ ", .style = color238 },
|
||||||
.{ .text = "if ", .style = color5 },
|
.{ .text = "if ", .style = color5 },
|
||||||
@ -1245,7 +1241,7 @@ const Preview = struct {
|
|||||||
.col_offset = 2,
|
.col_offset = 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = " 8 │ ", .style = color238 },
|
.{ .text = " 8 │ ", .style = color238 },
|
||||||
.{ .text = "try ", .style = color5 },
|
.{ .text = "try ", .style = color5 },
|
||||||
@ -1260,7 +1256,7 @@ const Preview = struct {
|
|||||||
.col_offset = 2,
|
.col_offset = 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = " 9 │ ", .style = color238 },
|
.{ .text = " 9 │ ", .style = color238 },
|
||||||
.{ .text = "} ", .style = standard },
|
.{ .text = "} ", .style = standard },
|
||||||
@ -1277,7 +1273,7 @@ const Preview = struct {
|
|||||||
.col_offset = 2,
|
.col_offset = 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = " 10 │ ", .style = color238 },
|
.{ .text = " 10 │ ", .style = color238 },
|
||||||
.{ .text = "try ", .style = color5 },
|
.{ .text = "try ", .style = color5 },
|
||||||
@ -1292,7 +1288,7 @@ const Preview = struct {
|
|||||||
.col_offset = 2,
|
.col_offset = 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = " 11 │ ", .style = color238 },
|
.{ .text = " 11 │ ", .style = color238 },
|
||||||
.{ .text = "} ", .style = standard },
|
.{ .text = "} ", .style = standard },
|
||||||
@ -1309,7 +1305,7 @@ const Preview = struct {
|
|||||||
.col_offset = 2,
|
.col_offset = 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = " 12 │ ", .style = color238 },
|
.{ .text = " 12 │ ", .style = color238 },
|
||||||
.{ .text = "try ", .style = color5 },
|
.{ .text = "try ", .style = color5 },
|
||||||
@ -1324,7 +1320,7 @@ const Preview = struct {
|
|||||||
.col_offset = 2,
|
.col_offset = 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = " 13 │ ", .style = color238 },
|
.{ .text = " 13 │ ", .style = color238 },
|
||||||
.{ .text = "} ", .style = standard },
|
.{ .text = "} ", .style = standard },
|
||||||
@ -1336,7 +1332,7 @@ const Preview = struct {
|
|||||||
.col_offset = 2,
|
.col_offset = 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = " 14 │ ", .style = color238 },
|
.{ .text = " 14 │ ", .style = color238 },
|
||||||
.{ .text = "try ", .style = color5 },
|
.{ .text = "try ", .style = color5 },
|
||||||
@ -1351,7 +1347,7 @@ const Preview = struct {
|
|||||||
.col_offset = 2,
|
.col_offset = 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = " 15 │ ", .style = color238 },
|
.{ .text = " 15 │ ", .style = color238 },
|
||||||
.{ .text = "}", .style = standard },
|
.{ .text = "}", .style = standard },
|
||||||
@ -1361,7 +1357,7 @@ const Preview = struct {
|
|||||||
.col_offset = 2,
|
.col_offset = 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = " 16 │ ", .style = color238 },
|
.{ .text = " 16 │ ", .style = color238 },
|
||||||
.{ .text = "}", .style = standard },
|
.{ .text = "}", .style = standard },
|
||||||
@ -1371,7 +1367,7 @@ const Preview = struct {
|
|||||||
.col_offset = 2,
|
.col_offset = 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = " 17 │ ", .style = color238 },
|
.{ .text = " 17 │ ", .style = color238 },
|
||||||
.{ .text = "}", .style = standard },
|
.{ .text = "}", .style = standard },
|
||||||
@ -1382,7 +1378,7 @@ const Preview = struct {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
{
|
{
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{
|
.{
|
||||||
.text = "───────┴",
|
.text = "───────┴",
|
||||||
@ -1395,8 +1391,9 @@ const Preview = struct {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (child.width > 10) {
|
if (child.width > 10) {
|
||||||
for (10..child.width) |col| {
|
for (10..child.width) |captured_col| {
|
||||||
_ = try child.print(
|
const col: u16 = @intCast(captured_col);
|
||||||
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{
|
.{
|
||||||
.text = "─",
|
.text = "─",
|
||||||
@ -1411,7 +1408,7 @@ const Preview = struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = "ghostty ", .style = color6 },
|
.{ .text = "ghostty ", .style = color6 },
|
||||||
.{ .text = "on ", .style = standard },
|
.{ .text = "on ", .style = standard },
|
||||||
@ -1427,7 +1424,7 @@ const Preview = struct {
|
|||||||
.col_offset = 2,
|
.col_offset = 2,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_ = try child.print(
|
_ = child.print(
|
||||||
&.{
|
&.{
|
||||||
.{ .text = "✦ ", .style = color4 },
|
.{ .text = "✦ ", .style = color4 },
|
||||||
.{ .text = "at ", .style = standard },
|
.{ .text = "at ", .style = standard },
|
||||||
@ -1446,23 +1443,20 @@ const Preview = struct {
|
|||||||
.{
|
.{
|
||||||
.x_off = x_off,
|
.x_off = x_off,
|
||||||
.y_off = next_start,
|
.y_off = next_start,
|
||||||
.width = .{
|
.width = width,
|
||||||
.limit = width,
|
.height = win.height - next_start,
|
||||||
},
|
|
||||||
.height = .{
|
|
||||||
.limit = win.height - next_start,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
child.fill(.{ .style = standard });
|
child.fill(.{ .style = standard });
|
||||||
var it = std.mem.splitAny(u8, lorem_ipsum, " \n");
|
var it = std.mem.splitAny(u8, lorem_ipsum, " \n");
|
||||||
var row: usize = 1;
|
var row: u16 = 1;
|
||||||
var col: usize = 2;
|
var col: u16 = 2;
|
||||||
while (row < child.height) {
|
while (row < child.height) {
|
||||||
const word = it.next() orelse line: {
|
const word = it.next() orelse line: {
|
||||||
it.reset();
|
it.reset();
|
||||||
break :line it.next() orelse unreachable;
|
break :line it.next() orelse unreachable;
|
||||||
};
|
};
|
||||||
|
const word_len: u16 = @intCast(word.len);
|
||||||
if (col + word.len > child.width) {
|
if (col + word.len > child.width) {
|
||||||
row += 1;
|
row += 1;
|
||||||
col = 2;
|
col = 2;
|
||||||
@ -1479,7 +1473,7 @@ const Preview = struct {
|
|||||||
if (std.mem.eql(u8, "odio", word)) break :style standard_curly_underline;
|
if (std.mem.eql(u8, "odio", word)) break :style standard_curly_underline;
|
||||||
break :style standard;
|
break :style standard;
|
||||||
};
|
};
|
||||||
_ = try child.printSegment(
|
_ = child.printSegment(
|
||||||
.{
|
.{
|
||||||
.text = word,
|
.text = word,
|
||||||
.style = style,
|
.style = style,
|
||||||
@ -1489,9 +1483,28 @@ const Preview = struct {
|
|||||||
.col_offset = col,
|
.col_offset = col,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
col += word.len + 1;
|
col += word_len + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
const child = win.child(.{
|
||||||
|
.x_off = 0,
|
||||||
|
.y_off = 0,
|
||||||
|
.width = win.width,
|
||||||
|
.height = win.height,
|
||||||
|
});
|
||||||
|
child.fill(.{
|
||||||
|
.style = self.ui_standard(),
|
||||||
|
});
|
||||||
|
|
||||||
|
_ = child.printSegment(.{
|
||||||
|
.text = "No theme found!",
|
||||||
|
.style = self.ui_standard(),
|
||||||
|
}, .{
|
||||||
|
.row_offset = win.height / 2 - 1,
|
||||||
|
.col_offset = win.width / 2 - 7,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user