diff options
| author | Adrian Robert | 2009-01-29 10:36:22 +0000 |
|---|---|---|
| committer | Adrian Robert | 2009-01-29 10:36:22 +0000 |
| commit | fc7a54a9b867af5b56fa295667fbe251d8fea480 (patch) | |
| tree | a534dd3a61a09a246b9d6bf371d831108b3f3bcd /src | |
| parent | 5e1dedc1ec8543cc4385b0a028e1f11495bc382f (diff) | |
| download | emacs-fc7a54a9b867af5b56fa295667fbe251d8fea480.tar.gz emacs-fc7a54a9b867af5b56fa295667fbe251d8fea480.zip | |
* nsterm.m (ns_confirm_quit): New variable.
(ns_set_default_prefs, syms_of_nsterm, ns_term_init): Initialize it.
(EmacsApp-applicationShouldTerminate:): Use it.
(EmacsPrefsController): Let user set it.
(ns_query_color): New function.
(ns_defined_color): Use it.
(ns_initialize): Drop.
(ns_term_init): Add two lines from ns_initialize(), and set
input_interrupt_mode to nil.
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsterm.m | 65 |
1 files changed, 39 insertions, 26 deletions
diff --git a/src/nsterm.m b/src/nsterm.m index 91dd37e3043..f41aeee2c93 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -186,6 +186,8 @@ Lisp_Object ns_use_qd_smoothing; | |||
| 186 | Lisp_Object ns_use_system_highlight_color; | 186 | Lisp_Object ns_use_system_highlight_color; |
| 187 | NSString *ns_selection_color; | 187 | NSString *ns_selection_color; |
| 188 | 188 | ||
| 189 | /* Confirm on exit. */ | ||
| 190 | Lisp_Object ns_confirm_quit; | ||
| 189 | 191 | ||
| 190 | NSArray *ns_send_types =0, *ns_return_types =0, *ns_drag_types =0; | 192 | NSArray *ns_send_types =0, *ns_return_types =0, *ns_drag_types =0; |
| 191 | 193 | ||
| @@ -1580,6 +1582,28 @@ ns_color_to_lisp (NSColor *col) | |||
| 1580 | } | 1582 | } |
| 1581 | 1583 | ||
| 1582 | 1584 | ||
| 1585 | void | ||
| 1586 | ns_query_color(void *col, XColor *color_def, int setPixel) | ||
| 1587 | /* -------------------------------------------------------------------------- | ||
| 1588 | Get ARGB values out of NSColor col and put them into color_def. | ||
| 1589 | If setPixel, set the pixel to a concatenated version. | ||
| 1590 | and set color_def pixel to the resulting index. | ||
| 1591 | -------------------------------------------------------------------------- */ | ||
| 1592 | { | ||
| 1593 | float r, g, b, a; | ||
| 1594 | |||
| 1595 | [((NSColor *)col) getRed: &r green: &g blue: &b alpha: &a]; | ||
| 1596 | color_def->red = r * 65535; | ||
| 1597 | color_def->green = g * 65535; | ||
| 1598 | color_def->blue = b * 65535; | ||
| 1599 | |||
| 1600 | if (setPixel == YES) | ||
| 1601 | color_def->pixel | ||
| 1602 | = ARGB_TO_ULONG((int)(a*255), | ||
| 1603 | (int)(r*255), (int)(g*255), (int)(b*255)); | ||
| 1604 | } | ||
| 1605 | |||
| 1606 | |||
| 1583 | int | 1607 | int |
| 1584 | ns_defined_color (struct frame *f, char *name, XColor *color_def, int alloc, | 1608 | ns_defined_color (struct frame *f, char *name, XColor *color_def, int alloc, |
| 1585 | char makeIndex) | 1609 | char makeIndex) |
| @@ -1592,7 +1616,6 @@ ns_defined_color (struct frame *f, char *name, XColor *color_def, int alloc, | |||
| 1592 | -------------------------------------------------------------------------- */ | 1616 | -------------------------------------------------------------------------- */ |
| 1593 | { | 1617 | { |
| 1594 | NSColor *temp; | 1618 | NSColor *temp; |
| 1595 | float r, g, b, a; | ||
| 1596 | int notFound = ns_get_color (name, &temp); | 1619 | int notFound = ns_get_color (name, &temp); |
| 1597 | 1620 | ||
| 1598 | NSTRACE (ns_defined_color); | 1621 | NSTRACE (ns_defined_color); |
| @@ -1603,15 +1626,7 @@ ns_defined_color (struct frame *f, char *name, XColor *color_def, int alloc, | |||
| 1603 | if (makeIndex && alloc) | 1626 | if (makeIndex && alloc) |
| 1604 | color_def->pixel = ns_index_color(temp, f); /* [temp retain]; */ | 1627 | color_def->pixel = ns_index_color(temp, f); /* [temp retain]; */ |
| 1605 | 1628 | ||
| 1606 | [temp getRed: &r green: &g blue: &b alpha: &a]; | 1629 | ns_query_color (temp, color_def, !makeIndex); |
| 1607 | color_def->red = r * 65535; | ||
| 1608 | color_def->green = g * 65535; | ||
| 1609 | color_def->blue = b * 65535; | ||
| 1610 | |||
| 1611 | if (!makeIndex) | ||
| 1612 | color_def->pixel | ||
| 1613 | = ARGB_TO_ULONG((int)(a*255), | ||
| 1614 | (int)(r*255), (int)(g*255), (int)(b*255)); | ||
| 1615 | 1630 | ||
| 1616 | return 1; | 1631 | return 1; |
| 1617 | } | 1632 | } |
| @@ -3128,7 +3143,9 @@ ns_read_socket (struct terminal *terminal, int expected, | |||
| 3128 | BLOCK_INPUT; | 3143 | BLOCK_INPUT; |
| 3129 | 3144 | ||
| 3130 | #ifdef COCOA_EXPERIMENTAL_CTRL_G | 3145 | #ifdef COCOA_EXPERIMENTAL_CTRL_G |
| 3131 | /* causes Feval to abort; unclear on why this isn't in calling code */ | 3146 | /* causes Feval to abort; should probably set this in calling code when |
| 3147 | it IS actually called from signal handler (which is only the case | ||
| 3148 | under NS if SYNC_INPUT is off) */ | ||
| 3132 | ++handling_signal; | 3149 | ++handling_signal; |
| 3133 | #endif | 3150 | #endif |
| 3134 | 3151 | ||
| @@ -3549,6 +3566,7 @@ ns_set_default_prefs () | |||
| 3549 | ns_antialias_threshold = 10.0; /* not exposed to lisp side */ | 3566 | ns_antialias_threshold = 10.0; /* not exposed to lisp side */ |
| 3550 | ns_use_qd_smoothing = Qnil; | 3567 | ns_use_qd_smoothing = Qnil; |
| 3551 | ns_use_system_highlight_color = Qt; | 3568 | ns_use_system_highlight_color = Qt; |
| 3569 | ns_confirm_quit = Qnil; | ||
| 3552 | } | 3570 | } |
| 3553 | 3571 | ||
| 3554 | 3572 | ||
| @@ -3739,25 +3757,12 @@ ns_create_terminal (struct ns_display_info *dpyinfo) | |||
| 3739 | } | 3757 | } |
| 3740 | 3758 | ||
| 3741 | 3759 | ||
| 3742 | void | ||
| 3743 | ns_initialize () | ||
| 3744 | /* -------------------------------------------------------------------------- | ||
| 3745 | Mainly vestigial under NS now that ns_create_terminal () does most things. | ||
| 3746 | -------------------------------------------------------------------------- */ | ||
| 3747 | { | ||
| 3748 | baud_rate = 38400; | ||
| 3749 | Fset_input_interrupt_mode (Qt); | ||
| 3750 | } | ||
| 3751 | |||
| 3752 | |||
| 3753 | struct ns_display_info * | 3760 | struct ns_display_info * |
| 3754 | ns_term_init (Lisp_Object display_name) | 3761 | ns_term_init (Lisp_Object display_name) |
| 3755 | /* -------------------------------------------------------------------------- | 3762 | /* -------------------------------------------------------------------------- |
| 3756 | Start the Application and get things rolling. | 3763 | Start the Application and get things rolling. |
| 3757 | -------------------------------------------------------------------------- */ | 3764 | -------------------------------------------------------------------------- */ |
| 3758 | { | 3765 | { |
| 3759 | extern Lisp_Object Fset_input_mode (Lisp_Object, Lisp_Object, | ||
| 3760 | Lisp_Object, Lisp_Object); | ||
| 3761 | struct terminal *terminal; | 3766 | struct terminal *terminal; |
| 3762 | struct ns_display_info *dpyinfo; | 3767 | struct ns_display_info *dpyinfo; |
| 3763 | static int ns_initialized = 0; | 3768 | static int ns_initialized = 0; |
| @@ -3772,7 +3777,8 @@ ns_term_init (Lisp_Object display_name) | |||
| 3772 | 3777 | ||
| 3773 | if (!ns_initialized) | 3778 | if (!ns_initialized) |
| 3774 | { | 3779 | { |
| 3775 | ns_initialize (); | 3780 | baud_rate = 38400; |
| 3781 | Fset_input_interrupt_mode (Qnil); | ||
| 3776 | ns_initialized = 1; | 3782 | ns_initialized = 1; |
| 3777 | } | 3783 | } |
| 3778 | 3784 | ||
| @@ -3858,6 +3864,8 @@ ns_term_init (Lisp_Object display_name) | |||
| 3858 | Qt, Qnil, NO, NO); | 3864 | Qt, Qnil, NO, NO); |
| 3859 | ns_default ("UseSystemHighlightColor", &ns_use_system_highlight_color, | 3865 | ns_default ("UseSystemHighlightColor", &ns_use_system_highlight_color, |
| 3860 | Qt, Qnil, NO, NO); | 3866 | Qt, Qnil, NO, NO); |
| 3867 | ns_default ("ConfirmQuit", &ns_confirm_quit, | ||
| 3868 | Qt, Qnil, NO, NO); | ||
| 3861 | } | 3869 | } |
| 3862 | 3870 | ||
| 3863 | if (EQ (ns_use_system_highlight_color, Qt)) | 3871 | if (EQ (ns_use_system_highlight_color, Qt)) |
| @@ -4187,7 +4195,7 @@ ns_term_shutdown (int sig) | |||
| 4187 | { | 4195 | { |
| 4188 | int ret; | 4196 | int ret; |
| 4189 | 4197 | ||
| 4190 | if (ns_shutdown_properly) | 4198 | if (ns_shutdown_properly || NILP (ns_confirm_quit)) |
| 4191 | return NSTerminateNow; | 4199 | return NSTerminateNow; |
| 4192 | 4200 | ||
| 4193 | /* XXX: This while() loop is needed because if the user switches to another | 4201 | /* XXX: This while() loop is needed because if the user switches to another |
| @@ -6185,6 +6193,7 @@ static void selectItemWithTag (NSPopUpButton *popup, int tag) | |||
| 6185 | [smoothFontsCheck setState: (NILP (ns_antialias_text) ? NO : YES)]; | 6193 | [smoothFontsCheck setState: (NILP (ns_antialias_text) ? NO : YES)]; |
| 6186 | [useQuickdrawCheck setState: (NILP (ns_use_qd_smoothing) ? NO : YES)]; | 6194 | [useQuickdrawCheck setState: (NILP (ns_use_qd_smoothing) ? NO : YES)]; |
| 6187 | [useSysHiliteCheck setState: (NILP (prevUseHighlightColor) ? NO : YES)]; | 6195 | [useSysHiliteCheck setState: (NILP (prevUseHighlightColor) ? NO : YES)]; |
| 6196 | [confirmQuitCheck setState: (NILP (ns_confirm_quit) ? NO : YES)]; | ||
| 6188 | #endif | 6197 | #endif |
| 6189 | } | 6198 | } |
| 6190 | 6199 | ||
| @@ -6242,6 +6251,7 @@ static void selectItemWithTag (NSPopUpButton *popup, int tag) | |||
| 6242 | ns_antialias_text = [smoothFontsCheck state] ? Qt : Qnil; | 6251 | ns_antialias_text = [smoothFontsCheck state] ? Qt : Qnil; |
| 6243 | ns_use_qd_smoothing = [useQuickdrawCheck state] ? Qt : Qnil; | 6252 | ns_use_qd_smoothing = [useQuickdrawCheck state] ? Qt : Qnil; |
| 6244 | ns_use_system_highlight_color = [useSysHiliteCheck state] ? Qt : Qnil; | 6253 | ns_use_system_highlight_color = [useSysHiliteCheck state] ? Qt : Qnil; |
| 6254 | ns_confirm_quit = [confirmQuitCheck state] ? Qt : Qnil; | ||
| 6245 | if (! EQ (ns_use_system_highlight_color, prevUseHighlightColor)) | 6255 | if (! EQ (ns_use_system_highlight_color, prevUseHighlightColor)) |
| 6246 | { | 6256 | { |
| 6247 | prevUseHighlightColor = ns_use_system_highlight_color; | 6257 | prevUseHighlightColor = ns_use_system_highlight_color; |
| @@ -6490,6 +6500,9 @@ or shrunk (negative). Zero (the default) means standard line height.\n\ | |||
| 6490 | &ns_use_system_highlight_color, | 6500 | &ns_use_system_highlight_color, |
| 6491 | "Whether to use the system default (on OS X only) for the highlight color. Nil means to use standard emacs (prior to version 21) 'grey'."); | 6501 | "Whether to use the system default (on OS X only) for the highlight color. Nil means to use standard emacs (prior to version 21) 'grey'."); |
| 6492 | 6502 | ||
| 6503 | DEFVAR_LISP ("ns-confirm-quit", &ns_confirm_quit, | ||
| 6504 | "Whether to confirm application quit using dialog."); | ||
| 6505 | |||
| 6493 | staticpro (&ns_display_name_list); | 6506 | staticpro (&ns_display_name_list); |
| 6494 | ns_display_name_list = Qnil; | 6507 | ns_display_name_list = Qnil; |
| 6495 | 6508 | ||