aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Reitter2009-03-14 21:19:56 +0000
committerDavid Reitter2009-03-14 21:19:56 +0000
commitc6c62e780c0a8023d59dcda99a80d9c525bd3912 (patch)
treece840baf685b906dadefe9cccab6c0cfa7b3936c /src
parentb769f3daadece9dd4e9b7f9f0f1d20b4bd9900e6 (diff)
downloademacs-c6c62e780c0a8023d59dcda99a80d9c525bd3912.tar.gz
emacs-c6c62e780c0a8023d59dcda99a80d9c525bd3912.zip
Unify shutdown handling under NS, via ns-power-off key event (where appropriate) and save-buffers-kill-emacs.
remove NS-specific preferences window that used to show NS-specific preferences. Integrate preferences in Lisp accessible customization system where possible. Remove ns-expand-space, because it can be set only during fontloading (i.e. not at runtime), and because of redundancy with line-spacing frame parameter. Remove loading of most and saving of all NS resources (from org.gnu.Emacs.plist). nsterm.m (ns_shutdown_properly, -terminate): remove global state variable as it was never reset (ns_term_init): remove initialization of Lisp-settable defaults and ns_expand_space (-setPanelFromDefaultValues): remove ns_expand_space. (-showPreferencesWindow): send new KEY_NS_SHOW_PREFS key. nsfont.m (nsfont_open): remove ns_expand_space, assume -0.5 i.e. no additional spacing, similar to Carbon port. nsterm.h: define KEY_NS_SHOW_PREFS key. nsfns.m (ns-popup-prefs-panel): remove. term/ns-win.el (ns-expand-space): remove. (ns-show-prefs event): run `customize'. (ns-power-off): run `save-buffers-kill-emacs', but ask user whether to save files (as is standard) (clipboard-yank, clipboard-kill-ring-save, clipboard-kill-region) (menu-bar-enable-clipboard): do not undefine these. (ns-save-preferences,ns-save-options,ns-show-preferences-help): remove.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog14
-rw-r--r--src/nsfns.m12
-rw-r--r--src/nsfont.m12
-rw-r--r--src/nsterm.h48
-rw-r--r--src/nsterm.m321
5 files changed, 58 insertions, 349 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e36287cb7f8..551e526ba61 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,17 @@
12009-03-14 David Reitter <david.reitter@gmail.com>
2
3 * nsterm.m (ns_shutdown_properly, -terminate): remove global state
4 variable as it was never reset
5 (ns_term_init): remove initialization of Lisp-settable defaults
6 and ns_expand_space
7 (-setPanelFromDefaultValues): remove ns_expand_space.
8 (-showPreferencesWindow): send new KEY_NS_SHOW_PREFS key.
9 * nsfont.m (nsfont_open): remove ns_expand_space, assume -0.5
10 i.e. no additional spacing, similar to Carbon port.
11
12 * nsterm.h: define KEY_NS_SHOW_PREFS key.
13 * nsfns.m (ns-popup-prefs-panel): remove.
14
12009-03-14 Jan Djärv <jan.h.d@swipnet.se> 152009-03-14 Jan Djärv <jan.h.d@swipnet.se>
2 16
3 * sound.c (alsa_configure): Remove call to deprecated 17 * sound.c (alsa_configure): Remove call to deprecated
diff --git a/src/nsfns.m b/src/nsfns.m
index 77a222b0c3d..b6d0d189cc5 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -1379,17 +1379,6 @@ FRAME nil means use the selected frame. */)
1379} 1379}
1380 1380
1381 1381
1382DEFUN ("ns-popup-prefs-panel", Fns_popup_prefs_panel, Sns_popup_prefs_panel,
1383 0, 0, "",
1384 doc: /* Pop up the preferences panel. */)
1385 ()
1386{
1387 check_ns ();
1388 [(EmacsApp *)NSApp showPreferencesWindow: NSApp];
1389 return Qnil;
1390}
1391
1392
1393DEFUN ("ns-popup-font-panel", Fns_popup_font_panel, Sns_popup_font_panel, 1382DEFUN ("ns-popup-font-panel", Fns_popup_font_panel, Sns_popup_font_panel,
1394 0, 1, "", 1383 0, 1, "",
1395 doc: /* Pop up the font panel. */) 1384 doc: /* Pop up the font panel. */)
@@ -2729,7 +2718,6 @@ be used as the image of the icon representing the frame. */);
2729 defsubr (&Sns_perform_service); 2718 defsubr (&Sns_perform_service);
2730 defsubr (&Sns_convert_utf8_nfd_to_nfc); 2719 defsubr (&Sns_convert_utf8_nfd_to_nfc);
2731 defsubr (&Sx_focus_frame); 2720 defsubr (&Sx_focus_frame);
2732 defsubr (&Sns_popup_prefs_panel);
2733 defsubr (&Sns_popup_font_panel); 2721 defsubr (&Sns_popup_font_panel);
2734 defsubr (&Sns_popup_color_panel); 2722 defsubr (&Sns_popup_color_panel);
2735 2723
diff --git a/src/nsfont.m b/src/nsfont.m
index e2e537f67e7..902e73d48e9 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -42,7 +42,6 @@ Author: Adrian Robert (arobert@cogsci.ucsd.edu)
42extern Lisp_Object Qns; 42extern Lisp_Object Qns;
43extern Lisp_Object Qnormal, Qbold, Qitalic, Qcondensed, Qexpanded; 43extern Lisp_Object Qnormal, Qbold, Qitalic, Qcondensed, Qexpanded;
44static Lisp_Object Qapple, Qroman, Qmedium; 44static Lisp_Object Qapple, Qroman, Qmedium;
45extern Lisp_Object ns_expand_space;
46extern Lisp_Object Qappend; 45extern Lisp_Object Qappend;
47extern int ns_antialias_text, ns_use_qd_smoothing; 46extern int ns_antialias_text, ns_use_qd_smoothing;
48extern float ns_antialias_threshold; 47extern float ns_antialias_threshold;
@@ -658,12 +657,12 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
658 min_height = [sfont ascender] - [sfont descender]; 657 min_height = [sfont ascender] - [sfont descender];
659 hd = full_height - min_height; 658 hd = full_height - min_height;
660 659
661 if (!NUMBERP (ns_expand_space)) 660 /* standard height, similar to Carbon. Emacs.app: was 0.5 by default. */
662 error ("No expand space defined"); 661 expand = 0.0;
663 662 shrink = 1.0;
664 /* ns_expand_space = 0.0 is use standard height; less shrink, more expand */ 663 hshrink = 1.0;
665 expand = XFLOATINT (ns_expand_space) + 0.5;
666 664
665 /*
667 if (expand < 0.0) 666 if (expand < 0.0)
668 { 667 {
669 shrink = 1 + expand; 668 shrink = 1 + expand;
@@ -672,6 +671,7 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
672 } 671 }
673 else 672 else
674 shrink = hshrink = 1.0; 673 shrink = hshrink = 1.0;
674 */
675 675
676 font_info->underpos = 2; /*[sfont underlinePosition] is often clipped out */ 676 font_info->underpos = 2; /*[sfont underlinePosition] is often clipped out */
677 font_info->underwidth = [sfont underlineThickness]; 677 font_info->underwidth = [sfont underlineThickness];
diff --git a/src/nsterm.h b/src/nsterm.h
index 7ba1243dc0e..392c79a278c 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -317,52 +317,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
317@end 317@end
318#endif /* NS_IMPL_COCOA */ 318#endif /* NS_IMPL_COCOA */
319 319
320
321/* ==========================================================================
322
323 Running the preferences window
324
325 ========================================================================== */
326
327@interface EmacsPrefsController : NSObject
328{
329 struct frame *frame;
330 IBOutlet NSWindow *prefsWindow;
331 IBOutlet NSPopUpButton *alternateModMenu;
332 IBOutlet NSPopUpButton *commandModMenu;
333#ifdef NS_IMPL_COCOA
334 IBOutlet NSPopUpButton *controlModMenu;
335 IBOutlet NSPopUpButton *functionModMenu;
336#endif
337 IBOutlet NSMatrix *cursorTypeMatrix;
338 IBOutlet NSSlider *expandSpaceSlider;
339#ifdef NS_IMPL_COCOA
340 IBOutlet NSButton *smoothFontsCheck;
341 IBOutlet NSButton *useQuickdrawCheck;
342 IBOutlet NSButton *useSysHiliteCheck;
343 IBOutlet NSButton *confirmQuitCheck;
344 Lisp_Object prevUseHighlightColor;
345#endif
346 float prevExpandSpace;
347#ifdef NS_IMPL_GNUSTEP
348 /* TODO: remove as soon as someone can edit the .nib to replace the
349 cursor-blink widget with checkbox conn to confirmQuitCheck */
350 IBOutlet NSSlider *cursorBlinkSlider;
351#endif
352}
353- (IBAction)cancel: (id)sender;
354- (IBAction)ok: (id)sender;
355- (IBAction)resetToDefaults: (id)sender;
356- (IBAction)runHelp: (id)sender;
357- (IBAction)setColors: (id)sender;
358- (IBAction)setDefaultFont: (id)sender;
359
360- (void) showForFrame: (struct frame *)f;
361- (void) setPanelFromValues;
362- (void) setPanelFromDefaultValues;
363- (void) setValuesFromPanel;
364@end
365
366extern NSArray *ns_send_types, *ns_return_types; 320extern NSArray *ns_send_types, *ns_return_types;
367extern EmacsMenu *mainMenu, *svcsMenu, *dockMenu; 321extern EmacsMenu *mainMenu, *svcsMenu, *dockMenu;
368 322
@@ -402,7 +356,7 @@ typedef unsigned long NSUInteger;
402#define KEY_NS_SPI_SERVICE_CALL ((1<<28)|(0<<16)|11) 356#define KEY_NS_SPI_SERVICE_CALL ((1<<28)|(0<<16)|11)
403#define KEY_NS_NEW_FRAME ((1<<28)|(0<<16)|12) 357#define KEY_NS_NEW_FRAME ((1<<28)|(0<<16)|12)
404#define KEY_NS_TOGGLE_TOOLBAR ((1<<28)|(0<<16)|13) 358#define KEY_NS_TOGGLE_TOOLBAR ((1<<28)|(0<<16)|13)
405#define KEY_NS_INFO_PREFS ((1<<28)|(0<<16)|14) 359#define KEY_NS_SHOW_PREFS ((1<<28)|(0<<16)|14)
406 360
407/* could use list to store these, but rest of emacs has a big infrastructure 361/* could use list to store these, but rest of emacs has a big infrastructure
408 for managing a table of bitmap "records" */ 362 for managing a table of bitmap "records" */
diff --git a/src/nsterm.m b/src/nsterm.m
index 9bc063e3054..07acc8d8013 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -136,15 +136,9 @@ Lisp_Object Qalt, Qcontrol, Qhyper, Qmeta, Qsuper;
136extern Lisp_Object Qcursor_color, Qcursor_type, Qns; 136extern Lisp_Object Qcursor_color, Qcursor_type, Qns;
137 137
138 138
139EmacsPrefsController *prefsController; 139/* Some preferences equivalent to those set by X resources under X are
140 140 managed through the OpenStep defaults system. We depart from X
141/* Preferences equivalent to those set by X resources under X are managed 141 behavior and refuse to read defaults when started under these
142 through the OpenStep defaults system. These pertain to behavior of the
143 graphical interface components. The one difference from X is that the
144 values below are SET when the user chooses save-options. This makes
145 things easier for users, but sometimes violates expectations when some
146 user-set options appear when running under -q/Q. Therefore we depart
147 from X behavior and refuse to read defaults when started under these
148 options. */ 142 options. */
149 143
150/* Set in emacs.c. */ 144/* Set in emacs.c. */
@@ -166,11 +160,6 @@ Lisp_Object ns_control_modifier;
166 the Function modifer (laptops). May be any of the modifier lisp symbols. */ 160 the Function modifer (laptops). May be any of the modifier lisp symbols. */
167Lisp_Object ns_function_modifier; 161Lisp_Object ns_function_modifier;
168 162
169/* A floating point value specifying vertical stretch (positive) or shrink
170 (negative) of text line spacing. Zero means default spacing.
171 YES indicates 0.5, NO indicates 0.0. */
172Lisp_Object ns_expand_space;
173
174/* Control via default 'GSFontAntiAlias' on OS X and GNUstep. */ 163/* Control via default 'GSFontAntiAlias' on OS X and GNUstep. */
175Lisp_Object ns_antialias_text; 164Lisp_Object ns_antialias_text;
176 165
@@ -234,7 +223,6 @@ static fd_set select_readfds, t_readfds;
234static struct timeval select_timeout; 223static struct timeval select_timeout;
235static int select_nfds; 224static int select_nfds;
236static NSAutoreleasePool *outerpool; 225static NSAutoreleasePool *outerpool;
237static BOOL ns_shutdown_properly = NO;
238static struct input_event *emacs_event = NULL; 226static struct input_event *emacs_event = NULL;
239static struct input_event *q_event_ptr = NULL; 227static struct input_event *q_event_ptr = NULL;
240static int n_emacs_events_pending = 0; 228static int n_emacs_events_pending = 0;
@@ -3563,7 +3551,6 @@ ns_set_default_prefs ()
3563 ns_command_modifier = Qsuper; 3551 ns_command_modifier = Qsuper;
3564 ns_control_modifier = Qcontrol; 3552 ns_control_modifier = Qcontrol;
3565 ns_function_modifier = Qnone; 3553 ns_function_modifier = Qnone;
3566 ns_expand_space = make_float (0.0);
3567 ns_antialias_text = Qt; 3554 ns_antialias_text = Qt;
3568 ns_antialias_threshold = 10.0; /* not exposed to lisp side */ 3555 ns_antialias_threshold = 10.0; /* not exposed to lisp side */
3569 ns_use_qd_smoothing = Qnil; 3556 ns_use_qd_smoothing = Qnil;
@@ -3838,48 +3825,20 @@ ns_term_init (Lisp_Object display_name)
3838 ns_set_default_prefs (); 3825 ns_set_default_prefs ();
3839 if (!ns_no_defaults) 3826 if (!ns_no_defaults)
3840 { 3827 {
3841 ns_default ("AlternateModifier", &ns_alternate_modifier,
3842 Qnil, Qnil, NO, YES);
3843 if (NILP (ns_alternate_modifier))
3844 ns_alternate_modifier = Qmeta;
3845 ns_default ("CommandModifier", &ns_command_modifier,
3846 Qnil, Qnil, NO, YES);
3847 if (NILP (ns_command_modifier))
3848 ns_command_modifier = Qsuper;
3849 ns_default ("ControlModifier", &ns_control_modifier,
3850 Qnil, Qnil, NO, YES);
3851 if (NILP (ns_control_modifier))
3852 ns_control_modifier = Qcontrol;
3853 ns_default ("FunctionModifier", &ns_function_modifier,
3854 Qnil, Qnil, NO, YES);
3855 if (NILP (ns_function_modifier))
3856 ns_function_modifier = Qnone;
3857 ns_default ("ExpandSpace", &ns_expand_space,
3858 make_float (0.5), make_float (0.0), YES, NO);
3859 ns_default ("GSFontAntiAlias", &ns_antialias_text, 3828 ns_default ("GSFontAntiAlias", &ns_antialias_text,
3860 Qt, Qnil, NO, NO); 3829 Qt, Qnil, NO, NO);
3861 tmp = Qnil; 3830 tmp = Qnil;
3831 /* this is a standard variable */
3862 ns_default ("AppleAntiAliasingThreshold", &tmp, 3832 ns_default ("AppleAntiAliasingThreshold", &tmp,
3863 make_float (10.0), make_float (6.0), YES, NO); 3833 make_float (10.0), make_float (6.0), YES, NO);
3864 ns_antialias_threshold = NILP (tmp) ? 10.0 : XFLOATINT (tmp); 3834 ns_antialias_threshold = NILP (tmp) ? 10.0 : XFLOATINT (tmp);
3865 ns_default ("UseQuickdrawSmoothing", &ns_use_qd_smoothing,
3866 Qt, Qnil, NO, NO);
3867 ns_default ("UseSystemHighlightColor", &ns_use_system_highlight_color,
3868 Qt, Qnil, NO, NO);
3869 ns_default ("ConfirmQuit", &ns_confirm_quit,
3870 Qt, Qnil, NO, NO);
3871 } 3835 }
3872 3836
3873 if (EQ (ns_use_system_highlight_color, Qt)) 3837 ns_selection_color = [[NSUserDefaults standardUserDefaults]
3874 { 3838 stringForKey: @"AppleHighlightColor"];
3875 ns_selection_color = [[NSUserDefaults standardUserDefaults] 3839 if (ns_selection_color == nil)
3876 stringForKey: @"AppleHighlightColor"];
3877 if (ns_selection_color == nil)
3878 ns_selection_color = NS_SELECTION_COLOR_DEFAULT;
3879 }
3880 else
3881 ns_selection_color = NS_SELECTION_COLOR_DEFAULT; 3840 ns_selection_color = NS_SELECTION_COLOR_DEFAULT;
3882 3841
3883 { 3842 {
3884 NSColorList *cl = [NSColorList colorListNamed: @"Emacs"]; 3843 NSColorList *cl = [NSColorList colorListNamed: @"Emacs"];
3885 3844
@@ -4008,7 +3967,6 @@ ns_term_shutdown (int sig)
4008 3967
4009 if (sig == 0 || sig == SIGTERM) 3968 if (sig == 0 || sig == SIGTERM)
4010 { 3969 {
4011 ns_shutdown_properly = YES;
4012 [NSApp terminate: NSApp]; 3970 [NSApp terminate: NSApp];
4013 } 3971 }
4014 else // force a stack trace to happen 3972 else // force a stack trace to happen
@@ -4104,9 +4062,15 @@ ns_term_shutdown (int sig)
4104 4062
4105- (void)showPreferencesWindow: (id)sender 4063- (void)showPreferencesWindow: (id)sender
4106{ 4064{
4107 if (prefsController == nil) 4065 struct frame *emacsframe = SELECTED_FRAME ();
4108 prefsController = [[EmacsPrefsController alloc] init]; 4066 NSEvent *theEvent = [NSApp currentEvent];
4109 [prefsController showForFrame: SELECTED_FRAME ()]; 4067
4068 if (!emacs_event)
4069 return;
4070 emacs_event->kind = NS_NONKEY_EVENT;
4071 emacs_event->code = KEY_NS_SHOW_PREFS;
4072 emacs_event->modifiers = 0;
4073 EV_TRAILER (theEvent);
4110} 4074}
4111 4075
4112 4076
@@ -4161,47 +4125,38 @@ ns_term_shutdown (int sig)
4161} 4125}
4162 4126
4163 4127
4164/* Termination sequences (ns_shutdown_properly): 4128/* Termination sequences:
4165 C-x C-c: 4129 C-x C-c:
4166 Cmd-Q: 4130 Cmd-Q:
4167 MenuBar | File | Exit: 4131 MenuBar | File | Exit:
4168 ns_term_shutdown: 0
4169 -terminate: 1
4170 -appShouldTerminate: 1
4171
4172 Select Quit from App menubar: 4132 Select Quit from App menubar:
4173 received -terminate: 0 4133 -terminate
4174 ns_term_shutdown: 0 4134 KEY_NS_POWER_OFF, (save-buffers-kill-emacs)
4175 -terminate: 1 4135 ns_term_shutdown()
4176 -appShouldTerminate: 1
4177 4136
4178 Select Quit from Dock menu: 4137 Select Quit from Dock menu:
4179 Logout attempt: 4138 Logout attempt:
4180 -appShouldTerminate: 0 4139 -appShouldTerminate
4181 Cancel -> Nothing else 4140 Cancel -> Nothing else
4182 Accept -> 4141 Accept ->
4183 -terminate: 0 4142
4184 ns_term_shutdown: 0 4143 -terminate
4185 -terminate: 1 4144 KEY_NS_POWER_OFF, (save-buffers-kill-emacs)
4186 -appShouldTerminate: 1 4145 ns_term_shutdown()
4146
4187*/ 4147*/
4188 4148
4189- (void) terminate: (id)sender 4149- (void) terminate: (id)sender
4190{ 4150{
4191 if (ns_shutdown_properly) 4151 struct frame *emacsframe = SELECTED_FRAME ();
4192 [super terminate: sender]; 4152
4193 else 4153 if (!emacs_event)
4194 { 4154 return;
4195 struct frame *emacsframe = SELECTED_FRAME (); 4155
4196 4156 emacs_event->kind = NS_NONKEY_EVENT;
4197 if (!emacs_event) 4157 emacs_event->code = KEY_NS_POWER_OFF;
4198 return; 4158 emacs_event->arg = Qt; /* mark as non-key event */
4199 4159 EV_TRAILER ((id)nil);
4200 ns_shutdown_properly = YES;
4201 emacs_event->kind = NON_ASCII_KEYSTROKE_EVENT;
4202 emacs_event->code = KEY_NS_POWER_OFF;
4203 EV_TRAILER ((id)nil);
4204 }
4205} 4160}
4206 4161
4207 4162
@@ -4209,7 +4164,7 @@ ns_term_shutdown (int sig)
4209{ 4164{
4210 int ret; 4165 int ret;
4211 4166
4212 if (ns_shutdown_properly || NILP (ns_confirm_quit)) 4167 if (NILP (ns_confirm_quit)) // || ns_shutdown_properly --> TO DO
4213 return NSTerminateNow; 4168 return NSTerminateNow;
4214 4169
4215 ret = NSRunAlertPanel([[NSProcessInfo processInfo] processName], 4170 ret = NSRunAlertPanel([[NSProcessInfo processInfo] processName],
@@ -6133,203 +6088,6 @@ extern void update_window_cursor (struct window *w, int on);
6133 6088
6134 6089
6135 6090
6136/* ==========================================================================
6137
6138 EmacsPrefsController implementation
6139
6140 ========================================================================== */
6141
6142
6143@implementation EmacsPrefsController
6144
6145/* in Tiger+, can just do [popup selectItemWithTag: tag]; */
6146static void selectItemWithTag (NSPopUpButton *popup, int tag)
6147{
6148 NSEnumerator *items = [[popup itemArray] objectEnumerator];
6149 NSMenuItem *item;
6150 while (item = [items nextObject])
6151 {
6152 if ([item tag] == tag)
6153 {
6154 [popup selectItem: item];
6155 return;
6156 }
6157 }
6158}
6159
6160- init
6161{
6162 [NSBundle loadNibNamed: @"preferences" owner: self];
6163 return self;
6164}
6165
6166
6167- (void) showForFrame: (struct frame *)f
6168{
6169 frame = f;
6170 [self setPanelFromValues];
6171 [prefsWindow makeKeyAndOrderFront: self];
6172 [prefsWindow display];
6173}
6174
6175
6176/* If you change this, change setPanelFromDefaultValues too. */
6177- (void) setPanelFromValues
6178{
6179 int cursorType
6180 = ns_lisp_to_cursor_type (get_frame_param (frame, Qcursor_type));
6181 prevExpandSpace = XFLOATINT (ns_expand_space);
6182
6183#ifdef NS_IMPL_COCOA
6184 prevUseHighlightColor = ns_use_system_highlight_color;
6185#endif
6186
6187 [expandSpaceSlider setFloatValue: prevExpandSpace];
6188 [cursorTypeMatrix selectCellWithTag: (cursorType == FILLED_BOX_CURSOR ? 1 :
6189 (cursorType == BAR_CURSOR ? 2 :
6190 (cursorType == HBAR_CURSOR ? 3 : 4)))];
6191 selectItemWithTag (alternateModMenu,
6192 parse_solitary_modifier (ns_alternate_modifier));
6193 selectItemWithTag (commandModMenu,
6194 parse_solitary_modifier (ns_command_modifier));
6195#ifdef NS_IMPL_COCOA
6196 selectItemWithTag (controlModMenu,
6197 parse_solitary_modifier (ns_control_modifier));
6198 selectItemWithTag (functionModMenu,
6199 parse_solitary_modifier (ns_function_modifier));
6200 [smoothFontsCheck setState: (NILP (ns_antialias_text) ? NO : YES)];
6201 [useQuickdrawCheck setState: (NILP (ns_use_qd_smoothing) ? NO : YES)];
6202 [useSysHiliteCheck setState: (NILP (prevUseHighlightColor) ? NO : YES)];
6203 [confirmQuitCheck setState: (NILP (ns_confirm_quit) ? NO : YES)];
6204#endif
6205}
6206
6207
6208/* This and ns_set_default_prefs should be changed together. */
6209- (void) setPanelFromDefaultValues
6210{
6211 [expandSpaceSlider setFloatValue: 0.0];
6212 [cursorTypeMatrix selectCellWithTag: 1]; /* filled box */
6213 selectItemWithTag (alternateModMenu, meta_modifier);
6214 selectItemWithTag (commandModMenu, super_modifier);
6215#ifdef NS_IMPL_COCOA
6216 selectItemWithTag (controlModMenu, ctrl_modifier);
6217 selectItemWithTag (functionModMenu, 0); /* none */
6218 [smoothFontsCheck setState: YES];
6219 [useQuickdrawCheck setState: NO];
6220 [useSysHiliteCheck setState: YES];
6221#endif
6222}
6223
6224
6225- (void) setValuesFromPanel
6226{
6227 int altTag = [[alternateModMenu selectedItem] tag];
6228 int cmdTag = [[commandModMenu selectedItem] tag];
6229#ifdef NS_IMPL_COCOA
6230 int ctrlTag = [[controlModMenu selectedItem] tag];
6231 int fnTag = [[functionModMenu selectedItem] tag];
6232#endif
6233 float expandSpace = [expandSpaceSlider floatValue];
6234 int cursorTag = [[cursorTypeMatrix selectedCell] tag];
6235 Lisp_Object cursor_type = ns_cursor_type_to_lisp
6236 ( cursorTag == 1 ? FILLED_BOX_CURSOR
6237 : cursorTag == 2 ? BAR_CURSOR
6238 : cursorTag == 3 ? HBAR_CURSOR : HOLLOW_BOX_CURSOR);
6239
6240 if (expandSpace != prevExpandSpace)
6241 {
6242 ns_expand_space = make_float (expandSpace);
6243 /* TODO: more needed: store needed metrics in nsfont_info, update
6244 frame default font max_bounds and fontp, recompute faces */
6245/* FRAME_LINE_HEIGHT (frame) *= (expandSpace / prevExpandSpace);
6246 x_set_window_size (frame, 0, frame->text_cols, frame->text_lines); */
6247 prevExpandSpace = expandSpace;
6248 }
6249
6250 store_frame_param (frame, Qcursor_type, cursor_type);
6251 x_set_cursor_type (frame, cursor_type, Qnil); /* FIXME: do only if changed */
6252
6253 ns_alternate_modifier = ns_mod_to_lisp (altTag);
6254 ns_command_modifier = ns_mod_to_lisp (cmdTag);
6255#ifdef NS_IMPL_COCOA
6256 ns_control_modifier = ns_mod_to_lisp (ctrlTag);
6257 ns_function_modifier = ns_mod_to_lisp (fnTag);
6258 ns_antialias_text = [smoothFontsCheck state] ? Qt : Qnil;
6259 ns_use_qd_smoothing = [useQuickdrawCheck state] ? Qt : Qnil;
6260 ns_use_system_highlight_color = [useSysHiliteCheck state] ? Qt : Qnil;
6261 ns_confirm_quit = [confirmQuitCheck state] ? Qt : Qnil;
6262 if (! EQ (ns_use_system_highlight_color, prevUseHighlightColor))
6263 {
6264 prevUseHighlightColor = ns_use_system_highlight_color;
6265 if (EQ (ns_use_system_highlight_color, Qt))
6266 {
6267 ns_selection_color = [[NSUserDefaults standardUserDefaults]
6268 stringForKey: @"AppleHighlightColor"];
6269 if (ns_selection_color == nil)
6270 ns_selection_color = NS_SELECTION_COLOR_DEFAULT;
6271 }
6272 else
6273 ns_selection_color = NS_SELECTION_COLOR_DEFAULT;
6274 }
6275#endif /* NS_IMPL_COCOA */
6276 Fcall_interactively (intern ("ns-save-preferences"), Qnil, Qnil);
6277}
6278
6279
6280/* buttons */
6281- (IBAction)cancel: (id)sender
6282{
6283 [prefsWindow close];
6284}
6285
6286
6287- (IBAction)ok: (id)sender
6288{
6289 [self setValuesFromPanel];
6290 [prefsWindow close];
6291}
6292
6293
6294- (IBAction)resetToDefaults: (id)sender
6295{
6296 [self setPanelFromDefaultValues];
6297}
6298
6299
6300- (IBAction)runHelp: (id)sender
6301{
6302 struct frame *emacsframe = frame;
6303 if (!emacs_event)
6304 return;
6305 ns_raise_frame(frame);
6306 emacs_event->kind = NS_NONKEY_EVENT;
6307 emacs_event->code = KEY_NS_INFO_PREFS;
6308 EV_TRAILER ((id)nil);
6309}
6310
6311
6312- (IBAction)setColors: (id)sender
6313{
6314 Lisp_Object lispFrame;
6315 XSETFRAME (lispFrame, frame);
6316 ns_raise_frame(frame);
6317 Fns_popup_color_panel (lispFrame);
6318}
6319
6320
6321- (IBAction)setDefaultFont: (id)sender
6322{
6323 Lisp_Object lispFrame;
6324 XSETFRAME (lispFrame, frame);
6325 ns_raise_frame(frame);
6326 Fns_popup_font_panel (lispFrame);
6327}
6328
6329@end /* EmacsPrefsController */
6330
6331
6332
6333 6091
6334/* ========================================================================== 6092/* ==========================================================================
6335 6093
@@ -6492,11 +6250,6 @@ Set to control, meta, alt, super, or hyper means it is taken to be that key.\n\
6492Set to none means that the function key is not interpreted by Emacs at all,\n\ 6250Set to none means that the function key is not interpreted by Emacs at all,\n\
6493allowing it to be used at a lower level for accented character entry."); 6251allowing it to be used at a lower level for accented character entry.");
6494 6252
6495 DEFVAR_LISP ("ns-expand-space", &ns_expand_space,
6496 "Amount by which spacing between lines is expanded (positive)\n\
6497or shrunk (negative). Zero (the default) means standard line height.\n\
6498(This variable should only be read, never set.)");
6499
6500 DEFVAR_LISP ("ns-antialias-text", &ns_antialias_text, 6253 DEFVAR_LISP ("ns-antialias-text", &ns_antialias_text,
6501 "Non-nil (the default) means to render text antialiased. Only has an effect on OS X Panther and above."); 6254 "Non-nil (the default) means to render text antialiased. Only has an effect on OS X Panther and above.");
6502 6255