unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: Alan Third <alan@idiocy.org>
Cc: 45502@debbugs.gnu.org, "Daniel Martín" <mardani29@yahoo.es>
Subject: bug#45502: [PATCH] Prettier key bindings in NS menu entries
Date: Tue, 29 Dec 2020 18:34:20 +0100	[thread overview]
Message-ID: <C13972A1-D792-46DA-B687-6223FB8AFAAF@acm.org> (raw)
In-Reply-To: <X+tQSuwIN12UDrad@breton.holly.idiocy.org>

[-- Attachment #1: Type: text/plain, Size: 955 bytes --]

29 dec. 2020 kl. 16.50 skrev Alan Third <alan@idiocy.org>:

> As far as I'm aware GNUstep is able to display the bindings correctly
> no matter how many characters they have, so we don't need the
> work-around. And I'm hoping that we'll be able to get GNUstep menus
> working again in the future.

All right, I've done what I think you meant and pushed to master; please tell me if I'm on the wrong track.

Here is a proof-of-concept patch for using fancy symbols instead of <right> etc.
Not production quality because (1) it's obviously ugly code, (2) I'm unsure about the PgUp/PgDn/Home/End symbols and (3) it only works with modifiers if the patch in bug#45536 is applied (which of course I think it should), but at least it gives a feeling for whether it's a good thing to do or not.

There is also the question whether to follow the platform convention of always using upper case letters, with an explicit Shift modifier if necessary.


[-- Attachment #2: key-symbols.diff --]
[-- Type: application/octet-stream, Size: 4796 bytes --]

diff --git a/src/nsmenu.m b/src/nsmenu.m
index d5321dcdc6..36566e9a11 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -552,9 +552,76 @@ - (void)fillWithWidgetValue: (void *)wvptr
         maxNameWidth = MAX(maxNameWidth, nameSize.width);
         if (wv->key)
           {
-            NSString *key = [NSString stringWithUTF8String: skipspc (wv->key)];
+            NSMutableString *key =
+              [NSMutableString stringWithUTF8String: skipspc (wv->key)];
+            [key replaceOccurrencesOfString: @"<backspace>"
+                                 withString: @"⌫"
+                                    options: NSLiteralSearch
+                                      range: NSMakeRange (0, [key length])];
+            [key replaceOccurrencesOfString: @"DEL"
+                                 withString: @"⌫"
+                                    options: NSLiteralSearch
+                                      range: NSMakeRange (0, [key length])];
+            [key replaceOccurrencesOfString: @"<deletechar>"
+                                 withString: @"⌦"
+                                    options: NSLiteralSearch
+                                      range: NSMakeRange (0, [key length])];
+            [key replaceOccurrencesOfString: @"<return>"
+                                 withString: @"↩"
+                                    options: NSLiteralSearch
+                                      range: NSMakeRange (0, [key length])];
+            [key replaceOccurrencesOfString: @"RET"
+                                 withString: @"↩"
+                                    options: NSLiteralSearch
+                                      range: NSMakeRange (0, [key length])];
+            [key replaceOccurrencesOfString: @"<left>"
+                                 withString: @"←"
+                                    options: NSLiteralSearch
+                                      range: NSMakeRange (0, [key length])];
+            [key replaceOccurrencesOfString: @"<right>"
+                                 withString: @"→"
+                                    options: NSLiteralSearch
+                                      range: NSMakeRange (0, [key length])];
+            [key replaceOccurrencesOfString: @"<up>"
+                                 withString: @"↑"
+                                    options: NSLiteralSearch
+                                      range: NSMakeRange (0, [key length])];
+            [key replaceOccurrencesOfString: @"<down>"
+                                 withString: @"↓"
+                                    options: NSLiteralSearch
+                                      range: NSMakeRange (0, [key length])];
+            [key replaceOccurrencesOfString: @"<prior>"
+                                 withString: @"⇞"
+                                    options: NSLiteralSearch
+                                      range: NSMakeRange (0, [key length])];
+            [key replaceOccurrencesOfString: @"<next>"
+                                 withString: @"⇟"
+                                    options: NSLiteralSearch
+                                      range: NSMakeRange (0, [key length])];
+            [key replaceOccurrencesOfString: @"<home>"
+                                 withString: @"↖"
+                                    options: NSLiteralSearch
+                                      range: NSMakeRange (0, [key length])];
+            [key replaceOccurrencesOfString: @"<end>"
+                                 withString: @"↘"
+                                    options: NSLiteralSearch
+                                      range: NSMakeRange (0, [key length])];
+            [key replaceOccurrencesOfString: @"<tab>"
+                                 withString: @"⇥"
+                                    options: NSLiteralSearch
+                                      range: NSMakeRange (0, [key length])];
+            [key replaceOccurrencesOfString: @"TAB"
+                                 withString: @"⇥"
+                                    options: NSLiteralSearch
+                                      range: NSMakeRange (0, [key length])];
+            [key replaceOccurrencesOfString: @"<backtab>"
+                                 withString: @"⇤"
+                                    options: NSLiteralSearch
+                                      range: NSMakeRange (0, [key length])];
             NSSize keySize = [key sizeWithAttributes: font_attribs];
             maxKeyWidth = MAX(maxKeyWidth, keySize.width);
+            Lisp_Object newkey = build_string ([key UTF8String]);
+            wv->key = SSDATA (newkey);
           }
       }
 

  reply	other threads:[~2020-12-29 17:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-28 14:23 bug#45502: [PATCH] Prettier key bindings in NS menu entries Mattias Engdegård
2020-12-28 18:36 ` Alan Third
2020-12-29 12:02   ` Mattias Engdegård
2020-12-29 13:53     ` Alan Third
2020-12-29 14:41       ` Mattias Engdegård
2020-12-29 15:50         ` Alan Third
2020-12-29 17:34           ` Mattias Engdegård [this message]
2020-12-29 21:24             ` Alan Third
2020-12-29 22:53               ` Mattias Engdegård
2020-12-29 23:49                 ` Alan Third
2020-12-30 12:19                   ` Mattias Engdegård
2020-12-30 12:46                     ` Alan Third
2020-12-30 13:09                       ` Alan Third
2020-12-30 15:53                         ` Mattias Engdegård
2020-12-30 13:12                       ` Mattias Engdegård
2020-12-28 22:46 ` Unknown

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C13972A1-D792-46DA-B687-6223FB8AFAAF@acm.org \
    --to=mattiase@acm.org \
    --cc=45502@debbugs.gnu.org \
    --cc=alan@idiocy.org \
    --cc=mardani29@yahoo.es \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).