Re: [dev] [PATCH] [st] Use inverted defaultbg/fg for selection when bg/fg are the same

From: Brandon Mulcahy <brandon_AT_jangler.info>
Date: Mon, 27 Oct 2014 14:24:21 -0400

On Sun, Oct 26, 2014 at 11:01:24PM -0300, dequis wrote:
> This patch allows that text to be read by selecting it, turning it into
> text with white bg and black fg (given default values for defaultbg/fg),
> just like most normal unformatted text when selected.
> ---
> st.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/st.c b/st.c
> index 12af1ab..e2b7003 100644
> --- a/st.c
> +++ b/st.c
> _AT_@ -3296,9 +3296,14 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
> }
>
> if(base.mode & ATTR_REVERSE) {
> - temp = fg;
> - fg = bg;
> - bg = temp;
> + if (bg == fg) {
> + bg = &dc.col[defaultfg];
> + fg = &dc.col[defaultbg];
> + } else {
> + temp = fg;
> + fg = bg;
> + bg = temp;
> + }
> }
>
> if(base.mode & ATTR_FAINT && !(base.mode & ATTR_BOLD)) {
> --
> 2.1.2
>

I like the idea, but not the implementation. This patch changes the definition
of ATTR_REVERSE, which isn't good. The alternative would be to define a
separate color scheme for selection. I'm not sure how much complexity that
would add to the code, but in my opinion almost any complexity dedicated to
handling an unusual case like this is too much. Perhaps this patch could live
on the wiki instead of being integrated into the st proper.
Received on Mon Oct 27 2014 - 19:24:21 CET

This archive was generated by hypermail 2.3.0 : Mon Oct 27 2014 - 19:36:08 CET