diff options
| author | Adrian Robert | 2009-01-21 17:09:28 +0000 |
|---|---|---|
| committer | Adrian Robert | 2009-01-21 17:09:28 +0000 |
| commit | a9b4df69505cd37d6be04fb493aec803fa1de497 (patch) | |
| tree | 9286566e66a35ef963b631929ba62c5c2a0c4e07 /src | |
| parent | cbe0b5bfa9426db7f60af0ec3bb555eaa6ccd43c (diff) | |
| download | emacs-a9b4df69505cd37d6be04fb493aec803fa1de497.tar.gz emacs-a9b4df69505cd37d6be04fb493aec803fa1de497.zip | |
* nsterm.m: (x_set_frame_alpha): Add prototype. (ns_fake_keydown, EmacsView-keyUp:): New variable and function to handle Ctrl-tab. (ns_get_color): Use unsigned long long for scanned hex string value. (ns_term_shutdown): Abort on non SIGTERM signals.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/nsterm.m | 80 |
2 files changed, 67 insertions, 19 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b1d021a186a..75e6549e46c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,7 +1,11 @@ | |||
| 1 | 2009-01-21 Adrian Robert <Adrian.B.Robert@gmail.com> | 1 | 2009-01-21 Adrian Robert <Adrian.B.Robert@gmail.com> |
| 2 | 2 | ||
| 3 | * nsmenu.m (NSMENUPROFILE): Change #if style. | 3 | * nsmenu.m (NSMENUPROFILE): Change #if style. |
| 4 | 4 | * nsterm.m: (x_set_frame_alpha): Add prototype. | |
| 5 | (ns_fake_keydown, EmacsView-keyUp:): New variable and function to | ||
| 6 | handle Ctrl-tab. (Bug#1841) | ||
| 7 | (ns_get_color): Use unsigned long long for scanned hex string value. | ||
| 8 | (ns_term_shutdown): Abort on non SIGTERM signals. | ||
| 5 | 9 | ||
| 6 | 2009-01-19 Chong Yidong <cyd@stupidchicken.com> | 10 | 2009-01-19 Chong Yidong <cyd@stupidchicken.com> |
| 7 | 11 | ||
diff --git a/src/nsterm.m b/src/nsterm.m index 3c79acea2df..9b89c833cd9 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -212,6 +212,7 @@ static int ns_window_num =0; | |||
| 212 | static NSRect uRect; | 212 | static NSRect uRect; |
| 213 | static BOOL gsaved = NO; | 213 | static BOOL gsaved = NO; |
| 214 | BOOL ns_in_resize = NO; | 214 | BOOL ns_in_resize = NO; |
| 215 | static BOOL ns_fake_keydown = NO; | ||
| 215 | int ns_tmp_flags; /* FIXME */ | 216 | int ns_tmp_flags; /* FIXME */ |
| 216 | struct nsfont_info *ns_tmp_font; /* FIXME */ | 217 | struct nsfont_info *ns_tmp_font; /* FIXME */ |
| 217 | /*static int debug_lock = 0; */ | 218 | /*static int debug_lock = 0; */ |
| @@ -302,6 +303,7 @@ void x_set_cursor_type (struct frame *, Lisp_Object, Lisp_Object); | |||
| 302 | /* TODO: get rid of need for these forward declarations */ | 303 | /* TODO: get rid of need for these forward declarations */ |
| 303 | static void ns_condemn_scroll_bars (struct frame *f); | 304 | static void ns_condemn_scroll_bars (struct frame *f); |
| 304 | static void ns_judge_scroll_bars (struct frame *f); | 305 | static void ns_judge_scroll_bars (struct frame *f); |
| 306 | void x_set_frame_alpha (struct frame *f); | ||
| 305 | 307 | ||
| 306 | /* unused variables needed for compatibility reasons */ | 308 | /* unused variables needed for compatibility reasons */ |
| 307 | int x_use_underline_position_properties, x_underline_at_descent_line; | 309 | int x_use_underline_position_properties, x_underline_at_descent_line; |
| @@ -1419,7 +1421,7 @@ ns_get_color (const char *name, NSColor **col) | |||
| 1419 | /* Direct colors (hex values) */ | 1421 | /* Direct colors (hex values) */ |
| 1420 | if (hex) | 1422 | if (hex) |
| 1421 | { | 1423 | { |
| 1422 | unsigned long color = 0; | 1424 | unsigned long long color = 0; |
| 1423 | if (sscanf (hex, "%x", &color)) | 1425 | if (sscanf (hex, "%x", &color)) |
| 1424 | { | 1426 | { |
| 1425 | float f1, f2, f3, f4; | 1427 | float f1, f2, f3, f4; |
| @@ -3986,8 +3988,15 @@ ns_term_shutdown (int sig) | |||
| 3986 | if (STRINGP (Vauto_save_list_file_name)) | 3988 | if (STRINGP (Vauto_save_list_file_name)) |
| 3987 | unlink (SDATA (Vauto_save_list_file_name)); | 3989 | unlink (SDATA (Vauto_save_list_file_name)); |
| 3988 | 3990 | ||
| 3989 | ns_shutdown_properly = YES; | 3991 | if (sig == 0 || sig == SIGTERM) |
| 3990 | [NSApp terminate: NSApp]; | 3992 | { |
| 3993 | ns_shutdown_properly = YES; | ||
| 3994 | [NSApp terminate: NSApp]; | ||
| 3995 | } | ||
| 3996 | else // force a stack trace to happen | ||
| 3997 | { | ||
| 3998 | abort(); | ||
| 3999 | } | ||
| 3991 | } | 4000 | } |
| 3992 | 4001 | ||
| 3993 | 4002 | ||
| @@ -4374,6 +4383,7 @@ extern void update_window_cursor (struct window *w, int on); | |||
| 4374 | } | 4383 | } |
| 4375 | 4384 | ||
| 4376 | 4385 | ||
| 4386 | |||
| 4377 | /*****************************************************************************/ | 4387 | /*****************************************************************************/ |
| 4378 | /* Keyboard handling. */ | 4388 | /* Keyboard handling. */ |
| 4379 | #define NS_KEYLOG 0 | 4389 | #define NS_KEYLOG 0 |
| @@ -4390,7 +4400,9 @@ extern void update_window_cursor (struct window *w, int on); | |||
| 4390 | NSTRACE (keyDown); | 4400 | NSTRACE (keyDown); |
| 4391 | 4401 | ||
| 4392 | /* Rhapsody and OS X give up and down events for the arrow keys */ | 4402 | /* Rhapsody and OS X give up and down events for the arrow keys */ |
| 4393 | if ([theEvent type] != NSKeyDown) | 4403 | if (ns_fake_keydown == YES) |
| 4404 | ns_fake_keydown = NO; | ||
| 4405 | else if ([theEvent type] != NSKeyDown) | ||
| 4394 | return; | 4406 | return; |
| 4395 | 4407 | ||
| 4396 | if (!emacs_event) | 4408 | if (!emacs_event) |
| @@ -4485,10 +4497,12 @@ extern void update_window_cursor (struct window *w, int on); | |||
| 4485 | } | 4497 | } |
| 4486 | 4498 | ||
| 4487 | if (flags & NSControlKeyMask) | 4499 | if (flags & NSControlKeyMask) |
| 4488 | emacs_event->modifiers |= parse_solitary_modifier (ns_control_modifier); | 4500 | emacs_event->modifiers |= |
| 4501 | parse_solitary_modifier (ns_control_modifier); | ||
| 4489 | 4502 | ||
| 4490 | if (flags & NS_FUNCTION_KEY_MASK && !fnKeysym) | 4503 | if (flags & NS_FUNCTION_KEY_MASK && !fnKeysym) |
| 4491 | emacs_event->modifiers |= parse_solitary_modifier (ns_function_modifier); | 4504 | emacs_event->modifiers |= |
| 4505 | parse_solitary_modifier (ns_function_modifier); | ||
| 4492 | 4506 | ||
| 4493 | if (flags & NSAlternateKeyMask) /* default = meta */ | 4507 | if (flags & NSAlternateKeyMask) /* default = meta */ |
| 4494 | { | 4508 | { |
| @@ -4501,10 +4515,13 @@ extern void update_window_cursor (struct window *w, int on); | |||
| 4501 | emacs_event->modifiers = 0; | 4515 | emacs_event->modifiers = 0; |
| 4502 | } | 4516 | } |
| 4503 | else | 4517 | else |
| 4504 | emacs_event->modifiers |= parse_solitary_modifier (ns_alternate_modifier); | 4518 | emacs_event->modifiers |= |
| 4519 | parse_solitary_modifier (ns_alternate_modifier); | ||
| 4505 | } | 4520 | } |
| 4506 | 4521 | ||
| 4507 | /*fprintf (stderr,"code =%x\tfnKey =%x\tflags = %x\tmods = %x\n",code,fnKeysym,flags,emacs_event->modifiers); */ | 4522 | if (NS_KEYLOG) |
| 4523 | fprintf (stderr, "keyDown: code =%x\tfnKey =%x\tflags = %x\tmods = %x\n", | ||
| 4524 | code, fnKeysym, flags, emacs_event->modifiers); | ||
| 4508 | 4525 | ||
| 4509 | /* if it was a function key or had modifiers, pass it directly to emacs */ | 4526 | /* if it was a function key or had modifiers, pass it directly to emacs */ |
| 4510 | if (fnKeysym || (emacs_event->modifiers | 4527 | if (fnKeysym || (emacs_event->modifiers |
| @@ -4534,7 +4551,7 @@ extern void update_window_cursor (struct window *w, int on); | |||
| 4534 | firstTime = NO; | 4551 | firstTime = NO; |
| 4535 | 4552 | ||
| 4536 | if (NS_KEYLOG && !processingCompose) | 4553 | if (NS_KEYLOG && !processingCompose) |
| 4537 | fprintf (stderr, "Begin compose sequence.\n"); | 4554 | fprintf (stderr, "keyDown: Begin compose sequence.\n"); |
| 4538 | 4555 | ||
| 4539 | processingCompose = YES; | 4556 | processingCompose = YES; |
| 4540 | [nsEvArray addObject: theEvent]; | 4557 | [nsEvArray addObject: theEvent]; |
| @@ -4543,6 +4560,26 @@ extern void update_window_cursor (struct window *w, int on); | |||
| 4543 | } | 4560 | } |
| 4544 | 4561 | ||
| 4545 | 4562 | ||
| 4563 | #ifdef NS_IMPL_COCOA | ||
| 4564 | /* Needed to pick up Ctrl-tab and possibly other events that OS X has | ||
| 4565 | decided not to send key-down for. | ||
| 4566 | See http://osdir.com/ml/editors.vim.mac/2007-10/msg00141.html | ||
| 4567 | If it matches one of these, send it on to keyDown. */ | ||
| 4568 | -(void)keyUp: (NSEvent *)theEvent | ||
| 4569 | { | ||
| 4570 | int flags = [theEvent modifierFlags]; | ||
| 4571 | int code = [theEvent keyCode]; | ||
| 4572 | if (code == 0x30 && (flags & NSControlKeyMask) && !(flags & NSCommandKeyMask)) | ||
| 4573 | { | ||
| 4574 | if (NS_KEYLOG) | ||
| 4575 | fprintf (stderr, "keyUp: passed test"); | ||
| 4576 | ns_fake_keydown = YES; | ||
| 4577 | [self keyDown: theEvent]; | ||
| 4578 | } | ||
| 4579 | } | ||
| 4580 | #endif | ||
| 4581 | |||
| 4582 | |||
| 4546 | /* <NSTextInput> implementation (called through super interpretKeyEvents:]). */ | 4583 | /* <NSTextInput> implementation (called through super interpretKeyEvents:]). */ |
| 4547 | 4584 | ||
| 4548 | 4585 | ||
| @@ -4553,7 +4590,8 @@ extern void update_window_cursor (struct window *w, int on); | |||
| 4553 | int len = [(NSString *)aString length]; | 4590 | int len = [(NSString *)aString length]; |
| 4554 | int i; | 4591 | int i; |
| 4555 | 4592 | ||
| 4556 | if (NS_KEYLOG) NSLog (@"insertText '%@'\tlen = %d", aString, len); | 4593 | if (NS_KEYLOG) |
| 4594 | NSLog (@"insertText '%@'\tlen = %d", aString, len); | ||
| 4557 | processingCompose = NO; | 4595 | processingCompose = NO; |
| 4558 | 4596 | ||
| 4559 | if (!emacs_event) | 4597 | if (!emacs_event) |
| @@ -4654,13 +4692,15 @@ if (NS_KEYLOG) NSLog (@"insertText '%@'\tlen = %d", aString, len); | |||
| 4654 | { | 4692 | { |
| 4655 | NSRange rng = workingText != nil | 4693 | NSRange rng = workingText != nil |
| 4656 | ? NSMakeRange (0, [workingText length]) : NSMakeRange (NSNotFound, 0); | 4694 | ? NSMakeRange (0, [workingText length]) : NSMakeRange (NSNotFound, 0); |
| 4657 | if (NS_KEYLOG) NSLog (@"markedRange request"); | 4695 | if (NS_KEYLOG) |
| 4696 | NSLog (@"markedRange request"); | ||
| 4658 | return rng; | 4697 | return rng; |
| 4659 | } | 4698 | } |
| 4660 | 4699 | ||
| 4661 | - (void)unmarkText | 4700 | - (void)unmarkText |
| 4662 | { | 4701 | { |
| 4663 | if (NS_KEYLOG) NSLog (@"unmark (accept) text"); | 4702 | if (NS_KEYLOG) |
| 4703 | NSLog (@"unmark (accept) text"); | ||
| 4664 | [self deleteWorkingText]; | 4704 | [self deleteWorkingText]; |
| 4665 | processingCompose = NO; | 4705 | processingCompose = NO; |
| 4666 | } | 4706 | } |
| @@ -4671,7 +4711,8 @@ if (NS_KEYLOG) NSLog (@"unmark (accept) text"); | |||
| 4671 | NSRect rect; | 4711 | NSRect rect; |
| 4672 | NSPoint pt; | 4712 | NSPoint pt; |
| 4673 | struct window *win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe)); | 4713 | struct window *win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe)); |
| 4674 | if (NS_KEYLOG) NSLog (@"firstRectForCharRange request"); | 4714 | if (NS_KEYLOG) |
| 4715 | NSLog (@"firstRectForCharRange request"); | ||
| 4675 | 4716 | ||
| 4676 | rect.size.width = theRange.length * FRAME_COLUMN_WIDTH (emacsframe); | 4717 | rect.size.width = theRange.length * FRAME_COLUMN_WIDTH (emacsframe); |
| 4677 | rect.size.height = FRAME_LINE_HEIGHT (emacsframe); | 4718 | rect.size.height = FRAME_LINE_HEIGHT (emacsframe); |
| @@ -4694,8 +4735,8 @@ if (NS_KEYLOG) NSLog (@"firstRectForCharRange request"); | |||
| 4694 | 4735 | ||
| 4695 | - (void)doCommandBySelector: (SEL)aSelector | 4736 | - (void)doCommandBySelector: (SEL)aSelector |
| 4696 | { | 4737 | { |
| 4697 | if (NS_KEYLOG) NSLog (@"Do command by selector: %@", | 4738 | if (NS_KEYLOG) |
| 4698 | NSStringFromSelector (aSelector)); | 4739 | NSLog (@"doCommandBySelector: %@", NSStringFromSelector (aSelector)); |
| 4699 | 4740 | ||
| 4700 | if (aSelector == @selector (deleteBackward:)) | 4741 | if (aSelector == @selector (deleteBackward:)) |
| 4701 | { | 4742 | { |
| @@ -4719,13 +4760,15 @@ if (NS_KEYLOG) NSLog (@"firstRectForCharRange request"); | |||
| 4719 | 4760 | ||
| 4720 | - (NSRange)selectedRange | 4761 | - (NSRange)selectedRange |
| 4721 | { | 4762 | { |
| 4722 | if (NS_KEYLOG) NSLog (@"selectedRange request"); | 4763 | if (NS_KEYLOG) |
| 4764 | NSLog (@"selectedRange request"); | ||
| 4723 | return NSMakeRange (NSNotFound, 0); | 4765 | return NSMakeRange (NSNotFound, 0); |
| 4724 | } | 4766 | } |
| 4725 | 4767 | ||
| 4726 | - (unsigned int)characterIndexForPoint: (NSPoint)thePoint | 4768 | - (unsigned int)characterIndexForPoint: (NSPoint)thePoint |
| 4727 | { | 4769 | { |
| 4728 | if (NS_KEYLOG) NSLog (@"characterIndexForPoint request"); | 4770 | if (NS_KEYLOG) |
| 4771 | NSLog (@"characterIndexForPoint request"); | ||
| 4729 | return 0; | 4772 | return 0; |
| 4730 | } | 4773 | } |
| 4731 | 4774 | ||
| @@ -4733,7 +4776,8 @@ if (NS_KEYLOG) NSLog (@"characterIndexForPoint request"); | |||
| 4733 | { | 4776 | { |
| 4734 | static NSAttributedString *str = nil; | 4777 | static NSAttributedString *str = nil; |
| 4735 | if (str == nil) str = [NSAttributedString new]; | 4778 | if (str == nil) str = [NSAttributedString new]; |
| 4736 | if (NS_KEYLOG) NSLog (@"attributedSubstringFromRange request"); | 4779 | if (NS_KEYLOG) |
| 4780 | NSLog (@"attributedSubstringFromRange request"); | ||
| 4737 | return str; | 4781 | return str; |
| 4738 | } | 4782 | } |
| 4739 | 4783 | ||