From: Alan Third Date: Sat, 23 Dec 2017 11:00:35 +0000 (+0000) Subject: Allow setting tooltip colors in NS port X-Git-Tag: emacs-27.0.90~5929 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=15cd18991c1d9a9bafeef7bf9b4dad91ecc0332a;p=emacs.git Allow setting tooltip colors in NS port * src/nsfns.m (Fx_show_tip): Get face colors and apply them to the tooltip. * src/nsmenu.m (EmacsTooltip::setBackgroundColor): (EmacsTooltip::setForegroundColor): New functions. * src/nsterm.h (EmacsTooltip::setBackgroundColor): (EmacsTooltip::setForegroundColor): New function prototypes. --- diff --git a/src/nsfns.m b/src/nsfns.m index d5049a7a911..3ede63f9854 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -2873,6 +2873,8 @@ Text larger than the specified size is clipped. */) struct frame *f; char *str; NSSize size; + NSColor *color; + Lisp_Object t; specbind (Qinhibit_redisplay, Qt); @@ -2900,6 +2902,14 @@ Text larger than the specified size is clipped. */) else Fx_hide_tip (); + t = x_get_arg (NULL, parms, Qbackground_color, NULL, NULL, RES_TYPE_STRING); + if (ns_lisp_to_color (t, &color) == 0) + [ns_tooltip setBackgroundColor: color]; + + t = x_get_arg (NULL, parms, Qforeground_color, NULL, NULL, RES_TYPE_STRING); + if (ns_lisp_to_color (t, &color) == 0) + [ns_tooltip setForegroundColor: color]; + [ns_tooltip setText: str]; size = [ns_tooltip frame].size; diff --git a/src/nsmenu.m b/src/nsmenu.m index 20b4e58b479..5748b20ce81 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -1364,6 +1364,16 @@ update_frame_tool_bar (struct frame *f) [textField setFrame: r]; } +- (void) setBackgroundColor: (NSColor *)col +{ + [textField setBackgroundColor: col]; +} + +- (void) setForegroundColor: (NSColor *)col +{ + [textField setTextColor: col]; +} + - (void) showAtX: (int)x Y: (int)y for: (int)seconds { NSRect wr = [win frame]; diff --git a/src/nsterm.h b/src/nsterm.h index bef2c1011bc..878923cbb41 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -585,6 +585,8 @@ typedef id instancetype; } - (instancetype) init; - (void) setText: (char *)text; +- (void) setBackgroundColor: (NSColor *)col; +- (void) setForegroundColor: (NSColor *)col; - (void) showAtX: (int)x Y: (int)y for: (int)seconds; - (void) hide; - (BOOL) isActive;