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