简体   繁体   中英

How to check if a highlight attribute is displayable on a terminal?

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?

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 (eg a visual disability that can't read low contrast or italics well).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM