an experimental irc client
at main 1.6 kB view raw
1const std = @import("std"); 2const vaxis = @import("vaxis"); 3 4const vxfw = vaxis.vxfw; 5 6const Allocator = std.mem.Allocator; 7const App = @import("app.zig").App; 8const ChildList = std.ArrayListUnmanaged(SubSurface); 9const Surface = vxfw.Surface; 10const SubSurface = vxfw.SubSurface; 11 12const default_rhs: vxfw.Text = .{ .text = "TODO: update this text" }; 13 14pub fn drawMain(ptr: *anyopaque, ctx: vxfw.DrawContext) Allocator.Error!Surface { 15 const self: *App = @ptrCast(@alignCast(ptr)); 16 const max = ctx.max.size(); 17 self.last_height = max.height; 18 if (self.selectedBuffer()) |buffer| { 19 switch (buffer) { 20 .client => |client| self.view.rhs = client.view(), 21 .channel => |channel| self.view.rhs = channel.view.widget(), 22 } 23 } else self.view.rhs = default_rhs.widget(); 24 25 var children: ChildList = .empty; 26 27 // UI is a tree of splits 28 // │ │ │ │ 29 // │ │ │ │ 30 // │ buffers │ buffer content │ members │ 31 // │ │ │ │ 32 // │ │ │ │ 33 // │ │ │ │ 34 // │ │ │ │ 35 36 const sub: vxfw.SubSurface = .{ 37 .origin = .{ .col = 0, .row = 0 }, 38 .surface = try self.view.widget().draw(ctx), 39 }; 40 try children.append(ctx.arena, sub); 41 42 return .{ 43 .size = ctx.max.size(), 44 .widget = self.widget(), 45 .buffer = &.{}, 46 .children = children.items, 47 }; 48}