╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ widget.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2096 fn select(self: *CopyableText, allocator: std.mem.Allocator, selected: usize) !void { 2097 self.selected = selected; 2098 const choice = self.choices[selected]; 2099 const text_input = self.textInput(); 2100 text_input.options.top_label.text = choice.label; 2101 text_input.options.bottom_label.text = choice.bottom_label; 2102 try text_input.setContent(allocator, choice.text); 2103 } 2104 2105 fn show(self: *CopyableText) void { 2106 const choice = self.choices[self.selected]; 2107 self.session.host_request = .{ .show_copyable_text = choice.copyable_text orelse choice.text }; 2108 } 2109 2110 fn textInput(self: *CopyableText) *wgt.TextInput { 2111 return &self.box.children.values()[if (self.choices.len > 1) self.choices.len else 0].widget.text_input; 2112 } 2113 2114 fn selector(self: *CopyableText, index: usize) *wgt.TextBox { 2115 return &self.box.children.values()[index].widget.text_box; 2116 } 2117 2118 fn maxWidth(choices: []const Choice) usize { 2119 var width: usize = 0; 2120 for (choices) |choice| width = @max(width, choice.text.len, choice.label.len, choice.bottom_label.len); 2121 return width; 2122 } 2123 2124 pub fn clearGrid(self: *CopyableText) void { 2125 self.box.clearGrid(); 2126 } 2127 2128 pub fn getGrid(self: CopyableText) ?Grid { 2129 return self.box.getGrid(); 2130 } 2131 2132 pub fn getFocus(self: *CopyableText) *Focus { 2133 return self.box.getFocus(); 2134 } 2135 }; 2136