1

I am writing a plugin and need to check if a highlight attribute (bold, italic, underline and so on) is actually displayable on a terminal. I tried to check it with termcap. For example of the underline,

!empty(&t_us) && !empty(&t_ue)

becomes TRUE on xterm, and displayable.
However,
becomes TRUE on win32, but not displayable.
becomes FALSE on nvim, but displayable.

Could someone have a good idea to check it correctly?

phd
  • 82,685
  • 13
  • 120
  • 165
Rick Howe
  • 429
  • 3
  • 6
  • Users can and often do lie to Vim by setting a `$TERM` that doesn't reflect their terminal emulator's capabilities so relying on `&t_xx` alone is certainly not a good idea. If you want your feature to be solid you wild probably have to check for `&t_xx` AND other things like `win32` and possibly other environment variables. – romainl Sep 23 '17 at 08:25
  • Even that won't help much, because there's no practical way to see what's actually on the terminal's screen. – Thomas Dickey Sep 23 '17 at 12:34

1 Answers1

-1

Highlighting colors and attributes should be controlable by the user; that's why we have the indirection via :highlight groups and bundles of such in the form of colorschemes.

That said, for WYSIWYG-rendering like HTML tags, most users probably want italic rendered as italic (and so on...)

Therefore, I would recommend to make this configurable (typicall via :highlight default ... so that it can be overridden by users, alternatively via g:pluginname_attributesForBlah if this would result in too much duplication for the user). You can still use your heuristics (based on the termcap info or $TERM) to provide good configuration defaults. That offers a comfortable default for the majority of plugin users (on common platforms and terminals), but still allows tweaking for special cases or users with special needs (e.g. a visual disability that can't read low contrast or italics well).

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324