╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ widget.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1416 }, 1417 else => {}, 1418 } 1419 } 1420 1421 fn select(self: *CopyableText, allocator: std.mem.Allocator, selected: usize) !void { 1422 self.selected = selected; 1423 const choice = self.choices[selected]; 1424 const text_input = self.textInput(); 1425 text_input.options.label = choice.label; 1426 text_input.options.bottom_label = choice.bottom_label; 1427 try text_input.setContent(allocator, choice.text); 1428 } 1429 1430 fn show(self: *CopyableText) void { 1431 const choice = self.choices[self.selected]; 1432 self.session.host_request = .{ .show_copyable_text = choice.copyable_text orelse choice.text }; 1433 } 1434 1435 fn textInput(self: *CopyableText) *wgt.TextInput { 1436 return &self.box.children.values()[if (self.choices.len > 1) self.choices.len else 0].widget.text_input; 1437 } 1438 1439 fn selector(self: *CopyableText, index: usize) *wgt.TextBox { 1440 return &self.box.children.values()[index].widget.text_box; 1441 } 1442 1443 fn maxWidth(choices: []const Choice) usize { 1444 var width: usize = 0; 1445 for (choices) |choice| width = @max(width, choice.text.len, choice.label.len, choice.bottom_label.len); 1446 return width; 1447 } 1448 1449 pub fn clearGrid(self: *CopyableText) void { 1450 self.box.clearGrid(); 1451 } 1452 1453 pub fn getGrid(self: CopyableText) ?Grid { 1454 return self.box.getGrid(); 1455 } 1456 1457 pub fn getFocus(self: *CopyableText) *Focus { 1458 return self.box.getFocus(); 1459 } 1460 }; 1461