╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ widget.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2051 fn select(self: *CopyableText, allocator: std.mem.Allocator, selected: usize) !void { 2052 self.selected = selected; 2053 const choice = self.choices[selected]; 2054 const text_input = self.textInput(); 2055 text_input.options.top_label.text = choice.label; 2056 text_input.options.bottom_label.text = choice.bottom_label; 2057 try text_input.setContent(allocator, choice.text); 2058 } 2059 2060 fn show(self: *CopyableText) void { 2061 const choice = self.choices[self.selected]; 2062 self.session.host_request = .{ .show_copyable_text = choice.copyable_text orelse choice.text }; 2063 } 2064 2065 fn textInput(self: *CopyableText) *wgt.TextInput { 2066 return &self.box.children.values()[if (self.choices.len > 1) self.choices.len else 0].widget.text_input; 2067 } 2068 2069 fn selector(self: *CopyableText, index: usize) *wgt.TextBox { 2070 return &self.box.children.values()[index].widget.text_box; 2071 } 2072 2073 fn maxWidth(choices: []const Choice) usize { 2074 var width: usize = 0; 2075 for (choices) |choice| width = @max(width, choice.text.len, choice.label.len, choice.bottom_label.len); 2076 return width; 2077 } 2078 2079 pub fn clearGrid(self: *CopyableText) void { 2080 self.box.clearGrid(); 2081 } 2082 2083 pub fn getGrid(self: CopyableText) ?Grid { 2084 return self.box.getGrid(); 2085 } 2086 2087 pub fn getFocus(self: *CopyableText) *Focus { 2088 return self.box.getFocus(); 2089 } 2090 }; 2091