add tui
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package tui
|
||||
|
||||
type Checkbox struct {
|
||||
Label string
|
||||
Checked bool
|
||||
}
|
||||
|
||||
func (c *Checkbox) Toggle() {
|
||||
c.Checked = !c.Checked
|
||||
}
|
||||
|
||||
func (c Checkbox) Render(focused bool) string {
|
||||
marker := checkBoxUnchecked
|
||||
if c.Checked {
|
||||
marker = checkBoxChecked
|
||||
}
|
||||
|
||||
style := labelStyle
|
||||
if focused {
|
||||
style = focusedStyle.Bold(true)
|
||||
}
|
||||
|
||||
return style.Render(marker + " " + c.Label)
|
||||
}
|
||||
Reference in New Issue
Block a user