From 6406d198e9f3f5b2d93987ed0fd4fe22bd590624 Mon Sep 17 00:00:00 2001 From: Zajcev Evgeny Date: Mon, 27 Jan 2020 15:49:46 +0300 Subject: [PATCH] * Support for (box . WIDTH) `cursor-type' Before this commit, block cursor becomes hollow under "large" masked images. Notion for "large" was hardcoded to be image larger then 32x32 in any dimension. This patch allows user to define his own notion for "large" image, taking full control of block cursor look under masked images. With cursor-type equal to `box' cursor will always be block under masked images. This differs from former behavior for box cursor. To get former behavior, set `cursor-type' to (box . 32) --- src/buffer.c | 4 ++++ src/xdisp.c | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index 80eaa97..4c47e9b 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -6247,6 +6247,9 @@ from (abs POSITION). If POSITION is positive, point was at the front t use the cursor specified for the frame nil don't display a cursor box display a filled box cursor + (box . WIDTH) display a filled box cursor, but make it + hollow if cursor is under masked image larger then + WIDTH in either dimention. 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 @@ -6255,6 +6258,7 @@ from (abs POSITION). If POSITION is positive, point was at the front ANYTHING ELSE display a hollow box cursor WIDTH and HEIGHT can't exceed the frame's canonical character size. +Except for (box . WIDTH) case. When the buffer is displayed in a non-selected window, the cursor's appearance is instead controlled by the variable diff --git a/src/xdisp.c b/src/xdisp.c index 3080f89..371589c 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -30683,6 +30683,14 @@ get_specified_cursor_type (Lisp_Object arg, int *width) if (EQ (arg, Qbox)) return FILLED_BOX_CURSOR; + if (CONSP (arg) + && EQ (XCAR (arg), Qbox) + && RANGED_FIXNUMP (0, XCDR (arg), INT_MAX)) + { + *width = XFIXNUM (XCDR (arg)); + return FILLED_BOX_CURSOR; + } + if (EQ (arg, Qhollow)) return HOLLOW_BOX_CURSOR; @@ -30849,12 +30857,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 >WIDTHxWIDTH and >NxN + where WIDTH is the value from cursor-type in form (box . WIDTH), 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; } } -- 2.7.4