From 1b7608f469309ab4362f820750140bf3f72c0d73 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Mon, 22 Jan 2024 11:21:02 -0600 Subject: [PATCH] examples: update text_input Signed-off-by: Tim Culverhouse --- examples/text_input.zig | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/text_input.zig b/examples/text_input.zig index d3c56aa..8708147 100644 --- a/examples/text_input.zig +++ b/examples/text_input.zig @@ -43,7 +43,10 @@ pub fn main() !void { // enum has the fields for those events (ie "key_press", "winsize") switch (event) { .key_press => |key| { - color_idx += 1; + color_idx = switch (color_idx) { + 255 => 0, + else => color_idx + 1, + }; text_input.update(.{ .key_press = key }); if (key.codepoint == 'c' and key.mods.ctrl) { break :outer; @@ -63,7 +66,12 @@ pub fn main() !void { // vaxis double buffers the screen. This new frame will be compared to // the old and only updated cells will be drawn win.clear(); - const child = win.initChild(win.width / 2 - 20, win.height / 2 - 3, .{ .limit = 40 }, .{ .limit = 3 }); + const child = win.initChild( + win.width / 2 - 20, + win.height / 2 - 3, + .{ .limit = 40 }, + .{ .limit = 3 }, + ); // draw the text_input using a bordered window const style: vaxis.Style = .{ .fg = .{ .index = color_idx },