summaryrefslogtreecommitdiff
path: root/internal/client/config/config.go
diff options
context:
space:
mode:
authorKyren223 <Kyren223@proton.me>2025-02-06 18:37:29 +0200
committerKyren223 <Kyren223@proton.me>2025-02-06 18:37:29 +0200
commitffb5935164568fc20ce3b803312fe0d51bfa43bf (patch)
treee22a239c2dedabd3adf7ec2164fe4d437b2f8107 /internal/client/config/config.go
parent98f29ba812f8ddc0f73ad4b1b02fc31bee42a067 (diff)
Added config for colors (not yet supported in most areas as I need to
make things not static so they color changes)
Diffstat (limited to 'internal/client/config/config.go')
-rw-r--r--internal/client/config/config.go47
1 files changed, 40 insertions, 7 deletions
diff --git a/internal/client/config/config.go b/internal/client/config/config.go
index 4a4bafc..aadde87 100644
--- a/internal/client/config/config.go
+++ b/internal/client/config/config.go
@@ -7,27 +7,60 @@ import (
"os"
"path/filepath"
"reflect"
+
+ "github.com/kyren223/eko/internal/client/ui/colors"
)
type Config struct {
- ServerName string `json:"server_name"`
- PrivateKeyPath string `json:"private_key_path"`
- InsertModeTabToSpace bool `json:"insert_mode_tab_to_space"`
- InsertModeSpacesPerTab uint8 `json:"insert_mode_spaces_per_tab"`
- InsecureDebugMode bool `json:"insecure_debug_mode"`
+ ServerName string `json:"server_name"`
+ PrivateKeyPath string `json:"private_key_path"`
+ InsertModeTabToSpace bool `json:"insert_mode_tab_to_space"`
+ InsertModeSpacesPerTab uint8 `json:"insert_mode_spaces_per_tab"`
+ InsecureDebugMode bool `json:"insecure_debug_mode"`
+ Colors []string `json:"colors"`
}
func Default() Config {
+ colors.Save()
+ cols := colors.Get()
+ sColors := make([]string, 0, colors.Count)
+ for _, color := range cols {
+ if color != "" {
+ sColors = append(sColors, colors.ToHex(color))
+ }
+ }
+
return Config{
ServerName: "eko.kyren.codes",
PrivateKeyPath: "",
InsertModeTabToSpace: true,
InsertModeSpacesPerTab: 4,
InsecureDebugMode: false,
+ Colors: sColors,
}
}
-func Verify(config *Config) error {
+func VerifyAndFix(config *Config) error {
+ if config.ServerName == "" {
+ config.ServerName = Default().ServerName
+ }
+
+ if config.Colors != nil {
+ for i, color := range config.Colors {
+ if !colors.IsHex(color) {
+ return fmt.Errorf("Color at %v is not a valid hex color", i)
+ }
+ }
+
+ if len(config.Colors) != colors.Count {
+ return fmt.Errorf(
+ "Expected %v colors, got %v colors, set this value to null to use the default colors",
+ colors.Count, len(config.Colors),
+ )
+ }
+
+ }
+
return nil
}
@@ -89,7 +122,7 @@ func Load() error {
config = finalConfig.Interface().(Config)
- err = Verify(&config)
+ err = VerifyAndFix(&config)
if err != nil {
return err
}