aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZajcev Evgeny2020-01-27 15:49:46 +0300
committerEli Zaretskii2020-02-07 12:00:14 +0200
commit63fd6c9ef050f8077823b3a45c841dc255257f3b (patch)
treeeeb5071fe9162229d658d46a238b2fe95af642c3
parentc4be80112556e06bd7e92138e44051cc8c62e709 (diff)
downloademacs-63fd6c9ef050f8077823b3a45c841dc255257f3b.tar.gz
emacs-63fd6c9ef050f8077823b3a45c841dc255257f3b.zip
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'.
-rw-r--r--doc/emacs/display.texi2
-rw-r--r--doc/lispref/frames.texi3
-rw-r--r--etc/NEWS6
-rw-r--r--src/buffer.c3
-rw-r--r--src/xdisp.c28
5 files changed, 28 insertions, 14 deletions
diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index 8444aef3bdd..dc6fe3a0327 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;
1654the text shown under the cursor is drawn using the frame's background 1654the text shown under the cursor is drawn using the frame's background
1655color.) To change its shape, customize the buffer-local variable 1655color.) To change its shape, customize the buffer-local variable
1656@code{cursor-type}; possible values are @code{box} (the default), 1656@code{cursor-type}; possible values are @code{box} (the default),
1657@code{(box . @var{SIZE})} (box cursor becoming a hollow box under
1658masked images larger than @var{SIZE} pixels in either dimension),
1657@code{hollow} (a hollow box), @code{bar} (a vertical bar), @code{(bar 1659@code{hollow} (a hollow box), @code{bar} (a vertical bar), @code{(bar
1658. @var{n})} (a vertical bar @var{n} pixels wide), @code{hbar} (a 1660. @var{n})} (a vertical bar @var{n} pixels wide), @code{hbar} (a
1659horizontal bar), @code{(hbar . @var{n})} (a horizontal bar @var{n} 1661horizontal bar), @code{(hbar . @var{n})} (a horizontal bar @var{n}
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi
index 2bb505c1c7a..70ebe2e87d7 100644
--- a/doc/lispref/frames.texi
+++ b/doc/lispref/frames.texi
@@ -2220,6 +2220,9 @@ How to display the cursor. Legitimate values are:
2220@table @code 2220@table @code
2221@item box 2221@item box
2222Display a filled box. (This is the default.) 2222Display a filled box. (This is the default.)
2223@item (box . @var{SIZE})
2224Display a filled box. However, display it as a hollow box if point is
2225under masked image larger than @var{SIZE} pixels in either dimension.
2223@item hollow 2226@item hollow
2224Display a hollow box. 2227Display a hollow box.
2225@item nil 2228@item nil
diff --git a/etc/NEWS b/etc/NEWS
index 6ab6a8aab3b..2c5133e1d24 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -64,6 +64,12 @@ It was declared obsolete in Emacs 27.1.
64 64
65* Changes in Emacs 28.1 65* Changes in Emacs 28.1
66 66
67** Support for '(box . SIZE)' cursor-type.
68By default, 'box' cursor always has a filled box shape. Unless you
69specify cursor-type to be '(box . SIZE)'. In such case, cursor
70becomes a hollow box if the point is under masked image larger than
71'SIZE' pixels in any dimension.
72
67 73
68* Editing Changes in Emacs 28.1 74* Editing Changes in Emacs 28.1
69 75
diff --git a/src/buffer.c b/src/buffer.c
index 5c65d4d4d19..cc7d4e4817c 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -6247,6 +6247,9 @@ Values are interpreted as follows:
6247 t use the cursor specified for the frame 6247 t use the cursor specified for the frame
6248 nil don't display a cursor 6248 nil don't display a cursor
6249 box display a filled box cursor 6249 box display a filled box cursor
6250 (box . SIZE) display a filled box cursor, but make it
6251 hollow if cursor is under masked image larger than
6252 SIZE pixels in either dimension.
6250 hollow display a hollow box cursor 6253 hollow display a hollow box cursor
6251 bar display a vertical bar cursor with default width 6254 bar display a vertical bar cursor with default width
6252 (bar . WIDTH) display a vertical bar cursor with width WIDTH 6255 (bar . WIDTH) display a vertical bar cursor with width WIDTH
diff --git a/src/xdisp.c b/src/xdisp.c
index 68a504fb2d4..038b8e53669 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -30741,14 +30741,6 @@ get_specified_cursor_type (Lisp_Object arg, int *width)
30741 return BAR_CURSOR; 30741 return BAR_CURSOR;
30742 } 30742 }
30743 30743
30744 if (CONSP (arg)
30745 && EQ (XCAR (arg), Qbar)
30746 && RANGED_FIXNUMP (0, XCDR (arg), INT_MAX))
30747 {
30748 *width = XFIXNUM (XCDR (arg));
30749 return BAR_CURSOR;
30750 }
30751
30752 if (EQ (arg, Qhbar)) 30744 if (EQ (arg, Qhbar))
30753 { 30745 {
30754 *width = 2; 30746 *width = 2;
@@ -30756,11 +30748,16 @@ get_specified_cursor_type (Lisp_Object arg, int *width)
30756 } 30748 }
30757 30749
30758 if (CONSP (arg) 30750 if (CONSP (arg)
30759 && EQ (XCAR (arg), Qhbar)
30760 && RANGED_FIXNUMP (0, XCDR (arg), INT_MAX)) 30751 && RANGED_FIXNUMP (0, XCDR (arg), INT_MAX))
30761 { 30752 {
30762 *width = XFIXNUM (XCDR (arg)); 30753 *width = XFIXNUM (XCDR (arg));
30763 return HBAR_CURSOR; 30754
30755 if (EQ (XCAR (arg), Qbox))
30756 return FILLED_BOX_CURSOR;
30757 else if (EQ (XCAR (arg), Qbar))
30758 return BAR_CURSOR;
30759 else if (EQ (XCAR (arg), Qhbar))
30760 return HBAR_CURSOR;
30764 } 30761 }
30765 30762
30766 /* Treat anything unknown as "hollow box cursor". 30763 /* Treat anything unknown as "hollow box cursor".
@@ -30898,12 +30895,15 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
30898 struct image *img = IMAGE_OPT_FROM_ID (f, glyph->u.img_id); 30895 struct image *img = IMAGE_OPT_FROM_ID (f, glyph->u.img_id);
30899 if (img != NULL && IMAGEP (img->spec)) 30896 if (img != NULL && IMAGEP (img->spec))
30900 { 30897 {
30901 /* Arbitrarily, interpret "Large" as >32x32 and >NxN 30898 /* Interpret "large" as >SIZExSIZE and >NxN
30899 where SIZE is the value from cursor-type in form (box . SIZE),
30902 where N = size of default frame font size. 30900 where N = size of default frame font size.
30903 This should cover most of the "tiny" icons people may use. */ 30901 So, setting cursor-type to (box . 32) should cover most of
30902 the "tiny" icons people may use. */
30904 if (!img->mask 30903 if (!img->mask
30905 || img->width > max (32, WINDOW_FRAME_COLUMN_WIDTH (w)) 30904 || (CONSP (BVAR (b, cursor_type))
30906 || img->height > max (32, WINDOW_FRAME_LINE_HEIGHT (w))) 30905 && img->width > max (*width, WINDOW_FRAME_COLUMN_WIDTH (w))
30906 && img->height > max (*width, WINDOW_FRAME_LINE_HEIGHT (w))))
30907 cursor_type = HOLLOW_BOX_CURSOR; 30907 cursor_type = HOLLOW_BOX_CURSOR;
30908 } 30908 }
30909 } 30909 }