From: Alan Third <alan@idiocy.org>
To: "Mattias Engdegård" <mattiase@acm.org>
Cc: 45502@debbugs.gnu.org
Subject: bug#45502: [PATCH] Prettier key bindings in NS menu entries
Date: Mon, 28 Dec 2020 18:36:05 +0000 [thread overview]
Message-ID: <X+ollXMWCspOUptK@breton.holly.idiocy.org> (raw)
In-Reply-To: <A879EF2E-3B21-4C73-9253-02083031FCCF@acm.org>
On Mon, Dec 28, 2020 at 03:23:25PM +0100, Mattias Engdegård wrote:
> The NS port shows key bindings in a rather cluttered way, with the
> key in brackets directly after the menu entry. The Mac port of Emacs
> is much neater with the bindings all aligned at a common tab
> position. We could do the same, but having done some experiments I
> actually prefer a right-alignment of the keys. Proof-of-concept
> patch attached.
>
> The alignment is made by padding with spaces, and then with hair
> spaces for extra precision; the result is not perfect but probably
> better than what we have now. If I get some time, I might do an
> experiment with more precise formatting.
>
> > I'd wondered about using NSAttributedString and NSParagraphStyle to
> > set a tab stop at a specific pixel point, that should allow perfect
> > alignment, or, and this is a bit hackier, display the binding in a
> > monospace font. Then you could use (variable space font) spaces and
> > tabs to line up the start of the binding text, then use (monospace
> > font) spaces to align the bindings. That's maybe a bit too much work,
> > though, and I'm not at all knowledgeable about how NSAttributedStrings
> > actually work, so maybe it's impossible.
>
> It didn't look obvious how to do it, but I could use some help.
I'm not sure either, but I guess the tabstop thing would look
something like:
NSMutableParagraphStyle *p = [NSMutableParagraphStyle
defaultParagraphStyle];
NSArray *tabstops = [NSArray withObject:[[[NSTextTab alloc]
initWithTextAlignment:NSTextAlignmentRight
location:50 // This is probably in points.
options:nil];
[p setTabStops:tabstops];
NSAttributedString *s = [[NSAttributedString alloc]
initWithString:yourString
attributes:someDictionaryObjectIncludingTheParagraphStyle];
[releaseAllTheAllocedObjects];
I can never remember how to make dictionaries, so I'll leave that to
you to work out. ;)
Hopefully then all you have to do is set the string as the title and it will
be drawn with the correct tabstop. Maybe NSMenuItems are special and
it won't work, though.
--
Alan Third
next prev parent reply other threads:[~2020-12-28 18:36 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 [this message]
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
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=X+ollXMWCspOUptK@breton.holly.idiocy.org \
--to=alan@idiocy.org \
--cc=45502@debbugs.gnu.org \
--cc=mattiase@acm.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 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).