feat(ui): Add use_selection_fg flag to control selection foreground color by clegoffic · Pull Request #2515 · gitui-org/gitui
Conversation
When set to False (default True), keep the foreground color of the selected object (commit hash, date, etc ...).
It changes the following:
- Added a new
use_selection_fgflag to theThemestruct, allowing users to toggle whether the selection foreground color is applied. - Set
use_selection_fgtotrueby default inTheme::Default. - Extended unit tests to validate the behavior of
use_selection_fg.
I followed the checklist:
- I added unittests
- I ran
make checkwithout errors - I tested the overall application
- I added an appropriate item to the changelog
@Upsylonbare can you elaborate on what the motivation for this change is? Maybe a screenshot of the old vs. new. to help illustrate the issue you try to solve
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THEMES.md
Outdated
Show resolved
Hide resolved
@Upsylonbare I also would like to keep fg colors same on selection,
good PR!
Can we do better without introducing extra use_selection_fg?
If make selection_fg optional, no extra fields required
For theme.ron that will mean doing
selection_fg: Some(None) (to override default)
And default impl. in code:
selection_fg: Some(Color::White)
So we keep previous behavior
Here's patch implementing that based on your commits,
let me know what you think:
https://gist.github.com/vlad-anger/a5fcd217fad7c68459980618e375d806
Here's patch implementing that based on your commits, let me know what you think:
Wouldn't this break user's theme configurations as it would change the selection_fg type?
Wouldn't this break user's theme configurations as it would change the selection_fg type
Correct, it will.
Only for users, who define custom theme and they
specified custom selection_fg - will be required
to do minor tweak.
Advantage is simplicity, logic incapsulated within one field
Maybe with my approach selection_fg: Some(Some(your_color))
(ehh tha'ts because of how Patch struct works, we already need to wrap in Some)
will look a bit outstanding of other colors config
Otherwise we need to take extra field for extra logic
branch of selection_fg, which also feels a bit much
So i'm not sure
Another option: we already have more than one code path for loading themes, so adding another one could potentially automate the migration. I’m all for making users’ lives easier, but I also understand if we don’t want to increase code complexity in this instance.
| if let Ok(patch) = Self::load_patch(theme_path).map_err(|e| { | |
| log::error!("theme error [{:?}]: {e}", theme_path); | |
| e | |
| }) { | |
| theme.apply(patch); | |
| } else if let Ok(old_theme) = Self::load_old_theme(theme_path) | |
| { | |
| theme = old_theme; | |
| if theme.save_patch(theme_path).is_ok() { | |
| log::info!( | |
| "Converted old theme to new format. ({:?})", | |
| theme_path | |
| ); | |
| } else { | |
| log::warn!( | |
| "Failed to save theme in new format. ({:?})", | |
| theme_path | |
| ); | |
| } | |
| } |
Another option: we already have more than one code path for loading themes, so adding another one could potentially automate the migration. I’m all for making users’ lives easier, but I also understand if we don’t want to increase code complexity in this instance.
if let Ok(patch) = Self::load_patch(theme_path).map_err(|e| { log::error!("theme error [{:?}]: {e}", theme_path); e }) { theme.apply(patch); } else if let Ok(old_theme) = Self::load_old_theme(theme_path) { theme = old_theme; if theme.save_patch(theme_path).is_ok() { log::info!( "Converted old theme to new format. ({:?})", theme_path ); } else { log::warn!( "Failed to save theme in new format. ({:?})", theme_path ); } }
Hi, I don't get your point here. To me the apply function you are referring is the one that load the ron theme into a theme struct. My patches only use this theme struct while rendering the line. But I may be wrong.
Can you share more details about what you are meaning ?
@vlad-anger I firstly thought the feature the way you wrote it in your gist but as said it breaks retrocompatibility with 'old' theme.
As @extrawurst accept it, I can rewrite the PR if everyone is fine with it.
Honestly i'm not sure what's better
selection_fg: Some(Some(your_color)) will also look a bit weird in theme config,
because of how patchy works, while having extra field also not perfect : )
Honestly i'm not sure what's better
selection_fg: Some(Some(your_color))will also look a bit weird in theme config, because of how patchy works, while having extra field also not perfect : )
Yes you're right.
To me this can be merge as is at it is a more verbose way to write theme and don't introduce messy writings in theme's file. It seems more "simpler" to the user. The "Some()" uses in the theme file will surely evolve in the future though. I think this kind of writing doesn't please anyone but we can't change it for now.
I'm the kind of guy that personalize a lot its tools so will surely do other PR in the style.rs file. I can keep your remarks in a corner of my head.
@Upsylonbare please resolve conflicts.
@naseschwarz can I get a final review and merge_ready if you think its a go?
When set to `False` (default `True`), keep the foreground color of the selected object (commit hash, date, etc ...).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters





