mirror of
https://github.com/mum4k/termdash.git
synced 2025-04-30 13:48:54 +08:00

This just wraps termbox, getting Events isn't supported yet. Also adding an experimental.
47 lines
1.3 KiB
Go
47 lines
1.3 KiB
Go
package termbox
|
|
|
|
// cell_options.go converts termdash cell options to the termbox format.
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/mum4k/termdash/cell"
|
|
termbox "github.com/nsf/termbox-go"
|
|
)
|
|
|
|
// cellColor converts termdash cell color to the termbox format.
|
|
func cellColor(c cell.Color) (termbox.Attribute, error) {
|
|
switch c {
|
|
case cell.ColorDefault:
|
|
return termbox.ColorDefault, nil
|
|
case cell.ColorBlack:
|
|
return termbox.ColorBlack, nil
|
|
case cell.ColorRed:
|
|
return termbox.ColorRed, nil
|
|
case cell.ColorGreen:
|
|
return termbox.ColorGreen, nil
|
|
case cell.ColorYellow:
|
|
return termbox.ColorYellow, nil
|
|
case cell.ColorBlue:
|
|
return termbox.ColorBlue, nil
|
|
case cell.ColorMagenta:
|
|
return termbox.ColorMagenta, nil
|
|
case cell.ColorCyan:
|
|
return termbox.ColorCyan, nil
|
|
case cell.ColorWhite:
|
|
return termbox.ColorWhite, nil
|
|
default:
|
|
return 0, fmt.Errorf("don't know how to convert cell color %v to the termbox format", c)
|
|
}
|
|
}
|
|
|
|
// cellOptsToFg converts the cell options to the termbox foreground attribute.
|
|
func cellOptsToFg(opts *cell.Options) (termbox.Attribute, error) {
|
|
return cellColor(opts.FgColor)
|
|
}
|
|
|
|
// cellOptsToBg converts the cell options to the termbox background attribute.
|
|
func cellOptsToBg(opts *cell.Options) (termbox.Attribute, error) {
|
|
return cellColor(opts.BgColor)
|
|
}
|