Fix usage example in README

This commit is contained in:
Tomasz Lisowski 2024-04-16 14:44:57 +01:00 committed by Tim Culverhouse
parent 47160418aa
commit a34d20541e

View file

@ -73,7 +73,7 @@ pub fn main() !void {
const deinit_status = gpa.deinit(); const deinit_status = gpa.deinit();
//fail test; can't try in defer as defer is executed after we return //fail test; can't try in defer as defer is executed after we return
if (deinit_status == .leak) { if (deinit_status == .leak) {
log.err("memory leak", .{}); std.log.err("memory leak", .{});
} }
} }
const alloc = gpa.allocator(); const alloc = gpa.allocator();
@ -109,7 +109,7 @@ pub fn main() !void {
while (true) { while (true) {
// nextEvent blocks until an event is in the queue // nextEvent blocks until an event is in the queue
const event = vx.nextEvent(); const event = vx.nextEvent();
log.debug("event: {}", .{event}); std.log.debug("event: {}", .{event});
// exhaustive switching ftw. Vaxis will send events if your Event enum // exhaustive switching ftw. Vaxis will send events if your Event enum
// has the fields for those events (ie "key_press", "winsize") // has the fields for those events (ie "key_press", "winsize")
switch (event) { switch (event) {
@ -156,24 +156,24 @@ pub fn main() !void {
// the old and only updated cells will be drawn // the old and only updated cells will be drawn
win.clear(); win.clear();
// Create a style // Create a style
const style: vaxis.Style = .{ const style: vaxis.Style = .{
.fg = .{ .index = color_idx }, .fg = .{ .index = color_idx },
}; };
// Create a bordered child window // Create a bordered child window
const child = win.child(.{ const child = win.child(.{
.x_off = win.width / 2 - 20, .x_off = win.width / 2 - 20,
.y_off = win.height / 2 - 3, .y_off = win.height / 2 - 3,
.width = .{ .limit = 40 }, .width = .{ .limit = 40 },
.height = .{ .limit = 3 }, .height = .{ .limit = 3 },
.border = .{ .border = .{
.where = .all, .where = .all,
.style = .{ .fg = .index = color_idx }, .style = style,
}, },
}) });
// Draw the text_input in the child window // Draw the text_input in the child window
text_input.draw(child); text_input.draw(child);
// Render the screen // Render the screen