╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Diff.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
317 } 318 319 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 320 self.scroll.deinit(allocator); 321 } 322 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 323 self.clearGrid(); 324 try self.scroll.build(allocator, constraint, root_focus); 325 } 326 pub fn clearGrid(self: *View) void { 327 self.scroll.clearGrid(); 328 } 329 pub fn getGrid(self: View) ?Grid { 330 return self.scroll.getGrid(); 331 } 332 pub fn getFocus(self: *View) *Focus { 333 return self.scroll.getFocus(); 334 } 335 pub fn atTop(self: *View) bool { 336 const box = self.inner(); 337 return self.scroll.y == 0 and (box.children.count() == 0 or box.getFocus().child_id == box.children.keys()[0]); 338 } 339 fn inner(self: *View) *wgt.Box(ui.Widget) { 340 return &self.scroll.child.box; 341 } 342 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 343 _ = allocator; 344 const sc = &self.scroll; 345 const box = self.inner(); 346 if (inp.rowDelta(key, @intCast(box.children.count()))) |delta| return ui.widget.moveRowFocus(box, sc, root_focus, delta); 347 switch (key) { 348 // scroll horizontally within the diff 349 .arrow_left => if (!ui.widget.moveInSelectedRow(box, root_focus, false) and sc.x > 0) { 350 sc.x -= 1; 351 sc.clampToContent(); 352 }, 353 .arrow_right => if (!ui.widget.moveInSelectedRow(box, root_focus, true)) { 354 sc.x += 1; 355 sc.clampToContent(); 356 }, 357 // Enter / a click on a "previous"/"next" row follow its "a:" link in 358 // the host (it reloads the adjacent window), so they don't reach here. 359 else => {}, 360 } 361 } 362 }; 363