palette changes for windows support
This commit is contained in:
parent
24eb7bf571
commit
a506bb92eb
|
@ -53,18 +53,18 @@ func NewStatusLine(configFileName string, palette console.Palette, license *meta
|
|||
|
||||
func (s *StatusBar) Draw(buffer *ui.Buffer) {
|
||||
|
||||
buffer.Fill(ui.NewCell(' ', ui.NewStyle(console.ColorClear, console.MenuColorBackground)), s.GetRect())
|
||||
buffer.Fill(ui.NewCell(' ', ui.NewStyle(console.ColorClear, console.GetMenuColorReverse())), s.GetRect())
|
||||
|
||||
indent := bindingsIndent
|
||||
for _, binding := range s.keyBindings {
|
||||
buffer.SetString(binding, ui.NewStyle(console.MenuColorText, console.MenuColorBackground), image.Pt(s.Max.X-len(binding)-indent, s.Min.Y))
|
||||
buffer.SetString(binding, ui.NewStyle(console.GetMenuColor(), console.GetMenuColorReverse()), image.Pt(s.Max.X-len(binding)-indent, s.Min.Y))
|
||||
indent += bindingsIndent + len(binding)
|
||||
}
|
||||
|
||||
buffer.SetString(s.text, ui.NewStyle(console.MenuColorText, console.MenuColorBackground), s.Min)
|
||||
buffer.SetString(s.text, ui.NewStyle(console.GetMenuColor(), console.GetMenuColorReverse()), s.Min)
|
||||
|
||||
if s.pause {
|
||||
buffer.SetString(pauseText, ui.NewStyle(console.MenuColorBackground, console.MenuColorText), image.Pt(s.Max.X-s.Dx()/2-len(pauseText)/2, s.Min.Y))
|
||||
buffer.SetString(pauseText, ui.NewStyle(console.GetMenuColorReverse(), console.GetMenuColor()), image.Pt(s.Max.X-s.Dx()/2-len(pauseText)/2, s.Min.Y))
|
||||
}
|
||||
|
||||
s.Block.Draw(buffer)
|
||||
|
|
|
@ -3,6 +3,7 @@ package console
|
|||
import (
|
||||
"fmt"
|
||||
ui "github.com/gizak/termui/v3"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
type Theme string
|
||||
|
@ -31,8 +32,10 @@ const (
|
|||
)
|
||||
|
||||
const (
|
||||
MenuColorBackground ui.Color = 235
|
||||
MenuColorText ui.Color = 255
|
||||
menuColorNix ui.Color = 255
|
||||
menuColorReverseNix ui.Color = 235
|
||||
menuColorWindows ui.Color = 255
|
||||
menuColorReverseWindows ui.Color = 0
|
||||
)
|
||||
|
||||
type Palette struct {
|
||||
|
@ -66,6 +69,24 @@ func GetPalette(theme Theme) Palette {
|
|||
}
|
||||
}
|
||||
|
||||
func GetMenuColor() ui.Color {
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
return menuColorWindows
|
||||
default:
|
||||
return menuColorNix
|
||||
}
|
||||
}
|
||||
|
||||
func GetMenuColorReverse() ui.Color {
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
return menuColorReverseWindows
|
||||
default:
|
||||
return menuColorReverseNix
|
||||
}
|
||||
}
|
||||
|
||||
func GetGradientColor(gradient []ui.Color, cur int, max int) ui.Color {
|
||||
ratio := float64(len(gradient)) / float64(max)
|
||||
index := int(ratio * float64(cur))
|
||||
|
|
Loading…
Reference in New Issue