Skip to content
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

Fixes #2797 - Refactor Color/TrueColor - Make TrueColor default #2896

Merged
merged 36 commits into from
Oct 14, 2023

Conversation

tig
Copy link
Collaborator

@tig tig commented Oct 9, 2023

Fixes #2797 - Refactor Color/True Color - Make TrueColor default
Partial fix for #457 -

Plan

  • Color becomes a class that represents a 32-bit color value accessible via R, G, and B properties (there will be an un-used A property as well given that most color systems include an alpha channel, even though there's no standard for that in most terminals).

    • Color will have properties for each of the 16 legacy color names (in the current Color enum). This enables most existing app code that uses Color.White etc... to work.
    • Color will provide a way to convert between legacy-16-color colors and 24-bit colors (Value will return (this.A<< 24) | (this.R<< 16) | (this.G<< 8) | tc.B).
  • Attribute will revert to looking more like it did in v1 with just a Foreground and Background property (the TrueColorForeground/Background properties will be removed.

    • Clean up extra methods that are no longer needed/redundant
      • Simplify constructors and remove duplicate code
      • Remove Attribute.Make - use new instead.
      • Remove Attribute.Get - Was only used in one unit test
      • Remove Driver.GetColors - not needed anymore
      • Remove HasValidColors stuff - With TrueColor and the map of color names to RGB values now in Color, it's not needed.
      • Remove Initalized stuff - With TrueColor and the map of color names to RGB values now in Color, it's not needed.
  • TrueColor should be the default; fallback to 16 color mode would be automatic if possible.

    • If not, users should be able to force it via ConfigurationManager. E.g. "Application.Force16Colors : true.
  • Persistence of colors to ConfigurationManager needs to be sorted out.

    • Json schema: Supports reading of #RGB, #RRGGBB, #RGBA, #RRGGBBAA, rgb(r,g,b), rgb(r,g,b,a), or a ColorName.
      • Alpha read but never used
      • Alpha is never written - this can be revisited someday
    • Still need to figure out how the ColorNames to RGB values map can be configurable.
      • New configurable property: Color.Colors 👍
  "Colors": {
    "White": "#F2F2F2",
    "BrightYellow": "#F9F1A5",
    "BrightCyan": "#61D6D6",
    "Cyan": "#3A96DD",
    "BrightMagenta": "#B4009E",
    "Magenta": "#881798",
    "BrightGreen": "#16C60C",
    "DarkGray": "#767676",
    "Green": "#13A10E",
    "BrightBlue": "#3B78FF",
    "Yellow": "#804020",
    "Blue": "#0037DA",
    "Black": "#0C0C0C",
    "BrightRed": "#E74856",
    "Gray": "#CCCCCC",
    "Red": "#C50F1F"
  },
- [ ] Somehow read these from the environment at startup?

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

@tig tig marked this pull request as draft October 9, 2023 02:14
@tig tig marked this pull request as ready for review October 10, 2023 04:52
@tig tig changed the title Fixes #2797 - Refactor Color/True Color - Make TrueColor default Fixes #2797 - Refactor Color/TrueColor - Make TrueColor default Oct 10, 2023
@tig
Copy link
Collaborator Author

tig commented Oct 10, 2023

@BDisp and @tznind - please review!

I've got a few things to clean up, but this is almost ready.

@tig
Copy link
Collaborator Author

tig commented Oct 11, 2023

I think this is ready!

@tig
Copy link
Collaborator Author

tig commented Oct 12, 2023

Working on ColorPicker... <3

pdXm8rk 1

Terminal.Gui/Drawing/Color.cs Outdated Show resolved Hide resolved
Terminal.Gui/Drawing/Color.cs Outdated Show resolved Hide resolved
Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs Show resolved Hide resolved
Terminal.Gui/Views/TextField.cs Outdated Show resolved Hide resolved
@tznind
Copy link
Collaborator

tznind commented Oct 13, 2023

Awesome work! I have left a few comments, nothing major.

@tig tig merged commit faff1ec into gui-cs:v2_develop Oct 14, 2023
1 check passed
@tig tig deleted the v2_truecolor_default branch April 3, 2024 01:50
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.

2 participants