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