╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ────────────╮ │src/ui/Repo/Files.zig│ ╰─────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 892 - box.getFocus().child_id = clone_url.getFocus().id; │ │1018 + if (box.getFocus().child_id == null) box.getFocus().child_id = clone_url.getFocus().id; │ │1019 try box.children.put(allocator, clone_url.getFocus().id, .{ .widget = .{ .copyable_text = clone_url }, .rect = null, .min_size = .{ .width = min_width, .height = 3 }, .max_size = .{ .width = min_width, .height = 3 } });│ │1020 } │ │1021 } │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 896 - │ │ 897 - var spacer = try ui.widget.Spacer.init(allocator); │ │ 898 - errdefer spacer.deinit(allocator); │ │ 899 - try box.children.put(allocator, spacer.getFocus().id, .{ .widget = .{ .spacer = spacer }, .rect = null, .min_size = null }); │ │1022 │ │ 901 - var text_box = try wgt.TextBox.init(allocator, data.content, .{ .border_style = .hidden, .wrap_kind = .none }); │ │ 902 - errdefer text_box.deinit(allocator); │ │ 903 - try box.children.put(allocator, text_box.getFocus().id, .{ .widget = .{ .text_box = text_box }, .rect = null, .min_size = null, .flex = .shrink });│ │ 904 - │ │ 905 - return .{ .box = box, .data = data }; │ │1023 + return .{ .box = box, .data = data, .session = session }; │ │1024 } │ │1025 │ │1026 pub fn deinit(self: *Header.View, allocator: std.mem.Allocator) void { │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1029 │ │1030 pub fn build(self: *Header.View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { │ │1031 self.clearGrid(); │ │1032 + if (self.findInput()) |text_input| { │ │1033 + text_input.options.bottom_label = if (root_focus.grandchild_id == text_input.getFocus().id) " press enter " else "";│ │1034 + } │ │1035 try self.box.build(allocator, constraint, root_focus); │ │1036 + if (!self.session.is_terminal) { │ │1037 + if (self.findInput()) |text_input| { │ │1038 + try self.session.text_inputs.put(self.session.arena.allocator(), text_input.getFocus().id, text_input); │ │1039 + } │ │1040 + } │ │1041 } │ │1042 │ │1043 pub fn input(self: *Header.View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1044 + const current = self.box.getFocus().child_id orelse return; │ │1045 + if (self.findInput()) |text_input| { │ │1046 + if (current == text_input.getFocus().id) { │ │1047 + switch (key) { │ │1048 + .enter => return self.submit(allocator, text_input), │ │1049 + .arrow_right => if (text_input.cursor == text_input.content.items.len) {│ │1050 + if (self.cloneUrl()) |clone_url| { │ │1051 + root_focus.setFocus(clone_url.getFocus().id); │ │1052 + return; │ │1053 + } │ │1054 + }, │ │1055 + else => {}, │ │1056 + } │ │1057 + return text_input.input(allocator, key, root_focus); │ │1058 + } │ │1059 + } │ │1060 const clone_url = self.cloneUrl() orelse return; │ │1061 + if (key == .arrow_left and clone_url.selected == 0) { │ │1062 + if (self.findInput()) |text_input| { │ │1063 + root_focus.setFocus(text_input.getFocus().id); │ │1064 + return; │ │1065 + } │ │1066 + } │ │1067 try clone_url.input(allocator, key, root_focus); │ │1068 } │ │1069 │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 922 - pub fn focusCloneUrl(self: *Header.View, root_focus: *Focus) bool { │ │1070 + // navigate to the typed term's results, pinned to the listing's ref. an │ │1071 + // empty term leaves the results for the plain listing. │ │1072 + fn submit(self: *Header.View, allocator: std.mem.Allocator, text_input: *wgt.TextInput) !void {│ │1073 + const term = try text_input.text(allocator); │ │1074 + defer allocator.free(term); │ │1075 + if (term.len == 0 and self.data.find == null) return; │ │1076 + const route = self.data.filesRoute("", 0) orelse return; │ │1077 + try self.session.navigate(route.withFind(term) orelse return); │ │1078 + } │ │1079 + │ │1080 + // enter the header, preferring the search box. │ │1081 + pub fn focusHeader(self: *Header.View, root_focus: *Focus) bool { │ │1082 + if (self.findInput()) |text_input| { │ │1083 + root_focus.setFocus(text_input.getFocus().id); │ │1084 + return true; │ │1085 + } │ │1086 const clone_url = self.cloneUrl() orelse return false; │ │1087 root_focus.setFocus(clone_url.getFocus().id); │ │1088 return true; │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────╮ │1089 } │ │1090 │ │ 928 - pub fn hasCloneUrl(self: *Header.View) bool { │ │ 929 - return self.cloneUrl() != null; │ │1091 + pub fn hasHeaderFocus(self: *Header.View) bool { │ │1092 + return self.cloneUrl() != null or self.findInput() != null;│ │1093 } │ │1094 │ │1095 fn cloneUrl(self: *Header.View) ?*ui.widget.CopyableText { │ ╰─────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────╮ │1096 for (self.box.children.values()) |*child| switch (child.widget) {│ │1097 .copyable_text => |*copyable_text| return copyable_text, │ │1098 + else => {}, │ │1099 + }; │ │1100 + return null; │ │1101 + } │ │1102 + │ │1103 + fn findInput(self: *Header.View) ?*wgt.TextInput { │ │1104 + for (self.box.children.values()) |*child| switch (child.widget) {│ │1105 + .text_input => |*text_input| return text_input, │ │1106 else => {}, │ │1107 }; │ │1108 return null; │ ╰───────────────────────────────────────────────────────────────────────────────────╯ ╭ added ─────╮ │src/find.zig│ ╰────────────╯