Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const Model = struct {
}

pub fn view(self: *const Model, ctx: *const zz.Context) []const u8 {
const style = zz.Style{}.bold(true).fg(zz.Color.cyan());
const style = (zz.Style{}).bold(true).fg(zz.Color.cyan());
const text = std.fmt.allocPrint(ctx.allocator, "Count: {d}\n\nPress q to quit", .{self.count}) catch "Error";
return style.render(ctx.allocator, text) catch text;
}
Expand Down Expand Up @@ -130,7 +130,7 @@ return .{ .println = "Log message" }; // Print above the program output
The styling system is inspired by Lipgloss:

```zig
const style = zz.Style{}
const style = (zz.Style{})
.bold(true)
.italic(true)
.fg(zz.Color.cyan())
Expand All @@ -149,11 +149,11 @@ const style = zz.Style{}
const output = try style.render(allocator, "Hello, World!");

// Text transforms
const upper_style = zz.Style{}.transform(zz.transforms.uppercase);
const upper_style = (zz.Style{}).transform(zz.transforms.uppercase);
const shouting = try upper_style.render(allocator, "hello"); // "HELLO"

// Whitespace formatting controls
const ws_style = zz.Style{}
const ws_style = (zz.Style{})
.underline(true)
.setUnderlineSpaces(true) // Underline extends through spaces
.setColorWhitespace(false); // Don't apply bg color to whitespace
Expand All @@ -162,11 +162,11 @@ const ws_style = zz.Style{}
const derived = style.unsetBold().unsetPadding().unsetBorder();

// Style inheritance (unset values inherit from parent)
const child = zz.Style{}.fg(zz.Color.red()).inherit(style);
const child = (zz.Style{}).fg(zz.Color.red()).inherit(style);

// Style ranges - apply different styles to byte ranges
const ranges = &[_]zz.StyleRange{
.{ .start = 0, .end = 5, .s = zz.Style{}.bold(true) },
.{ .start = 0, .end = 5, .s = (zz.Style{}).bold(true) },
};
const ranged = try zz.renderWithRanges(allocator, "Hello World", ranges);

Expand Down