╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ AuthTab.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
46 const name = self.session.data.user_name orelse return "logout"; 47 // validateName caps the name, so the buffer always fits it 48 return std.fmt.bufPrint(&self.text_buf, logout_prefix ++ "{s}", .{name}) catch unreachable; 49 } 50 51 // what the tab's text needs, plus its border 52 pub fn minWidth(self: *View) usize { 53 return self.text().len + 2; 54 } 55 56 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 57 // update the displayed text based on session state. the inner Text 58 // widget's content is just a slice, so we can repoint it without 59 // re-allocating. 60 if (self.text_box.box.children.values().len > 0) { 61 const text_widget = &self.text_box.box.children.values()[0].widget.text; 62 text_widget.content = self.text(); 63 } 64 try self.text_box.build(allocator, constraint, root_focus); 65 } 66 67 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 68 try self.text_box.input(allocator, key, root_focus); 69 } 70 71 pub fn clearGrid(self: *View) void { 72 self.text_box.clearGrid(); 73 } 74 75 pub fn getGrid(self: View) ?Grid { 76 return self.text_box.getGrid(); 77 } 78 79 pub fn getFocus(self: *View) *Focus { 80 return self.text_box.getFocus(); 81 } 82 }; 83