bug-gnu-emacs
[Top][All Lists]
Advanced

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

Patch to emacs-21.2 enabling an underscore cursor


From: Dave Lambert
Subject: Patch to emacs-21.2 enabling an underscore cursor
Date: Fri, 05 Apr 2002 12:01:02 -0500

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 via email to

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