diff options
| author | Adrian Robert | 2009-01-22 12:23:47 +0000 |
|---|---|---|
| committer | Adrian Robert | 2009-01-22 12:23:47 +0000 |
| commit | c7cef62d4d2307682398fe5eb7e7a38640f52b2c (patch) | |
| tree | 5bea4d942842be2730b73771c2011edd27206a39 /src | |
| parent | 10f87c6f1db7afcd05a3a56f441c7d4d61fee0f2 (diff) | |
| download | emacs-c7cef62d4d2307682398fe5eb7e7a38640f52b2c.tar.gz emacs-c7cef62d4d2307682398fe5eb7e7a38640f52b2c.zip | |
* nsmenu.m (EmacsMenu-parseKeyEquiv:, addItemWithWidgetValue:): Display all shortcuts, including those w/o super modifier.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 3 | ||||
| -rw-r--r-- | src/nsmenu.m | 25 |
2 files changed, 19 insertions, 9 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index ee077760872..283f3fb4201 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -3,6 +3,9 @@ | |||
| 3 | * nsterm.m (EmavsView-keyDown:): Treat nil as Qnone for | 3 | * nsterm.m (EmavsView-keyDown:): Treat nil as Qnone for |
| 4 | ns_alternate_modifier. (Bug#1217) | 4 | ns_alternate_modifier. (Bug#1217) |
| 5 | 5 | ||
| 6 | * nsmenu.m (EmacsMenu-parseKeyEquiv:, addItemWithWidgetValue:): | ||
| 7 | Display all shortcuts, including those w/o super modifier. | ||
| 8 | |||
| 6 | 2009-01-22 Chong Yidong <cyd@stupidchicken.com> | 9 | 2009-01-22 Chong Yidong <cyd@stupidchicken.com> |
| 7 | 10 | ||
| 8 | * fileio.c (Vwrite_region_post_annotation_function) | 11 | * fileio.c (Vwrite_region_post_annotation_function) |
diff --git a/src/nsmenu.m b/src/nsmenu.m index 393c4f4d872..e52b0c44ff9 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m | |||
| @@ -589,21 +589,27 @@ name_is_separator (name) | |||
| 589 | } | 589 | } |
| 590 | 590 | ||
| 591 | 591 | ||
| 592 | /* parse a widget_value's key rep (examples: 's-p', 's-S', '(C-x C-s)', '<f13>') | 592 | /* Parse a widget_value's key rep (examples: 's-p', 's-S', '(C-x C-s)', '<f13>') |
| 593 | into an accelerator string */ | 593 | into an accelerator string. We are only able to display a single character |
| 594 | for an accelerator, together with an optional modifier combination. (Under | ||
| 595 | Carbon more control was possible, but in Cocoa multi-char strings passed to | ||
| 596 | NSMenuItem get ignored. For now we try to display a super-single letter | ||
| 597 | combo, and return the others as strings to be appended to the item title. | ||
| 598 | (This is signaled by setting keyEquivModMask to 0 for now.) */ | ||
| 594 | -(NSString *)parseKeyEquiv: (char *)key | 599 | -(NSString *)parseKeyEquiv: (char *)key |
| 595 | { | 600 | { |
| 596 | char *tpos = key; | 601 | char *tpos = key; |
| 597 | keyEquivModMask = 0; | 602 | keyEquivModMask = NSCommandKeyMask; |
| 598 | /* currently we just parse 'super' combinations; | 603 | |
| 599 | later we'll set keyEquivModMask */ | ||
| 600 | if (!key || !strlen (key)) | 604 | if (!key || !strlen (key)) |
| 601 | return @""; | 605 | return @""; |
| 602 | 606 | ||
| 603 | while (*tpos == ' ' || *tpos == '(') | 607 | while (*tpos == ' ' || *tpos == '(') |
| 604 | tpos++; | 608 | tpos++; |
| 605 | if (*tpos != 's'/* || tpos[3] != ')'*/) | 609 | if (*tpos != 's') { |
| 606 | return @""; | 610 | keyEquivModMask = 0; /* signal */ |
| 611 | return [NSString stringWithUTF8String: tpos]; | ||
| 612 | } | ||
| 607 | return [NSString stringWithFormat: @"%c", tpos[2]]; | 613 | return [NSString stringWithFormat: @"%c", tpos[2]]; |
| 608 | } | 614 | } |
| 609 | 615 | ||
| @@ -626,12 +632,13 @@ name_is_separator (name) | |||
| 626 | title = @"< ? >"; /* (get out in the open so we know about it) */ | 632 | title = @"< ? >"; /* (get out in the open so we know about it) */ |
| 627 | 633 | ||
| 628 | keyEq = [self parseKeyEquiv: wv->key]; | 634 | keyEq = [self parseKeyEquiv: wv->key]; |
| 635 | if (keyEquivModMask == 0) | ||
| 636 | title = [title stringByAppendingFormat: @" (%@)", keyEq]; | ||
| 629 | 637 | ||
| 630 | item = [self addItemWithTitle: (NSString *)title | 638 | item = [self addItemWithTitle: (NSString *)title |
| 631 | action: @selector (menuDown:) | 639 | action: @selector (menuDown:) |
| 632 | keyEquivalent: keyEq]; | 640 | keyEquivalent: keyEq]; |
| 633 | if (keyEquivModMask) | 641 | [item setKeyEquivalentModifierMask: keyEquivModMask]; |
| 634 | [item setKeyEquivalentModifierMask: keyEquivModMask]; | ||
| 635 | 642 | ||
| 636 | [item setEnabled: wv->enabled]; | 643 | [item setEnabled: wv->enabled]; |
| 637 | 644 | ||