╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ──────────────╮ │src/ui/Repo/Patches.zig│ ╰───────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 93 } │ │ 94 │ │ 95 pub fn input(self: *Source, allocator: std.mem.Allocator, key: xitui.input.Key, root_focus: *xitui.focus.Focus) !void { │ │ 96 + if (key == .mouse) { │ │ 97 + var iter = self.selectors.iterator(); │ │ 98 + while (iter.next()) |selector| { │ │ 99 + if (inp.leftClickOn(root_focus, selector.value.*, key.mouse)) { │ │100 + self.selected = selector.key; │ │101 + return; │ │102 + } │ │103 + } │ │104 + } │ │105 const current = self.box.getFocus().child_id orelse return; │ │ 76 - const index = self.box.children.getIndex(current) orelse return; │ │ 77 - if (self.input_index == 0 or (index == self.input_index and key != .arrow_left)) return self.field().input(allocator, key, root_focus);│ │ 78 - switch (key) { │ │ 79 - .arrow_left => if (index > 0) { │ │ 80 - self.existing = index == self.input_index; │ │ 81 - root_focus.setFocus(self.box.children.keys()[index - 1]); │ │ 82 - }, │ │ 83 - .arrow_right => { │ │ 84 - self.existing = true; │ │ 85 - root_focus.setFocus(self.box.children.keys()[index + 1]); │ │ 86 - }, │ │ 87 - .enter => { │ │ 88 - self.existing = index == self.input_index - 1; │ │ 89 - if (self.existing) root_focus.setFocus(self.field().getFocus().id); │ │ 90 - }, │ │ 91 - .mouse => |mouse| { │ │ 92 - for (self.box.children.keys()[0..self.input_index], 0..) |id, i| { │ │ 93 - if (@import("../input.zig").leftClickOn(root_focus, id, mouse)) self.existing = i == self.input_index - 1; │ │106 + const text_input = self.field(); │ │107 + if (current == text_input.getFocus().id) { │ │108 + if (key == .arrow_left) { │ │109 + if (self.selectors.get(self.selected)) |id| { │ │110 + root_focus.setFocus(id); │ │111 + return; │ │112 } │ │113 + } │ │114 + return text_input.input(allocator, key, root_focus); │ │115 + } │ │116 + │ │117 + var iter = self.selectors.iterator(); │ │118 + var previous: ?Kind = null; │ │119 + while (iter.next()) |selector| { │ │120 + if (selector.value.* == current) { │ │121 + self.selected = selector.key; │ │122 + break; │ │123 + } │ │124 + previous = selector.key; │ │125 + } else return; │ │126 + switch (key) { │ │127 + .arrow_left => if (previous) |kind| { │ │128 + self.selected = kind; │ │129 + root_focus.setFocus(self.selectors.get(kind) orelse return); │ │130 }, │ │131 + .arrow_right => if (iter.next()) |next| { │ │132 + self.selected = next.key; │ │133 + root_focus.setFocus(next.value.*); │ │134 + } else if (self.selected == .branch) root_focus.setFocus(text_input.getFocus().id), │ │135 + .enter => if (self.selected == .branch) root_focus.setFocus(text_input.getFocus().id), │ │136 else => {}, │ │137 } │ │138 } │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ───────────────╮ │src/ui/widget/thread.zig│ ╰────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1651 } │ │1652 │ │1653 if (supports_drafts and record == null) { │ │1654 - var source = try Data.Source.init(allocator, session, if (saved_fields) |saved| saved.source_branch else "", if (saved_fields) |saved| saved.branch_source else (session.data.host_kind == .local));│ │1654 + var source = try Data.Source.init(allocator, session, if (saved_fields) |saved| saved.source_branch else "", if (saved_fields) |saved| saved.source_kind else .fork); │ │1655 errdefer source.deinit(allocator); │ │1656 try box.children.put(allocator, source.getFocus().id, .{ .widget = .{ .patch_source = source }, .rect = null, .min_size = .{ .width = null, .height = 3 } }); │ │1657 } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │2141 if (formWidget(form, .patch_source)) |source| { │ │2142 source.field().options.label = if (failure == .invalid_source_branch) " source branch (not found) " else if (failure == .same_branch) " source branch (same as target) " else if (failure == .unrelated_branches) " source branch (unrelated) " else " source branch "; │ │2143 const submit = formWidget(form, .submit_button) orelse return error.MissingFormField; │ │2144 - try submit.setLabel(allocator, if (source.existing) "submit patch" else "submit draft"); │ │2144 + try submit.setLabel(allocator, switch (source.selected) { │ │2145 + .fork => "submit draft", │ │2146 + .branch => "submit patch", │ │2147 + }); │ │2148 } │ │2149 (try formField(form, "target_branch")).options.label = │ │2150 if (failure == .invalid_target_branch) " target branch (invalid) " else if (self.data.view == .edit and failure == .same_branch) " target branch (same as source) " else if (self.data.view == .edit and failure == .unrelated_branches) " target branch (unrelated to source) " else if (self.data.view == .edit and failure == .invalid_source_branch) " target branch (source branch not found) " else " target branch ";│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │2526 │ │2527 if (comptime supports_drafts) { │ │2528 const source = formWidget(form, .patch_source) orelse return error.MissingFormField; │ │2526 - const source_branch = if (source.existing) try source.field().text(allocator) else null; │ │2529 + const source_branch = switch (source.selected) { │ │2530 + .fork => null, │ │2531 + .branch => try source.field().text(allocator), │ │2532 + }; │ │2533 defer if (source_branch) |branch| allocator.free(branch); │ │2534 const event_id_hex = Data.create(self.data, self.session, allocator, title, tags, description, target_branch, source_branch) catch |err| {│ │2535 const failure = FeedbackFailure.fromError(err) orelse return err; │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ │2669 .description = try aa.dupe(u8, description), │ │2670 .target_branch = try aa.dupe(u8, target_branch), │ │2671 .source_branch = if (source) |value| try value.field().text(aa) else "",│ │2666 - .branch_source = if (source) |value| value.existing else false, │ │2672 + .source_kind = if (source) |value| value.selected else .fork, │ │2673 } else .{ │ │2674 .title = try aa.dupe(u8, title), │ │2675 .tags = try aa.dupe(u8, tags), │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ──╮ │src/web.zig│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────╮ │430 .description = description, │ │431 .target_branch = target_branch, │ │432 .source_branch = source_branch orelse "", │ │433 - .branch_source = source_branch != null, │ │433 + .source_kind = if (source_branch != null) .branch else .fork,│ │434 } } }; │ │435 } │ │436 │ ╰──────────────────────────────────────────────────────────────────────────╯