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
Make color numbers on Windows consistent #482
Comments
For which release do you aim this? I think we should make one release with the current scheme, and updated, finally-correct docs, and then, for the next release, try to unify the codepaths between *nix and windows as far as color handling and config goes, and I suspect it would be a risky-ish change. What are your thoughts on this? |
I'm not sure; I'm inclined to get all the changes done before the next production release. I agree that it will be risky and there are already a lot of changes since v643. On the other hand, the current behavior is ugly and hard to understand, so I'd like to get it all cleaned up and unified as soon as practical. I certainly have no objection to at least getting the initial cleanup phase done and make a numbered release for it before embarking on the bigger change. The decision about whether to make that build a production release can be made separately. |
Well, I really want to have one release with correct docs of the behavior over the past few years, before changing the behavior, and before refactoring and replacing the code which is responsible for this behavior. Maybe you'll fix -Da and -Dd/s/k/u, I'll open a PR only for the docs (or just take the diff I posted at the other issue, polish it, and commit it yourself) then make a release, then we'll start with the code changes? The code we'll be touching is decades old, and it would be easy to introduce issues which might not be noticed till after the release... |
Hm, it appears that colordesc() has a feature whereby if the first char of the color description is 'u', it adds LVB_COMMON_UNDERSCORE to the color. This confusingly conflicts with the 'u' character that selects underscored text as the text whose color is changed. As far as I can see, it's not documented in the man page. It will be a fair amount of work to implement now that options are parsed before get_term, so I'm inclined to remove it. @avih @adoxa Does anyone have thoughts? |
Well, IIRC LVB_COMMON_UNDERSCORE is related to CJK codepages? I have zero familiarity with it, but this is also something I'm inclined to not-modify till after the release. |
In b4ea7b4 I think I've fixed the -D bugs introduced by the init reordering in 09377f7. I haven't updated the man page yet but will do that next. I did remove support for the undocumented 'u' character. With some work that can be re-added if necessary. However I think long term it would be better to implement the new attribute modifiers added in 608c8e5 (which are currently ignored on Windows), rather than to have Windows-specific syntax for this. |
@gwsw Check your emails from 27/8 July 2017 - I sent you a patch where 'u' was indeed documented (present in 520 release). @avih When the console gained terminal emulation everyone got a real underline, so there became a choice between sticking with the color or having an actual underline (or both). |
Ah, I see that now. Unfortunately the introduction of color letters has made the use of this 'u' modifier ambiguous in some cases. For example, -Dukr could mean "make underlined text black fg on red bg" or it could mean "make blinking text red fg on default bg with underline". I'm not sure what to do about this, but ultimately I think we should use "_" rather than "u" to add the UNDERSCORE bit. Whether that should be part of this initial phase or later, I'm not sure yet. |
For future reference, the functionality and docs of Also for reference,
Agreed, but he docs curently say that these modifiers don't work on windows:
I don't know if "not supported" refers to difficulties of entering them as arguments at the If the former, then they can be entered with other means, like the I don't see that dos/windows are excluded when parsing these in Also, as we now know, the handling of d/s/k/u is different than the "upper case letters", like N. However, with the (very) little I tried, I don't think I could make it work with neither lower case letter nor upper case, but that shouldn't serve as evidence that it completely doesn't work.
Please, later. I wouldn't have touched the At this phase IMO let's just add correct docs, fix bugs which were introduce after the last release - as much as we find such, and make a release. Then we can break things. |
In 48c3369 I have restored the 'u' modifier, but only at the end of the color string. This is now integrated with the new attribute letters ( BTW I have made a small update to the man page in this change but the man page changes for Windows are not yet complete. |
In a1391d8 the u and s modifiers now work with uppercase color selectors as well as lowercase. |
I wouldn't call it restore. It's a different thing. It was working only with d/s/k/u on any version of windows, and now it it doesn't work for d/s/k/u on any version of windows, but does work on the upper case letters on win10 and later. Nevertheless, I think it's not worth spending any more time on it, so let it be. |
Can you explain this, or give an example? As far as I can see, it works with the lowercase letters. For example, -Dsgu displays search matches (standout) in underlined green and -Dubu displays underlined text in underlined blue. It also works with numeric colors: -Ds4u displays error messages in underlined red. This is all with --use-color disabled of course. |
Apologies. I only looked briefly at the code, and was a bit fraustrated that instead of restoring 2-3 lines of code for the
That's not true. Not sure why I thought that's the case, as I only tested it on win10 (before the recent changes). Now I tested the same version again, and it only works on 10 for me (not XP, not 7). Anyway, looking at it again, I have misinterpreted the scope of it, and i now do see it has code for d/s/k/u too. Apologies again. So, I just tried it too, and the first thing I tried is It's also broken (normal/inverse text invisible) without the Removing the
These have a similar issue for me. It does affect the mapped attribute as expected, but normal text is invisible... |
I'm not sure what you mean "added a new feature"; are you referring to the I do see the bug where normal text disappears with -Dd2. It only happens when you put the -D option on the command line; it works correctly if you invoke -D as a command within less. I'll look into that. |
I was referring to 48c3369 and a1391d8, which looked like a new feature to me ("add alphabetic alternative..." - on all platforms) and touched a considerable number of lines of code. Hard for me to tell whether all of it was a response to this "let's restore 'u'" thing, or only parts of it, and I may have misunderstood that as well. |
I see. 48c3369 was just restoring 'u' functionality but it involved more code than adoxa's original implementation because the -D option (like all options) is handled before get_term, so we don't yet know what the default window color is. So we need to save some state in opt_D and actually set the colors in get_term. a1391d8 was making 'u' work for uppercase letters, which is indeed a new feature but I think worth it because it's not much code and avoids yet another way that uppercase letters behave differently from lowercase letters. The invisible normal text bug should be fixed in top of tree now. |
Confirmed. Thanks. Also, for what it's worth, help doesn't crash if built with gcc/clang mingw ( The crash was a regression of commit 1fafd96 . |
Currently on Windows, if a color is specified by -D followed by an uppercase letter and a number, the number is interpreted as an 8-bit SGR 38;5 color value, but if a color is specified by -D followed by a lowercase letter and a number, the number is interpreted as a 4-bit CHAR_INFO.Attribute color value. On other platforms, all color numbers are interpreted as SGR 38;5 values.
This should be unified so that on Windows, all color numbers are SGR values.
This breaks backwards compatibility on Windows. However the CHAR_INFO.Attribute colors would still accessible using letters instead of numbers for color values (for example, to make underlined text be red on blue, use -Durb instead of -Du4.1).
The text was updated successfully, but these errors were encountered: