emacs-diffs
[Top][All Lists]
Advanced

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

master 63fd6c9 1/2: Support for (box . SIZE) 'cursor-type'


From: Eli Zaretskii
Subject: master 63fd6c9 1/2: Support for (box . SIZE) 'cursor-type'
Date: Fri, 7 Feb 2020 05:11:48 -0500 (EST)

branch: master
commit 63fd6c9ef050f8077823b3a45c841dc255257f3b
Author: Zajcev Evgeny <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Support for (box . SIZE) 'cursor-type'
    
    This allows control of the minimum size of a masked image under
    which the box cursor becomes hollow.
    * buffer.c (cursor-type): Add commentary about (box . SIZE)
    'cursor-type'.
    * xdisp.c (get_specified_cursor_type): Check for 'cursor-type'
    of the form (box . SIZE).
    (get_window_cursor_type): Check masked image size for
    (box . SIZE) 'cursor-type'.
    
    * doc/emacs/display.texi (Cursor Display):
    * doc/emacs/display.texi (Cursor Parameters): Add description
    of (box . SIZE) 'cursor-type'.
    
    * etc/NEWS: Mention the new (box . SIZE) 'cursor-type'.
---
 doc/emacs/display.texi  |  2 ++
 doc/lispref/frames.texi |  3 +++
 etc/NEWS                |  6 ++++++
 src/buffer.c            |  3 +++
 src/xdisp.c             | 28 ++++++++++++++--------------
 5 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index 8444aef..dc6fe3a 100644
--- a/doc/emacs/display.texi
+++ b/doc/emacs/display.texi
@@ -1654,6 +1654,8 @@ Customization}).  (The other attributes of this face have 
no effect;
 the text shown under the cursor is drawn using the frame's background
 color.)  To change its shape, customize the buffer-local variable
 @code{cursor-type}; possible values are @code{box} (the default),
+@code{(box . @var{SIZE})} (box cursor becoming a hollow box under
+masked images larger than @var{SIZE} pixels in either dimension),
 @code{hollow} (a hollow box), @code{bar} (a vertical bar), @code{(bar
 . @var{n})} (a vertical bar @var{n} pixels wide), @code{hbar} (a
 horizontal bar), @code{(hbar . @var{n})} (a horizontal bar @var{n}
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi
index 2bb505c..70ebe2e 100644
--- a/doc/lispref/frames.texi
+++ b/doc/lispref/frames.texi
@@ -2220,6 +2220,9 @@ How to display the cursor.  Legitimate values are:
 @table @code
 @item box
 Display a filled box.  (This is the default.)
+@item (box . @var{SIZE})
+Display a filled box.  However, display it as a hollow box if point is
+under masked image larger than @var{SIZE} pixels in either dimension.
 @item hollow
 Display a hollow box.
 @item nil
diff --git a/etc/NEWS b/etc/NEWS
index 6ab6a8a..2c5133e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -64,6 +64,12 @@ It was declared obsolete in Emacs 27.1.
 
 * Changes in Emacs 28.1
 
+** Support for '(box . SIZE)' cursor-type.
+By default, 'box' cursor always has a filled box shape.  Unless you
+specify cursor-type to be '(box . SIZE)'.  In such case, cursor
+becomes a hollow box if the point is under masked image larger than
+'SIZE' pixels in any dimension.
+
 
 * Editing Changes in Emacs 28.1
 
diff --git a/src/buffer.c b/src/buffer.c
index 5c65d4d..cc7d4e4 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -6247,6 +6247,9 @@ Values are interpreted as follows:
   t               use the cursor specified for the frame
   nil             don't display a cursor
   box             display a filled box cursor
+  (box . SIZE)    display a filled box cursor, but make it
+                  hollow if cursor is under masked image larger than
+                  SIZE pixels in either dimension.
   hollow          display a hollow box cursor
   bar             display a vertical bar cursor with default width
   (bar . WIDTH)   display a vertical bar cursor with width WIDTH
diff --git a/src/xdisp.c b/src/xdisp.c
index 68a504f..038b8e5 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -30741,14 +30741,6 @@ get_specified_cursor_type (Lisp_Object arg, int *width)
       return BAR_CURSOR;
     }
 
-  if (CONSP (arg)
-      && EQ (XCAR (arg), Qbar)
-      && RANGED_FIXNUMP (0, XCDR (arg), INT_MAX))
-    {
-      *width = XFIXNUM (XCDR (arg));
-      return BAR_CURSOR;
-    }
-
   if (EQ (arg, Qhbar))
     {
       *width = 2;
@@ -30756,11 +30748,16 @@ get_specified_cursor_type (Lisp_Object arg, int 
*width)
     }
 
   if (CONSP (arg)
-      && EQ (XCAR (arg), Qhbar)
       && RANGED_FIXNUMP (0, XCDR (arg), INT_MAX))
     {
       *width = XFIXNUM (XCDR (arg));
-      return HBAR_CURSOR;
+
+      if (EQ (XCAR (arg), Qbox))
+          return FILLED_BOX_CURSOR;
+      else if (EQ (XCAR (arg), Qbar))
+          return BAR_CURSOR;
+      else if (EQ (XCAR (arg), Qhbar))
+          return HBAR_CURSOR;
     }
 
   /* Treat anything unknown as "hollow box cursor".
@@ -30898,12 +30895,15 @@ get_window_cursor_type (struct window *w, struct 
glyph *glyph, int *width,
              struct image *img = IMAGE_OPT_FROM_ID (f, glyph->u.img_id);
              if (img != NULL && IMAGEP (img->spec))
                {
-                 /* Arbitrarily, interpret "Large" as >32x32 and >NxN
+                 /* Interpret "large" as >SIZExSIZE and >NxN
+                     where SIZE is the value from cursor-type in form (box . 
SIZE),
                     where N = size of default frame font size.
-                    This should cover most of the "tiny" icons people may use. 
 */
+                     So, setting cursor-type to (box . 32) should cover most of
+                     the "tiny" icons people may use.  */
                  if (!img->mask
-                     || img->width > max (32, WINDOW_FRAME_COLUMN_WIDTH (w))
-                     || img->height > max (32, WINDOW_FRAME_LINE_HEIGHT (w)))
+                      || (CONSP (BVAR (b, cursor_type))
+                          && img->width > max (*width, 
WINDOW_FRAME_COLUMN_WIDTH (w))
+                          && img->height > max (*width, 
WINDOW_FRAME_LINE_HEIGHT (w))))
                    cursor_type = HOLLOW_BOX_CURSOR;
                }
            }



reply via email to

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