v0.1.0 initial commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package tui
|
||||
|
||||
import (
|
||||
"github.com/lixenwraith/terminal"
|
||||
)
|
||||
|
||||
// CheckState represents checkbox visual state
|
||||
type CheckState uint8
|
||||
|
||||
const (
|
||||
CheckNone CheckState = iota // [ ]
|
||||
CheckPartial // [o]
|
||||
CheckFull // [x]
|
||||
CheckPlus // [+]
|
||||
)
|
||||
|
||||
// Checkbox draws a checkbox indicator
|
||||
func (r Region) Checkbox(x, y int, state CheckState, fg terminal.RGB) {
|
||||
if x < 0 || x+2 >= r.W || y < 0 || y >= r.H {
|
||||
return
|
||||
}
|
||||
var ch rune
|
||||
switch state {
|
||||
case CheckNone:
|
||||
ch = ' '
|
||||
case CheckPartial:
|
||||
ch = 'o'
|
||||
case CheckFull:
|
||||
ch = 'x'
|
||||
case CheckPlus:
|
||||
ch = '+'
|
||||
}
|
||||
r.Cell(x, y, '[', fg, terminal.RGB{}, terminal.AttrNone)
|
||||
r.Cell(x+1, y, ch, fg, terminal.RGB{}, terminal.AttrNone)
|
||||
r.Cell(x+2, y, ']', fg, terminal.RGB{}, terminal.AttrNone)
|
||||
}
|
||||
Reference in New Issue
Block a user