package debugger
import (
"errors"
"fmt"
"github.com/gdamore/tcell/v2"
"github.com/pancsta/cview"
)
var themeDark = map [string ]string {
"active" : "yellow" ,
"active2" : "greenyellow" ,
"inactive" : "limegreen" ,
"highlight" : "darkslategrey" ,
"highlight2" : "dimgrey" ,
"highlight3" : tcell .Color233 .CSS (),
"err" : "red" ,
"errBg" : "indianred" ,
"errRecent" : "#FF5FAF" ,
"grey" : "darkgrey" ,
"white" : "white" ,
"yellow" : "yellow" ,
"darkGrey" : "darkgrey" ,
"green" : "green" ,
"lightGrey" : "darkgrey" ,
"title" : tcell .ColorWhite .CSS (),
"border" : tcell .ColorGrey .CSS (),
"graphics" : tcell .ColorWhite .CSS (),
"fgPrimary" : tcell .ColorWhite .CSS (),
"fgSecondary" : tcell .ColorYellow .CSS (),
"tertiary" : tcell .ColorLimeGreen .CSS (),
"inverse" : tcell .ColorBlack .CSS (),
"contrastPrimary" : tcell .ColorBlack .CSS (),
"contrastSecondary" : tcell .ColorLightSlateGray .CSS (),
"bgPrimary" : tcell .ColorBlack .CSS (),
"bgContrast" : tcell .ColorGreen .CSS (),
"bgMoreContrast" : tcell .ColorDarkGreen .CSS (),
"scrollBar" : tcell .ColorWhite .CSS (),
}
var themeLight = map [string ]string {
"active" : "#7B6200" ,
"active2" : "#005500" ,
"inactive" : "#007700" ,
"highlight" : "#C8DCE0" ,
"highlight2" : "#B0B8BB" ,
"highlight3" : "#EBEBEB" ,
"err" : "#CC0000" ,
"errBg" : "#B03030" ,
"errRecent" : "#C7006B" ,
"grey" : "#555555" ,
"white" : "#111111" ,
"yellow" : "#8B7500" ,
"darkGrey" : "#888888" ,
"green" : "#006400" ,
"bgPrimary" : tcell .ColorWhite .CSS (),
"bgContrast" : tcell .ColorOldLace .CSS (),
"bgMoreContrast" : tcell .ColorLightGrey .CSS (),
"fgPrimary" : tcell .ColorBlack .CSS (),
"fgSecondary" : tcell .ColorDimGrey .CSS (),
"border" : tcell .ColorGrey .CSS (),
"title" : tcell .ColorBlack .CSS (),
"graphics" : tcell .ColorBlack .CSS (),
"tertiary" : tcell .ColorDarkGreen .CSS (),
"inverse" : tcell .ColorWhite .CSS (),
"contrastPrimary" : tcell .ColorWhite .CSS (),
"contrastSecondary" : tcell .ColorDarkGrey .CSS (),
"scrollBar" : tcell .ColorBlack .CSS (),
"lightGrey" : "darkgrey" ,
}
type Theme struct {
Active string
Active2 string
Inactive string
Highlight string
Highlight2 string
Highlight3 string
Err string
ErrBg string
ErrRecent string
Grey string
White string
Yellow string
DarkGrey string
Green string
LightGrey string
Title string
Border string
Graphics string
BgPrimary string
BgContrast string
BgMoreContrast string
FgPrimary string
FgSecondary string
Tertiary string
Inverse string
ContrastPrimary string
ContrastSecondary string
ScrollBar string
}
func mapToTheme(theme map [string ]string , isDark bool ) (Theme , error ) {
var errs error
get := func (name string ) string {
v , ok := theme [name ]
if ok {
return v
}
errs = errors .Join (errs , fmt .Errorf ("missing theme key: %s" , name ))
if isDark {
return "white"
}
return "black"
}
return Theme {
Active : get ("active" ),
Active2 : get ("active2" ),
Inactive : get ("inactive" ),
Highlight : get ("highlight" ),
Highlight2 : get ("highlight2" ),
Highlight3 : get ("highlight3" ),
Err : get ("err" ),
ErrBg : get ("errBg" ),
ErrRecent : get ("errRecent" ),
Grey : get ("grey" ),
White : get ("white" ),
Yellow : get ("yellow" ),
DarkGrey : get ("darkGrey" ),
Green : get ("green" ),
LightGrey : get ("lightGrey" ),
Title : get ("title" ),
Border : get ("border" ),
Graphics : get ("graphics" ),
BgPrimary : get ("bgPrimary" ),
BgContrast : get ("bgContrast" ),
BgMoreContrast : get ("bgMoreContrast" ),
FgPrimary : get ("fgPrimary" ),
FgSecondary : get ("fgSecondary" ),
Tertiary : get ("tertiary" ),
Inverse : get ("inverse" ),
ContrastPrimary : get ("contrastPrimary" ),
ContrastSecondary : get ("contrastSecondary" ),
ScrollBar : get ("scrollBar" ),
}, errs
}
func (t Theme ) Apply () {
cview .Styles .TitleColor = tcell .GetColor (t .Title )
cview .Styles .BorderColor = tcell .GetColor (t .Border )
cview .Styles .GraphicsColor = tcell .GetColor (t .Graphics )
cview .Styles .PrimaryTextColor = tcell .GetColor (t .FgPrimary )
cview .Styles .SecondaryTextColor = tcell .GetColor (t .FgSecondary )
cview .Styles .TertiaryTextColor = tcell .GetColor (t .Tertiary )
cview .Styles .InverseTextColor = tcell .GetColor (t .Inverse )
cview .Styles .ContrastPrimaryTextColor = tcell .GetColor (t .ContrastPrimary )
cview .Styles .ContrastSecondaryTextColor = tcell .GetColor (t .ContrastSecondary )
cview .Styles .PrimitiveBackgroundColor = tcell .GetColor (t .BgPrimary )
cview .Styles .ContrastBackgroundColor = tcell .GetColor (t .BgContrast )
cview .Styles .MoreContrastBackgroundColor = tcell .GetColor (t .BgMoreContrast )
cview .Styles .ScrollBarColor = tcell .GetColor (t .ScrollBar )
}
The pages are generated with Golds v0.8.4 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .