emacs-devel
[Top][All Lists]
Advanced

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

Re: Mouse-hovering over 'mouse-face' overlays/regions on a TTY Emacs


From: João Távora
Subject: Re: Mouse-hovering over 'mouse-face' overlays/regions on a TTY Emacs
Date: Mon, 30 Nov 2020 19:09:38 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin)

Eli Zaretskii <eliz@gnu.org> writes:

>> From: João Távora <joaotavora@gmail.com>
>> Cc: jared@finder.org,  emacs-devel@gnu.org
>> Date: Mon, 30 Nov 2020 18:28:16 +0000
>> 
>> > You need to implement tty_draw_row_with_mouse_face for macOS terminal.
>> > Look at the other implementations, it should be easy.
>> 
>> Thanks.  In which file should I do that?  I.e. how do I implement a C
>> function for a specific terminal?
>
> I guess nsterm.m is the right place?  Maybe wait for Alan to chime in.

Yes, I look at it but that would be for graphical stuff right?

> An alternative is to make the function in term.c be compiled on macOS,
> I think the code there is fairly generic.  Maybe this is the best way.
> Assuming term.c gets compiled on macOS, that is.

Yep, I tried that and it works like a charm!  I just freed some code
from the #ifdef HAVE_GPM shackles, and it compiled and linked cleanly.
Which is just as well since I have no idea what these data structures
are :-)

Anyway, a patch after my sig, which I will use for a while

João

diff --git a/src/term.c b/src/term.c
index fee3b55575..178a73b6fc 100644
--- a/src/term.c
+++ b/src/term.c
@@ -790,8 +790,6 @@ tty_write_glyphs (struct frame *f, struct glyph *string, 
int len)
   cmcheckmagic (tty);
 }
 
-#ifdef HAVE_GPM                        /* Only used by GPM code.  */
-
 static void
 tty_write_glyphs_with_face (register struct frame *f, register struct glyph 
*string,
                            register int len, register int face_id)
@@ -847,7 +845,6 @@ tty_write_glyphs_with_face (register struct frame *f, 
register struct glyph *str
 
   cmcheckmagic (tty);
 }
-#endif
 
 /* An implementation of insert_glyphs for termcap frames. */
 
@@ -2380,24 +2377,6 @@ DEFUN ("resume-tty", Fresume_tty, Sresume_tty, 0, 1, 0,
                               Mouse
  ***********************************************************************/
 
-#ifdef HAVE_GPM
-
-#ifndef HAVE_WINDOW_SYSTEM
-void
-term_mouse_moveto (int x, int y)
-{
-  /* TODO: how to set mouse position?
-  const char *name;
-  int fd;
-  name = (const char *) ttyname (0);
-  fd = emacs_open (name, O_WRONLY, 0);
-     SOME_FUNCTION (x, y, fd);
-  emacs_close (fd);
-  last_mouse_x = x;
-  last_mouse_y = y;  */
-}
-#endif /* HAVE_WINDOW_SYSTEM */
-
 /* Implementation of draw_row_with_mouse_face for TTY/GPM.  */
 void
 tty_draw_row_with_mouse_face (struct window *w, struct glyph_row *row,
@@ -2430,6 +2409,24 @@ tty_draw_row_with_mouse_face (struct window *w, struct 
glyph_row *row,
   cursor_to (f, save_y, save_x);
 }
 
+#ifdef HAVE_GPM
+
+#ifndef HAVE_WINDOW_SYSTEM
+void
+term_mouse_moveto (int x, int y)
+{
+  /* TODO: how to set mouse position?
+  const char *name;
+  int fd;
+  name = (const char *) ttyname (0);
+  fd = emacs_open (name, O_WRONLY, 0);
+     SOME_FUNCTION (x, y, fd);
+  emacs_close (fd);
+  last_mouse_x = x;
+  last_mouse_y = y;  */
+}
+#endif /* HAVE_WINDOW_SYSTEM */
+
 /* Return the current time, as a Time value.  Wrap around on overflow.  */
 static Time
 current_Time (void)
diff --git a/src/xdisp.c b/src/xdisp.c
index 76ef420a36..fc1ff9144c 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -31836,9 +31836,11 @@ draw_row_with_mouse_face (struct window *w, int 
start_x, struct glyph_row *row,
       return;
     }
 #endif
-#if defined (HAVE_GPM) || defined (MSDOS) || defined (WINDOWSNT)
+#if defined (HAVE_GPM) || defined (MSDOS) || defined (WINDOWSNT) ||     \
+    defined (DARWIN_OS)
   tty_draw_row_with_mouse_face (w, row, start_hpos, end_hpos, draw);
 #endif
+
 }
 
 /* Display the active region described by mouse_face_* according to DRAW.  */



reply via email to

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