╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ AuthTab.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
30 .text_box = text_box, 31 .data = data, 32 .session = session, 33 }; 34 } 35 36 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 37 self.text_box.deinit(allocator); 38 } 39 40 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 41 // update the displayed label based on session state. the inner Text 42 // widget's content is just a slice, so we can repoint it without 43 // re-allocating. 44 if (self.text_box.box.children.values().len > 0) { 45 const text_widget = &self.text_box.box.children.values()[0].widget.text; 46 text_widget.content = if (self.session.data.user_id != null) "logout" else "login"; 47 } 48 try self.text_box.build(allocator, constraint, root_focus); 49 } 50 51 pub fn input(self: *View, allocator: std.mem.Allocator, key: inp.Key, root_focus: *Focus) !void { 52 try self.text_box.input(allocator, key, root_focus); 53 } 54 55 pub fn clearGrid(self: *View) void { 56 self.text_box.clearGrid(); 57 } 58 59 pub fn getGrid(self: View) ?Grid { 60 return self.text_box.getGrid(); 61 } 62 63 pub fn getFocus(self: *View) *Focus { 64 return self.text_box.getFocus(); 65 } 66 }; 67