╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Diff.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
279 } 280 pub fn getGrid(self: View) ?Grid { 281 return self.scroll.getGrid(); 282 } 283 pub fn getFocus(self: *View) *Focus { 284 return self.scroll.getFocus(); 285 } 286 pub fn atTop(self: *View) bool { 287 const box = self.inner(); 288 return self.scroll.y == 0 and (box.children.count() == 0 or box.getFocus().child_id == box.children.keys()[0]); 289 } 290 fn inner(self: *View) *wgt.Box(ui.Widget) { 291 return &self.scroll.child.box; 292 } 293 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 294 _ = allocator; 295 const sc = &self.scroll; 296 const box = self.inner(); 297 if (inp.rowDelta(key, @intCast(box.children.count()))) |delta| return ui.widget.moveRowFocus(box, sc, root_focus, delta); 298 switch (key) { 299 // scroll horizontally within the diff 300 .arrow_left => if (!ui.widget.moveInSelectedRow(box, root_focus, false) and sc.x > 0) { 301 sc.x -= 1; 302 sc.clampToContent(); 303 }, 304 .arrow_right => if (!ui.widget.moveInSelectedRow(box, root_focus, true)) { 305 sc.x += 1; 306 sc.clampToContent(); 307 }, 308 // Enter / a click on a "previous"/"next" row follow its "a:" link in 309 // the host (it reloads the adjacent window), so they don't reach here. 310 else => {}, 311 } 312 } 313 }; 314