╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Diff.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
343 } 344 pub fn atTop(self: *View) bool { 345 const box = self.inner(); 346 return self.scroll.y == 0 and (box.children.count() == 0 or box.getFocus().child_id == box.children.keys()[0]); 347 } 348 fn inner(self: *View) *wgt.Box(ui.Widget) { 349 return &self.scroll.child.box; 350 } 351 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 352 _ = allocator; 353 const sc = &self.scroll; 354 const box = self.inner(); 355 if (inp.rowDelta(key, @intCast(box.children.count()))) |delta| return ui.widget.moveRowFocus(box, sc, root_focus, delta); 356 switch (key) { 357 // scroll horizontally within the diff 358 .arrow_left => if (!ui.widget.moveInSelectedRow(box, root_focus, false) and sc.x > 0) { 359 sc.x -= 1; 360 sc.clampToContent(); 361 }, 362 .arrow_right => if (!ui.widget.moveInSelectedRow(box, root_focus, true)) { 363 sc.x += 1; 364 sc.clampToContent(); 365 }, 366 // Enter / a click on a "previous"/"next" row follow its "a:" link in 367 // the host (it reloads the adjacent window), so they don't reach here. 368 else => {}, 369 } 370 } 371 }; 372