feat(config): add theme.border.preset (#523)
This commit is contained in:
parent
f7fc1ea0fa
commit
0930a884eb
2 changed files with 81 additions and 3 deletions
15
cmd/root.go
15
cmd/root.go
|
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/ayn2op/discordo/internal/config"
|
||||
"github.com/ayn2op/discordo/internal/consts"
|
||||
"github.com/ayn2op/discordo/internal/logger"
|
||||
"github.com/rivo/tview"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/zalando/go-keyring"
|
||||
)
|
||||
|
|
@ -36,6 +37,20 @@ var (
|
|||
return err
|
||||
}
|
||||
|
||||
tview.Borders.Horizontal = cfg.Theme.Border.Preset.Horizontal
|
||||
tview.Borders.Vertical = cfg.Theme.Border.Preset.Vertical
|
||||
tview.Borders.TopLeft = cfg.Theme.Border.Preset.TopLeft
|
||||
tview.Borders.TopRight = cfg.Theme.Border.Preset.TopRight
|
||||
tview.Borders.BottomLeft = cfg.Theme.Border.Preset.BottomLeft
|
||||
tview.Borders.BottomRight = cfg.Theme.Border.Preset.BottomRight
|
||||
|
||||
tview.Borders.HorizontalFocus = tview.Borders.Horizontal
|
||||
tview.Borders.VerticalFocus = tview.Borders.Vertical
|
||||
tview.Borders.TopLeftFocus = tview.Borders.TopLeft
|
||||
tview.Borders.TopRightFocus = tview.Borders.TopRight
|
||||
tview.Borders.BottomLeftFocus = tview.Borders.BottomLeft
|
||||
tview.Borders.BottomRightFocus = tview.Borders.BottomRight
|
||||
|
||||
app = newApp(cfg)
|
||||
return app.run(token)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,14 +1,69 @@
|
|||
package config
|
||||
|
||||
import "github.com/rivo/tview"
|
||||
import (
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
type BorderPreset struct {
|
||||
Horizontal rune
|
||||
Vertical rune
|
||||
TopLeft rune
|
||||
TopRight rune
|
||||
BottomLeft rune
|
||||
BottomRight rune
|
||||
}
|
||||
|
||||
func (p *BorderPreset) UnmarshalTOML(v any) error {
|
||||
switch v.(string) {
|
||||
case "double":
|
||||
*p = BorderPreset{
|
||||
Horizontal: tview.BoxDrawingsDoubleHorizontal,
|
||||
Vertical: tview.BoxDrawingsDoubleVertical,
|
||||
TopLeft: tview.BoxDrawingsDoubleDownAndRight,
|
||||
TopRight: tview.BoxDrawingsDoubleDownAndLeft,
|
||||
BottomLeft: tview.BoxDrawingsDoubleUpAndRight,
|
||||
BottomRight: tview.BoxDrawingsDoubleUpAndLeft,
|
||||
}
|
||||
case "thick":
|
||||
*p = BorderPreset{
|
||||
Horizontal: tview.BoxDrawingsHeavyHorizontal,
|
||||
Vertical: tview.BoxDrawingsHeavyVertical,
|
||||
TopLeft: tview.BoxDrawingsHeavyDownAndRight,
|
||||
TopRight: tview.BoxDrawingsHeavyDownAndLeft,
|
||||
BottomLeft: tview.BoxDrawingsHeavyUpAndRight,
|
||||
BottomRight: tview.BoxDrawingsHeavyUpAndLeft,
|
||||
}
|
||||
case "round":
|
||||
*p = BorderPreset{
|
||||
Horizontal: tview.BoxDrawingsLightHorizontal,
|
||||
Vertical: tview.BoxDrawingsLightVertical,
|
||||
TopLeft: tview.BoxDrawingsLightArcDownAndRight,
|
||||
TopRight: tview.BoxDrawingsLightArcDownAndLeft,
|
||||
BottomLeft: tview.BoxDrawingsLightArcUpAndRight,
|
||||
BottomRight: tview.BoxDrawingsLightArcUpAndLeft,
|
||||
}
|
||||
case "hidden":
|
||||
*p = BorderPreset{
|
||||
Horizontal: ' ',
|
||||
Vertical: ' ',
|
||||
TopLeft: ' ',
|
||||
TopRight: ' ',
|
||||
BottomLeft: ' ',
|
||||
BottomRight: ' ',
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type (
|
||||
BorderTheme struct {
|
||||
Enabled bool `toml:"enabled"`
|
||||
Padding [4]int `toml:"padding"`
|
||||
|
||||
Color string `toml:"color"`
|
||||
ActiveColor string `toml:"active_color"`
|
||||
Color string `toml:"color"`
|
||||
ActiveColor string `toml:"active_color"`
|
||||
Preset BorderPreset `toml:"preset"`
|
||||
}
|
||||
|
||||
Theme struct {
|
||||
|
|
@ -48,6 +103,14 @@ func defaultTheme() Theme {
|
|||
|
||||
Color: "default",
|
||||
ActiveColor: "gold",
|
||||
Preset: BorderPreset{
|
||||
Horizontal: tview.Borders.Horizontal,
|
||||
Vertical: tview.Borders.Vertical,
|
||||
TopLeft: tview.Borders.TopLeft,
|
||||
TopRight: tview.Borders.TopRight,
|
||||
BottomLeft: tview.Borders.BottomLeft,
|
||||
BottomRight: tview.Borders.BottomRight,
|
||||
},
|
||||
},
|
||||
|
||||
BackgroundColor: "default",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue