Mercurial > emacs
comparison src/nsterm.m @ 96749:e18e64789955
(lisp_to_mod): Use parse_solitary_modifier instead.
(ns_lisp_to_color): Don't mess with internal Lisp data fields.
(ns_term_init, ns_term_shutdown, initFrameFromEmacs, ns_list_fonts):
Use SDATA.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 16 Jul 2008 20:34:57 +0000 |
parents | 6fad3f85eab7 |
children | 1e2f7aab70ba |
comparison
equal
deleted
inserted
replaced
96748:92f7bbffcb45 | 96749:e18e64789955 |
---|---|
141 Lisp_Object Vx_toolkit_scroll_bars; | 141 Lisp_Object Vx_toolkit_scroll_bars; |
142 static Lisp_Object Qmodifier_value; | 142 static Lisp_Object Qmodifier_value; |
143 /*PENDING: unsure why these defined in term files, anyway we need in keymap.c */ | 143 /*PENDING: unsure why these defined in term files, anyway we need in keymap.c */ |
144 Lisp_Object Qalt, Qcontrol, Qhyper, Qmeta, Qsuper; | 144 Lisp_Object Qalt, Qcontrol, Qhyper, Qmeta, Qsuper; |
145 extern Lisp_Object Qcursor_color, Qcursor_type, Qns; | 145 extern Lisp_Object Qcursor_color, Qcursor_type, Qns; |
146 extern int lisp_to_mod (Lisp_Object lmod); | |
147 | 146 |
148 | 147 |
149 EmacsPrefsController *prefsController; | 148 EmacsPrefsController *prefsController; |
150 | 149 |
151 /* Defaults managed through the OpenStep defaults system. These pertain to | 150 /* Defaults managed through the OpenStep defaults system. These pertain to |
253 #define NS_FUNCTION_KEY_MASK 0x800000 | 252 #define NS_FUNCTION_KEY_MASK 0x800000 |
254 #define EV_MODIFIERS(e) \ | 253 #define EV_MODIFIERS(e) \ |
255 ((([e modifierFlags] & NSHelpKeyMask) ? \ | 254 ((([e modifierFlags] & NSHelpKeyMask) ? \ |
256 hyper_modifier : 0) \ | 255 hyper_modifier : 0) \ |
257 | (([e modifierFlags] & NSAlternateKeyMask) ? \ | 256 | (([e modifierFlags] & NSAlternateKeyMask) ? \ |
258 lisp_to_mod (ns_alternate_modifier) : 0) \ | 257 parse_solitary_modifier (ns_alternate_modifier) : 0) \ |
259 | (([e modifierFlags] & NSShiftKeyMask) ? \ | 258 | (([e modifierFlags] & NSShiftKeyMask) ? \ |
260 shift_modifier : 0) \ | 259 shift_modifier : 0) \ |
261 | (([e modifierFlags] & NSControlKeyMask) ? \ | 260 | (([e modifierFlags] & NSControlKeyMask) ? \ |
262 lisp_to_mod (ns_control_modifier) : 0) \ | 261 parse_solitary_modifier (ns_control_modifier) : 0) \ |
263 | (([e modifierFlags] & NS_FUNCTION_KEY_MASK) ? \ | 262 | (([e modifierFlags] & NS_FUNCTION_KEY_MASK) ? \ |
264 lisp_to_mod (ns_function_modifier) : 0) \ | 263 parse_solitary_modifier (ns_function_modifier) : 0) \ |
265 | (([e modifierFlags] & NSCommandKeyMask) ? \ | 264 | (([e modifierFlags] & NSCommandKeyMask) ? \ |
266 lisp_to_mod (ns_command_modifier):0)) | 265 parse_solitary_modifier (ns_command_modifier):0)) |
267 | 266 |
268 #define EV_UDMODIFIERS(e) \ | 267 #define EV_UDMODIFIERS(e) \ |
269 ((([e type] == NSLeftMouseDown) ? down_modifier : 0) \ | 268 ((([e type] == NSLeftMouseDown) ? down_modifier : 0) \ |
270 | (([e type] == NSRightMouseDown) ? down_modifier : 0) \ | 269 | (([e type] == NSRightMouseDown) ? down_modifier : 0) \ |
271 | (([e type] == NSLeftMouseDragged) ? down_modifier : 0) \ | 270 | (([e type] == NSLeftMouseDragged) ? down_modifier : 0) \ |
1511 /* -------------------------------------------------------------------------- | 1510 /* -------------------------------------------------------------------------- |
1512 Convert a Lisp string object to a NS color | 1511 Convert a Lisp string object to a NS color |
1513 -------------------------------------------------------------------------- */ | 1512 -------------------------------------------------------------------------- */ |
1514 { | 1513 { |
1515 NSTRACE (ns_lisp_to_color); | 1514 NSTRACE (ns_lisp_to_color); |
1516 if (XTYPE (color) == Lisp_String) | 1515 if (STRINGP (color)) |
1517 return ns_get_color (XSTRING (color)->data, col); | 1516 return ns_get_color (SDATA (color), col); |
1518 else if (XTYPE (color) == Lisp_Symbol) | 1517 else if (SYMBOLP (color)) |
1519 return ns_get_color (XSTRING (XSYMBOL (color)->xname)->data, col); | 1518 return ns_get_color (SDATA (SYMBOL_NAME (color)), col); |
1520 return 1; | 1519 return 1; |
1521 } | 1520 } |
1522 | 1521 |
1523 | 1522 |
1524 Lisp_Object | 1523 Lisp_Object |
3846 } | 3845 } |
3847 } | 3846 } |
3848 | 3847 |
3849 cl = [[NSColorList alloc] | 3848 cl = [[NSColorList alloc] |
3850 initWithName: @"Emacs" | 3849 initWithName: @"Emacs" |
3851 fromFile: [NSString stringWithCString: XSTRING (tem)->data]]; | 3850 fromFile: [NSString stringWithCString: SDATA (tem)]]; |
3852 if (cl ==nil) | 3851 if (cl ==nil) |
3853 fatal ("Could not find %s.\n", XSTRING (tem1)->data); | 3852 fatal ("Could not find %s.\n", SDATA (tem1)); |
3854 [cl writeToFile: nil]; | 3853 [cl writeToFile: nil]; |
3855 } | 3854 } |
3856 } | 3855 } |
3857 | 3856 |
3858 { | 3857 { |
3936 void | 3935 void |
3937 ns_term_shutdown (int sig) | 3936 ns_term_shutdown (int sig) |
3938 { | 3937 { |
3939 /* code not reached in emacs.c after this is called by shut_down_emacs: */ | 3938 /* code not reached in emacs.c after this is called by shut_down_emacs: */ |
3940 if (STRINGP (Vauto_save_list_file_name)) | 3939 if (STRINGP (Vauto_save_list_file_name)) |
3941 unlink (XSTRING (Vauto_save_list_file_name)->data); | 3940 unlink (SDATA (Vauto_save_list_file_name)); |
3942 | 3941 |
3943 ns_shutdown_properly = YES; | 3942 ns_shutdown_properly = YES; |
3944 [NSApp terminate: NSApp]; | 3943 [NSApp terminate: NSApp]; |
3945 } | 3944 } |
3946 | 3945 |
4550 if (flags & NSShiftKeyMask) | 4549 if (flags & NSShiftKeyMask) |
4551 emacs_event->modifiers |= shift_modifier; | 4550 emacs_event->modifiers |= shift_modifier; |
4552 | 4551 |
4553 if (flags & NSCommandKeyMask) | 4552 if (flags & NSCommandKeyMask) |
4554 { | 4553 { |
4555 emacs_event->modifiers |= lisp_to_mod (ns_command_modifier); | 4554 emacs_event->modifiers |= parse_solitary_modifier (ns_command_modifier); |
4556 /* if super (default), take input manager's word so things like | 4555 /* if super (default), take input manager's word so things like |
4557 dvorak / qwerty layout work */ | 4556 dvorak / qwerty layout work */ |
4558 if (EQ (ns_command_modifier, Qsuper) | 4557 if (EQ (ns_command_modifier, Qsuper) |
4559 && !fnKeysym | 4558 && !fnKeysym |
4560 && [[theEvent characters] length] != 0) | 4559 && [[theEvent characters] length] != 0) |
4584 #endif | 4583 #endif |
4585 } | 4584 } |
4586 } | 4585 } |
4587 | 4586 |
4588 if (flags & NSControlKeyMask) | 4587 if (flags & NSControlKeyMask) |
4589 emacs_event->modifiers |= lisp_to_mod (ns_control_modifier); | 4588 emacs_event->modifiers |= parse_solitary_modifier (ns_control_modifier); |
4590 | 4589 |
4591 if (flags & NS_FUNCTION_KEY_MASK && !fnKeysym) | 4590 if (flags & NS_FUNCTION_KEY_MASK && !fnKeysym) |
4592 emacs_event->modifiers |= lisp_to_mod (ns_function_modifier); | 4591 emacs_event->modifiers |= parse_solitary_modifier (ns_function_modifier); |
4593 | 4592 |
4594 if (flags & NSAlternateKeyMask) /* default = meta */ | 4593 if (flags & NSAlternateKeyMask) /* default = meta */ |
4595 { | 4594 { |
4596 if (EQ (ns_alternate_modifier, Qnone) && !fnKeysym) | 4595 if (EQ (ns_alternate_modifier, Qnone) && !fnKeysym) |
4597 { /* accept pre-interp alt comb */ | 4596 { /* accept pre-interp alt comb */ |
4600 /*HACK: clear lone shift modifier to stop next if from firing */ | 4599 /*HACK: clear lone shift modifier to stop next if from firing */ |
4601 if (emacs_event->modifiers == shift_modifier) | 4600 if (emacs_event->modifiers == shift_modifier) |
4602 emacs_event->modifiers = 0; | 4601 emacs_event->modifiers = 0; |
4603 } | 4602 } |
4604 else | 4603 else |
4605 emacs_event->modifiers |= lisp_to_mod (ns_alternate_modifier); | 4604 emacs_event->modifiers |= parse_solitary_modifier (ns_alternate_modifier); |
4606 } | 4605 } |
4607 | 4606 |
4608 /*fprintf (stderr,"code =%x\tfnKey =%x\tflags = %x\tmods = %x\n",code,fnKeysym,flags,emacs_event->modifiers); */ | 4607 /*fprintf (stderr,"code =%x\tfnKey =%x\tflags = %x\tmods = %x\n",code,fnKeysym,flags,emacs_event->modifiers); */ |
4609 | 4608 |
4610 /* if it was a function key or had modifiers, pass it directly to emacs */ | 4609 /* if it was a function key or had modifiers, pass it directly to emacs */ |
5221 if (ns_drag_types) | 5220 if (ns_drag_types) |
5222 [self registerForDraggedTypes: ns_drag_types]; | 5221 [self registerForDraggedTypes: ns_drag_types]; |
5223 | 5222 |
5224 tem = f->name; | 5223 tem = f->name; |
5225 name = [NSString stringWithUTF8String: | 5224 name = [NSString stringWithUTF8String: |
5226 NILP (tem) ? (unsigned char *)"Emacs" : XSTRING (tem)->data]; | 5225 NILP (tem) ? (unsigned char *)"Emacs" : SDATA (tem)]; |
5227 [win setTitle: name]; | 5226 [win setTitle: name]; |
5228 | 5227 |
5229 /* toolbar support */ | 5228 /* toolbar support */ |
5230 toolbar = [[EmacsToolbar alloc] initForView: self withIdentifier: | 5229 toolbar = [[EmacsToolbar alloc] initForView: self withIdentifier: |
5231 [NSString stringWithFormat: @"Emacs Frame %d", | 5230 [NSString stringWithFormat: @"Emacs Frame %d", |
5240 FRAME_NS_TOOLBAR_HEIGHT (f) = 0; | 5239 FRAME_NS_TOOLBAR_HEIGHT (f) = 0; |
5241 | 5240 |
5242 tem = f->icon_name; | 5241 tem = f->icon_name; |
5243 if (!NILP (tem)) | 5242 if (!NILP (tem)) |
5244 [win setMiniwindowTitle: | 5243 [win setMiniwindowTitle: |
5245 [NSString stringWithUTF8String: XSTRING (tem)->data]]; | 5244 [NSString stringWithUTF8String: SDATA (tem)]]; |
5246 | 5245 |
5247 { | 5246 { |
5248 NSScreen *screen = [win screen]; | 5247 NSScreen *screen = [win screen]; |
5249 | 5248 |
5250 if (screen != 0) | 5249 if (screen != 0) |
6147 [expandSpaceSlider setFloatValue: prevExpandSpace]; | 6146 [expandSpaceSlider setFloatValue: prevExpandSpace]; |
6148 [cursorBlinkSlider setFloatValue: prevBlinkRate]; | 6147 [cursorBlinkSlider setFloatValue: prevBlinkRate]; |
6149 [cursorTypeMatrix selectCellWithTag: (cursorType == filled_box ? 1 : | 6148 [cursorTypeMatrix selectCellWithTag: (cursorType == filled_box ? 1 : |
6150 (cursorType == bar ? 2 : | 6149 (cursorType == bar ? 2 : |
6151 (cursorType == underscore ? 3 : 4)))]; | 6150 (cursorType == underscore ? 3 : 4)))]; |
6152 selectItemWithTag (alternateModMenu, lisp_to_mod (ns_alternate_modifier)); | 6151 selectItemWithTag (alternateModMenu, |
6153 selectItemWithTag (commandModMenu, lisp_to_mod (ns_command_modifier)); | 6152 parse_solitary_modifier (ns_alternate_modifier)); |
6153 selectItemWithTag (commandModMenu, | |
6154 parse_solitary_modifier (ns_command_modifier)); | |
6154 #ifdef NS_IMPL_COCOA | 6155 #ifdef NS_IMPL_COCOA |
6155 selectItemWithTag (controlModMenu, lisp_to_mod (ns_control_modifier)); | 6156 selectItemWithTag (controlModMenu, |
6156 selectItemWithTag (functionModMenu, lisp_to_mod (ns_function_modifier)); | 6157 parse_solitary_modifier (ns_control_modifier)); |
6158 selectItemWithTag (functionModMenu, | |
6159 parse_solitary_modifier (ns_function_modifier)); | |
6157 [smoothFontsCheck setState: ns_antialias_text ? YES : NO]; | 6160 [smoothFontsCheck setState: ns_antialias_text ? YES : NO]; |
6158 [useQuickdrawCheck setState: ns_use_qd_smoothing ? YES : NO]; | 6161 [useQuickdrawCheck setState: ns_use_qd_smoothing ? YES : NO]; |
6159 [useSysHiliteCheck setState: prevUseHighlightColor ? YES : NO]; | 6162 [useSysHiliteCheck setState: prevUseHighlightColor ? YES : NO]; |
6160 #endif | 6163 #endif |
6161 } | 6164 } |
6370 NSString *famName; | 6373 NSString *famName; |
6371 | 6374 |
6372 NSTRACE (ns_list_fonts); | 6375 NSTRACE (ns_list_fonts); |
6373 | 6376 |
6374 CHECK_STRING (pattern); | 6377 CHECK_STRING (pattern); |
6375 patt = XSTRING (pattern)->data; | 6378 patt = SDATA (pattern); |
6376 | 6379 |
6377 #if 0 | 6380 #if 0 |
6378 /* temporary: for font_backend, we use fontsets, and when these are defined, | 6381 /* temporary: for font_backend, we use fontsets, and when these are defined, |
6379 the old XLFD-based system is used; eventually this will be replaced by | 6382 the old XLFD-based system is used; eventually this will be replaced by |
6380 backend code, but for now we allow specs that are just family names */ | 6383 backend code, but for now we allow specs that are just family names */ |