unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* Patch to emacs-21.2 enabling an underscore cursor
@ 2002-04-05 17:01 Dave Lambert
  2002-04-06 17:31 ` Richard Stallman
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Lambert @ 2002-04-05 17:01 UTC (permalink / raw)



The patch below allows Emacs to produce an underscore-like cursor.
The underscore cursor is set by putting `(cursor-type . hbar)' in
default-frame-alist.  It supports variable heights, as 'bar cursor
does.

I've implemented the changes only for X: I don't know Win32, and
couldn't test it if I did.

Thanks,
Dave


diff -ru emacs-21.2/src/xfns.c emacs-21.2-fiddled/src/xfns.c
--- emacs-21.2/src/xfns.c	Fri Feb 22 10:56:32 2002
+++ emacs-21.2-fiddled/src/xfns.c	Sun Mar 31 15:48:41 2002
@@ -188,7 +188,7 @@
 
 Lisp_Object Qauto_raise;
 Lisp_Object Qauto_lower;
-Lisp_Object Qbar;
+Lisp_Object Qbar, Qhbar;
 Lisp_Object Qborder_color;
 Lisp_Object Qborder_width;
 Lisp_Object Qbox;
@@ -1730,6 +1730,19 @@
       type = BAR_CURSOR;
       *width = XINT (XCDR (arg));
     }
+  else if (EQ (arg, Qhbar))
+    {
+      type = HBAR_CURSOR;
+      *width = 2;
+    }
+  else if (CONSP (arg)
+	   && EQ (XCAR (arg), Qhbar)
+	   && INTEGERP (XCDR (arg))
+	   && XINT (XCDR (arg)) >= 0)
+    {
+      type = HBAR_CURSOR;
+      *width = XINT (XCDR (arg));
+    }
   else if (NILP (arg))
     type = NO_CURSOR;
   else
@@ -11450,6 +11463,8 @@
   staticpro (&Qauto_lower);
   Qbar = intern ("bar");
   staticpro (&Qbar);
+  Qhbar = intern ("hbar");
+  staticpro (&Qhbar);
   Qborder_color = intern ("border-color");
   staticpro (&Qborder_color);
   Qborder_width = intern ("border-width");
diff -ru emacs-21.2/src/xterm.c emacs-21.2-fiddled/src/xterm.c
--- emacs-21.2/src/xterm.c	Sat Mar 16 10:34:56 2002
+++ emacs-21.2-fiddled/src/xterm.c	Sun Mar 31 15:49:33 2002
@@ -452,7 +452,8 @@
 static void XTframe_rehighlight P_ ((struct frame *));
 static void x_frame_rehighlight P_ ((struct x_display_info *));
 static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
-static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int));
+static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int,
+				   enum text_cursor_kinds));
 static int x_intersect_rectangles P_ ((XRectangle *, XRectangle *,
 				       XRectangle *));
 static void expose_frame P_ ((struct frame *, int, int, int, int));
@@ -11206,10 +11207,11 @@
    --gerd.  */
 
 static void
-x_draw_bar_cursor (w, row, width)
+x_draw_bar_cursor (w, row, width, kind)
      struct window *w;
      struct glyph_row *row;
      int width;
+     enum text_cursor_kinds kind;
 {
   struct frame *f = XFRAME (w->frame);
   struct glyph *cursor_glyph;
@@ -11263,10 +11265,19 @@
       width = min (cursor_glyph->pixel_width, width);
   
       x_clip_to_row (w, row, gc, 0);
-      XFillRectangle (dpy, window, gc,
-		      WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x),
-		      WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y),
-		      width, row->height);
+      if (kind == BAR_CURSOR)
+	  XFillRectangle (dpy, window, gc,
+			  WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x),
+			  WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y),
+			  width, row->height);
+      else
+	  XFillRectangle (dpy, window, gc,
+			  WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x),
+			  WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y +
+						   row->height - width),
+			  cursor_glyph->pixel_width,
+			  width);
+
       XSetClipMask (dpy, gc, None);
     }
 }
@@ -11577,7 +11588,11 @@
 	  break;
 
 	case BAR_CURSOR:
-	  x_draw_bar_cursor (w, glyph_row, new_cursor_width);
+	  x_draw_bar_cursor (w, glyph_row, new_cursor_width, BAR_CURSOR);
+	  break;
+
+	case HBAR_CURSOR:
+	    x_draw_bar_cursor (w, glyph_row, new_cursor_width, HBAR_CURSOR);
 	  break;
 
 	case NO_CURSOR:
diff -ru emacs-21.2/src/xterm.h emacs-21.2-fiddled/src/xterm.h
--- emacs-21.2/src/xterm.h	Fri Feb 22 10:51:48 2002
+++ emacs-21.2-fiddled/src/xterm.h	Sun Mar 31 15:42:25 2002
@@ -112,7 +112,8 @@
   NO_CURSOR = -1,
   FILLED_BOX_CURSOR,
   HOLLOW_BOX_CURSOR,
-  BAR_CURSOR
+  BAR_CURSOR,
+  HBAR_CURSOR
 };
 
 /* Structure recording X pixmap and reference count.

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

* Re: Patch to emacs-21.2 enabling an underscore cursor
  2002-04-05 17:01 Patch to emacs-21.2 enabling an underscore cursor Dave Lambert
@ 2002-04-06 17:31 ` Richard Stallman
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Stallman @ 2002-04-06 17:31 UTC (permalink / raw)
  Cc: bug-gnu-emacs

Thanks very much--this seems like something some users will want.
Would you be willing to sign a disclaimer for your changes so we can
use it?

    I've implemented the changes only for X: I don't know Win32, and
    couldn't test it if I did.

I am glad you couldn't test it; I couldn't either.  But you might not
want to call it "Win".  In hacker terminology, calling something a
"win" is a form of praise.  If you wish to praise Microsoft Windows,
you're free to do so; but if you don't, then you might want to think
twice about using the term "Win32".

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

end of thread, other threads:[~2002-04-06 17:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-05 17:01 Patch to emacs-21.2 enabling an underscore cursor Dave Lambert
2002-04-06 17:31 ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).