Immediate mode renderer for libvaxis

move enterAltScreen and setMouseMode to helper functions

reykjalin.org bec46a41 8fda8418

verified
+11 -5
+2
src/demo.zig
··· 60 60 var vx: Vxim = .init(gpa); 61 61 defer vx.deinit(gpa); 62 62 63 + try vx.enterAltScreen(); 64 + 63 65 try vx.startLoop(gpa, update); 64 66 } 65 67
+9 -5
src/root.zig
··· 162 162 return self._arena_state.allocator(); 163 163 } 164 164 165 + pub fn enterAltScreen(self: *Self) !void { 166 + try self._vx.enterAltScreen(self._tty.writer()); 167 + try self._vx.queryTerminal(self._tty.writer(), 1 * std.time.ns_per_s); 168 + } 169 + 170 + pub fn setMouseMode(self: *Self, mouse_mode: bool) !void { 171 + try self._vx.setMouseMode(self._tty.writer(), mouse_mode); 172 + } 173 + 165 174 pub fn button(self: *Self, id: WidgetId, win: vaxis.Window, opts: ButtonOptions) ButtonAction { 166 175 const button_widget = win.child(.{ 167 176 .x_off = opts.x, ··· 655 664 gpa: std.mem.Allocator, 656 665 updateFn: fn (ctx: UpdateContext) anyerror!UpdateResult, 657 666 ) !void { 658 - try self._vx.enterAltScreen(self._tty.writer()); 659 - try self._vx.queryTerminal(self._tty.writer(), 1 * std.time.ns_per_s); 660 - 661 - try self._vx.setMouseMode(self._tty.writer(), true); 662 - 663 667 main_loop: while (true) { 664 668 defer _ = self._arena_state.reset(.retain_capacity); 665 669