From: "Gerd Möllmann" <gerd.moellmann@gmail.com>
To: 74854@debbugs.gnu.org
Subject: bug#74854: [PATCH] Improve menu separator display on ttys slightly
Date: Fri, 13 Dec 2024 16:09:30 +0100 [thread overview]
Message-ID: <m2frmrfwlx.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1030 bytes --]
Tags: patch
Improvements:
1. Separators are displayed as lines over the whole menu, not
only as "--".
2. Support for 3 types of separators: --space -> line
of spaces, --double-line -> line of '=', others -> line of '-'
In GNU Emacs 31.0.50 (build 15, aarch64-apple-darwin24.2.0) of
2024-12-13 built on pro2
Repository revision: 7bf7e339a4ae5b253623ee62b71ba50786339490
Repository branch: cl-packages
System Description: macOS 15.2
Configured using:
'configure --without-ns --cache-file
/var/folders/1d/k_6t25f94sl83szqbf8gpkrh0000gn/T//config.cache.cl-packages
--with-native-compilation --with-mps=yes CC=clang
'CFLAGS=-Wgnu-imaginary-constant -Wunused-result -g
-fno-omit-frame-pointer -F
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
-Wno-ignored-attributes -Wno-flag-enum -Wno-missing-method-return-type
-Wno-variadic-macros -Wno-strict-prototypes -Wno-availability
-Wno-nullability-completeness' --prefix=/Users/gerd/.local'
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Improve-menu-separator-display-on-ttys-slightly.patch --]
[-- Type: text/patch, Size: 3432 bytes --]
From 18e01b73e72b8aa36bd995d29317e9834c53f868 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gerd=20M=C3=B6llmann?= <gerd@gnu.org>
Date: Fri, 13 Dec 2024 15:54:21 +0100
Subject: [PATCH] Improve menu separator display on ttys slightly
* src/xdisp.c (display_tty_menu_separator): New function displaying
separators with '-', '=', or ' '.
(display_tty_menu_item): Use it.
---
src/xdisp.c | 44 +++++++++++++++++++++++++++++++++-----------
1 file changed, 33 insertions(+), 11 deletions(-)
diff --git a/src/xdisp.c b/src/xdisp.c
index 1bfc4bb1797..e9f9fcc16f6 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -27249,6 +27249,34 @@ deep_copy_glyph_row (struct frame *f, struct glyph_row *to, struct glyph_row *fr
fill_up_frame_row_with_spaces (f, to, to_used);
}
+/* Produce glyphs for a menu separator on a tty.
+
+ FIXME: This is only a "good enough for now" implementation of
+ menu separators as described in the Elisp info manual. We
+ should probably ignore menu separators when computing the width
+ of a menu. Secondly, we could draw actual horizontal lines of
+ different styles on ttys, maybe optionally using Unicode
+ characters via display table entries. Patches very welcome. */
+
+static void
+display_tty_menu_separator (struct it *it, const char *label, int width)
+{
+ static char sep[200];
+ char c;
+ if (strcmp (label, "--space") == 0)
+ c = ' ';
+ else if (strcmp (label, "--double-line") == 0)
+ c = '=';
+ else
+ c = '-';
+ memset (sep, c, sizeof sep);
+ sep[sizeof sep - 1] = 0;
+ display_string (sep, Qnil, Qnil, 0, 0, it, width - 1, width - 1,
+ FRAME_COLS (it->f) - 1, -1);
+ display_string (" ", Qnil, Qnil, 0, 0, it, 1, 0,
+ FRAME_COLS (it->f) - 1, -1);
+}
+
/* Display one menu item on a TTY, by overwriting the glyphs in the
frame F's desired glyph matrix with glyphs produced from the menu
item text. Called from term.c to display TTY drop-down menus one
@@ -27323,6 +27351,7 @@ display_tty_menu_item (const char *item_text, int width, int face_id,
/* Pad with a space on the left. */
display_string (" ", Qnil, Qnil, 0, 0, &it, 1, 0, FRAME_COLS (f) - 1, -1);
width--;
+
/* Display the menu item, pad with spaces to WIDTH. */
if (submenu)
{
@@ -27333,20 +27362,13 @@ display_tty_menu_item (const char *item_text, int width, int face_id,
display_string (" >", Qnil, Qnil, 0, 0, &it, width, 0,
FRAME_COLS (f) - 1, -1);
}
- else if (menu_separator_name_p (item_text))
+ else if (menu_separator_name_p (item_text))
{
- /* FIXME: This is only a "good enough for now" implementation of
- menu separators as described in the Elisp info manual. We
- should probably ignore menu separators when computing the width
- of a menu. Secondly, we could draw actual horizontal lines of
- different styles on ttys, maybe optionally using Unicode
- characters via display table entries. Patches very welcome. */
- display_string ("--", Qnil, Qnil, 0, 0, &it, width, 0,
- FRAME_COLS (f) - 1, -1);
+ display_tty_menu_separator (&it, item_text, width);
}
else
- display_string (item_text, Qnil, Qnil, 0, 0, &it,
- width, 0, FRAME_COLS (f) - 1, -1);
+ display_string (item_text, Qnil, Qnil, 0, 0, &it, width, 0,
+ FRAME_COLS (f) - 1, -1);
row->used[TEXT_AREA] = max (saved_used, row->used[TEXT_AREA]);
row->truncated_on_right_p = saved_truncated;
--
2.47.1
next reply other threads:[~2024-12-13 15:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-13 15:09 Gerd Möllmann [this message]
2024-12-13 16:16 ` bug#74854: [PATCH] Improve menu separator display on ttys slightly Eli Zaretskii
2024-12-13 17:24 ` Gerd Möllmann
2024-12-14 7:15 ` Eli Zaretskii
2024-12-14 7:25 ` Gerd Möllmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2frmrfwlx.fsf@gmail.com \
--to=gerd.moellmann@gmail.com \
--cc=74854@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.