Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Console] Add Ansi8 (256 color) support, improve true color (Ansi24) support detection#46944

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:6.2fromjulien-boudry:path-arcenciel
Jul 22, 2022

Conversation

@julien-boudry
Copy link
Contributor

QA
Branch?6.2 for features
Bug fix?no
New feature?yes
Deprecations?no
LicenseMIT
  • Refactor the detection code of the colorimetric capacities of the terminal (much easier to extend next)
  • Improve true color terminal detection according tohttps://github.com/termstandard/colors/
  • Add detection for 256 colors terminal (Ansi8 support) and add the conversion from true color (Ansi24) to it. This is especially useful for the Apple Terminal which is still deployed by default in 2022, but not only.

@carsonbotcarsonbot added this to the6.2 milestoneJul 14, 2022
@julien-boudryjulien-boudry changed the titlePath arcenciel[Console] Ansi8 (256 color) support, improve true color (Ansi24) support detectionJul 14, 2022
julien-boudry added a commit to julien-boudry/symfony that referenced this pull requestJul 14, 2022
@julien-boudryjulien-boudry changed the title[Console] Ansi8 (256 color) support, improve true color (Ansi24) support detection[Console] Add Ansi8 (256 color) support, improve true color (Ansi24) support detectionJul 15, 2022
@carsonbot
Copy link

Hey!

I think@CupOfTea696 has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

@julien-boudry
Copy link
ContributorAuthor

julien-boudry commentedJul 15, 2022
edited
Loading

In pratice:

  • Many terminals support Ansi24 (truecolor), but can not be identified (Gnome, Windows Terminal...) as true color. Before this PR, Sf rollback to Ansi4 (16 colors) for them. After this PR, is still often the case yet, but few of them can be added to the Ansi24 detection, and some others can be added at least at the Ansi8 (256 colors) detection (because of env TERM name like xterm-256). But is not possible for Gnome Terminal and Windows Terminal (for example), still unchanged.

  • Almost all terminals support 256 colors (Ansi8). Before this PR, Sf rollback to Ansi4 (16 colors) for them. After this PR, almost all (including Apple Terminal) use conversion from true Ansi 24 (truecolor) to Ansi8 (256 colors). It's better. (but also not Gnome, not Windows)

  • Future scope?

    • Use Ansi24 (truecolor) by default, and degrade only if 256 colors is explicit? (today, it's the opposite) Could work in a large majority of cases (including Gnome or Windows Terminal for many years), has no impact on Apple Terminal, but can lead to some problems with very old or rare terminals.(but Gnome developer says about that: We don't care 😄)
      In fact, conversion to Ansi4 (16 colors) will never happen (because no one declares it explicitly) without using a database like Termcap maybe (but not perfect also).

    • Or go ahead with speculative detection based on other ENV variables (like env OS variable on windows).

@julien-boudryjulien-boudryforce-pushed thepath-arcenciel branch 2 times, most recently from4d7092c toe0ea32eCompareJuly 15, 2022 22:24
@julien-boudryjulien-boudry requested a review fromstofJuly 15, 2022 22:39
@julien-boudryjulien-boudryforce-pushed thepath-arcenciel branch 3 times, most recently from7f8f760 toaaa3f37CompareJuly 18, 2022 23:54
@julien-boudry
Copy link
ContributorAuthor

Note:@fabpot fabbot.io doesn't like Enum with methods. And not also empty line before doc. comments on CASE. (I have removed it here).

@julien-boudryjulien-boudry requested a review fromstofJuly 19, 2022 00:02
@julien-boudry
Copy link
ContributorAuthor

I will change the enum name soon as discussed. Add one more test. And Squash all these commits at the end. And possibly, we will be perfect.

@julien-boudryjulien-boudry marked this pull request as draftJuly 19, 2022 12:12
@julien-boudryjulien-boudryforce-pushed thepath-arcenciel branch 2 times, most recently from922741b tocfaffa0CompareJuly 21, 2022 18:25
julien-boudry added a commit to julien-boudry/symfony that referenced this pull requestJul 21, 2022
…improves terminal support detection (Ansi4, Ansi8, Ansi24)* The detection of terminal capabilities is always conservatively estimated, without speculation that may result in display errors. But significantly improved, bringing in particular 256 colors compatibility with Apple Terminal (instead of 8).* Ansi8 is used by converting the RGB hexadecimal to the nearest color.* The whole corresponding code is refactored and many tests are added for both existing and new features.
@julien-boudryjulien-boudry marked this pull request as ready for reviewJuly 21, 2022 18:26
@julien-boudryjulien-boudry requested a review fromstofJuly 21, 2022 18:28
…improves terminal support detection (Ansi4, Ansi8, Ansi24)* The detection of terminal capabilities is always conservatively estimated, without speculation that may result in display errors. But significantly improved, bringing in particular 256 colors compatibility with Apple Terminal (instead of 8).* Ansi8 is used by converting the RGB hexadecimal to the nearest color.* The whole corresponding code is refactored and many tests are added for both existing and new features.
@fabpot
Copy link
Member

Thank you@julien-boudry.

@fabpotfabpot merged commit6c8c93d intosymfony:6.2Jul 22, 2022
fabpot added a commit that referenced this pull requestSep 7, 2022
…lor Mode (julien-boudry)This PR was merged into the 6.2 branch.Discussion----------[Console] Terminal Color Mode refactoring and force Color Mode| Q             | A| ------------- | ---| Branch?       | 6.2 for features| Bug fix?      | no| New feature?  | yes| Deprecations? | no| License       | MITContinue#46944Terminal Color Mode refactoring: Adding a way to force color mode by the dev. user (with a new method), fewer `getenv()` calls (cache value), simpler tests (use the a new method and a new constant).For example, it can be useful in an environment where none of the expected environment variables are available (Docker container...) , but where the support of a specific mode is imperative.A future evolution could be to add an optional default option to all commands to force a particular mode by the final user.Commits-------4cb8384 [Console] Terminal Color Mode refactoring: Adding a way to force color mode by user, fewer getenv() calls, simpler tests.
@fabpotfabpot mentioned this pull requestOct 24, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@chalasrchalasrAwaiting requested review from chalasrchalasr is a code owner

@stofstofAwaiting requested review from stof

Assignees

No one assigned

Projects

None yet

Milestone

6.2

Development

Successfully merging this pull request may close these issues.

4 participants

@julien-boudry@carsonbot@fabpot@stof

[8]ページ先頭

©2009-2025 Movatter.jp