this repo has no description
13
fork

Configure Feed

Select the types of activity you want to include in your feed.

cli example working

authored by

Jeffrey C. Ollie and committed by
Tim Culverhouse
45d4a4f4 fc28d184

+7 -13
+7 -13
examples/cli.zig
··· 4 4 const TextInput = vaxis.widgets.TextInput; 5 5 6 6 const log = std.log.scoped(.main); 7 - pub fn main() !void { 8 - var gpa = std.heap.GeneralPurposeAllocator(.{}){}; 9 - defer { 10 - const deinit_status = gpa.deinit(); 11 - if (deinit_status == .leak) { 12 - log.err("memory leak", .{}); 13 - } 14 - } 15 - const alloc = gpa.allocator(); 7 + pub fn main(init: std.process.Init) !void { 8 + const io = init.io; 9 + const alloc = init.gpa; 16 10 17 11 var buffer: [1024]u8 = undefined; 18 - var tty = try vaxis.Tty.init(&buffer); 12 + var tty = try vaxis.Tty.init(io, &buffer); 19 13 defer tty.deinit(); 20 14 21 - var vx = try vaxis.init(alloc, .{}); 15 + var vx = try vaxis.init(io, alloc, init.environ_map, .{}); 22 16 defer vx.deinit(alloc, tty.writer()); 23 17 24 18 var loop: vaxis.Loop(Event) = .{ .tty = &tty, .vaxis = &vx }; 25 - try loop.init(); 19 + try loop.init(io); 26 20 27 21 try loop.start(); 28 22 defer loop.stop(); ··· 44 38 // queue which can serve as the primary event queue for an application 45 39 while (true) { 46 40 // nextEvent blocks until an event is in the queue 47 - const event = loop.nextEvent(); 41 + const event = try loop.nextEvent(); 48 42 // exhaustive switching ftw. Vaxis will send events if your Event 49 43 // enum has the fields for those events (ie "key_press", "winsize") 50 44 switch (event) {