Mercurial > emacs
changeset 101353:08e158d75ee0
* nsmenu.m (EmacsMenu-parseKeyEquiv:, addItemWithWidgetValue:): Display all shortcuts, including those w/o super modifier.
author | Adrian Robert <Adrian.B.Robert@gmail.com> |
---|---|
date | Thu, 22 Jan 2009 12:23:47 +0000 |
parents | 913b00d24272 |
children | 8802a9b050fb |
files | src/ChangeLog src/nsmenu.m |
diffstat | 2 files changed, 19 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Thu Jan 22 11:41:24 2009 +0000 +++ b/src/ChangeLog Thu Jan 22 12:23:47 2009 +0000 @@ -3,6 +3,9 @@ * nsterm.m (EmavsView-keyDown:): Treat nil as Qnone for ns_alternate_modifier. (Bug#1217) + * nsmenu.m (EmacsMenu-parseKeyEquiv:, addItemWithWidgetValue:): + Display all shortcuts, including those w/o super modifier. + 2009-01-22 Chong Yidong <cyd@stupidchicken.com> * fileio.c (Vwrite_region_post_annotation_function)
--- a/src/nsmenu.m Thu Jan 22 11:41:24 2009 +0000 +++ b/src/nsmenu.m Thu Jan 22 12:23:47 2009 +0000 @@ -589,21 +589,27 @@ } -/* parse a widget_value's key rep (examples: 's-p', 's-S', '(C-x C-s)', '<f13>') - into an accelerator string */ +/* Parse a widget_value's key rep (examples: 's-p', 's-S', '(C-x C-s)', '<f13>') + into an accelerator string. We are only able to display a single character + for an accelerator, together with an optional modifier combination. (Under + Carbon more control was possible, but in Cocoa multi-char strings passed to + NSMenuItem get ignored. For now we try to display a super-single letter + combo, and return the others as strings to be appended to the item title. + (This is signaled by setting keyEquivModMask to 0 for now.) */ -(NSString *)parseKeyEquiv: (char *)key { char *tpos = key; - keyEquivModMask = 0; - /* currently we just parse 'super' combinations; - later we'll set keyEquivModMask */ + keyEquivModMask = NSCommandKeyMask; + if (!key || !strlen (key)) return @""; while (*tpos == ' ' || *tpos == '(') tpos++; - if (*tpos != 's'/* || tpos[3] != ')'*/) - return @""; + if (*tpos != 's') { + keyEquivModMask = 0; /* signal */ + return [NSString stringWithUTF8String: tpos]; + } return [NSString stringWithFormat: @"%c", tpos[2]]; } @@ -626,12 +632,13 @@ title = @"< ? >"; /* (get out in the open so we know about it) */ keyEq = [self parseKeyEquiv: wv->key]; + if (keyEquivModMask == 0) + title = [title stringByAppendingFormat: @" (%@)", keyEq]; item = [self addItemWithTitle: (NSString *)title action: @selector (menuDown:) keyEquivalent: keyEq]; - if (keyEquivModMask) - [item setKeyEquivalentModifierMask: keyEquivModMask]; + [item setKeyEquivalentModifierMask: keyEquivModMask]; [item setEnabled: wv->enabled];