From: "Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Po Lu <luangruo@yahoo.com>
Cc: Al Haji-Ali <abdo.haji.ali@gmail.com>,
Eli Zaretskii <eliz@gnu.org>,
62573@debbugs.gnu.org
Subject: bug#62573: 29.0.60; Cursor color not being inverted in emacs-29
Date: Thu, 06 Apr 2023 12:12:04 +0200 [thread overview]
Message-ID: <m1bkk1nwuj.fsf@yahoo.es> (raw)
In-Reply-To: <87ttxxrfpf.fsf@yahoo.com> (Po Lu's message of "Mon, 03 Apr 2023 08:07:24 +0800")
[-- Attachment #1: Type: text/plain, Size: 1642 bytes --]
Po Lu <luangruo@yahoo.com> writes:
> 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.
>
OK, I've removed the trailing underscore in the other macros as well.
Here's a new patch with the requested changes. If everything looks
good, could someone install the patch for me? (I don't have push access
to the repository.)
Thanks.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Change-cursor-color-on-NS-port-when-it-matches-the-f.patch --]
[-- Type: text/x-patch, Size: 6498 bytes --]
From bbce06787debc564353ffc09ad74566e1fa254a0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <mardani29@yahoo.es>
Date: Sun, 2 Apr 2023 22:39:44 +0200
Subject: [PATCH] Change cursor color on NS port when it matches the face
background
* src/macfont.m (CG_SET_FILL_COLOR_WITH_FRAME_CURSOR): New macro.
(CG_SET_FILL_COLOR_WITH_FRAME_BACKGROUND): New macro.
(macfont_draw): When the cursor's color matches the face background,
set the fill color of the cursor to the face foreground.
* src/nsterm.m (ns_maybe_dumpglyphs_background): When dumping the
background of a glyph string, apply the logic mentioned
above. (Bug#62573)
---
src/macfont.m | 50 +++++++++++++++++++++++++++++++++++---------------
src/nsterm.m | 20 ++++++++++++--------
2 files changed, 47 insertions(+), 23 deletions(-)
diff --git a/src/macfont.m b/src/macfont.m
index d0cdbcd08c7..9f9f6f4efaf 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -632,21 +632,35 @@ static void mac_font_get_glyphs_for_variants (CFDataRef, UTF32Char,
#define CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND(context, face) \
do { \
- CGColorRef refcol_ = get_cgcolor (NS_FACE_FOREGROUND (face)); \
- CGContextSetFillColorWithColor (context, refcol_) ; \
- CGColorRelease (refcol_); \
+ CGColorRef refcol = get_cgcolor (NS_FACE_FOREGROUND (face)); \
+ CGContextSetFillColorWithColor (context, refcol); \
+ CGColorRelease (refcol); \
} while (0)
#define CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND(context, face) \
do { \
- CGColorRef refcol_ = get_cgcolor (NS_FACE_BACKGROUND (face)); \
- CGContextSetFillColorWithColor (context, refcol_); \
- CGColorRelease (refcol_); \
+ CGColorRef refcol = get_cgcolor (NS_FACE_BACKGROUND (face)); \
+ CGContextSetFillColorWithColor (context, refcol); \
+ CGColorRelease (refcol); \
+ } while (0)
+#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)
#define CG_SET_STROKE_COLOR_WITH_FACE_FOREGROUND(context, face) \
do { \
- CGColorRef refcol_ = get_cgcolor (NS_FACE_FOREGROUND (face)); \
- CGContextSetStrokeColorWithColor (context, refcol_); \
- CGColorRelease (refcol_); \
+ CGColorRef refcol = get_cgcolor (NS_FACE_FOREGROUND (face)); \
+ CGContextSetStrokeColorWithColor (context, refcol); \
+ CGColorRelease (refcol); \
} while (0)
@@ -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 c9f955000ac..37462cf49e2 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);
--
2.34.1
next prev parent reply other threads:[~2023-04-06 10:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-31 18:34 bug#62573: 29.0.60; Cursor color not being inverted in emacs-29 Al Haji-Ali
2023-03-31 19:15 ` Eli Zaretskii
2023-03-31 21:46 ` Al Haji-Ali
2023-04-01 5:38 ` Eli Zaretskii
2023-04-01 19:56 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-02 0:44 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-02 21:24 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-03 0:07 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-06 10:12 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-04-08 11:36 ` Eli Zaretskii
2023-04-02 5:09 ` Eli Zaretskii
2023-04-02 5:52 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-02 6:58 ` Eli Zaretskii
2023-04-02 11:01 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-02 11:12 ` Eli Zaretskii
2023-04-02 14:28 ` Al Haji-Ali
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1bkk1nwuj.fsf@yahoo.es \
--to=bug-gnu-emacs@gnu.org \
--cc=62573@debbugs.gnu.org \
--cc=abdo.haji.ali@gmail.com \
--cc=eliz@gnu.org \
--cc=luangruo@yahoo.com \
--cc=mardani29@yahoo.es \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.