Skip to content

Fix flipped ANSI colour intensity flag bug and use canonical CGA colour tag names#2979

Merged
kcgen merged 3 commits intomainfrom
jn/ansi-markup-fix
Oct 9, 2023
Merged

Fix flipped ANSI colour intensity flag bug and use canonical CGA colour tag names#2979
kcgen merged 3 commits intomainfrom
jn/ansi-markup-fix

Conversation

@johnnovak
Copy link
Copy Markdown
Member

@johnnovak johnnovak commented Oct 9, 2023

Description

Our ANSI markup tag processor was buggy—the handling of low vs high intensity colours was flipped. E.g., [color=green] resulted in high intensity green (light green), and [color=light-green] in low intensity green. I noticed this about a year ago, but kinda glossed over it. People somehow got used to this weirdness and marked up brown dutifully as [color=light-yellow] in the MORE command, for example. Err... 😐

Also, the colour tags used the standard symbolic ANSI colour names which I found quite confusing even with the flipping corrected:

  • [color=yellow] would need to be specified for "brown".
  • [color=light-yellow] would need to be specified for "yellow".
  • [color=light-white] would need to be specified for "white".
  • [color=white] would need to be specified for "light gray".
  • [color=light-black] would need to be specified for "dark gray".

As I see it, using the symbolic ANSI colour names has no benefits; it only creates a lot of confusion and their use is rather pointless as we're operating in a DOS context where CGA colour names are the norm. Therefore, I'm switching to using canonical CGA colour names as well. For reference:

image

I used the attached remap-colors.sh script to remap all [color=XYZ] tags automatically to the new schema:

./remap-colors.sh src 
./remap-colors.sh include
./remap-colors.sh contrib/resources/translations

Script (change extension to .sh after downloading it): remap-colors.zip

Manual testing

Ran INTRO, HELP, MIXER /?, and MORE FOO.TXT to test.

Checklist

Please tick the items as you have addressed them. Don't remove items; leave the ones that are not applicable unchecked.

I have:

  • followed the project's contributing guidelines and code of conduct.
  • performed a self-review of my code.
  • commented on the particularly hard-to-understand areas of my code.
  • split my work into well-defined, bisectable commits, and I named my commits well.
  • applied the appropriate labels (bug, enhancement, refactoring, documentation, etc.)
  • checked that all my commits can be built.
  • confirmed that my code does not cause performance regressions (e.g., by running the Quake benchmark).
  • added unit tests where applicable to prove the correctness of my code and to avoid future regressions.
  • made corresponding changes to the documentation or the website according to the documentation guidelines.
  • locally verified my website or documentation changes.

Also change markup colour tags to use canonical CGA colour names instead
of the symbolic ANSI colour names which would only cause confusion.
@johnnovak johnnovak self-assigned this Oct 9, 2023
@johnnovak johnnovak added bug Something isn't working plumbing Issues related to low-level support functions and classes labels Oct 9, 2023
@johnnovak johnnovak requested review from kcgen, shermp and weirddan455 and removed request for kcgen October 9, 2023 12:45
@johnnovak johnnovak marked this pull request as ready for review October 9, 2023 12:50
@johnnovak johnnovak changed the title Fix swapped low and high intensity colour markup Fix flipped ANSI colour intensity flag bug and use canonical CGA colour tag names Oct 9, 2023
@Kappa971
Copy link
Copy Markdown
Contributor

Kappa971 commented Oct 9, 2023

Please merge this #2980 first.

Copy link
Copy Markdown
Member

@kcgen kcgen left a comment

Choose a reason for hiding this comment

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

Nice fix up, @johnnovak !

@kcgen kcgen merged commit 254dbe2 into main Oct 9, 2023
@kcgen
Copy link
Copy Markdown
Member

kcgen commented Oct 9, 2023

There were non-trivial conflicts with #2980, but resolved them and had to to combine the commits here before merge (which is OK - the nice script allows us to reverse the fields back to the previous values; nice script - @johnnovak !).

@Kappa971, can you confirm the Italian translation made it through the process with your 2980 changes intact plus the new color tags?

Expand the it.lng diff: 254dbe2#diff-705892e440c647dc5fc3705d4c074e218b8ebd58e5a8e94c7b78db3cd7fafee8

@Kappa971
Copy link
Copy Markdown
Contributor

Kappa971 commented Oct 9, 2023

@Kappa971, can you confirm the Italian translation made it through the process with your 2980 changes intact plus the new color tags?

I think it's all intact,
but I haven't made 2980 changes 😆

@kcgen
Copy link
Copy Markdown
Member

kcgen commented Oct 9, 2023

I think it's all intact, but I haven't made 2980 changes 😆

Perfect. Yup, the Italian file contains ~700 changes:

2023-10-09_09-31

@shermp
Copy link
Copy Markdown
Collaborator

shermp commented Oct 9, 2023

For context, the reason for the naming was simple, the lighter colour variants had a light prefix. I guess I wasn't thinking in terms of intensity, but rather "light" and "bold" variants.

I used the ANSI colours, because that's what I knew about, and was consistent with all the other escape sequences.

@johnnovak
Copy link
Copy Markdown
Member Author

For context, the reason for the naming was simple, the lighter colour variants had a light prefix. I guess I wasn't thinking in terms of intensity, but rather "light" and "bold" variants.

I used the ANSI colours, because that's what I knew about, and was consistent with all the other escape sequences.

Yup, no problem @shermp. Your markup handler is very nice, and there's nice unit test coverage too! Using the ANSI names was a reasonable initial choice, but in practice, it turns out the "indirection" of ANSI names is cumbersome; a what-you-see-is-what-you-get approach is just better. Incremental improvement! 😎 🚀

@kcgen kcgen deleted the jn/ansi-markup-fix branch October 14, 2023 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working plumbing Issues related to low-level support functions and classes

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants