1
0
mirror of https://github.com/mum4k/termdash.git synced 2025-05-01 22:17:51 +08:00
termdash/terminal/termbox/color_mode.go
Jakub Sobon 53fe40fcec
Naive implementation of the terminalapi using the termbox library.
This just wraps termbox, getting Events isn't supported yet.

Also adding an experimental.
2018-03-27 20:20:05 +01:00

25 lines
642 B
Go

package termbox
import (
"fmt"
"github.com/mum4k/termdash/terminalapi"
termbox "github.com/nsf/termbox-go"
)
// colorMode converts termdash color modes to the termbox format.
func colorMode(cm terminalapi.ColorMode) (termbox.OutputMode, error) {
switch cm {
case terminalapi.ColorMode8:
return termbox.OutputNormal, nil
case terminalapi.ColorMode256:
return termbox.Output256, nil
case terminalapi.ColorMode216:
return termbox.Output216, nil
case terminalapi.ColorModeGrayscale:
return termbox.OutputGrayscale, nil
default:
return -1, fmt.Errorf("don't know how to convert color mode %v to the termbox format", cm)
}
}