Skip to content

Conversation

gerhardol
Copy link
Member

@gerhardol gerhardol commented Aug 7, 2024

Supersedes #11824
Fixes #11821

Proposed changes

This PR has four serial parts, the last commit could be dropped.

  • feat: ANSI PrintColors also in Release builds

Enable the routine to print the ANSI terminal colors also in release builds.
The colors are used to display e.g. git-diff.

  • feat: Configure ANSI background colors separately

Specify foreground/background colors for the terminal separately,
to enable themes that work better with GE colors.

Apply theme colors for difftastic: Do not change background
for bold text, to improve readability.
Only reverse video for normal red/green.

  • feat: GE theme ANSI terminal colors

Adjust the ANSI terminal colors to align with the GE theme.
The background/foreground colors are separate to improve the
display for the extremely bright GE colors.

The theme is somehow based on mintty Helmhotz, but heavily modified
especially for background (reverse video) to align with the
existing GE theme colors.

  • feat: moved lines in diff as reverse

If GE theme colors are applied, set moved lines as
reverse video (colored background) to match the appearances

Screenshots

Yellow foreground is still not great, but not much used by git-diff
The background (reverse) are to most used with the last commit
image image

Before

image

image

image

no reverse video

image

image

image

reverse video

Not convinced that this is better, but maybe more predictable

image

image

image

Difftastic

Visibility is still not great, that need to be handled in difftastic itself

image

image

Test methodology

Tests are updated

Merge strategy

  • Rebase merge (PR submitter must change the commit message for the last commit).
    I agree that the maintainer squash merge this PR (if the commit message is clear).

✒️ I contribute this code under The Developer Certificate of Origin.

Enable the routine to print the ANSI terminal colors also in release builds.
The colors are used to display e.g. git-diff.

The colors are printed by setting the environment variable
GIT_EXTENSIONS_CONSOLE_COLORS, seen in
"Search files in commit" (git-grep) results.
@gerhardol gerhardol force-pushed the feature/i11821-ansi-background-theme-colors branch from c9dbaa5 to 8d7d47b Compare August 7, 2024 15:21
@RussKie
Copy link
Member

RussKie commented Aug 8, 2024

Not convinced that this is better, but maybe more predictable

image

image

I'm finding the coloured background much easier on eyes. So, thank you.

Copy link
Member

@RussKie RussKie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Haven't run.

Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 LGTM, have not reviewed in detail

@mstv
Copy link
Member

mstv commented Aug 9, 2024

FYI: git inconsistently highlights (leading whitespace of) removed and added moved lines:

grafik

�[2;7;35m-	#def...�[m
�[2;7;34m+�[m	�[2;7;34m#def...�[m�[41m �[m

Specify foreground/background colors for the terminal separately,
to enable themes that work better with GE colors.

Apply theme colors for difftastic: Do not change background
for bold text, to improve readability.
Only reverse video for normal red/green.
Adjust the ANSI terminal colors to align with the GE theme.
The background/foreground colors are separate to improve the
display for the extremely bright GE colors.

The theme is somehow based on mintty Helmhotz, but heavily modified
especially for background (reverse video) to align with the
existing GE theme colors.
If GE theme colors are applied, set moved lines as
reverse video (colored background) to match the appearances
@gerhardol gerhardol force-pushed the feature/i11821-ansi-background-theme-colors branch from fc4a6a3 to 21e6752 Compare August 9, 2024 19:32
gerhardol added a commit to gerhardol/gitextensions that referenced this pull request Aug 9, 2024
…textensions#11830)

Try to keep the current linenumber when switching to a new commit
in file tree, instead of always resetting to first line.
@gerhardol gerhardol force-pushed the feature/i11821-ansi-background-theme-colors branch from 21e6752 to e850eeb Compare August 9, 2024 20:45
@gerhardol gerhardol merged commit 441f1d7 into gitextensions:master Aug 9, 2024
4 checks passed
@gerhardol gerhardol deleted the feature/i11821-ansi-background-theme-colors branch August 9, 2024 21:08
@gerhardol
Copy link
Member Author

There are still some potential palette issues.
I got the printout below on a Win11 setup with system-dark, app-bright but no intentional cusom setting.
Cannot reproduce though.

GetForeColorForBackColor() tries to get a color from some pairs, using HSL perceived luminance, that is obviously not always the best.
Not sure if colors or method should be tweaked.
Regardless, I do not consider this critical for a release.

unnamed

The pairs checked looks like this:

image

@RussKie RussKie added this to the 5.0.0 milestone Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[vNext] Diff colouring not enough contrast
3 participants