htop icon indicating copy to clipboard operation
htop copied to clipboard

Stopgap solution to preserve colors and attributes on highlighting

Open C0rn3j opened this issue 4 months ago • 5 comments

Old demo with wrong column highlights

Screencast_20240929_172318.webm

Screencast_20240929_181531.webm

This is a decent workaround for https://github.com/htop-dev/htop/issues/243 solely by using text attributes by taking the idea in https://github.com/htop-dev/htop/pull/434 and expanding it.
This is a stopgap solution until the issue is properly resolved by actually being able to define the desired text colors while keeping the highlight background, which I assume will take a while.
This does not have the same problem as #434 as we are not changing text color by bolding it, we are primarily relying on the terminal to do its highlighting by means of A_STANDOUT.

This works for any highlight color.

There is a couple problems:

  • [x] A Function is from original PR and needs renaming: RichString_setAttrn_preserveBold -> RichString_setAttrn_preserve || RichString_setAttrn_preserve_with_standout ?
    Settled on _preserveWithStandout for now
  • [x] There are debug statements left in the current code
  • [ ] I am not a C/C++ dev, someone please verify my actual functional code makes sense
    • [ ] Currently I check if text color is not default (ColorPair 0) or if text is Bolded, is there even a situation where text is bolded but not colored?
  • [ ] The entire column gets lit up - is this desired? I presume not.
    • A) Should I solve this in my code by ensuring the char is not a space -> I fixed it by doing that in the current code.
    • B) Should this be fixed in other code that ensures it's not setting params and text colors for spaces?
      image
  • [ ] Biggest thorn is the fact that we can be setting highlight color that is identical to the text color, which means we are not highlighting anything different from default text.
    • This is detected and text attribute is set to italics to at least differentiate it, but it is not an amazing solution, we would need to at least italicize the entire column for it to not look poorly(I presume checking chars ahead and behind until whitespace is found and italicizing those would work):
      image
    • See my comment in #243 for a list of attribute tricks if you want to try to wizard a better solution, underline looks terrible and bolding has the same issue as italics + color issues
    • This could be solved by not having the theme use the same text color as the highlight color
  • [ ] Does this work fine in most terminals? They need to treat A_STANDOUT well from what I understand.

Mildly related to #1541

C0rn3j avatar Sep 29 '24 15:09 C0rn3j