unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dave Lambert <dlambert@acm.org>
Subject: Patch to emacs-21.2 enabling an underscore cursor
Date: Fri, 05 Apr 2002 12:01:02 -0500	[thread overview]
Message-ID: <E16tX5C-0002cd-00@fencepost.gnu.org> (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.

             reply	other threads:[~2002-04-05 17:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-05 17:01 Dave Lambert [this message]
2002-04-06 17:31 ` Patch to emacs-21.2 enabling an underscore cursor Richard Stallman

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E16tX5C-0002cd-00@fencepost.gnu.org \
    --to=dlambert@acm.org \
    /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 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).