-
Notifications
You must be signed in to change notification settings - Fork 7
feat: custom theme support #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| func load_config() (*themeConfig, error){ | ||
| cfgPath := filepath.Join(os.Getenv("HOME"), ".config", "gitx", "config.toml") | ||
| if _,err := os.Stat(cfgPath); os.IsNotExist(err) { | ||
| return &themeConfig{Theme: DefaultThemeName}, nil //fallback | ||
| } | ||
|
|
||
| var cfg themeConfig | ||
| if _, err := toml.DecodeFile(cfgPath, &cfg); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return &cfg, nil | ||
| } | ||
|
|
||
| func load_custom_theme(name string) (*Palette, error){ | ||
| themePath := filepath.Join(os.Getenv("HOME"), ".config", "gitx", "themes", name+".toml") | ||
| if _,err := os.Stat(themePath); os.IsNotExist(err) { | ||
| return nil, fmt.Errorf("theme not found: %s", name) | ||
| } | ||
|
|
||
| var tf ThemeFile | ||
| if _, err := toml.DecodeFile(themePath, &tf); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // Create a Palette from the ThemeFile | ||
| p := Palette{ | ||
| Fg: tf.Fg, | ||
| Bg: tf.Bg, | ||
| Black: tf.Normal["Black"], Red: tf.Normal["Red"], Green: tf.Normal["Green"], Yellow: tf.Normal["Yellow"], | ||
| Blue: tf.Normal["Blue"], Magenta: tf.Normal["Magenta"], Cyan: tf.Normal["Cyan"], White: tf.Normal["White"], | ||
|
|
||
| BrightBlack: tf.Bright["Black"], BrightRed: tf.Bright["Red"], BrightGreen: tf.Bright["Green"], BrightYellow: tf.Bright["Yellow"], | ||
| BrightBlue: tf.Bright["Blue"], BrightMagenta: tf.Bright["Magenta"], BrightCyan: tf.Bright["Cyan"], BrightWhite: tf.Bright["White"], | ||
|
|
||
| DarkBlack: tf.Dark["Black"], DarkRed: tf.Dark["Red"], DarkGreen: tf.Dark["Green"], DarkYellow: tf.Dark["Yellow"], | ||
| DarkBlue: tf.Dark["Blue"], DarkMagenta: tf.Dark["Magenta"], DarkCyan: tf.Dark["Cyan"], DarkWhite: tf.Dark["White"], | ||
|
|
||
| } | ||
|
|
||
| Palettes[name] = p // Add to Palettes map for future use | ||
| Themes[name] = NewThemeFromPalette(p) // Add to Themes map | ||
|
|
||
| return &p, nil | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although the scope of this PR does not include adding proper functionality for the user provided config file, that is .config/gitx/config.toml. Would you be interested in refactoring this into a separate file? I'll help in the effort by pushing some changes in your branch if you are okay with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey, can you please clarify what you mean by "proper functionality" for the config file.
And yeah, I’m cool with refactoring and happy to have your help on my branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for not clarifying it properly.
By "proper functionality" I mean basic settings any cli or tui app may have that can be configured via the config file.
For example the Theme setting you have implemented that can be found in the users's .config folder, in the config.toml file.
To have a proper chat about this you can join the discord server linked in the readme file and ping mere there in the appropriate channel, my discord handle is @bakayu.
This is a big effort feature request and I appreciate your help in this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah got it, thanks for clarifying, I'll ping you on discord so we can discuss and refactor together.
|
Can you resolve the merge conflict so that the CI can be run? |
Sure, I’ll resolve it. |
|
Thank you for the contribution! @Divy13ansh |
Closes: #21
This PR adds full support for custom themes in GITx, allowing users to define their own color schemes in TOML files. Users can now:
Usage:
config.toml
theme_1.toml
run gitx
<ctrl + t>