diff options
| author | Jan Djärv | 2013-04-28 11:55:20 +0200 |
|---|---|---|
| committer | Jan Djärv | 2013-04-28 11:55:20 +0200 |
| commit | edbdcec0a296f1cab2ffcced455e9a04c0408509 (patch) | |
| tree | 6c731b5cc6a8b4d886c8bb3ed0464042779d225c /src | |
| parent | 4afd650a586bdf3bb393b4b3aef042c7e2a5c8a4 (diff) | |
| download | emacs-edbdcec0a296f1cab2ffcced455e9a04c0408509.tar.gz emacs-edbdcec0a296f1cab2ffcced455e9a04c0408509.zip | |
* nsfns.m (handlePanelKeys): New function.
(EmacsOpenPanel:performKeyEquivalent:)
(EmacsSavePanel:performKeyEquivalent:): Call handlePanelKeys to handle
arrows/function/control and copy/paste keys.
Fixes: debbugs:14296
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/nsfns.m | 88 |
2 files changed, 93 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index c9d458c3479..84aa50f7047 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2013-04-28 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * nsfns.m (handlePanelKeys): New function. | ||
| 4 | (EmacsOpenPanel:performKeyEquivalent:) | ||
| 5 | (EmacsSavePanel:performKeyEquivalent:): Call handlePanelKeys to handle | ||
| 6 | arrows/function/control and copy/paste keys (Bug#14296). | ||
| 7 | |||
| 1 | 2013-04-27 Juri Linkov <juri@jurta.org> | 8 | 2013-04-27 Juri Linkov <juri@jurta.org> |
| 2 | 9 | ||
| 3 | * callint.c (Fcall_interactively): Call `Qread_number' for | 10 | * callint.c (Fcall_interactively): Call `Qread_number' for |
diff --git a/src/nsfns.m b/src/nsfns.m index a483f847dec..0d6d0e72835 100644 --- a/src/nsfns.m +++ b/src/nsfns.m | |||
| @@ -1477,7 +1477,7 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */) | |||
| 1477 | [panel setCanChooseFiles: YES]; | 1477 | [panel setCanChooseFiles: YES]; |
| 1478 | } | 1478 | } |
| 1479 | 1479 | ||
| 1480 | block_input (); | 1480 | block_input (); |
| 1481 | #if defined (NS_IMPL_COCOA) && \ | 1481 | #if defined (NS_IMPL_COCOA) && \ |
| 1482 | MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 | 1482 | MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 |
| 1483 | if (! NILP (mustmatch) || ! NILP (dir_only_p)) | 1483 | if (! NILP (mustmatch) || ! NILP (dir_only_p)) |
| @@ -2544,6 +2544,75 @@ Value is t if tooltip was open, nil otherwise. */) | |||
| 2544 | 2544 | ||
| 2545 | ========================================================================== */ | 2545 | ========================================================================== */ |
| 2546 | 2546 | ||
| 2547 | /* | ||
| 2548 | Handle arrow/function/control keys and copy/paste/cut in file dialogs. | ||
| 2549 | Return YES if handeled, NO if not. | ||
| 2550 | */ | ||
| 2551 | static BOOL | ||
| 2552 | handlePanelKeys (NSSavePanel *panel, NSEvent *theEvent) | ||
| 2553 | { | ||
| 2554 | NSString *s; | ||
| 2555 | int i; | ||
| 2556 | BOOL ret = NO; | ||
| 2557 | |||
| 2558 | if ([theEvent type] != NSKeyDown) return NO; | ||
| 2559 | s = [theEvent characters]; | ||
| 2560 | |||
| 2561 | for (i = 0; i < [s length]; ++i) | ||
| 2562 | { | ||
| 2563 | int ch = (int) [s characterAtIndex: i]; | ||
| 2564 | switch (ch) | ||
| 2565 | { | ||
| 2566 | case NSHomeFunctionKey: | ||
| 2567 | case NSDownArrowFunctionKey: | ||
| 2568 | case NSUpArrowFunctionKey: | ||
| 2569 | case NSLeftArrowFunctionKey: | ||
| 2570 | case NSRightArrowFunctionKey: | ||
| 2571 | case NSPageUpFunctionKey: | ||
| 2572 | case NSPageDownFunctionKey: | ||
| 2573 | case NSEndFunctionKey: | ||
| 2574 | [panel sendEvent: theEvent]; | ||
| 2575 | ret = YES; | ||
| 2576 | break; | ||
| 2577 | /* As we don't have the standard key commands for | ||
| 2578 | copy/paste/cut/select-all in our edit menu, we must handle | ||
| 2579 | them here. TODO: handle Emacs key bindings for copy/cut/select-all | ||
| 2580 | here, paste works, because we have that in our Edit menu. | ||
| 2581 | I.e. refactor out code in nsterm.m, keyDown: to figure out the | ||
| 2582 | correct modifier. | ||
| 2583 | */ | ||
| 2584 | case 'x': // Cut | ||
| 2585 | case 'c': // Copy | ||
| 2586 | case 'v': // Paste | ||
| 2587 | case 'a': // Select all | ||
| 2588 | if ([theEvent modifierFlags] & NSCommandKeyMask) | ||
| 2589 | { | ||
| 2590 | [NSApp sendAction: | ||
| 2591 | (ch == 'x' | ||
| 2592 | ? @selector(cut:) | ||
| 2593 | : (ch == 'c' | ||
| 2594 | ? @selector(copy:) | ||
| 2595 | : (ch == 'v' | ||
| 2596 | ? @selector(paste:) | ||
| 2597 | : @selector(selectAll:)))) | ||
| 2598 | to:nil from:panel]; | ||
| 2599 | ret = YES; | ||
| 2600 | } | ||
| 2601 | default: | ||
| 2602 | // Send all control keys, as the text field supports C-a, C-f, C-e | ||
| 2603 | // C-b and more. | ||
| 2604 | if ([theEvent modifierFlags] & NSControlKeyMask) | ||
| 2605 | { | ||
| 2606 | [panel sendEvent: theEvent]; | ||
| 2607 | ret = YES; | ||
| 2608 | } | ||
| 2609 | break; | ||
| 2610 | } | ||
| 2611 | } | ||
| 2612 | |||
| 2613 | |||
| 2614 | return ret; | ||
| 2615 | } | ||
| 2547 | 2616 | ||
| 2548 | @implementation EmacsSavePanel | 2617 | @implementation EmacsSavePanel |
| 2549 | #ifdef NS_IMPL_COCOA | 2618 | #ifdef NS_IMPL_COCOA |
| @@ -2572,6 +2641,14 @@ Value is t if tooltip was open, nil otherwise. */) | |||
| 2572 | { | 2641 | { |
| 2573 | return ns_directory_from_panel (self); | 2642 | return ns_directory_from_panel (self); |
| 2574 | } | 2643 | } |
| 2644 | |||
| 2645 | - (BOOL)performKeyEquivalent:(NSEvent *)theEvent | ||
| 2646 | { | ||
| 2647 | BOOL ret = handlePanelKeys (self, theEvent); | ||
| 2648 | if (! ret) | ||
| 2649 | ret = [super performKeyEquivalent:theEvent]; | ||
| 2650 | return ret; | ||
| 2651 | } | ||
| 2575 | @end | 2652 | @end |
| 2576 | 2653 | ||
| 2577 | 2654 | ||
| @@ -2609,7 +2686,14 @@ Value is t if tooltip was open, nil otherwise. */) | |||
| 2609 | { | 2686 | { |
| 2610 | return ns_directory_from_panel (self); | 2687 | return ns_directory_from_panel (self); |
| 2611 | } | 2688 | } |
| 2612 | 2689 | - (BOOL)performKeyEquivalent:(NSEvent *)theEvent | |
| 2690 | { | ||
| 2691 | // NSOpenPanel inherits NSSavePanel, so passing self is OK. | ||
| 2692 | BOOL ret = handlePanelKeys (self, theEvent); | ||
| 2693 | if (! ret) | ||
| 2694 | ret = [super performKeyEquivalent:theEvent]; | ||
| 2695 | return ret; | ||
| 2696 | } | ||
| 2613 | @end | 2697 | @end |
| 2614 | 2698 | ||
| 2615 | 2699 | ||