aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Möllmann2025-01-26 11:31:32 +0100
committerGerd Möllmann2025-01-26 16:41:01 +0100
commit4e78a3e117f4ca0b6b9f3b7a2d7919cb5b2e0295 (patch)
tree670d6de7ac8f3cb465c74fb2f1c97e43ca5f8fc2 /src
parent01d93d56cd469ddb45d142da948caef9f2dc1a3f (diff)
downloademacs-4e78a3e117f4ca0b6b9f3b7a2d7919cb5b2e0295.tar.gz
emacs-4e78a3e117f4ca0b6b9f3b7a2d7919cb5b2e0295.zip
Display separators on tty menus with display table entries
* src/xdisp.c (display_tty_menu_separator): Lookup separator char in standard-display-table, make a string, and display that using display_string. * src/xdisp.c (display_tty_menu_separator_char): New function. (display_tty_menu_separator): Use it. * lisp/disp-table.el (display-table): Increase from 12 to 18. (box-double-vertical, box-double-horizontal, box-double-down-right) (box-double-down-left, box-double-up-right, box-double-up-left): New symbols for extra slots. (display-table-slot, set-display-table-slot): Change doc string. (describe-display-table): Describe new slots. (standard-display-unicode-special-glyphs): Define new slots. * src/disptab.h (DISP_TABLE_P): Add enumerators. (DISP_TABLE_EXTRA_SLOTS): Define based on enum box. * src/dispnew.c (produce_box_glyphs): Add new enumerators to switch to make it exhaustive. * src/xdisp.c (display_tty_menu_separator): Use BOX_DOUBLE_HORIZONTAL for '=' if present. * doc/lispref/display.texi: Add documentation. * etc/NEWS: Mention in NEWS.
Diffstat (limited to 'src')
-rw-r--r--src/dispnew.c7
-rw-r--r--src/disptab.h10
-rw-r--r--src/xdisp.c39
3 files changed, 39 insertions, 17 deletions
diff --git a/src/dispnew.c b/src/dispnew.c
index d28dc3d54fa..d1e731e69f8 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -3614,6 +3614,13 @@ produce_box_glyphs (enum box box, struct glyph_row *row, int x, int n,
3614 case BOX_UP_LEFT: 3614 case BOX_UP_LEFT:
3615 dflt = '+'; 3615 dflt = '+';
3616 break; 3616 break;
3617 case BOX_DOUBLE_VERTICAL:
3618 case BOX_DOUBLE_HORIZONTAL:
3619 case BOX_DOUBLE_DOWN_RIGHT:
3620 case BOX_DOUBLE_DOWN_LEFT:
3621 case BOX_DOUBLE_UP_RIGHT:
3622 case BOX_DOUBLE_UP_LEFT:
3623 emacs_abort ();
3617 } 3624 }
3618 3625
3619 /* FIXME/tty: some face for the border. */ 3626 /* FIXME/tty: some face for the border. */
diff --git a/src/disptab.h b/src/disptab.h
index 8db9a06d2f4..5ab73715e6c 100644
--- a/src/disptab.h
+++ b/src/disptab.h
@@ -28,7 +28,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
28 && EQ (XCHAR_TABLE (obj)->purpose, Qdisplay_table) \ 28 && EQ (XCHAR_TABLE (obj)->purpose, Qdisplay_table) \
29 && CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (obj)) == DISP_TABLE_EXTRA_SLOTS) 29 && CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (obj)) == DISP_TABLE_EXTRA_SLOTS)
30 30
31#define DISP_TABLE_EXTRA_SLOTS 12
32#define DISP_TRUNC_GLYPH(dp) ((dp)->extras[0]) 31#define DISP_TRUNC_GLYPH(dp) ((dp)->extras[0])
33#define DISP_CONTINUE_GLYPH(dp) ((dp)->extras[1]) 32#define DISP_CONTINUE_GLYPH(dp) ((dp)->extras[1])
34#define DISP_ESCAPE_GLYPH(dp) ((dp)->extras[2]) 33#define DISP_ESCAPE_GLYPH(dp) ((dp)->extras[2])
@@ -43,7 +42,14 @@ enum box
43 BOX_DOWN_RIGHT, 42 BOX_DOWN_RIGHT,
44 BOX_DOWN_LEFT, 43 BOX_DOWN_LEFT,
45 BOX_UP_RIGHT, 44 BOX_UP_RIGHT,
46 BOX_UP_LEFT 45 BOX_UP_LEFT,
46 BOX_DOUBLE_VERTICAL,
47 BOX_DOUBLE_HORIZONTAL,
48 BOX_DOUBLE_DOWN_RIGHT,
49 BOX_DOUBLE_DOWN_LEFT,
50 BOX_DOUBLE_UP_RIGHT,
51 BOX_DOUBLE_UP_LEFT
52#define DISP_TABLE_EXTRA_SLOTS (BOX_DOUBLE_UP_LEFT + 1)
47}; 53};
48 54
49extern Lisp_Object disp_char_vector (struct Lisp_Char_Table *, int); 55extern Lisp_Object disp_char_vector (struct Lisp_Char_Table *, int);
diff --git a/src/xdisp.c b/src/xdisp.c
index 2676e982c9e..5b5cb3849fc 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -27272,33 +27272,42 @@ deep_copy_glyph_row (struct frame *f, struct glyph_row *to, struct glyph_row *fr
27272 fill_up_frame_row_with_spaces (f, to, to_used); 27272 fill_up_frame_row_with_spaces (f, to, to_used);
27273} 27273}
27274 27274
27275/* Return the character to be used for displaying a tty menu separator.
27276 C is the character to be used by default. BOX is the display table
27277 entry for the character to be used instead. It is looked up in
27278 standard-display-table. Value is the character to use. */
27279
27280static int
27281display_tty_menu_separator_char (int c, enum box box)
27282{
27283 if (DISP_TABLE_P (Vstandard_display_table))
27284 {
27285 struct Lisp_Char_Table *dp = XCHAR_TABLE (Vstandard_display_table);
27286 Lisp_Object gc = dp->extras[box];
27287 if (GLYPH_CODE_P (gc))
27288 c = GLYPH_CODE_CHAR (gc);
27289 }
27290 return c;
27291}
27292
27275/* Produce glyphs for a menu separator on a tty. 27293/* Produce glyphs for a menu separator on a tty.
27276 27294
27277 FIXME: This is only a "good enough for now" implementation of menu 27295 FIXME: This is only a "good enough for now" implementation of menu
27278 separators as described in the Elisp info manual. We should probably 27296 separators as described in the Elisp info manual. We should probably
27279 ignore menu separators when computing the width of a menu. Secondly, 27297 ignore menu separators when computing the width of a menu. */
27280 optionally using Unicode characters via display table entries would
27281 be nice. Patches very welcome. */
27282 27298
27283static void 27299static void
27284display_tty_menu_separator (struct it *it, const char *label, int width) 27300display_tty_menu_separator (struct it *it, const char *label, int width)
27285{ 27301{
27286 USE_SAFE_ALLOCA; 27302 int c;
27287 char c;
27288 if (strcmp (label, "--space") == 0) 27303 if (strcmp (label, "--space") == 0)
27289 c = ' '; 27304 c = ' ';
27290 else if (strcmp (label, "--double-line") == 0) 27305 else if (strcmp (label, "--double-line") == 0)
27291 c = '='; 27306 c = display_tty_menu_separator_char ('=', BOX_DOUBLE_HORIZONTAL);
27292 else 27307 else
27293 c = '-'; 27308 c = display_tty_menu_separator_char ('-', BOX_HORIZONTAL);
27294 char *sep = SAFE_ALLOCA (width); 27309 Lisp_Object sep = Fmake_string (make_fixnum (width - 1), make_fixnum (c), Qt);
27295 memset (sep, c, width - 1); 27310 display_string ((char *) SDATA (sep), Qnil, Qnil, 0, 0, it, width, -1, -1, 1);
27296 sep[width - 1] = 0;
27297 display_string (sep, Qnil, Qnil, 0, 0, it, width - 1, width - 1,
27298 FRAME_COLS (it->f) - 1, -1);
27299 display_string (" ", Qnil, Qnil, 0, 0, it, 1, 0,
27300 FRAME_COLS (it->f) - 1, -1);
27301 SAFE_FREE ();
27302} 27311}
27303 27312
27304/* Display one menu item on a TTY, by overwriting the glyphs in the 27313/* Display one menu item on a TTY, by overwriting the glyphs in the