mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
Merge pull request #2703 from furtidev/port-to-latest-vaxis
cli: update to latest libvaxis and fix `+list-themes` bugs
This commit is contained in:
@ -1238,8 +1238,6 @@ fn addDeps(
|
||||
step.root_module.addImport("vaxis", b.dependency("vaxis", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.libxev = false,
|
||||
.images = false,
|
||||
}).module("vaxis"));
|
||||
step.root_module.addImport("wuffs", b.dependency("wuffs", .{
|
||||
.target = target,
|
||||
@ -1261,6 +1259,7 @@ fn addDeps(
|
||||
step.root_module.addImport("zf", b.dependency("zf", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.with_tui = false,
|
||||
}).module("zf"));
|
||||
|
||||
// Mac Stuff
|
||||
|
@ -53,12 +53,12 @@
|
||||
.hash = "1220217ae916146a4c598f8ba5bfff0ff940335d00572e337f20b4accf24fa2ca4fc",
|
||||
},
|
||||
.vaxis = .{
|
||||
.url = "https://github.com/rockorager/libvaxis/archive/refs/tags/v0.5.1.tar.gz",
|
||||
.hash = "1220de23a3240e503397ea579de4fd85db422f537e10036ef74717c50164475813ce",
|
||||
.url = "git+https://github.com/rockorager/libvaxis/?ref=main#6d729a2dc3b934818dffe06d2ba3ce02841ed74b",
|
||||
.hash = "12200df4ebeaed45de26cb2c9f3b6f3746d8013b604e035dae658f86f586c8c91d2f",
|
||||
},
|
||||
.zf = .{
|
||||
.url = "https://github.com/natecraddock/zf/archive/refs/tags/0.10.2.tar.gz",
|
||||
.hash = "1220014ae47a57902e90aa7b4ff9751832ba1f426d7b138580db06859e0e9b51dfe5",
|
||||
.url = "git+https://github.com/natecraddock/zf/?ref=main#ed99ca18b02dda052e20ba467e90b623c04690dd",
|
||||
.hash = "1220edc3b8d8bedbb50555947987e5e8e2f93871ca3c8e8d4cc8f1377c15b5dd35e8",
|
||||
},
|
||||
.z2d = .{
|
||||
.url = "git+https://github.com/vancluever/z2d?ref=main#285a796eb9c25a2389f087d008f0e60faf0b8eda",
|
||||
|
@ -1,3 +1,3 @@
|
||||
# This file is auto-generated! check build-support/check-zig-cache-hash.sh for
|
||||
# more details.
|
||||
"sha256-uQY8KYNPqwVH+LFXXqVGNYZdG2imeCZoamJf7bMokX4="
|
||||
"sha256-D1SQIlmdP9x1PDgRVOy1qJGmu9osDbuyxGOcFj646N4="
|
||||
|
@ -111,7 +111,7 @@ fn prettyPrint(alloc: Allocator, keybinds: Config.Keybinds) !u8 {
|
||||
// align things nicely
|
||||
var iter = keybinds.set.bindings.iterator();
|
||||
var bindings = std.ArrayList(Binding).init(alloc);
|
||||
var widest_key: usize = 0;
|
||||
var widest_key: u16 = 0;
|
||||
var buf: [64]u8 = undefined;
|
||||
while (iter.next()) |bind| {
|
||||
const action = switch (bind.value_ptr.*) {
|
||||
@ -134,7 +134,7 @@ fn prettyPrint(alloc: Allocator, keybinds: Config.Keybinds) !u8 {
|
||||
const alt_style: vaxis.Style = .{ .fg = .{ .index = 3 } };
|
||||
const shift_style: vaxis.Style = .{ .fg = .{ .index = 4 } };
|
||||
|
||||
var longest_col: usize = 0;
|
||||
var longest_col: u16 = 0;
|
||||
|
||||
// Print the list
|
||||
for (bindings.items) |bind| {
|
||||
@ -143,20 +143,20 @@ fn prettyPrint(alloc: Allocator, keybinds: Config.Keybinds) !u8 {
|
||||
var result: vaxis.Window.PrintResult = .{ .col = 0, .row = 0, .overflow = false };
|
||||
const trigger = bind.trigger;
|
||||
if (trigger.mods.super) {
|
||||
result = try win.printSegment(.{ .text = "super", .style = super_style }, .{ .col_offset = result.col });
|
||||
result = try win.printSegment(.{ .text = " + " }, .{ .col_offset = result.col });
|
||||
result = win.printSegment(.{ .text = "super", .style = super_style }, .{ .col_offset = result.col });
|
||||
result = win.printSegment(.{ .text = " + " }, .{ .col_offset = result.col });
|
||||
}
|
||||
if (trigger.mods.ctrl) {
|
||||
result = try win.printSegment(.{ .text = "ctrl ", .style = ctrl_style }, .{ .col_offset = result.col });
|
||||
result = try win.printSegment(.{ .text = " + " }, .{ .col_offset = result.col });
|
||||
result = win.printSegment(.{ .text = "ctrl ", .style = ctrl_style }, .{ .col_offset = result.col });
|
||||
result = win.printSegment(.{ .text = " + " }, .{ .col_offset = result.col });
|
||||
}
|
||||
if (trigger.mods.alt) {
|
||||
result = try win.printSegment(.{ .text = "alt ", .style = alt_style }, .{ .col_offset = result.col });
|
||||
result = try win.printSegment(.{ .text = " + " }, .{ .col_offset = result.col });
|
||||
result = win.printSegment(.{ .text = "alt ", .style = alt_style }, .{ .col_offset = result.col });
|
||||
result = win.printSegment(.{ .text = " + " }, .{ .col_offset = result.col });
|
||||
}
|
||||
if (trigger.mods.shift) {
|
||||
result = try win.printSegment(.{ .text = "shift", .style = shift_style }, .{ .col_offset = result.col });
|
||||
result = try win.printSegment(.{ .text = " + " }, .{ .col_offset = result.col });
|
||||
result = win.printSegment(.{ .text = "shift", .style = shift_style }, .{ .col_offset = result.col });
|
||||
result = win.printSegment(.{ .text = " + " }, .{ .col_offset = result.col });
|
||||
}
|
||||
|
||||
const key = switch (trigger.key) {
|
||||
@ -166,20 +166,20 @@ fn prettyPrint(alloc: Allocator, keybinds: Config.Keybinds) !u8 {
|
||||
};
|
||||
// We don't track the key print because we index the action off the *widest* key so we get
|
||||
// nice alignment no matter what was printed for mods
|
||||
_ = try win.printSegment(.{ .text = key }, .{ .col_offset = result.col });
|
||||
_ = win.printSegment(.{ .text = key }, .{ .col_offset = result.col });
|
||||
|
||||
if (longest_col < result.col) longest_col = result.col;
|
||||
|
||||
const action = try std.fmt.allocPrint(alloc, "{}", .{bind.action});
|
||||
// If our action has an argument, we print the argument in a different color
|
||||
if (std.mem.indexOfScalar(u8, action, ':')) |idx| {
|
||||
_ = try win.print(&.{
|
||||
_ = win.print(&.{
|
||||
.{ .text = action[0..idx] },
|
||||
.{ .text = action[idx .. idx + 1], .style = .{ .dim = true } },
|
||||
.{ .text = action[idx + 1 ..], .style = .{ .fg = .{ .index = 5 } } },
|
||||
}, .{ .col_offset = longest_col + widest_key + 2 });
|
||||
} else {
|
||||
_ = try win.printSegment(.{ .text = action }, .{ .col_offset = longest_col + widest_key + 2 });
|
||||
_ = win.printSegment(.{ .text = action }, .{ .col_offset = longest_col + widest_key + 2 });
|
||||
}
|
||||
try vx.prettyPrint(writer);
|
||||
}
|
||||
|
@ -256,7 +256,10 @@ const Preview = struct {
|
||||
|
||||
fn updateFiltered(self: *Preview) !void {
|
||||
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;
|
||||
|
||||
@ -290,7 +293,7 @@ const Preview = struct {
|
||||
|
||||
for (self.themes, 0..) |*theme, i| {
|
||||
theme.rank = zf.rank(theme.theme, tokens.items, .{
|
||||
.to_lower = false,
|
||||
.to_lower = true,
|
||||
.plain = true,
|
||||
});
|
||||
if (theme.rank != null) try self.filtered.append(i);
|
||||
@ -500,8 +503,8 @@ const Preview = struct {
|
||||
const theme_list = win.child(.{
|
||||
.x_off = 0,
|
||||
.y_off = 0,
|
||||
.width = .{ .limit = 32 },
|
||||
.height = .{ .limit = win.height },
|
||||
.width = 32,
|
||||
.height = win.height,
|
||||
});
|
||||
|
||||
var highlight: ?usize = null;
|
||||
@ -543,7 +546,8 @@ const Preview = struct {
|
||||
|
||||
theme_list.fill(.{ .style = self.ui_standard() });
|
||||
|
||||
for (0..theme_list.height) |row| {
|
||||
for (0..theme_list.height) |row_capture| {
|
||||
const row: u16 = @intCast(row_capture);
|
||||
const index = self.window + row;
|
||||
if (index >= self.filtered.items.len) break;
|
||||
|
||||
@ -556,7 +560,7 @@ const Preview = struct {
|
||||
};
|
||||
|
||||
if (style == .selected) {
|
||||
_ = try theme_list.printSegment(
|
||||
_ = theme_list.printSegment(
|
||||
.{
|
||||
.text = "❯ ",
|
||||
.style = self.ui_selected(),
|
||||
@ -567,7 +571,7 @@ const Preview = struct {
|
||||
},
|
||||
);
|
||||
}
|
||||
_ = try theme_list.printSegment(
|
||||
_ = theme_list.printSegment(
|
||||
.{
|
||||
.text = theme.theme,
|
||||
.style = switch (style) {
|
||||
@ -586,8 +590,9 @@ const Preview = struct {
|
||||
);
|
||||
if (style == .selected) {
|
||||
if (theme.theme.len < theme_list.width - 4) {
|
||||
for (2 + theme.theme.len..theme_list.width - 2) |i|
|
||||
_ = try theme_list.printSegment(
|
||||
for (2 + theme.theme.len..theme_list.width - 2) |i_capture| {
|
||||
const i: u16 = @intCast(i_capture);
|
||||
_ = theme_list.printSegment(
|
||||
.{
|
||||
.text = " ",
|
||||
.style = self.ui_selected(),
|
||||
@ -598,7 +603,8 @@ const Preview = struct {
|
||||
},
|
||||
);
|
||||
}
|
||||
_ = try theme_list.printSegment(
|
||||
}
|
||||
_ = theme_list.printSegment(
|
||||
.{
|
||||
.text = " ❮",
|
||||
.style = self.ui_selected(),
|
||||
@ -625,12 +631,8 @@ const Preview = struct {
|
||||
.{
|
||||
.x_off = win.width / 2 -| width / 2,
|
||||
.y_off = win.height / 2 -| height / 2,
|
||||
.width = .{
|
||||
.limit = width,
|
||||
},
|
||||
.height = .{
|
||||
.limit = height,
|
||||
},
|
||||
.width = width,
|
||||
.height = height,
|
||||
.border = .{
|
||||
.where = .all,
|
||||
.style = self.ui_standard(),
|
||||
@ -660,8 +662,9 @@ const Preview = struct {
|
||||
.{ .keys = "⏎", .help = "Close search window." },
|
||||
};
|
||||
|
||||
for (key_help, 0..) |help, i| {
|
||||
_ = try child.printSegment(
|
||||
for (key_help, 0..) |help, captured_i| {
|
||||
const i: u16 = @intCast(captured_i);
|
||||
_ = child.printSegment(
|
||||
.{
|
||||
.text = help.keys,
|
||||
.style = self.ui_standard(),
|
||||
@ -671,7 +674,7 @@ const Preview = struct {
|
||||
.col_offset = 2,
|
||||
},
|
||||
);
|
||||
_ = try child.printSegment(
|
||||
_ = child.printSegment(
|
||||
.{
|
||||
.text = "—",
|
||||
.style = self.ui_standard(),
|
||||
@ -681,7 +684,7 @@ const Preview = struct {
|
||||
.col_offset = 15,
|
||||
},
|
||||
);
|
||||
_ = try child.printSegment(
|
||||
_ = child.printSegment(
|
||||
.{
|
||||
.text = help.help,
|
||||
.style = self.ui_standard(),
|
||||
@ -697,12 +700,8 @@ const Preview = struct {
|
||||
const child = win.child(.{
|
||||
.x_off = 20,
|
||||
.y_off = win.height - 5,
|
||||
.width = .{
|
||||
.limit = win.width - 40,
|
||||
},
|
||||
.height = .{
|
||||
.limit = 3,
|
||||
},
|
||||
.width = win.width - 40,
|
||||
.height = 3,
|
||||
.border = .{
|
||||
.where = .all,
|
||||
.style = self.ui_standard(),
|
||||
@ -714,44 +713,45 @@ const Preview = struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn drawPreview(self: *Preview, alloc: std.mem.Allocator, win: vaxis.Window, x_off: usize) !void {
|
||||
const width = win.width - x_off;
|
||||
pub fn drawPreview(self: *Preview, alloc: std.mem.Allocator, win: vaxis.Window, x_off_unconverted: i17) !void {
|
||||
const x_off: u16 = @intCast(x_off_unconverted);
|
||||
const width: u16 = win.width - x_off;
|
||||
|
||||
if (self.filtered.items.len > 0) {
|
||||
const theme = self.themes[self.filtered.items[self.current]];
|
||||
|
||||
var config = try Config.default(alloc);
|
||||
defer config.deinit();
|
||||
|
||||
config.loadFile(config._arena.?.allocator(), theme.path) catch |err| {
|
||||
const theme_path_len: u16 = @intCast(theme.path.len);
|
||||
|
||||
const child = win.child(
|
||||
.{
|
||||
.x_off = x_off,
|
||||
.y_off = 0,
|
||||
.width = .{
|
||||
.limit = width,
|
||||
},
|
||||
.height = .{
|
||||
.limit = win.height,
|
||||
},
|
||||
.width = width,
|
||||
.height = win.height,
|
||||
},
|
||||
);
|
||||
child.fill(.{ .style = self.ui_standard() });
|
||||
const middle = child.height / 2;
|
||||
{
|
||||
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,
|
||||
.style = self.ui_err(),
|
||||
},
|
||||
.{
|
||||
.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,
|
||||
.style = self.ui_err(),
|
||||
@ -761,27 +761,28 @@ const Preview = struct {
|
||||
},
|
||||
.{
|
||||
.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});
|
||||
_ = try child.printSegment(
|
||||
const text_len: u16 = @intCast(text.len);
|
||||
_ = child.printSegment(
|
||||
.{
|
||||
.text = text,
|
||||
.style = self.ui_err(),
|
||||
},
|
||||
.{
|
||||
.row_offset = middle + 1,
|
||||
.col_offset = child.width / 2 -| text.len / 2,
|
||||
.col_offset = child.width / 2 -| text_len / 2,
|
||||
},
|
||||
);
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
var next_start: usize = 0;
|
||||
var next_start: u16 = 0;
|
||||
|
||||
const fg: vaxis.Color = .{
|
||||
.rgb = [_]u8{
|
||||
@ -844,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(
|
||||
.{
|
||||
.x_off = x_off,
|
||||
.y_off = next_start,
|
||||
.width = .{
|
||||
.limit = width,
|
||||
},
|
||||
.height = .{
|
||||
.limit = 4,
|
||||
},
|
||||
.width = width,
|
||||
.height = 4,
|
||||
},
|
||||
);
|
||||
child.fill(.{ .style = standard });
|
||||
_ = try child.printSegment(
|
||||
_ = child.printSegment(
|
||||
.{
|
||||
.text = theme.theme,
|
||||
.style = standard_bold_italic,
|
||||
@ -867,10 +866,10 @@ const Preview = struct {
|
||||
},
|
||||
.{
|
||||
.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,
|
||||
.style = standard,
|
||||
@ -880,7 +879,7 @@ const Preview = struct {
|
||||
},
|
||||
.{
|
||||
.row_offset = 2,
|
||||
.col_offset = child.width / 2 -| theme.path.len / 2,
|
||||
.col_offset = child.width / 2 -| theme_path_len / 2,
|
||||
.wrap = .none,
|
||||
},
|
||||
);
|
||||
@ -888,37 +887,36 @@ const Preview = struct {
|
||||
}
|
||||
|
||||
if (config._diagnostics.items().len > 0) {
|
||||
const diagnostic_items_len: u16 = @intCast(config._diagnostics.items().len);
|
||||
const child = win.child(
|
||||
.{
|
||||
.x_off = x_off,
|
||||
.y_off = next_start,
|
||||
.width = .{
|
||||
.limit = width,
|
||||
},
|
||||
.height = .{
|
||||
.limit = if (config._diagnostics.items().len == 0) 0 else 2 + config._diagnostics.items().len,
|
||||
},
|
||||
.width = width,
|
||||
.height = if (config._diagnostics.items().len == 0) 0 else 2 + diagnostic_items_len,
|
||||
},
|
||||
);
|
||||
{
|
||||
const text = "Problems were encountered trying to load the theme:";
|
||||
_ = try child.printSegment(
|
||||
const text_len: u16 = @intCast(text.len);
|
||||
_ = child.printSegment(
|
||||
.{
|
||||
.text = text,
|
||||
.style = self.ui_err(),
|
||||
},
|
||||
.{
|
||||
.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);
|
||||
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 child.printSegment(
|
||||
_ = child.printSegment(
|
||||
.{
|
||||
.text = buf.items,
|
||||
.style = self.ui_err(),
|
||||
@ -936,24 +934,21 @@ const Preview = struct {
|
||||
const child = win.child(.{
|
||||
.x_off = x_off,
|
||||
.y_off = next_start,
|
||||
.width = .{
|
||||
.limit = width,
|
||||
},
|
||||
.height = .{
|
||||
.limit = 6,
|
||||
},
|
||||
.width = width,
|
||||
.height = 6,
|
||||
});
|
||||
|
||||
child.fill(.{ .style = standard });
|
||||
|
||||
for (0..16) |i| {
|
||||
for (0..16) |captured_i| {
|
||||
const i: u16 = @intCast(captured_i);
|
||||
const r = i / 8;
|
||||
const c = i % 8;
|
||||
const text = if (self.hex)
|
||||
try std.fmt.allocPrint(alloc, " {x:0>2}", .{i})
|
||||
else
|
||||
try std.fmt.allocPrint(alloc, "{d:3}", .{i});
|
||||
_ = try child.printSegment(
|
||||
_ = child.printSegment(
|
||||
.{
|
||||
.text = text,
|
||||
.style = standard,
|
||||
@ -963,7 +958,7 @@ const Preview = struct {
|
||||
.col_offset = c * 8,
|
||||
},
|
||||
);
|
||||
_ = try child.printSegment(
|
||||
_ = child.printSegment(
|
||||
.{
|
||||
.text = "████",
|
||||
.style = .{
|
||||
@ -976,7 +971,7 @@ const Preview = struct {
|
||||
.col_offset = 4 + c * 8,
|
||||
},
|
||||
);
|
||||
_ = try child.printSegment(
|
||||
_ = child.printSegment(
|
||||
.{
|
||||
.text = "████",
|
||||
.style = .{
|
||||
@ -997,12 +992,8 @@ const Preview = struct {
|
||||
.{
|
||||
.x_off = x_off,
|
||||
.y_off = next_start,
|
||||
.width = .{
|
||||
.limit = width,
|
||||
},
|
||||
.height = .{
|
||||
.limit = 24,
|
||||
},
|
||||
.width = width,
|
||||
.height = 24,
|
||||
},
|
||||
);
|
||||
const bold: vaxis.Style = .{
|
||||
@ -1052,7 +1043,7 @@ const Preview = struct {
|
||||
.bg = bg,
|
||||
};
|
||||
child.fill(.{ .style = standard });
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = "→", .style = color2 },
|
||||
.{ .text = " ", .style = standard },
|
||||
@ -1066,7 +1057,7 @@ const Preview = struct {
|
||||
},
|
||||
);
|
||||
{
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{
|
||||
.text = "───────┬",
|
||||
@ -1079,8 +1070,9 @@ const Preview = struct {
|
||||
},
|
||||
);
|
||||
if (child.width > 10) {
|
||||
for (10..child.width) |col| {
|
||||
_ = try child.print(
|
||||
for (10..child.width) |captured_col| {
|
||||
const col: u16 = @intCast(captured_col);
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{
|
||||
.text = "─",
|
||||
@ -1095,7 +1087,7 @@ const Preview = struct {
|
||||
}
|
||||
}
|
||||
}
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{
|
||||
.text = " │ ",
|
||||
@ -1118,7 +1110,7 @@ const Preview = struct {
|
||||
},
|
||||
);
|
||||
{
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{
|
||||
.text = "───────┼",
|
||||
@ -1131,8 +1123,9 @@ const Preview = struct {
|
||||
},
|
||||
);
|
||||
if (child.width > 10) {
|
||||
for (10..child.width) |col| {
|
||||
_ = try child.print(
|
||||
for (10..child.width) |captured_col| {
|
||||
const col: u16 = @intCast(captured_col);
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{
|
||||
.text = "─",
|
||||
@ -1147,7 +1140,7 @@ const Preview = struct {
|
||||
}
|
||||
}
|
||||
}
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = " 1 │ ", .style = color238 },
|
||||
.{ .text = "const", .style = color5 },
|
||||
@ -1162,7 +1155,7 @@ const Preview = struct {
|
||||
.col_offset = 2,
|
||||
},
|
||||
);
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = " 2 │", .style = color238 },
|
||||
},
|
||||
@ -1171,7 +1164,7 @@ const Preview = struct {
|
||||
.col_offset = 2,
|
||||
},
|
||||
);
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = " 3 │ ", .style = color238 },
|
||||
.{ .text = "pub ", .style = color5 },
|
||||
@ -1187,7 +1180,7 @@ const Preview = struct {
|
||||
.col_offset = 2,
|
||||
},
|
||||
);
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = " 4 │ ", .style = color238 },
|
||||
.{ .text = "const ", .style = color5 },
|
||||
@ -1200,7 +1193,7 @@ const Preview = struct {
|
||||
.col_offset = 2,
|
||||
},
|
||||
);
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = " 5 │ ", .style = color238 },
|
||||
.{ .text = "var ", .style = color5 },
|
||||
@ -1215,7 +1208,7 @@ const Preview = struct {
|
||||
.col_offset = 2,
|
||||
},
|
||||
);
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = " 6 │ ", .style = color238 },
|
||||
.{ .text = "while ", .style = color5 },
|
||||
@ -1232,7 +1225,7 @@ const Preview = struct {
|
||||
.col_offset = 2,
|
||||
},
|
||||
);
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = " 7 │ ", .style = color238 },
|
||||
.{ .text = "if ", .style = color5 },
|
||||
@ -1248,7 +1241,7 @@ const Preview = struct {
|
||||
.col_offset = 2,
|
||||
},
|
||||
);
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = " 8 │ ", .style = color238 },
|
||||
.{ .text = "try ", .style = color5 },
|
||||
@ -1263,7 +1256,7 @@ const Preview = struct {
|
||||
.col_offset = 2,
|
||||
},
|
||||
);
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = " 9 │ ", .style = color238 },
|
||||
.{ .text = "} ", .style = standard },
|
||||
@ -1280,7 +1273,7 @@ const Preview = struct {
|
||||
.col_offset = 2,
|
||||
},
|
||||
);
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = " 10 │ ", .style = color238 },
|
||||
.{ .text = "try ", .style = color5 },
|
||||
@ -1295,7 +1288,7 @@ const Preview = struct {
|
||||
.col_offset = 2,
|
||||
},
|
||||
);
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = " 11 │ ", .style = color238 },
|
||||
.{ .text = "} ", .style = standard },
|
||||
@ -1312,7 +1305,7 @@ const Preview = struct {
|
||||
.col_offset = 2,
|
||||
},
|
||||
);
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = " 12 │ ", .style = color238 },
|
||||
.{ .text = "try ", .style = color5 },
|
||||
@ -1327,7 +1320,7 @@ const Preview = struct {
|
||||
.col_offset = 2,
|
||||
},
|
||||
);
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = " 13 │ ", .style = color238 },
|
||||
.{ .text = "} ", .style = standard },
|
||||
@ -1339,7 +1332,7 @@ const Preview = struct {
|
||||
.col_offset = 2,
|
||||
},
|
||||
);
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = " 14 │ ", .style = color238 },
|
||||
.{ .text = "try ", .style = color5 },
|
||||
@ -1354,7 +1347,7 @@ const Preview = struct {
|
||||
.col_offset = 2,
|
||||
},
|
||||
);
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = " 15 │ ", .style = color238 },
|
||||
.{ .text = "}", .style = standard },
|
||||
@ -1364,7 +1357,7 @@ const Preview = struct {
|
||||
.col_offset = 2,
|
||||
},
|
||||
);
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = " 16 │ ", .style = color238 },
|
||||
.{ .text = "}", .style = standard },
|
||||
@ -1374,7 +1367,7 @@ const Preview = struct {
|
||||
.col_offset = 2,
|
||||
},
|
||||
);
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = " 17 │ ", .style = color238 },
|
||||
.{ .text = "}", .style = standard },
|
||||
@ -1385,7 +1378,7 @@ const Preview = struct {
|
||||
},
|
||||
);
|
||||
{
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{
|
||||
.text = "───────┴",
|
||||
@ -1398,8 +1391,9 @@ const Preview = struct {
|
||||
},
|
||||
);
|
||||
if (child.width > 10) {
|
||||
for (10..child.width) |col| {
|
||||
_ = try child.print(
|
||||
for (10..child.width) |captured_col| {
|
||||
const col: u16 = @intCast(captured_col);
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{
|
||||
.text = "─",
|
||||
@ -1414,7 +1408,7 @@ const Preview = struct {
|
||||
}
|
||||
}
|
||||
}
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = "ghostty ", .style = color6 },
|
||||
.{ .text = "on ", .style = standard },
|
||||
@ -1430,7 +1424,7 @@ const Preview = struct {
|
||||
.col_offset = 2,
|
||||
},
|
||||
);
|
||||
_ = try child.print(
|
||||
_ = child.print(
|
||||
&.{
|
||||
.{ .text = "✦ ", .style = color4 },
|
||||
.{ .text = "at ", .style = standard },
|
||||
@ -1449,23 +1443,20 @@ const Preview = struct {
|
||||
.{
|
||||
.x_off = x_off,
|
||||
.y_off = next_start,
|
||||
.width = .{
|
||||
.limit = width,
|
||||
},
|
||||
.height = .{
|
||||
.limit = win.height - next_start,
|
||||
},
|
||||
.width = width,
|
||||
.height = win.height - next_start,
|
||||
},
|
||||
);
|
||||
child.fill(.{ .style = standard });
|
||||
var it = std.mem.splitAny(u8, lorem_ipsum, " \n");
|
||||
var row: usize = 1;
|
||||
var col: usize = 2;
|
||||
var row: u16 = 1;
|
||||
var col: u16 = 2;
|
||||
while (row < child.height) {
|
||||
const word = it.next() orelse line: {
|
||||
it.reset();
|
||||
break :line it.next() orelse unreachable;
|
||||
};
|
||||
const word_len: u16 = @intCast(word.len);
|
||||
if (col + word.len > child.width) {
|
||||
row += 1;
|
||||
col = 2;
|
||||
@ -1482,7 +1473,7 @@ const Preview = struct {
|
||||
if (std.mem.eql(u8, "odio", word)) break :style standard_curly_underline;
|
||||
break :style standard;
|
||||
};
|
||||
_ = try child.printSegment(
|
||||
_ = child.printSegment(
|
||||
.{
|
||||
.text = word,
|
||||
.style = style,
|
||||
@ -1492,9 +1483,28 @@ const Preview = struct {
|
||||
.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