all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#29823: NS port tooltip colours
@ 2017-12-23 11:21 Alan Third
  2018-01-04 20:57 ` Charles A. Roelli
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Third @ 2017-12-23 11:21 UTC (permalink / raw)
  To: 29823

[-- Attachment #1: Type: text/plain, Size: 362 bytes --]

The NS port doesn’t support customising tooltips as described in the
Emacs manual. I’ve attached a patch that allows you to customise the
background and foreground colours.

It may be better to try using the existing frame code to generate the
tooltips as they would then support all parameters, but I’m not sure
how to go about doing that.
-- 
Alan Third

[-- Attachment #2: 0001-Allow-setting-tooltip-colors-in-NS-port.patch --]
[-- Type: text/plain, Size: 2297 bytes --]

From fda76ad237ac01ce398796e02a2a9463027ce7c9 Mon Sep 17 00:00:00 2001
From: Alan Third <alan@idiocy.org>
Date: Sat, 23 Dec 2017 11:00:35 +0000
Subject: [PATCH] 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.
---
 src/nsfns.m  | 10 ++++++++++
 src/nsmenu.m | 10 ++++++++++
 src/nsterm.h |  2 ++
 3 files changed, 22 insertions(+)

diff --git a/src/nsfns.m b/src/nsfns.m
index 064b476fb4..05605bf657 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -2873,6 +2873,8 @@ with offset DY added (default is -10).
   struct frame *f;
   char *str;
   NSSize size;
+  NSColor *color;
+  Lisp_Object t;
 
   specbind (Qinhibit_redisplay, Qt);
 
@@ -2900,6 +2902,14 @@ with offset DY added (default is -10).
   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 d2e102a2a9..63ed4f5d1d 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -1373,6 +1373,16 @@ - (void) setText: (char *)text
   [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 e669c95931..184ada99ae 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;
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-04 21:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-23 11:21 bug#29823: NS port tooltip colours Alan Third
2018-01-04 20:57 ` Charles A. Roelli
2018-01-04 21:21   ` Alan Third

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.