Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions crates/edit/src/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2074,17 +2074,18 @@ impl<'a> Context<'a, '_> {
self.button_activated()
}

/// Creates a checkbox with the given text.
/// Returns true if the checkbox was activated.
/// EN: Creates a checkbox with fixed-width ASCII markers that render consistently in terminals.
/// 中文:使用固定寬度的 ASCII 標記建立核取方塊,確保各終端機一致顯示。
/// EN: Returns true if the checkbox was activated.
/// 中文:核取方塊被啟用時回傳 true。
pub fn checkbox(&mut self, classname: &'static str, text: &str, checked: &mut bool) -> bool {
self.styled_label_begin(classname);
self.attr_focusable();
if self.is_focused() {
self.attr_reverse();
}
self.styled_label_add_text(if *checked { "[ " } else { "[ " });
self.styled_label_add_text(if *checked { "[x] " } else { "[ ] " });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe [X] ?

Image

self.styled_label_add_text(text);
self.styled_label_add_text("]");
self.styled_label_end();

let activated = self.button_activated();
Expand Down