bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#62573: 29.0.60; Cursor color not being inverted in emacs-29


From: Po Lu
Subject: bug#62573: 29.0.60; Cursor color not being inverted in emacs-29
Date: Mon, 03 Apr 2023 08:07:24 +0800
User-agent: Gnus/5.13 (Gnus v5.13)

Daniel Martín <mardani29@yahoo.es> writes:

> +#define CG_SET_FILL_COLOR_WITH_FRAME_CURSOR(context, frame)             \
> +  do {                                                                  \
> +    CGColorRef refcol_ =                                                \
> +      get_cgcolor_from_nscolor (FRAME_CURSOR_COLOR (frame), frame);     \
> +    CGContextSetFillColorWithColor (context, refcol_);                  \
> +    CGColorRelease (refcol_);                                           \
> +  } while (0)
> +#define CG_SET_FILL_COLOR_WITH_FRAME_BACKGROUND(context, frame)         \
> +  do {                                                                  \
> +    CGColorRef refcol_ =                                                \
> +      get_cgcolor_from_nscolor (FRAME_BACKGROUND_COLOR (frame), frame); \
> +    CGContextSetFillColorWithColor (context, refcol_);                  \
> +    CGColorRelease (refcol_);                                           \
> +  } while (0)

Thanks.  The GNU Coding Standards split expressions, before operators.
So this should read:

  do {
    CGColorRef refcol
      = ...

also, since you put this in a separate block, you don't have to worry
about shadowing, so there's no need to use names with a trailing
underscore.

>  #define CG_SET_STROKE_COLOR_WITH_FACE_FOREGROUND(context, face)         \
>    do {                                                                  \
>      CGColorRef refcol_ = get_cgcolor (NS_FACE_FOREGROUND (face));       \
> @@ -2933,9 +2947,12 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor 
> (no
>      {
>        if (s->hl == DRAW_CURSOR)
>          {
> -       CGColorRef colorref = get_cgcolor_from_nscolor (FRAME_CURSOR_COLOR 
> (f), f);
> -       CGContextSetFillColorWithColor (context, colorref);
> -       CGColorRelease (colorref);
> +          if (face && (NS_FACE_BACKGROUND (face)
> +                       == [(NSColor *) FRAME_CURSOR_COLOR (f)
> +                                       unsignedLong]))
> +            CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND (context, face);
> +          else
> +            CG_SET_FILL_COLOR_WITH_FRAME_CURSOR (context, f);
>          }
>        else
>          CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face);
> @@ -2949,9 +2966,12 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor 
> (no
>        CGContextScaleCTM (context, 1, -1);
>        if (s->hl == DRAW_CURSOR)
>          {
> -       CGColorRef colorref = get_cgcolor_from_nscolor 
> (FRAME_BACKGROUND_COLOR (f), f);
> -       CGContextSetFillColorWithColor (context, colorref);
> -       CGColorRelease (colorref);
> +          if (face && (NS_FACE_BACKGROUND (face)
> +                       == [(NSColor *) FRAME_CURSOR_COLOR (f)
> +                                       unsignedLong]))
> +            CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face);
> +          else
> +            CG_SET_FILL_COLOR_WITH_FRAME_BACKGROUND (context, f);
>          }
>        else
>          CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND (context, face);
> diff --git a/src/nsterm.m b/src/nsterm.m
> index 46007ec4fcb..637bc4b6419 100644
> --- a/src/nsterm.m
> +++ b/src/nsterm.m
> @@ -3750,14 +3750,18 @@ Function modeled after x_draw_glyph_string_box ().
>       {
>            struct face *face = s->face;
>            if (!face->stipple)
> -         {
> -           if (s->hl != DRAW_CURSOR)
> -             [(NS_FACE_BACKGROUND (face) != 0
> -               ? [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
> -               : FRAME_BACKGROUND_COLOR (s->f)) set];
> -           else
> -             [FRAME_CURSOR_COLOR (s->f) set];
> -         }
> +            {
> +              if (s->hl != DRAW_CURSOR)
> +                [(NS_FACE_BACKGROUND (face) != 0
> +                  ? [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
> +                  : FRAME_BACKGROUND_COLOR (s->f)) set];
> +              else if (face && (NS_FACE_BACKGROUND (face)
> +                                == [(NSColor *) FRAME_CURSOR_COLOR (s->f)
> +                                                unsignedLong]))
> +                [[NSColor colorWithUnsignedLong:NS_FACE_FOREGROUND (face)] 
> set];
> +              else
> +                [FRAME_CURSOR_COLOR (s->f) set];
> +            }
>            else
>              {
>                struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (s->f);

LGTM.  Thanks.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]