bakkeby / st-flexipatch

An st build with preprocessor directives to decide which patches to include during build time
MIT License
347 stars 107 forks source link

[Patch Request] Selection colors patch #91

Closed RedPenguin88 closed 6 months ago

RedPenguin88 commented 1 year ago

selectioncolors allows defining the foreground and background colors used when selecting text with the mouse. Is it possible to add this?

Additionally, there is selectionbg-alpha for compatibility with the alpha patch. Not sure if this works with the alpha-focus-highlight patch.

bakkeby commented 1 year ago

The patch on its own doesn't look particularly complicated.

The problem is that the glyph_attribute enum is already exhausted.

https://github.com/bakkeby/st-flexipatch/blob/e6a2fb489c192e2cd9439691014f48779d4966ad/st.h#L42-L68

One way to solve that would be to get rid of the enum and declare the values as long constants. This means that the mode where these are used also needs to be a long rather than an int. Can easily get messy.

Judging from the patch page the original 0.8.2 patch resulted in colour reversing for external programs to be disabled. It could be a compromise to take that patch instead despite the flaw.

RedPenguin88 commented 1 year ago

I see. I've added it to my build which works fine since I don't use the sixel patch myself. I will leave this issue open in case you want to implement the 0.8.2 patch. Otherwise, feel free to close.

On a side note, thank you for the various flexipatch projects! They act as an invaluable guide for resolving patch incompatibilities for my own build!

JCallicoat commented 7 months ago

Just changing mode member in Glyph from ushort to unint32_t works fine to double the size of the bitfield. I have the 0.8.4 patch working with flexipatch using the following and would be happy to submit a full PR if the increased size per glyph when using the patch is acceptable.

    #if SELECTION_COLORS_PATCH
    ATTR_SELECTED   = 1 << 16,
    #endif // SELECTION_COLORS_PATCH

    ...

    #if SELECTION_COLORS_PATCH
    uint32_t mode;    /* attribute flags */
    #else
    ushort mode;      /* attribute flags */
    #endif // SELECTION_COLORS_PATCH
bakkeby commented 7 months ago

That's a good point. Maybe it should just be unint32_t regardless of what patches are applied. Gives room for other patches that may hook into the attributes.