From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Newsgroups: gmane.emacs.bugs Subject: bug#74854: [PATCH] Improve menu separator display on ttys slightly Date: Fri, 13 Dec 2024 18:24:24 +0100 Message-ID: References: <8634iry2vg.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="485"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 74854@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 13 18:26:35 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tM9Qw-000AVg-Jh for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 13 Dec 2024 18:26:34 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tM9QU-00085F-OT; Fri, 13 Dec 2024 12:26:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tM9QS-00084k-0b for bug-gnu-emacs@gnu.org; Fri, 13 Dec 2024 12:26:04 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tM9QR-0007Yc-0v for bug-gnu-emacs@gnu.org; Fri, 13 Dec 2024 12:26:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=V8OIcrPCUZxlwiKOK06KjB32Z2ioQPqDQI3WKKVDxMI=; b=CbP1DV5euckcyfenjswBYnI3cQCcpdIxMIJKiqzVWwXr0fdLDTgYZqB083KbtYYx9rc5XOKyXMARxKfo7yl1D2HjjU/Dzfb7wom0ngTOJSqZUECKs3cCs4oSBgXe6vokp1vmcHw8u0K5G/tcebZO2F8OraTRFuGq/QWpQKXKRzBqYECTPpBPLvLQd5QQyKjbxmRVK2yyd0t925+iFGUegwE4HDSPZbwTsxM80ri3u4I3sfukXzE/WNPx3u3AkgoshxU299ORogalxf5ICGs2mggR1p/Uk6VcsHknC+q5IX5Rj8rwuZuRkApESzB9AvU6U8e+WESYM+twgWPvZIVFCw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tM9QQ-0001fV-9y for bug-gnu-emacs@gnu.org; Fri, 13 Dec 2024 12:26:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 13 Dec 2024 17:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74854 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 74854-submit@debbugs.gnu.org id=B74854.17341107456380 (code B ref 74854); Fri, 13 Dec 2024 17:26:02 +0000 Original-Received: (at 74854) by debbugs.gnu.org; 13 Dec 2024 17:25:45 +0000 Original-Received: from localhost ([127.0.0.1]:44002 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tM9Q3-0001eb-D3 for submit@debbugs.gnu.org; Fri, 13 Dec 2024 12:25:44 -0500 Original-Received: from mail-ej1-f44.google.com ([209.85.218.44]:54781) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tM9Pw-0001eD-7J for 74854@debbugs.gnu.org; Fri, 13 Dec 2024 12:25:36 -0500 Original-Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-aa6a92f863cso396663866b.1 for <74854@debbugs.gnu.org>; Fri, 13 Dec 2024 09:25:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734110666; x=1734715466; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=V8OIcrPCUZxlwiKOK06KjB32Z2ioQPqDQI3WKKVDxMI=; b=aibAZYyQazp4NWuIjxa4TRcYM8afQXgAVcFdz0TKKbDfZeFU9bvFcbRaWVceciz2zR coN2huDEpLADqMMPcIyfB3Hvvz712S0SJlv0KUc4O5VGFj4R2n42lygpkl/XNJNzXVM8 bVDxaRAqOlUhHB1cTUmS6V97tNbtENzhMQs7nWBBZQdSnN6ai85UI21J7e8nu3+eEDAj fuZRlS48No9Uh8xWJHoLPvQSgd8Fy75QTMKCq7UTOccZzCyQyvVnedPk2ICCfpFIweWS 5z/r7oMW3j0TClVAsx9j0cCT7Jhn6ZdFM2wT/SYHzHVoQZc07hgYnT8rcXG5RmBp4RhV HKNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734110666; x=1734715466; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=V8OIcrPCUZxlwiKOK06KjB32Z2ioQPqDQI3WKKVDxMI=; b=ZxOf9ZyR47aLLs47x/E/aYEHhIrHLmXxf8ULfkcyXdI7zh1zLNnOicfcpAd3rYDVqM GZ3HyHqOHFNsAb9Dk6K6wNFMvhKL2pS9sWPdBKYhOk5QvQV6ZJceuSdkyoDXSHXVohM0 8xghlux1/oqA0EP/hws46GNmzC9YlVQe9NPpLxkmMFgXzu05sf9g2BjMAO6/gIovwXis k7UqqdunD33zj7GAYgK9u9eacBkalNH1l8l0XjhXFJQc3f1Hog96eMZCVhmr7wSUHjvk qqjLKUX3dFVCmiq33fAqPGXhYVf3/aeIxz3IqCzALI4qYhi3oCFd1MBtii2XRMKcmifv gLKQ== X-Gm-Message-State: AOJu0Yz8ImJwNVj8608UeVCj1es4uH62JOFp8U0qJugmEDw782u2MBvw KV1damk3faq/OvAqF4y1YXLWZTR6+F74U+leeF17RJjhNg6v0wmn7olh5Q== X-Gm-Gg: ASbGnctnpzGLmsuzmlk8t0onRaC2I81UC1NQehs3dRAWe1/73D1Qc7t/3C88jM0kcw7 sBeAKIvC23ElU4OQDbGT6ls67WV8bay4EZCDa6y1xw+1jXRc7mKIPbUNoNI9f79lFE4DIhBoK5q cCbl9JvwCaiyt1673nPNRvCXLjEq7/bpsuepMCVFyQfAiyhQokg3q0bdp6U0TgaKmR/hxe+Fdr+ hSIxe6s+jVd64mPWkR5z2CYC4Q81FFqjYfIAPS9+d53z9oBnANURodc7kJo5bfMB8a2sT2yFt6Y +xnU865GaPLv/15FoEfiRaHYY9asFRBYZQMObQ1O3jFJiHr8VA8gNYpUP8AJ X-Google-Smtp-Source: AGHT+IHHRnag3d5iulaHE1dfUiKipvUq3X7b3BH3vMDVpWb9uAB7OOebtHcC3YP6XHGhdYRBSQzG8g== X-Received: by 2002:a17:907:9705:b0:aab:75f1:e520 with SMTP id a640c23a62f3a-aab779b3b5fmr348475266b.34.1734110665778; Fri, 13 Dec 2024 09:24:25 -0800 (PST) Original-Received: from pro2 (p200300e0b7097800193cd38c2c718030.dip0.t-ipconnect.de. [2003:e0:b709:7800:193c:d38c:2c71:8030]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa66e2182f3sm874570166b.156.2024.12.13.09.24.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 09:24:25 -0800 (PST) In-Reply-To: <8634iry2vg.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 13 Dec 2024 18:16:51 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:296987 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > How about using alloca with 'width' as its argument? Good point, new patch attached. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Improve-menu-separator-display-on-ttys-slightly-bug-.patch >From 6c7c4623674646c33a7b4738de3533ccaa65c9ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerd=20M=C3=B6llmann?= Date: Fri, 13 Dec 2024 15:54:21 +0100 Subject: [PATCH] Improve menu separator display on ttys slightly (bug#74854) * src/xdisp.c (display_tty_menu_separator): New function displaying separators with '-', '=', or ' '. (display_tty_menu_item): Use it. --- src/xdisp.c | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/src/xdisp.c b/src/xdisp.c index 1bfc4bb1797..bbe4210d734 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -27249,6 +27249,35 @@ 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, + optionally using Unicode characters via display table entries would + be nice. Patches very welcome. */ + +static void +display_tty_menu_separator (struct it *it, const char *label, int width) +{ + USE_SAFE_ALLOCA; + char c; + if (strcmp (label, "--space") == 0) + c = ' '; + else if (strcmp (label, "--double-line") == 0) + c = '='; + else + c = '-'; + char *sep = SAFE_ALLOCA (width); + memset (sep, c, width - 1); + sep[width - 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); + SAFE_FREE (); +} + /* 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 +27352,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 +27363,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 --=-=-=--