this repo has no description
3
fork

Configure Feed

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

wip: split view layout

+90 -12
+2 -2
build.zig.zon
··· 7 7 .hash = "1220affeb3fe37ef09411b5a213b5fdf9bb6568e9913bade204694648983a8b2776d", 8 8 }, 9 9 .vaxis = .{ 10 - .url = "git+https://github.com/rockorager/libvaxis#0eaf6226b2dd58720c5954d3646d6782e0c063f5", 11 - .hash = "12208b6363d1bff963081ee4cba5c8be9f782e89ed7604e5ceab61999b1a7980f791", 10 + .url = "git+https://github.com/rockorager/libvaxis#d8e5ec0d7bbeb6e70efc95734cd06082c3d518ff", 11 + .hash = "1220717a916024027282ea35359f8348858f3f49601af55f817c44d9806d08a6e06b", 12 12 }, 13 13 .zeit = .{ 14 14 .url = "git+https://github.com/rockorager/zeit?ref=main#d943bc4bfe9e18490460dfdd64f48e997065eba8",
+88 -10
src/app.zig
··· 30 30 mouse: ?vaxis.Mouse = null, 31 31 members: struct { 32 32 scroll_offset: usize = 0, 33 - width: usize = 16, 33 + width: u16 = 16, 34 34 resizing: bool = false, 35 35 } = .{}, 36 36 messages: struct { ··· 41 41 scroll_offset: usize = 0, 42 42 count: usize = 0, 43 43 selected_idx: usize = 0, 44 - width: usize = 16, 44 + width: u16 = 16, 45 45 resizing: bool = false, 46 46 } = .{}, 47 47 paste: struct { ··· 55 55 }; 56 56 57 57 pub const App = struct { 58 - explicit_join: bool = false, 58 + explicit_join: bool, 59 59 alloc: std.mem.Allocator, 60 60 /// System certificate bundle 61 - bundle: std.crypto.Certificate.Bundle = .{}, 61 + bundle: std.crypto.Certificate.Bundle, 62 62 /// List of all configured clients 63 63 clients: std.ArrayList(*irc.Client), 64 64 /// if we have already called deinit 65 - deinited: bool = false, 65 + deinited: bool, 66 66 /// Process environment 67 67 env: std.process.EnvMap, 68 68 /// Local timezone 69 69 tz: zeit.TimeZone, 70 70 71 - state: State = .{}, 71 + state: State, 72 72 73 - completer: ?Completer = null, 73 + completer: ?Completer, 74 74 75 - should_quit: bool = false, 75 + should_quit: bool, 76 76 77 77 binds: std.ArrayList(Bind), 78 78 ··· 83 83 write_queue: comlink.WriteQueue, 84 84 write_thread: std.Thread, 85 85 86 + lhs: vxfw.SplitView, 87 + rhs: vxfw.SplitView, 88 + 86 89 /// initialize vaxis, lua state 87 90 pub fn init(self: *App, gpa: std.mem.Allocator) !void { 88 91 self.* = .{ 89 92 .alloc = gpa, 93 + .state = .{}, 90 94 .clients = std.ArrayList(*irc.Client).init(gpa), 91 95 .env = try std.process.getEnvMap(gpa), 92 96 .binds = try std.ArrayList(Bind).initCapacity(gpa, 16), ··· 95 99 .lua = undefined, 96 100 .write_queue = .{}, 97 101 .write_thread = undefined, 102 + .lhs = .{ 103 + .width = self.state.buffers.width, 104 + .lhs = self.bufferWidget(), 105 + .rhs = self.rhs.widget(), 106 + }, 107 + .rhs = .{ 108 + .width = self.state.members.width, 109 + .constrain = .rhs, 110 + .lhs = self.contentWidget(), 111 + .rhs = self.memberWidget(), 112 + }, 113 + .explicit_join = false, 114 + .bundle = .{}, 115 + .deinited = false, 116 + .completer = null, 117 + .should_quit = false, 98 118 }; 99 119 100 120 self.lua = try Lua.init(&self.alloc); ··· 219 239 var children = std.ArrayList(vxfw.SubSurface).init(ctx.arena); 220 240 _ = &children; 221 241 222 - const text: vxfw.Text = .{ .text = "hey" }; 223 - _ = text; 242 + // UI is a tree of splits 243 + // │ │ │ │ 244 + // │ │ │ │ 245 + // │ buffers │ buffer content │ members │ 246 + // │ │ │ │ 247 + // │ │ │ │ 248 + // │ │ │ │ 249 + // │ │ │ │ 250 + 251 + const sub: vxfw.SubSurface = .{ 252 + .origin = .{ .col = 0, .row = 0 }, 253 + .surface = try self.lhs.widget().draw(ctx), 254 + }; 255 + try children.append(sub); 256 + 224 257 return .{ 225 258 .size = ctx.max.size(), 226 259 .widget = self.widget(), 227 260 .buffer = &.{}, 228 261 .children = children.items, 229 262 }; 263 + } 264 + 265 + fn bufferWidget(self: *App) vxfw.Widget { 266 + return .{ 267 + .userdata = self, 268 + .captureHandler = null, 269 + .eventHandler = null, 270 + .drawFn = App.typeErasedBufferDrawFn, 271 + }; 272 + } 273 + 274 + fn typeErasedBufferDrawFn(ptr: *anyopaque, ctx: vxfw.DrawContext) Allocator.Error!vxfw.Surface { 275 + _ = ptr; 276 + const text: vxfw.Text = .{ .text = "buffers" }; 277 + return text.draw(ctx); 278 + } 279 + 280 + fn contentWidget(self: *App) vxfw.Widget { 281 + return .{ 282 + .userdata = self, 283 + .captureHandler = null, 284 + .eventHandler = null, 285 + .drawFn = App.typeErasedContentDrawFn, 286 + }; 287 + } 288 + 289 + fn typeErasedContentDrawFn(ptr: *anyopaque, ctx: vxfw.DrawContext) Allocator.Error!vxfw.Surface { 290 + _ = ptr; 291 + const text: vxfw.Text = .{ .text = "content" }; 292 + return text.draw(ctx); 293 + } 294 + 295 + fn memberWidget(self: *App) vxfw.Widget { 296 + return .{ 297 + .userdata = self, 298 + .captureHandler = null, 299 + .eventHandler = null, 300 + .drawFn = App.typeErasedMembersDrawFn, 301 + }; 302 + } 303 + 304 + fn typeErasedMembersDrawFn(ptr: *anyopaque, ctx: vxfw.DrawContext) Allocator.Error!vxfw.Surface { 305 + _ = ptr; 306 + const text: vxfw.Text = .{ .text = "members" }; 307 + return text.draw(ctx); 230 308 } 231 309 232 310 // pub fn run(self: *App, lua_state: *Lua) !void {