╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ UserNotifications.zig ────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
242 } 243 244 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 245 const logout_id = self.control_ids[logout_index]; 246 if (key == .mouse and inp.leftClickOn(root_focus, logout_id, key.mouse)) return logOut(self.session); 247 const direction = inp.vertDirection(key); 248 if (self.headerActive()) { 249 const focused = root_focus.grandchild_id orelse return; 250 if (key == .enter and focused == logout_id) return logOut(self.session); 251 if (direction == .down) { 252 // the empty message has nothing to focus 253 if (self.view_index == @backingInt(ui.RoutablePage.UserView.notifications) and self.data.isEmpty()) return; 254 root_focus.setFocus(self.contentStack().getFocus().id); 255 } else if (std.mem.indexOfScalar(usize, &self.control_ids, focused)) |current| { 256 if (inp.moveTab(key, current, self.control_ids.len)) |next| root_focus.setFocus(self.control_ids[next]); 257 } 258 return; 259 } 260 if (direction == .up) if (self.contentStack().getSelected()) |selected| if (selected.atTop(root_focus)) { 261 root_focus.setFocus(self.control_ids[self.view_index]); 262 return; 263 }; 264 try self.contentStack().input(allocator, key, root_focus); 265 } 266 267 // moving up from the sub header returns to the page's tabs 268 pub fn atTop(self: *View) bool { 269 return self.headerActive(); 270 } 271 272 // arriving from the page's tabs lands on the sub header, not the content 273 pub fn focusHeader(self: *View, root_focus: *Focus) bool { 274 root_focus.setFocus(self.control_ids[self.view_index]); 275 return true; 276 } 277 278 pub fn clearGrid(self: *View) void { 279 self.box.clearGrid(); 280 } 281 282 pub fn getGrid(self: View) ?Grid { 283 return self.box.getGrid(); 284 } 285 286 pub fn getFocus(self: *View) *Focus { 287 return self.box.getFocus(); 288 } 289 }; 290