From 2f83b0d6ca1b8fc4a53e19e1aaeb2af6b93b44e1 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Tue, 30 Apr 2024 16:00:23 -0500 Subject: [PATCH] update readme --- README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6bf4226..9d5ddab 100644 --- a/README.md +++ b/README.md @@ -78,16 +78,18 @@ pub fn main() !void { } const alloc = gpa.allocator(); - // Initialize Vaxis with our event type - var vx = try vaxis.init(Event, .{}); + // Initialize Vaxis + var vx = try vaxis.init(alloc, .{}); // deinit takes an optional allocator. If your program is exiting, you can // choose to pass a null allocator to save some exit time. defer vx.deinit(alloc); + + var loop: vaxis.Loop(Event) = .{}; // Start the read loop. This puts the terminal in raw mode and begins // reading user input - try vx.startReadThread(); - defer vx.stopReadThread(); + try loop.run(); + defer loop.stop(); // Optionally enter the alternate screen try vx.enterAltScreen(); @@ -108,7 +110,7 @@ pub fn main() !void { // queue which can serve as the primary event queue for an application while (true) { // nextEvent blocks until an event is in the queue - const event = vx.nextEvent(); + const event = loop.nextEvent(); std.log.debug("event: {}", .{event}); // exhaustive switching ftw. Vaxis will send events if your Event enum // has the fields for those events (ie "key_press", "winsize") @@ -132,12 +134,11 @@ pub fn main() !void { // locks on the screen. All applications must handle this event // unless they aren't using a screen (IE only detecting features) // - // This is the only call that the core of Vaxis needs an allocator - // for. The allocations are because we keep a copy of each cell to + // The allocations are because we keep a copy of each cell to // optimize renders. When resize is called, we allocated two slices: // one for the screen, and one for our buffered screen. Each cell in // the buffered screen contains an ArrayList(u8) to be able to store - // the grapheme for that cell Each cell is initialized with a size + // the grapheme for that cell. Each cell is initialized with a size // of 1, which is sufficient for all of ASCII. Anything requiring // more than one byte will incur an allocation on the first render // after it is drawn. Thereafter, it will not allocate unless the