╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ───────────╮ │src/ui/Repo/Diff.zig│ ╰────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │348 const box = self.inner(); │ │349 const keys = box.children.keys(); │ │350 if (keys.len == 0) return; │ │343 - const cur: isize = if (root_focus.grandchild_id) |g| @intCast(box.children.getIndex(g) orelse 0) else 0;│ │351 + const cur: isize = if (box.getFocus().child_id) |c| @intCast(box.children.getIndex(c) orelse 0) else 0; │ │352 const target: usize = @intCast(std.math.clamp(cur + delta, 0, @as(isize, @intCast(keys.len - 1)))); │ │353 root_focus.setFocus(keys[target]); │ │354 } │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ────────╮ │src/ui/widget.zig│ ╰─────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────╮ │165 if (next == @as(usize, @intCast(cur))) return; │ │166 root_focus.setFocus(keys[next]); │ │167 if (box.children.values()[next].rect) |rect| scroll.scrollToRect(rect); │ │168 +} │ │169 + │ │170 +// focus the box beside the selected one in `row`, false when there is none that way.│ │171 +pub fn moveInRow(row: *wgt.Box(Widget), root_focus: *Focus, right: bool) bool { │ │172 + const selected = row.getFocus().child_id orelse return false; │ │173 + const index = row.children.getIndex(selected) orelse return false; │ │174 + const target = if (right) index + 1 else index -| 1; │ │175 + if (target == index or target >= row.children.count()) return false; │ │176 + root_focus.setFocus(row.children.keys()[target]); │ │177 + return true; │ │178 } │ │179 │ │180 pub const FlowBox = struct { │ ╰──────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ───────────────╮ │src/ui/widget/thread.zig│ ╰────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────╮ │1258 .box => |*box| box, │ │1259 else => return false, │ │1260 }; │ │1261 - const selected = row.getFocus().child_id orelse return false; │ │1262 - const selected_index = row.children.getIndex(selected) orelse return false; │ │1263 - const target = if (right) selected_index + 1 else selected_index -| 1; │ │1264 - if (target == selected_index or target >= row.children.count()) return false;│ │1265 - root_focus.setFocus(row.children.keys()[target]); │ │1261 + if (!widget.moveInRow(row, root_focus, right)) return false; │ │1262 if (child.rect) |rect| self.scroll.scrollToRect(rect); │ │1263 return true; │ │1264 } │ ╰───────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │2514 .arrow_up, .back_tab => if (formStep(form, cur, false)) |i| self.focusResolveChild(form, i, root_focus) else self.focusHeader(root_focus),│ │2515 .arrow_down, .tab => if (formStep(form, cur, true)) |i| self.focusResolveChild(form, i, root_focus), │ │2516 .arrow_left, .arrow_right => switch (child.widget) { │ │2521 - .box => |*row| { │ │2522 - const row_cid = row.getFocus().child_id orelse return; │ │2523 - const row_index = row.children.getIndex(row_cid) orelse return; │ │2524 - if (key == .arrow_left) { │ │2525 - if (row_index > 0) root_focus.setFocus(row.children.keys()[row_index - 1]); │ │2526 - } else if (row_index + 1 < row.children.count()) { │ │2527 - root_focus.setFocus(row.children.keys()[row_index + 1]); │ │2528 - } │ │2529 - }, │ │2517 + .box => |*row| _ = widget.moveInRow(row, root_focus, key == .arrow_right), │ │2518 else => try child.widget.input(allocator, key, root_focus), │ │2519 }, │ │2520 .enter => if (on_submit) try self.submitResolution(allocator), │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯