juliusHuelsmann / st

Repatch repository of developed 'Vim Browse' and 'Alpha Focus Highlight' patches for simple terminal (st).
https://st.suckless.org/patches/alpha_focus_highlight/
MIT License
28 stars 11 forks source link

VIM: underlined text gets highlighted #13

Closed paretje closed 4 years ago

paretje commented 4 years ago

The vimbrowse patch contains the following hunk for st.h:

@@ -33,6 +36,8 @@ enum glyph_attribute {
        ATTR_WRAP       = 1 << 8,
        ATTR_WIDE       = 1 << 9,
        ATTR_WDUMMY     = 1 << 10,
+       ATTR_HIGHLIGHT  = 1 << 11 | ATTR_UNDERLINE,
+       ATTR_CURRENT    = 1 << 12,
        ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
 };

This causes all underlined text to be white on a red background. However, if I just use:

        ATTR_WRAP       = 1 << 8,
        ATTR_WIDE       = 1 << 9,
        ATTR_WDUMMY     = 1 << 10,
+       ATTR_HIGHLIGHT  = 1 << 11,
+       ATTR_CURRENT    = 1 << 12,
        ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,

then I don't have this issue.

I suspect you wanted to toggle underline for highlighted text, or always enable/disable underline for it, however:

    if (base.mode & ATTR_HIGHLIGHT) {
        base.bg = highlightBg;
        base.fg = highlightFg;
    } else if ((base.mode & ATTR_CURRENT) && (win.mode & MODE_NORMAL)) {
        base.bg = currentBg;
        base.fg = currentFg;
    }

will also match ATR_UNDERLINE. I think you better drop ATTR_UNDERLINE from ATTR_HIGHLIGHT, and define and use e.g. ATTR_UNDERLINE_HIGHLIGHT when setting the mode, or just use ATTR_UNDERLINE directly.

Apart from that: thank you for your work. I had combined keyboard-selection and scrollback, but your patch finally convinced me to use st as my default terminal emulator.

juliusHuelsmann commented 4 years ago

Thanks for the bugfix! :) I merged it, released it & added you as contributor at the suckless.org page, the application of the updates usually takes a few days.