1 /* Functions for the NeXT/Open/GNUstep and MacOSX window system.
3 Copyright (C) 1989, 1992-1994, 2005-2006, 2008-2011 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 Originally by Carl Edman
22 Updated by Christian Limpach (chris@nice.ch)
23 OpenStep/Rhapsody port by Scott Bender (sbender@harmony-ds.com)
24 MacOSX/Aqua port by Christophe de Dinechin (descubes@earthlink.net)
25 GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
28 /* This should be the first include, as it may set up #defines affecting
29 interpretation of even the system includes. */
37 #include "blockinput.h"
42 #include "termhooks.h"
44 #include "character.h"
48 int fns_trace_num = 1;
49 #define NSTRACE(x) fprintf (stderr, "%s:%d: [%d] " #x "\n", \
50 __FILE__, __LINE__, ++fns_trace_num)
57 extern NSArray *ns_send_types, *ns_return_types, *ns_drag_types;
59 extern Lisp_Object Qforeground_color;
60 extern Lisp_Object Qbackground_color;
61 extern Lisp_Object Qcursor_color;
62 extern Lisp_Object Qinternal_border_width;
63 extern Lisp_Object Qvisibility;
64 extern Lisp_Object Qcursor_type;
65 extern Lisp_Object Qicon_type;
66 extern Lisp_Object Qicon_name;
67 extern Lisp_Object Qicon_left;
68 extern Lisp_Object Qicon_top;
69 extern Lisp_Object Qleft;
70 extern Lisp_Object Qright;
71 extern Lisp_Object Qtop;
72 extern Lisp_Object Qdisplay;
73 extern Lisp_Object Qvertical_scroll_bars;
74 extern Lisp_Object Qauto_raise;
75 extern Lisp_Object Qauto_lower;
76 extern Lisp_Object Qbox;
77 extern Lisp_Object Qscroll_bar_width;
78 extern Lisp_Object Qx_resource_name;
79 extern Lisp_Object Qface_set_after_frame_default;
80 extern Lisp_Object Qunderline, Qundefined;
81 extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth;
82 extern Lisp_Object Qunsplittable, Qmenu_bar_lines, Qbuffer_predicate, Qtitle;
83 extern Lisp_Object Qnone;
86 Lisp_Object Qbuffered;
87 Lisp_Object Qfontsize;
89 /* hack for OS X file panels */
92 EmacsTooltip *ns_tooltip;
94 /* Need forward declaration here to preserve organizational integrity of file */
95 Lisp_Object Fx_open_connection (Lisp_Object, Lisp_Object, Lisp_Object);
97 extern BOOL ns_in_resize;
100 /* ==========================================================================
102 Internal utility functions
104 ========================================================================== */
111 error ("OpenStep is not in use or not initialized");
115 /* Nonzero if we can use mouse menus. */
123 /* Extract a frame as a FRAME_PTR, defaulting to the selected frame
124 and checking validity for NS. */
126 check_ns_frame (Lisp_Object frame)
131 f = SELECTED_FRAME ();
134 CHECK_LIVE_FRAME (frame);
137 if (! FRAME_NS_P (f))
138 error ("non-Nextstep frame used");
143 /* Let the user specify an Nextstep display with a frame.
144 nil stands for the selected frame--or, if that is not an Nextstep frame,
145 the first Nextstep display on the list. */
146 static struct ns_display_info *
147 check_ns_display_info (Lisp_Object frame)
151 struct frame *f = SELECTED_FRAME ();
152 if (FRAME_NS_P (f) && FRAME_LIVE_P (f) )
153 return FRAME_NS_DISPLAY_INFO (f);
154 else if (x_display_list != 0)
155 return x_display_list;
157 error ("Nextstep windows are not in use or not initialized");
159 else if (INTEGERP (frame))
161 struct terminal *t = get_terminal (frame, 1);
163 if (t->type != output_ns)
164 error ("Terminal %d is not a Nextstep display", XINT (frame));
166 return t->display_info.ns;
168 else if (STRINGP (frame))
169 return ns_display_info_for_name (frame);
174 CHECK_LIVE_FRAME (frame);
176 if (! FRAME_NS_P (f))
177 error ("non-Nextstep frame used");
178 return FRAME_NS_DISPLAY_INFO (f);
180 return NULL; /* shut compiler up */
185 ns_get_window (Lisp_Object maybeFrame)
187 id view =nil, window =nil;
189 if (!FRAMEP (maybeFrame) || !FRAME_NS_P (XFRAME (maybeFrame)))
190 maybeFrame = selected_frame;/*wrong_type_argument (Qframep, maybeFrame); */
192 if (!NILP (maybeFrame))
193 view = FRAME_NS_VIEW (XFRAME (maybeFrame));
194 if (view) window =[view window];
201 ns_get_screen (Lisp_Object screen)
204 struct terminal *terminal;
206 if (EQ (Qt, screen)) /* not documented */
207 return [NSScreen mainScreen];
209 terminal = get_terminal (screen, 1);
210 if (terminal->type != output_ns)
214 f = SELECTED_FRAME ();
215 else if (FRAMEP (screen))
219 struct ns_display_info *dpyinfo = terminal->display_info.ns;
220 f = dpyinfo->x_focus_frame
221 ? dpyinfo->x_focus_frame : dpyinfo->x_highlight_frame;
224 return ((f && FRAME_NS_P (f)) ? [[FRAME_NS_VIEW (f) window] screen]
229 /* Return the X display structure for the display named NAME.
230 Open a new connection if necessary. */
231 struct ns_display_info *
232 ns_display_info_for_name (Lisp_Object name)
235 struct ns_display_info *dpyinfo;
239 for (dpyinfo = x_display_list, names = ns_display_name_list;
241 dpyinfo = dpyinfo->next, names = XCDR (names))
244 tem = Fstring_equal (XCAR (XCAR (names)), name);
249 error ("Emacs for OpenStep does not yet support multi-display.");
251 Fx_open_connection (name, Qnil, Qnil);
252 dpyinfo = x_display_list;
255 error ("OpenStep on %s not responding.\n", SDATA (name));
262 interpret_services_menu (NSMenu *menu, Lisp_Object prefix, Lisp_Object old)
263 /* --------------------------------------------------------------------------
264 Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
265 -------------------------------------------------------------------------- */
275 count = [menu numberOfItems];
276 for (i = 0; i<count; i++)
278 item = [menu itemAtIndex: i];
279 name = [[item title] UTF8String];
282 nameStr = build_string (name);
284 if ([item hasSubmenu])
286 old = interpret_services_menu ([item submenu],
287 Fcons (nameStr, prefix), old);
291 keys = [item keyEquivalent];
292 if (keys && [keys length] )
294 key = [keys characterAtIndex: 0];
295 res = make_number (key|super_modifier);
301 old = Fcons (Fcons (res,
302 Freverse (Fcons (nameStr,
312 /* ==========================================================================
314 Frame parameter setters
316 ========================================================================== */
320 x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
324 if (ns_lisp_to_color (arg, &col))
326 store_frame_param (f, Qforeground_color, oldval);
327 error ("Unknown color");
331 [f->output_data.ns->foreground_color release];
332 f->output_data.ns->foreground_color = col;
334 if (FRAME_NS_VIEW (f))
336 update_face_from_frame_parameter (f, Qforeground_color, arg);
337 /*recompute_basic_faces (f); */
338 if (FRAME_VISIBLE_P (f))
345 x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
349 NSView *view = FRAME_NS_VIEW (f);
352 if (ns_lisp_to_color (arg, &col))
354 store_frame_param (f, Qbackground_color, oldval);
355 error ("Unknown color");
358 /* clear the frame; in some instances the NS-internal GC appears not to
359 update, or it does update and cannot clear old text properly */
360 if (FRAME_VISIBLE_P (f))
364 [f->output_data.ns->background_color release];
365 f->output_data.ns->background_color = col;
368 [[view window] setBackgroundColor: col];
369 alpha = [col alphaComponent];
372 [[view window] setOpaque: NO];
374 [[view window] setOpaque: YES];
376 face = FRAME_DEFAULT_FACE (f);
379 col = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), f);
381 = (EMACS_UINT) [[col colorWithAlphaComponent: alpha] retain];
384 update_face_from_frame_parameter (f, Qbackground_color, arg);
387 if (FRAME_VISIBLE_P (f))
394 x_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
398 if (ns_lisp_to_color (arg, &col))
400 store_frame_param (f, Qcursor_color, oldval);
401 error ("Unknown color");
404 [FRAME_CURSOR_COLOR (f) release];
405 FRAME_CURSOR_COLOR (f) = [col retain];
407 if (FRAME_VISIBLE_P (f))
409 x_update_cursor (f, 0);
410 x_update_cursor (f, 1);
412 update_face_from_frame_parameter (f, Qcursor_color, arg);
417 x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
419 NSView *view = FRAME_NS_VIEW (f);
420 NSTRACE (x_set_icon_name);
425 /* see if it's changed */
428 if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt))
431 else if (!STRINGP (oldval) && EQ (oldval, Qnil) == EQ (arg, Qnil))
438 if (!NILP (f->title))
441 /* explicit name and no icon-name -> explicit_name */
442 if (f->explicit_name)
446 /* no explicit name and no icon-name ->
447 name has to be rebuild from icon_title_format */
448 windows_or_buffers_changed++;
453 /* Don't change the name if it's already NAME. */
454 if ([[view window] miniwindowTitle] &&
455 ([[[view window] miniwindowTitle]
456 isEqualToString: [NSString stringWithUTF8String:
460 [[view window] setMiniwindowTitle:
461 [NSString stringWithUTF8String: SDATA (arg)]];
465 ns_set_name_internal (FRAME_PTR f, Lisp_Object name)
468 Lisp_Object encoded_name, encoded_icon_name;
470 NSView *view = FRAME_NS_VIEW (f);
473 encoded_name = ENCODE_UTF_8 (name);
476 str = [NSString stringWithUTF8String: SDATA (encoded_name)];
478 /* Don't change the name if it's already NAME. */
479 if (! [[[view window] title] isEqualToString: str])
480 [[view window] setTitle: str];
482 if (!STRINGP (f->icon_name))
483 encoded_icon_name = encoded_name;
485 encoded_icon_name = ENCODE_UTF_8 (f->icon_name);
487 str = [NSString stringWithUTF8String: SDATA (encoded_icon_name)];
489 if ([[view window] miniwindowTitle] &&
490 ! [[[view window] miniwindowTitle] isEqualToString: str])
491 [[view window] setMiniwindowTitle: str];
496 ns_set_name (struct frame *f, Lisp_Object name, int explicit)
499 NSTRACE (ns_set_name);
504 /* Make sure that requests from lisp code override requests from
505 Emacs redisplay code. */
508 /* If we're switching from explicit to implicit, we had better
509 update the mode lines and thereby update the title. */
510 if (f->explicit_name && NILP (name))
511 update_mode_lines = 1;
513 f->explicit_name = ! NILP (name);
515 else if (f->explicit_name)
519 name = build_string([ns_app_name UTF8String]);
523 /* Don't change the name if it's already NAME. */
524 if (! NILP (Fstring_equal (name, f->name)))
529 /* title overrides explicit name */
530 if (! NILP (f->title))
533 ns_set_name_internal (f, name);
537 /* This function should be called when the user's lisp code has
538 specified a name for the frame; the name will override any set by the
541 x_explicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval)
543 NSTRACE (x_explicitly_set_name);
544 ns_set_name (f, arg, 1);
548 /* This function should be called by Emacs redisplay code to set the
549 name; names set this way will never override names set by the user's
552 x_implicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval)
554 NSTRACE (x_implicitly_set_name);
556 /* Deal with NS specific format t. */
557 if (FRAME_NS_P (f) && ((FRAME_ICONIFIED_P (f) && EQ (Vicon_title_format, Qt))
558 || EQ (Vframe_title_format, Qt)))
559 ns_set_name_as_filename (f);
561 ns_set_name (f, arg, 0);
565 /* Change the title of frame F to NAME.
566 If NAME is nil, use the frame name as the title. */
569 x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
571 NSTRACE (x_set_title);
572 /* Don't change the title if it's already NAME. */
573 if (EQ (name, f->title))
576 update_mode_lines = 1;
585 ns_set_name_internal (f, name);
590 ns_set_name_as_filename (struct frame *f)
593 Lisp_Object name, filename;
594 Lisp_Object buf = XWINDOW (f->selected_window)->buffer;
596 NSAutoreleasePool *pool;
598 Lisp_Object encoded_name, encoded_filename;
600 NSTRACE (ns_set_name_as_filename);
602 if (f->explicit_name || ! NILP (f->title) || ns_in_resize)
606 pool = [[NSAutoreleasePool alloc] init];
607 filename = XBUFFER (buf)->filename;
608 name = XBUFFER (buf)->name;
612 if (! NILP (filename))
613 name = Ffile_name_nondirectory (filename);
615 name = build_string ([ns_app_name UTF8String]);
619 encoded_name = ENCODE_UTF_8 (name);
622 view = FRAME_NS_VIEW (f);
624 title = FRAME_ICONIFIED_P (f) ? [[[view window] miniwindowTitle] UTF8String]
625 : [[[view window] title] UTF8String];
627 if (title && (! strcmp (title, SDATA (encoded_name))))
634 str = [NSString stringWithUTF8String: SDATA (encoded_name)];
635 if (str == nil) str = @"Bad coding";
637 if (FRAME_ICONIFIED_P (f))
638 [[view window] setMiniwindowTitle: str];
643 if (! NILP (filename))
646 encoded_filename = ENCODE_UTF_8 (filename);
649 fstr = [NSString stringWithUTF8String: SDATA (encoded_filename)];
650 if (fstr == nil) fstr = @"";
652 /* work around a bug observed on 10.3 and later where
653 setTitleWithRepresentedFilename does not clear out previous state
654 if given filename does not exist */
655 if (! [[NSFileManager defaultManager] fileExistsAtPath: fstr])
656 [[view window] setRepresentedFilename: @""];
662 [[view window] setRepresentedFilename: fstr];
663 [[view window] setTitle: str];
673 ns_set_doc_edited (struct frame *f, Lisp_Object arg)
675 NSView *view = FRAME_NS_VIEW (f);
676 NSAutoreleasePool *pool;
677 if (!MINI_WINDOW_P (XWINDOW (f->selected_window)))
680 pool = [[NSAutoreleasePool alloc] init];
681 [[view window] setDocumentEdited: !NILP (arg)];
689 x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
692 int olines = FRAME_MENU_BAR_LINES (f);
693 if (FRAME_MINIBUF_ONLY_P (f))
696 if (INTEGERP (value))
697 nlines = XINT (value);
701 FRAME_MENU_BAR_LINES (f) = 0;
704 FRAME_EXTERNAL_MENU_BAR (f) = 1;
705 /* does for all frames, whereas we just want for one frame
706 [NSMenu setMenuBarVisible: YES]; */
710 if (FRAME_EXTERNAL_MENU_BAR (f) == 1)
711 free_frame_menubar (f);
712 /* [NSMenu setMenuBarVisible: NO]; */
713 FRAME_EXTERNAL_MENU_BAR (f) = 0;
718 /* toolbar support */
720 x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
723 Lisp_Object root_window;
725 if (FRAME_MINIBUF_ONLY_P (f))
728 if (INTEGERP (value) && XINT (value) >= 0)
729 nlines = XFASTINT (value);
735 FRAME_EXTERNAL_TOOL_BAR (f) = 1;
736 update_frame_tool_bar (f);
740 if (FRAME_EXTERNAL_TOOL_BAR (f))
742 free_frame_tool_bar (f);
743 FRAME_EXTERNAL_TOOL_BAR (f) = 0;
747 x_set_window_size (f, 0, f->text_cols, f->text_lines);
752 ns_implicitly_set_icon_type (struct frame *f)
755 EmacsView *view = FRAME_NS_VIEW (f);
757 Lisp_Object chain, elt;
758 NSAutoreleasePool *pool;
761 NSTRACE (ns_implicitly_set_icon_type);
764 pool = [[NSAutoreleasePool alloc] init];
765 if (f->output_data.ns->miniimage
766 && [[NSString stringWithUTF8String: SDATA (f->name)]
767 isEqualToString: [(NSImage *)f->output_data.ns->miniimage name]])
774 tem = assq_no_quit (Qicon_type, f->param_alist);
775 if (CONSP (tem) && ! NILP (XCDR (tem)))
782 for (chain = Vns_icon_type_alist;
783 (image = nil) && CONSP (chain);
784 chain = XCDR (chain))
787 /* special case: 't' means go by file type */
788 if (SYMBOLP (elt) && EQ (elt, Qt) && SDATA (f->name)[0] == '/')
791 = [NSString stringWithUTF8String: SDATA (f->name)];
792 if ([[NSFileManager defaultManager] fileExistsAtPath: str])
793 image = [[[NSWorkspace sharedWorkspace] iconForFile: str] retain];
795 else if (CONSP (elt) &&
796 STRINGP (XCAR (elt)) &&
797 STRINGP (XCDR (elt)) &&
798 fast_string_match (XCAR (elt), f->name) >= 0)
800 image = [EmacsImage allocInitFromFile: XCDR (elt)];
802 image = [[NSImage imageNamed:
803 [NSString stringWithUTF8String:
804 SDATA (XCDR (elt))]] retain];
810 image = [[[NSWorkspace sharedWorkspace] iconForFileType: @"text"] retain];
814 [f->output_data.ns->miniimage release];
815 f->output_data.ns->miniimage = image;
816 [view setMiniwindowImage: setMini];
823 x_set_icon_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
825 EmacsView *view = FRAME_NS_VIEW (f);
829 NSTRACE (x_set_icon_type);
831 if (!NILP (arg) && SYMBOLP (arg))
833 arg =build_string (SDATA (SYMBOL_NAME (arg)));
834 store_frame_param (f, Qicon_type, arg);
837 /* do it the implicit way */
840 ns_implicitly_set_icon_type (f);
846 image = [EmacsImage allocInitFromFile: arg];
848 image =[NSImage imageNamed: [NSString stringWithUTF8String:
853 image = [NSImage imageNamed: @"text"];
857 f->output_data.ns->miniimage = image;
858 [view setMiniwindowImage: setMini];
862 /* Xism; we stub out (we do implement this in ns-win.el) */
864 XParseGeometry (char *string, int *x, int *y,
865 unsigned int *width, unsigned int *height)
867 message1 ("Warning: XParseGeometry not supported under NS.\n");
872 /* TODO: move to nsterm? */
874 ns_lisp_to_cursor_type (Lisp_Object arg)
877 if (XTYPE (arg) == Lisp_String)
879 else if (XTYPE (arg) == Lisp_Symbol)
880 str = SDATA (SYMBOL_NAME (arg));
882 if (!strcmp (str, "box")) return FILLED_BOX_CURSOR;
883 if (!strcmp (str, "hollow")) return HOLLOW_BOX_CURSOR;
884 if (!strcmp (str, "hbar")) return HBAR_CURSOR;
885 if (!strcmp (str, "bar")) return BAR_CURSOR;
886 if (!strcmp (str, "no")) return NO_CURSOR;
892 ns_cursor_type_to_lisp (int arg)
896 case FILLED_BOX_CURSOR: return Qbox;
897 case HOLLOW_BOX_CURSOR: return intern ("hollow");
898 case HBAR_CURSOR: return intern ("hbar");
899 case BAR_CURSOR: return intern ("bar");
901 default: return intern ("no");
905 /* This is the same as the xfns.c definition. */
907 x_set_cursor_type (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval)
909 set_frame_cursor_types (f, arg);
911 /* Make sure the cursor gets redrawn. */
912 cursor_type_changed = 1;
916 /* called to set mouse pointer color, but all other terms use it to
917 initialize pointer types (and don't set the color ;) */
919 x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
921 /* don't think we can do this on Nextstep */
926 #define Xstr(x) Str(x)
929 ns_appkit_version_str (void)
933 #ifdef NS_IMPL_GNUSTEP
934 sprintf(tmp, "gnustep-gui-%s", Xstr(GNUSTEP_GUI_VERSION));
935 #elif defined(NS_IMPL_COCOA)
936 sprintf(tmp, "apple-appkit-%.2f", NSAppKitVersionNumber);
940 return build_string (tmp);
944 /* This is for use by x-server-version and collapses all version info we
945 have into a single int. For a better picture of the implementation
946 running, use ns_appkit_version_str.*/
948 ns_appkit_version_int (void)
950 #ifdef NS_IMPL_GNUSTEP
951 return GNUSTEP_GUI_MAJOR_VERSION * 100 + GNUSTEP_GUI_MINOR_VERSION;
952 #elif defined(NS_IMPL_COCOA)
953 return (int)NSAppKitVersionNumber;
960 x_icon (struct frame *f, Lisp_Object parms)
961 /* --------------------------------------------------------------------------
962 Strangely-named function to set icon position parameters in frame.
963 This is irrelevant under OS X, but might be needed under GNUstep,
964 depending on the window manager used. Note, this is not a standard
965 frame parameter-setter; it is called directly from x-create-frame.
966 -------------------------------------------------------------------------- */
968 Lisp_Object icon_x, icon_y;
969 struct ns_display_info *dpyinfo = check_ns_display_info (Qnil);
971 f->output_data.ns->icon_top = Qnil;
972 f->output_data.ns->icon_left = Qnil;
974 /* Set the position of the icon. */
975 icon_x = x_get_arg (dpyinfo, parms, Qicon_left, 0, 0, RES_TYPE_NUMBER);
976 icon_y = x_get_arg (dpyinfo, parms, Qicon_top, 0, 0, RES_TYPE_NUMBER);
977 if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))
979 CHECK_NUMBER (icon_x);
980 CHECK_NUMBER (icon_y);
981 f->output_data.ns->icon_top = icon_y;
982 f->output_data.ns->icon_left = icon_x;
984 else if (!EQ (icon_x, Qunbound) || !EQ (icon_y, Qunbound))
985 error ("Both left and top icon corners of icon must be specified");
989 /* Note: see frame.c for template, also where generic functions are impl */
990 frame_parm_handler ns_frame_parm_handlers[] =
992 x_set_autoraise, /* generic OK */
993 x_set_autolower, /* generic OK */
994 x_set_background_color,
995 0, /* x_set_border_color, may be impossible under Nextstep */
996 0, /* x_set_border_width, may be impossible under Nextstep */
999 x_set_font, /* generic OK */
1000 x_set_foreground_color,
1003 x_set_internal_border_width, /* generic OK */
1004 x_set_menu_bar_lines,
1006 x_explicitly_set_name,
1007 x_set_scroll_bar_width, /* generic OK */
1009 x_set_unsplittable, /* generic OK */
1010 x_set_vertical_scroll_bars, /* generic OK */
1011 x_set_visibility, /* generic OK */
1012 x_set_tool_bar_lines,
1013 0, /* x_set_scroll_bar_foreground, will ignore (not possible on NS) */
1014 0, /* x_set_scroll_bar_background, will ignore (not possible on NS) */
1015 x_set_screen_gamma, /* generic OK */
1016 x_set_line_spacing, /* generic OK, sets f->extra_line_spacing to int */
1017 x_set_fringe_width, /* generic OK */
1018 x_set_fringe_width, /* generic OK */
1019 0, /* x_set_wait_for_wm, will ignore */
1020 0, /* x_set_fullscreen will ignore */
1021 x_set_font_backend, /* generic OK */
1023 0, /* x_set_sticky */
1024 0, /* x_set_tool_bar_position */
1029 /* ==========================================================================
1033 ========================================================================== */
1035 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
1037 doc: /* Make a new Nextstep window, called a \"frame\" in Emacs terms.
1038 Return an Emacs frame object.
1039 PARMS is an alist of frame parameters.
1040 If the parameters specify that the frame should not have a minibuffer,
1041 and do not specify a specific minibuffer window to use,
1042 then `default-minibuffer-frame' must be a frame whose minibuffer can
1043 be shared by the new frame. */)
1046 static int desc_ctr = 1;
1048 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
1049 Lisp_Object frame, tem;
1051 int minibuffer_only = 0;
1052 int count = specpdl_ptr - specpdl;
1053 Lisp_Object display;
1054 struct ns_display_info *dpyinfo = NULL;
1057 Lisp_Object tfont, tfontsize;
1058 int window_prompting = 0;
1063 /* Seems a little strange, but other terms do it. Perhaps the code below
1064 is modifying something? */
1065 parms = Fcopy_alist (parms);
1067 display = x_get_arg (dpyinfo, parms, Qterminal, 0, 0, RES_TYPE_STRING);
1068 if (EQ (display, Qunbound))
1070 dpyinfo = check_ns_display_info (display);
1072 if (!dpyinfo->terminal->name)
1073 error ("Terminal is not live, can't create new frames on it");
1075 kb = dpyinfo->terminal->kboard;
1077 name = x_get_arg (dpyinfo, parms, Qname, 0, 0, RES_TYPE_STRING);
1079 && ! EQ (name, Qunbound)
1081 error ("Invalid frame name--not a string or nil");
1084 Vx_resource_name = name;
1086 Vx_resource_name = Vinvocation_name;
1088 parent = x_get_arg (dpyinfo, parms, Qparent_id, 0, 0, RES_TYPE_NUMBER);
1089 if (EQ (parent, Qunbound))
1091 if (! NILP (parent))
1092 CHECK_NUMBER (parent);
1095 GCPRO4 (parms, parent, name, frame);
1097 tem = x_get_arg (dpyinfo, parms, Qminibuffer, "minibuffer", "Minibuffer",
1099 if (EQ (tem, Qnone) || NILP (tem))
1101 f = make_frame_without_minibuffer (Qnil, kb, display);
1103 else if (EQ (tem, Qonly))
1105 f = make_minibuffer_frame ();
1106 minibuffer_only = 1;
1108 else if (WINDOWP (tem))
1110 f = make_frame_without_minibuffer (tem, kb, display);
1117 /* Set the name; the functions to which we pass f expect the name to
1119 if (EQ (name, Qunbound) || NILP (name) || (XTYPE (name) != Lisp_String))
1121 f->name = build_string ([ns_app_name UTF8String]);
1122 f->explicit_name =0;
1127 f->explicit_name = 1;
1128 specbind (Qx_resource_name, name);
1131 XSETFRAME (frame, f);
1132 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
1134 f->terminal = dpyinfo->terminal;
1135 f->terminal->reference_count++;
1137 f->output_method = output_ns;
1138 f->output_data.ns = (struct ns_output *)xmalloc (sizeof *(f->output_data.ns));
1139 memset (f->output_data.ns, 0, sizeof (*(f->output_data.ns)));
1141 FRAME_FONTSET (f) = -1;
1143 /* record_unwind_protect (unwind_create_frame, frame); safety; maybe later? */
1145 f->icon_name = x_get_arg (dpyinfo, parms, Qicon_name, "iconName", "Title",
1147 if (! STRINGP (f->icon_name))
1148 f->icon_name = Qnil;
1150 FRAME_NS_DISPLAY_INFO (f) = dpyinfo;
1152 f->output_data.ns->window_desc = desc_ctr++;
1155 f->output_data.ns->parent_desc = (Window) XFASTINT (parent);
1156 f->output_data.ns->explicit_parent = 1;
1160 f->output_data.ns->parent_desc = FRAME_NS_DISPLAY_INFO (f)->root_window;
1161 f->output_data.ns->explicit_parent = 0;
1164 f->resx = dpyinfo->resx;
1165 f->resy = dpyinfo->resy;
1168 register_font_driver (&nsfont_driver, f);
1169 x_default_parameter (f, parms, Qfont_backend, Qnil,
1170 "fontBackend", "FontBackend", RES_TYPE_STRING);
1173 /* use for default font name */
1174 id font = [NSFont userFixedPitchFontOfSize: -1.0]; /* default */
1175 tfontsize = x_default_parameter (f, parms, Qfontsize,
1176 make_number (0 /*(int)[font pointSize]*/),
1177 "fontSize", "FontSize", RES_TYPE_NUMBER);
1178 tfont = x_default_parameter (f, parms, Qfont,
1179 build_string ([[font fontName] UTF8String]),
1180 "font", "Font", RES_TYPE_STRING);
1184 x_default_parameter (f, parms, Qborder_width, make_number (0),
1185 "borderwidth", "BorderWidth", RES_TYPE_NUMBER);
1186 x_default_parameter (f, parms, Qinternal_border_width, make_number (2),
1187 "internalBorderWidth", "InternalBorderWidth",
1190 /* default scrollbars on right on Mac */
1193 #ifdef NS_IMPL_GNUSTEP
1198 x_default_parameter (f, parms, Qvertical_scroll_bars, spos,
1199 "verticalScrollBars", "VerticalScrollBars",
1202 x_default_parameter (f, parms, Qforeground_color, build_string ("Black"),
1203 "foreground", "Foreground", RES_TYPE_STRING);
1204 x_default_parameter (f, parms, Qbackground_color, build_string ("White"),
1205 "background", "Background", RES_TYPE_STRING);
1206 /* FIXME: not suppported yet in Nextstep */
1207 x_default_parameter (f, parms, Qline_spacing, Qnil,
1208 "lineSpacing", "LineSpacing", RES_TYPE_NUMBER);
1209 x_default_parameter (f, parms, Qleft_fringe, Qnil,
1210 "leftFringe", "LeftFringe", RES_TYPE_NUMBER);
1211 x_default_parameter (f, parms, Qright_fringe, Qnil,
1212 "rightFringe", "RightFringe", RES_TYPE_NUMBER);
1215 init_frame_faces (f);
1217 /* The X resources controlling the menu-bar and tool-bar are
1218 processed specially at startup, and reflected in the mode
1219 variables; ignore them here. */
1220 x_default_parameter (f, parms, Qmenu_bar_lines,
1221 NILP (Vmenu_bar_mode)
1222 ? make_number (0) : make_number (1),
1223 NULL, NULL, RES_TYPE_NUMBER);
1224 x_default_parameter (f, parms, Qtool_bar_lines,
1225 NILP (Vtool_bar_mode)
1226 ? make_number (0) : make_number (1),
1227 NULL, NULL, RES_TYPE_NUMBER);
1229 x_default_parameter (f, parms, Qbuffer_predicate, Qnil, "bufferPredicate",
1230 "BufferPredicate", RES_TYPE_SYMBOL);
1231 x_default_parameter (f, parms, Qtitle, Qnil, "title", "Title",
1234 /* TODO: other terms seem to get away w/o this complexity.. */
1235 if (NILP (Fassq (Qwidth, parms)))
1238 = x_get_arg (dpyinfo, parms, Qwidth, "width", "Width",
1240 if (! EQ (value, Qunbound))
1241 parms = Fcons (Fcons (Qwidth, value), parms);
1243 if (NILP (Fassq (Qheight, parms)))
1246 = x_get_arg (dpyinfo, parms, Qheight, "height", "Height",
1248 if (! EQ (value, Qunbound))
1249 parms = Fcons (Fcons (Qheight, value), parms);
1251 if (NILP (Fassq (Qleft, parms)))
1254 = x_get_arg (dpyinfo, parms, Qleft, "left", "Left", RES_TYPE_NUMBER);
1255 if (! EQ (value, Qunbound))
1256 parms = Fcons (Fcons (Qleft, value), parms);
1258 if (NILP (Fassq (Qtop, parms)))
1261 = x_get_arg (dpyinfo, parms, Qtop, "top", "Top", RES_TYPE_NUMBER);
1262 if (! EQ (value, Qunbound))
1263 parms = Fcons (Fcons (Qtop, value), parms);
1266 window_prompting = x_figure_window_size (f, parms, 1);
1268 tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
1269 f->no_split = minibuffer_only || (!EQ (tem, Qunbound) && !EQ (tem, Qnil));
1271 /* NOTE: on other terms, this is done in set_mouse_color, however this
1272 was not getting called under Nextstep */
1273 f->output_data.ns->text_cursor = [NSCursor IBeamCursor];
1274 f->output_data.ns->nontext_cursor = [NSCursor arrowCursor];
1275 f->output_data.ns->modeline_cursor = [NSCursor pointingHandCursor];
1276 f->output_data.ns->hand_cursor = [NSCursor pointingHandCursor];
1277 f->output_data.ns->hourglass_cursor = [NSCursor disappearingItemCursor];
1278 f->output_data.ns->horizontal_drag_cursor = [NSCursor resizeLeftRightCursor];
1279 FRAME_NS_DISPLAY_INFO (f)->vertical_scroll_bar_cursor
1280 = [NSCursor arrowCursor];
1281 f->output_data.ns->current_pointer = f->output_data.ns->text_cursor;
1283 [[EmacsView alloc] initFrameFromEmacs: f];
1287 /* It is now ok to make the frame official even if we get an error below.
1288 The frame needs to be on Vframe_list or making it visible won't work. */
1289 Vframe_list = Fcons (frame, Vframe_list);
1290 /*FRAME_NS_DISPLAY_INFO (f)->reference_count++; */
1292 x_default_parameter (f, parms, Qicon_type, Qnil, "bitmapIcon", "BitmapIcon",
1294 x_default_parameter (f, parms, Qauto_raise, Qnil, "autoRaise", "AutoRaiseLower",
1296 x_default_parameter (f, parms, Qauto_lower, Qnil, "autoLower", "AutoLower",
1298 x_default_parameter (f, parms, Qcursor_type, Qbox, "cursorType", "CursorType",
1300 x_default_parameter (f, parms, Qscroll_bar_width, Qnil, "scrollBarWidth",
1301 "ScrollBarWidth", RES_TYPE_NUMBER);
1302 x_default_parameter (f, parms, Qalpha, Qnil, "alpha", "Alpha",
1305 width = FRAME_COLS (f);
1306 height = FRAME_LINES (f);
1308 SET_FRAME_COLS (f, 0);
1309 FRAME_LINES (f) = 0;
1310 change_frame_size (f, height, width, 1, 0, 0);
1312 if (! f->output_data.ns->explicit_parent)
1314 tem = x_get_arg (dpyinfo, parms, Qvisibility, 0, 0, RES_TYPE_SYMBOL);
1315 if (EQ (tem, Qunbound))
1317 x_set_visibility (f, tem, Qnil);
1318 if (EQ (tem, Qicon))
1319 x_iconify_frame (f);
1320 else if (! NILP (tem))
1322 x_make_frame_visible (f);
1323 f->async_visible = 1;
1324 [[FRAME_NS_VIEW (f) window] makeKeyWindow];
1327 f->async_visible = 0;
1330 if (FRAME_HAS_MINIBUF_P (f)
1331 && (!FRAMEP (kb->Vdefault_minibuffer_frame)
1332 || !FRAME_LIVE_P (XFRAME (kb->Vdefault_minibuffer_frame))))
1333 kb->Vdefault_minibuffer_frame = frame;
1335 /* All remaining specified parameters, which have not been "used"
1336 by x_get_arg and friends, now go in the misc. alist of the frame. */
1337 for (tem = parms; CONSP (tem); tem = XCDR (tem))
1338 if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem))))
1339 f->param_alist = Fcons (XCAR (tem), f->param_alist);
1342 Vwindow_list = Qnil;
1344 return unbind_to (count, frame);
1348 DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0,
1349 doc: /* Set the input focus to FRAME.
1350 FRAME nil means use the selected frame. */)
1353 struct frame *f = check_ns_frame (frame);
1354 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f);
1356 if (dpyinfo->x_focus_frame != f)
1358 EmacsView *view = FRAME_NS_VIEW (f);
1360 [NSApp activateIgnoringOtherApps: YES];
1361 [[view window] makeKeyAndOrderFront: view];
1369 DEFUN ("ns-popup-font-panel", Fns_popup_font_panel, Sns_popup_font_panel,
1371 doc: /* Pop up the font panel. */)
1378 fm = [NSFontManager sharedFontManager];
1380 f = SELECTED_FRAME ();
1383 CHECK_FRAME (frame);
1387 [fm setSelectedFont: ((struct nsfont_info *)f->output_data.ns->font)->nsfont
1389 [fm orderFrontFontPanel: NSApp];
1394 DEFUN ("ns-popup-color-panel", Fns_popup_color_panel, Sns_popup_color_panel,
1396 doc: /* Pop up the color panel. */)
1403 f = SELECTED_FRAME ();
1406 CHECK_FRAME (frame);
1410 [NSApp orderFrontColorPanel: NSApp];
1415 DEFUN ("ns-read-file-name", Fns_read_file_name, Sns_read_file_name, 1, 4, 0,
1416 doc: /* Use a graphical panel to read a file name, using prompt PROMPT.
1417 Optional arg DIR, if non-nil, supplies a default directory.
1418 Optional arg ISLOAD, if non-nil, means read a file name for saving.
1419 Optional arg INIT, if non-nil, provides a default file name to use. */)
1420 (Lisp_Object prompt, Lisp_Object dir, Lisp_Object isLoad, Lisp_Object init)
1422 static id fileDelegate = nil;
1427 NSString *promptS = NILP (prompt) || !STRINGP (prompt) ? nil :
1428 [NSString stringWithUTF8String: SDATA (prompt)];
1429 NSString *dirS = NILP (dir) || !STRINGP (dir) ?
1430 [NSString stringWithUTF8String: SDATA (current_buffer->directory)] :
1431 [NSString stringWithUTF8String: SDATA (dir)];
1432 NSString *initS = NILP (init) || !STRINGP (init) ? nil :
1433 [NSString stringWithUTF8String: SDATA (init)];
1437 if (fileDelegate == nil)
1438 fileDelegate = [EmacsFileDelegate new];
1440 [NSCursor setHiddenUntilMouseMoves: NO];
1442 if ([dirS characterAtIndex: 0] == '~')
1443 dirS = [dirS stringByExpandingTildeInPath];
1445 panel = NILP (isLoad) ?
1446 (id)[EmacsSavePanel savePanel] : (id)[EmacsOpenPanel openPanel];
1448 [panel setTitle: promptS];
1450 /* Puma (10.1) does not have */
1451 if ([panel respondsToSelector: @selector (setAllowsOtherFileTypes:)])
1452 [panel setAllowsOtherFileTypes: YES];
1454 [panel setTreatsFilePackagesAsDirectories: YES];
1455 [panel setDelegate: fileDelegate];
1461 ret = [panel runModalForDirectory: dirS file: initS];
1465 [panel setCanChooseDirectories: YES];
1466 ret = [panel runModalForDirectory: dirS file: initS types: nil];
1469 ret = (ret == NSOKButton) || panelOK;
1472 fname = build_string ([[panel filename] UTF8String]);
1474 [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow];
1477 return ret ? fname : Qnil;
1481 DEFUN ("ns-get-resource", Fns_get_resource, Sns_get_resource, 2, 2, 0,
1482 doc: /* Return the value of the property NAME of OWNER from the defaults database.
1483 If OWNER is nil, Emacs is assumed. */)
1484 (Lisp_Object owner, Lisp_Object name)
1490 owner = build_string([ns_app_name UTF8String]);
1491 CHECK_STRING (name);
1492 /*fprintf (stderr, "ns-get-resource checking resource '%s'\n", SDATA (name)); */
1494 value =[[[NSUserDefaults standardUserDefaults]
1495 objectForKey: [NSString stringWithUTF8String: SDATA (name)]]
1499 return build_string (value);
1504 DEFUN ("ns-set-resource", Fns_set_resource, Sns_set_resource, 3, 3, 0,
1505 doc: /* Set property NAME of OWNER to VALUE, from the defaults database.
1506 If OWNER is nil, Emacs is assumed.
1507 If VALUE is nil, the default is removed. */)
1508 (Lisp_Object owner, Lisp_Object name, Lisp_Object value)
1512 owner = build_string ([ns_app_name UTF8String]);
1513 CHECK_STRING (name);
1516 [[NSUserDefaults standardUserDefaults] removeObjectForKey:
1517 [NSString stringWithUTF8String: SDATA (name)]];
1521 CHECK_STRING (value);
1522 [[NSUserDefaults standardUserDefaults] setObject:
1523 [NSString stringWithUTF8String: SDATA (value)]
1524 forKey: [NSString stringWithUTF8String:
1532 DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
1533 Sx_server_max_request_size,
1535 doc: /* This function is a no-op. It is only present for completeness. */)
1536 (Lisp_Object display)
1539 /* This function has no real equivalent under NeXTstep. Return nil to
1545 DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
1546 doc: /* Return the vendor ID string of Nextstep display server DISPLAY.
1547 DISPLAY should be either a frame or a display name (a string).
1548 If omitted or nil, the selected frame's display is used. */)
1549 (Lisp_Object display)
1551 #ifdef NS_IMPL_GNUSTEP
1552 return build_string ("GNU");
1554 return build_string ("Apple");
1559 DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0,
1560 doc: /* Return the version numbers of the server of DISPLAY.
1561 The value is a list of three integers: the major and minor
1562 version numbers of the X Protocol in use, and the distributor-specific
1563 release number. See also the function `x-server-vendor'.
1565 The optional argument DISPLAY specifies which display to ask about.
1566 DISPLAY should be either a frame or a display name (a string).
1567 If omitted or nil, that stands for the selected frame's display. */)
1568 (Lisp_Object display)
1570 /*NOTE: it is unclear what would best correspond with "protocol";
1571 we return 10.3, meaning Panther, since this is roughly the
1572 level that GNUstep's APIs correspond to.
1573 The last number is where we distinguish between the Apple
1574 and GNUstep implementations ("distributor-specific release
1575 number") and give int'ized versions of major.minor. */
1576 return Fcons (make_number (10),
1577 Fcons (make_number (3),
1578 Fcons (make_number (ns_appkit_version_int()), Qnil)));
1582 DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0,
1583 doc: /* Return the number of screens on Nextstep display server DISPLAY.
1584 DISPLAY should be a frame, the display name as a string, or a terminal ID.
1585 If omitted or nil, the selected frame's display is used. */)
1586 (Lisp_Object display)
1591 num = [[NSScreen screens] count];
1593 return (num != 0) ? make_number (num) : Qnil;
1597 DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height,
1599 doc: /* Return the height of Nextstep display server DISPLAY, in millimeters.
1600 DISPLAY should be a frame, the display name as a string, or a terminal ID.
1601 If omitted or nil, the selected frame's display is used. */)
1602 (Lisp_Object display)
1605 return make_number ((int)
1606 ([ns_get_screen (display) frame].size.height/(92.0/25.4)));
1610 DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width,
1612 doc: /* Return the width of Nextstep display server DISPLAY, in millimeters.
1613 DISPLAY should be a frame, the display name as a string, or a terminal ID.
1614 If omitted or nil, the selected frame's display is used. */)
1615 (Lisp_Object display)
1618 return make_number ((int)
1619 ([ns_get_screen (display) frame].size.width/(92.0/25.4)));
1623 DEFUN ("x-display-backing-store", Fx_display_backing_store,
1624 Sx_display_backing_store, 0, 1, 0,
1625 doc: /* Return whether the Nexstep display DISPLAY supports backing store.
1626 The value may be `buffered', `retained', or `non-retained'.
1627 DISPLAY should be a frame, the display name as a string, or a terminal ID.
1628 If omitted or nil, the selected frame's display is used. */)
1629 (Lisp_Object display)
1632 switch ([ns_get_window (display) backingType])
1634 case NSBackingStoreBuffered:
1635 return intern ("buffered");
1636 case NSBackingStoreRetained:
1637 return intern ("retained");
1638 case NSBackingStoreNonretained:
1639 return intern ("non-retained");
1641 error ("Strange value for backingType parameter of frame");
1643 return Qnil; /* not reached, shut compiler up */
1647 DEFUN ("x-display-visual-class", Fx_display_visual_class,
1648 Sx_display_visual_class, 0, 1, 0,
1649 doc: /* Return the visual class of the Nextstep display server DISPLAY.
1650 The value is one of the symbols `static-gray', `gray-scale',
1651 `static-color', `pseudo-color', `true-color', or `direct-color'.
1652 DISPLAY should be a frame, the display name as a string, or a terminal ID.
1653 If omitted or nil, the selected frame's display is used. */)
1654 (Lisp_Object display)
1656 NSWindowDepth depth;
1658 depth = [ns_get_screen (display) depth];
1660 if ( depth == NSBestDepth (NSCalibratedWhiteColorSpace, 2, 2, YES, NULL))
1661 return intern ("static-gray");
1662 else if (depth == NSBestDepth (NSCalibratedWhiteColorSpace, 8, 8, YES, NULL))
1663 return intern ("gray-scale");
1664 else if ( depth == NSBestDepth (NSCalibratedRGBColorSpace, 8, 8, YES, NULL))
1665 return intern ("pseudo-color");
1666 else if ( depth == NSBestDepth (NSCalibratedRGBColorSpace, 4, 12, NO, NULL))
1667 return intern ("true-color");
1668 else if ( depth == NSBestDepth (NSCalibratedRGBColorSpace, 8, 24, NO, NULL))
1669 return intern ("direct-color");
1671 /* color mgmt as far as we do it is really handled by Nextstep itself anyway */
1672 return intern ("direct-color");
1676 DEFUN ("x-display-save-under", Fx_display_save_under,
1677 Sx_display_save_under, 0, 1, 0,
1678 doc: /* Return t if DISPLAY supports the save-under feature.
1679 The optional argument DISPLAY specifies which display to ask about.
1680 DISPLAY should be a frame, the display name as a string, or a terminal ID.
1681 If omitted or nil, the selected frame's display is used. */)
1682 (Lisp_Object display)
1685 switch ([ns_get_window (display) backingType])
1687 case NSBackingStoreBuffered:
1690 case NSBackingStoreRetained:
1691 case NSBackingStoreNonretained:
1695 error ("Strange value for backingType parameter of frame");
1697 return Qnil; /* not reached, shut compiler up */
1701 DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection,
1703 doc: /* Open a connection to a display server.
1704 DISPLAY is the name of the display to connect to.
1705 Optional second arg XRM-STRING is a string of resources in xrdb format.
1706 If the optional third arg MUST-SUCCEED is non-nil,
1707 terminate Emacs if we can't open the connection.
1708 \(In the Nextstep version, the last two arguments are currently ignored.) */)
1709 (Lisp_Object display, Lisp_Object resource_string, Lisp_Object must_succeed)
1711 struct ns_display_info *dpyinfo;
1713 CHECK_STRING (display);
1715 nxatoms_of_nsselect ();
1716 dpyinfo = ns_term_init (display);
1719 if (!NILP (must_succeed))
1720 fatal ("OpenStep on %s not responding.\n",
1723 error ("OpenStep on %s not responding.\n",
1727 /* Register our external input/output types, used for determining
1728 applicable services and also drag/drop eligibility. */
1729 ns_send_types = [[NSArray arrayWithObject: NSStringPboardType] retain];
1730 ns_return_types = [[NSArray arrayWithObject: NSStringPboardType] retain];
1731 ns_drag_types = [[NSArray arrayWithObjects:
1733 NSTabularTextPboardType,
1734 NSFilenamesPboardType,
1737 NSFontPboardType, nil] retain];
1743 DEFUN ("x-close-connection", Fx_close_connection, Sx_close_connection,
1745 doc: /* Close the connection to the current Nextstep display server.
1746 The argument DISPLAY is currently ignored. */)
1747 (Lisp_Object display)
1750 /*ns_delete_terminal (dpyinfo->terminal); */
1751 [NSApp terminate: NSApp];
1756 DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0,
1757 doc: /* Return the list of display names that Emacs has connections to. */)
1760 Lisp_Object tail, result;
1763 for (tail = ns_display_name_list; CONSP (tail); tail = XCDR (tail))
1764 result = Fcons (XCAR (XCAR (tail)), result);
1770 DEFUN ("ns-hide-others", Fns_hide_others, Sns_hide_others,
1772 doc: /* Hides all applications other than Emacs. */)
1776 [NSApp hideOtherApplications: NSApp];
1780 DEFUN ("ns-hide-emacs", Fns_hide_emacs, Sns_hide_emacs,
1782 doc: /* If ON is non-nil, the entire Emacs application is hidden.
1783 Otherwise if Emacs is hidden, it is unhidden.
1784 If ON is equal to `activate', Emacs is unhidden and becomes
1785 the active application. */)
1789 if (EQ (on, intern ("activate")))
1791 [NSApp unhide: NSApp];
1792 [NSApp activateIgnoringOtherApps: YES];
1795 [NSApp unhide: NSApp];
1797 [NSApp hide: NSApp];
1802 DEFUN ("ns-emacs-info-panel", Fns_emacs_info_panel, Sns_emacs_info_panel,
1804 doc: /* Shows the 'Info' or 'About' panel for Emacs. */)
1808 [NSApp orderFrontStandardAboutPanel: nil];
1813 DEFUN ("ns-font-name", Fns_font_name, Sns_font_name, 1, 1, 0,
1814 doc: /* Determine font postscript or family name for font NAME.
1815 NAME should be a string containing either the font name or an XLFD
1816 font descriptor. If string contains `fontset' and not
1817 `fontset-startup', it is left alone. */)
1821 CHECK_STRING (name);
1826 if (strstr (nm, "fontset") && !strstr (nm, "fontset-startup"))
1829 return build_string (ns_xlfd_to_fontname (SDATA (name)));
1833 DEFUN ("ns-list-colors", Fns_list_colors, Sns_list_colors, 0, 1, 0,
1834 doc: /* Return a list of all available colors.
1835 The optional argument FRAME is currently ignored. */)
1838 Lisp_Object list = Qnil;
1839 NSEnumerator *colorlists;
1844 CHECK_FRAME (frame);
1845 if (! FRAME_NS_P (XFRAME (frame)))
1846 error ("non-Nextstep frame used in `ns-list-colors'");
1851 colorlists = [[NSColorList availableColorLists] objectEnumerator];
1852 while (clist = [colorlists nextObject])
1854 if ([[clist name] length] < 7 ||
1855 [[clist name] rangeOfString: @"PANTONE"].location == 0)
1857 NSEnumerator *cnames = [[clist allKeys] reverseObjectEnumerator];
1859 while (cname = [cnames nextObject])
1860 list = Fcons (build_string ([cname UTF8String]), list);
1861 /* for (i = [[clist allKeys] count] - 1; i >= 0; i--)
1862 list = Fcons (build_string ([[[clist allKeys] objectAtIndex: i]
1863 UTF8String]), list); */
1873 DEFUN ("ns-list-services", Fns_list_services, Sns_list_services, 0, 0, 0,
1874 doc: /* List available Nextstep services by querying NSApp. */)
1877 Lisp_Object ret = Qnil;
1882 svcs = [[NSMenu alloc] initWithTitle: @"Services"];
1883 [NSApp setServicesMenu: svcs]; /* this and next rebuild on <10.4 */
1884 [NSApp registerServicesMenuSendTypes: ns_send_types
1885 returnTypes: ns_return_types];
1887 /* On Tiger, services menu updating was made lazier (waits for user to
1888 actually click on the menu), so we have to force things along: */
1889 #ifdef NS_IMPL_COCOA
1890 if (NSAppKitVersionNumber >= 744.0)
1892 delegate = [svcs delegate];
1893 if (delegate != nil)
1895 if ([delegate respondsToSelector: @selector (menuNeedsUpdate:)])
1896 [delegate menuNeedsUpdate: svcs];
1897 if ([delegate respondsToSelector:
1898 @selector (menu:updateItem:atIndex:shouldCancel:)])
1900 int i, len = [delegate numberOfItemsInMenu: svcs];
1901 for (i =0; i<len; i++)
1902 [svcs addItemWithTitle: @"" action: NULL keyEquivalent: @""];
1903 for (i =0; i<len; i++)
1904 if (![delegate menu: svcs
1905 updateItem: (NSMenuItem *)[svcs itemAtIndex: i]
1906 atIndex: i shouldCancel: NO])
1913 [svcs setAutoenablesItems: NO];
1914 #ifdef NS_IMPL_COCOA
1915 [svcs update]; /* on OS X, converts from '/' structure */
1918 ret = interpret_services_menu (svcs, Qnil, ret);
1923 DEFUN ("ns-perform-service", Fns_perform_service, Sns_perform_service,
1925 doc: /* Perform Nextstep SERVICE on SEND.
1926 SEND should be either a string or nil.
1927 The return value is the result of the service, as string, or nil if
1928 there was no result. */)
1929 (Lisp_Object service, Lisp_Object send)
1936 CHECK_STRING (service);
1939 utfStr = SDATA (service);
1940 svcName = [NSString stringWithUTF8String: utfStr];
1942 pb =[NSPasteboard pasteboardWithUniqueName];
1943 ns_string_to_pasteboard (pb, send);
1945 if (NSPerformService (svcName, pb) == NO)
1946 Fsignal (Qquit, Fcons (build_string ("service not available"), Qnil));
1948 if ([[pb types] count] == 0)
1949 return build_string ("");
1950 return ns_string_from_pasteboard (pb);
1954 DEFUN ("ns-convert-utf8-nfd-to-nfc", Fns_convert_utf8_nfd_to_nfc,
1955 Sns_convert_utf8_nfd_to_nfc, 1, 1, 0,
1956 doc: /* Return an NFC string that matches the UTF-8 NFD string STR. */)
1959 /* TODO: If GNUstep ever implements precomposedStringWithCanonicalMapping,
1964 utfStr = [NSString stringWithUTF8String: SDATA (str)];
1965 if (![utfStr respondsToSelector:
1966 @selector (precomposedStringWithCanonicalMapping)])
1969 ("Warning: ns-convert-utf8-nfd-to-nfc unsupported under GNUstep.\n");
1973 utfStr = [utfStr precomposedStringWithCanonicalMapping];
1974 return build_string ([utfStr UTF8String]);
1978 #ifdef NS_IMPL_COCOA
1980 /* Compile and execute the AppleScript SCRIPT and return the error
1981 status as function value. A zero is returned if compilation and
1982 execution is successful, in which case *RESULT is set to a Lisp
1983 string or a number containing the resulting script value. Otherwise,
1986 ns_do_applescript (Lisp_Object script, Lisp_Object *result)
1988 NSAppleEventDescriptor *desc;
1989 NSDictionary* errorDict;
1990 NSAppleEventDescriptor* returnDescriptor = NULL;
1992 NSAppleScript* scriptObject =
1993 [[NSAppleScript alloc] initWithSource:
1994 [NSString stringWithUTF8String: SDATA (script)]];
1996 returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
1997 [scriptObject release];
2001 if (returnDescriptor != NULL)
2003 // successful execution
2004 if (kAENullEvent != [returnDescriptor descriptorType])
2007 // script returned an AppleScript result
2008 if ((typeUnicodeText == [returnDescriptor descriptorType]) ||
2009 #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
2010 (typeUTF16ExternalRepresentation
2011 == [returnDescriptor descriptorType]) ||
2013 (typeUTF8Text == [returnDescriptor descriptorType]) ||
2014 (typeCString == [returnDescriptor descriptorType]))
2016 desc = [returnDescriptor coerceToDescriptorType: typeUTF8Text];
2018 *result = build_string([[desc stringValue] UTF8String]);
2022 /* use typeUTF16ExternalRepresentation? */
2023 // coerce the result to the appropriate ObjC type
2024 desc = [returnDescriptor coerceToDescriptorType: typeUTF8Text];
2026 *result = make_number([desc int32Value]);
2032 // no script result, return error
2038 DEFUN ("ns-do-applescript", Fns_do_applescript, Sns_do_applescript, 1, 1, 0,
2039 doc: /* Execute AppleScript SCRIPT and return the result.
2040 If compilation and execution are successful, the resulting script value
2041 is returned as a string, a number or, in the case of other constructs, t.
2042 In case the execution fails, an error is signaled. */)
2043 (Lisp_Object script)
2048 CHECK_STRING (script);
2052 status = ns_do_applescript (script, &result);
2056 else if (!STRINGP (result))
2057 error ("AppleScript error %d", status);
2059 error ("%s", SDATA (result));
2065 /* ==========================================================================
2067 Miscellaneous functions not called through hooks
2069 ========================================================================== */
2072 /* called from image.c */
2074 check_x_frame (Lisp_Object frame)
2076 return check_ns_frame (frame);
2080 /* called from frame.c */
2081 struct ns_display_info *
2082 check_x_display_info (Lisp_Object frame)
2084 return check_ns_display_info (frame);
2089 x_set_scroll_bar_default_width (struct frame *f)
2091 int wid = FRAME_COLUMN_WIDTH (f);
2092 FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = NS_SCROLL_BAR_WIDTH_DEFAULT;
2093 FRAME_CONFIG_SCROLL_BAR_COLS (f) = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) +
2098 /* terms impl this instead of x-get-resource directly */
2100 x_get_string_resource (XrmDatabase rdb, char *name, char *class)
2102 /* remove appname prefix; TODO: allow for !="Emacs" */
2103 char *toCheck = class + (!strncmp (class, "Emacs.", 6) ? 6 : 0);
2107 if (inhibit_x_resources)
2108 /* --quick was passed, so this is a no-op. */
2111 res = [[[NSUserDefaults standardUserDefaults] objectForKey:
2112 [NSString stringWithUTF8String: toCheck]] UTF8String];
2113 return !res ? NULL :
2114 (!strncasecmp (res, "YES", 3) ? "true" :
2115 (!strncasecmp (res, "NO", 2) ? "false" : res));
2120 x_get_focus_frame (struct frame *frame)
2122 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (frame);
2123 Lisp_Object nsfocus;
2125 if (!dpyinfo->x_focus_frame)
2128 XSETFRAME (nsfocus, dpyinfo->x_focus_frame);
2134 x_pixel_width (struct frame *f)
2136 return FRAME_PIXEL_WIDTH (f);
2141 x_pixel_height (struct frame *f)
2143 return FRAME_PIXEL_HEIGHT (f);
2148 x_char_width (struct frame *f)
2150 return FRAME_COLUMN_WIDTH (f);
2155 x_char_height (struct frame *f)
2157 return FRAME_LINE_HEIGHT (f);
2162 x_screen_planes (struct frame *f)
2164 return FRAME_NS_DISPLAY_INFO (f)->n_planes;
2169 x_sync (struct frame *f)
2171 /* XXX Not implemented XXX */
2177 /* ==========================================================================
2179 Lisp definitions that, for whatever reason, we can't alias as 'ns-XXX'.
2181 ========================================================================== */
2184 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
2185 doc: /* Internal function called by `color-defined-p', which see.
2186 \(Note that the Nextstep version of this function ignores FRAME.) */)
2187 (Lisp_Object color, Lisp_Object frame)
2191 return ns_lisp_to_color (color, &col) ? Qnil : Qt;
2195 DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
2196 doc: /* Internal function called by `color-values', which see. */)
2197 (Lisp_Object color, Lisp_Object frame)
2200 CGFloat red, green, blue, alpha;
2203 CHECK_STRING (color);
2205 if (ns_lisp_to_color (color, &col))
2208 [[col colorUsingColorSpaceName: NSCalibratedRGBColorSpace]
2209 getRed: &red green: &green blue: &blue alpha: &alpha];
2210 return list3 (make_number (lrint (red*65280)),
2211 make_number (lrint (green*65280)),
2212 make_number (lrint (blue*65280)));
2216 DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
2217 doc: /* Internal function called by `display-color-p', which see. */)
2218 (Lisp_Object display)
2220 NSWindowDepth depth;
2221 NSString *colorSpace;
2223 depth = [ns_get_screen (display) depth];
2224 colorSpace = NSColorSpaceFromDepth (depth);
2226 return [colorSpace isEqualToString: NSDeviceWhiteColorSpace]
2227 || [colorSpace isEqualToString: NSCalibratedWhiteColorSpace]
2232 DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p,
2233 Sx_display_grayscale_p, 0, 1, 0,
2234 doc: /* Return t if the Nextstep display supports shades of gray.
2235 Note that color displays do support shades of gray.
2236 The optional argument DISPLAY specifies which display to ask about.
2237 DISPLAY should be either a frame, a display name (a string), or terminal ID.
2238 If omitted or nil, that stands for the selected frame's display. */)
2239 (Lisp_Object display)
2241 NSWindowDepth depth;
2243 depth = [ns_get_screen (display) depth];
2245 return NSBitsPerPixelFromDepth (depth) > 1 ? Qt : Qnil;
2249 DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width,
2251 doc: /* Return the width in pixels of the Nextstep display DISPLAY.
2252 The optional argument DISPLAY specifies which display to ask about.
2253 DISPLAY should be either a frame, a display name (a string), or terminal ID.
2254 If omitted or nil, that stands for the selected frame's display. */)
2255 (Lisp_Object display)
2258 return make_number ((int) [ns_get_screen (display) frame].size.width);
2262 DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
2263 Sx_display_pixel_height, 0, 1, 0,
2264 doc: /* Return the height in pixels of the Nextstep display DISPLAY.
2265 The optional argument DISPLAY specifies which display to ask about.
2266 DISPLAY should be either a frame, a display name (a string), or terminal ID.
2267 If omitted or nil, that stands for the selected frame's display. */)
2268 (Lisp_Object display)
2271 return make_number ((int) [ns_get_screen (display) frame].size.height);
2275 DEFUN ("display-usable-bounds", Fns_display_usable_bounds,
2276 Sns_display_usable_bounds, 0, 1, 0,
2277 doc: /* Return the bounds of the usable part of the screen.
2278 The return value is a list of integers (LEFT TOP WIDTH HEIGHT), which
2279 are the boundaries of the usable part of the screen, excluding areas
2280 reserved for the Mac menu, dock, and so forth.
2282 The screen queried corresponds to DISPLAY, which should be either a
2283 frame, a display name (a string), or terminal ID. If omitted or nil,
2284 that stands for the selected frame's display. */)
2285 (Lisp_Object display)
2292 screen = ns_get_screen (display);
2296 vScreen = [screen visibleFrame];
2298 /* NS coordinate system is upside-down.
2299 Transform to screen-specific coordinates. */
2300 return list4 (make_number ((int) vScreen.origin.x),
2301 make_number ((int) [screen frame].size.height
2302 - vScreen.size.height - vScreen.origin.y),
2303 make_number ((int) vScreen.size.width),
2304 make_number ((int) vScreen.size.height));
2308 DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes,
2310 doc: /* Return the number of bitplanes of the Nextstep display DISPLAY.
2311 The optional argument DISPLAY specifies which display to ask about.
2312 DISPLAY should be either a frame, a display name (a string), or terminal ID.
2313 If omitted or nil, that stands for the selected frame's display. */)
2314 (Lisp_Object display)
2318 (NSBitsPerPixelFromDepth ([ns_get_screen (display) depth]));
2322 DEFUN ("x-display-color-cells", Fx_display_color_cells,
2323 Sx_display_color_cells, 0, 1, 0,
2324 doc: /* Returns the number of color cells of the Nextstep display DISPLAY.
2325 The optional argument DISPLAY specifies which display to ask about.
2326 DISPLAY should be either a frame, a display name (a string), or terminal ID.
2327 If omitted or nil, that stands for the selected frame's display. */)
2328 (Lisp_Object display)
2330 struct ns_display_info *dpyinfo;
2333 dpyinfo = check_ns_display_info (display);
2334 /* We force 24+ bit depths to 24-bit to prevent an overflow. */
2335 return make_number (1 << min (dpyinfo->n_planes, 24));
2339 /* Unused dummy def needed for compatibility. */
2340 Lisp_Object tip_frame;
2342 /* TODO: move to xdisp or similar */
2344 compute_tip_xy (struct frame *f,
2353 Lisp_Object left, top;
2354 EmacsView *view = FRAME_NS_VIEW (f);
2357 /* Start with user-specified or mouse position. */
2358 left = Fcdr (Fassq (Qleft, parms));
2359 top = Fcdr (Fassq (Qtop, parms));
2361 if (!INTEGERP (left) || !INTEGERP (top))
2363 pt = last_mouse_motion_position;
2364 /* Convert to screen coordinates */
2365 pt = [view convertPoint: pt toView: nil];
2366 pt = [[view window] convertBaseToScreen: pt];
2370 /* Absolute coordinates. */
2372 pt.y = x_display_pixel_height (FRAME_NS_DISPLAY_INFO (f)) - XINT (top)
2376 /* Ensure in bounds. (Note, screen origin = lower left.) */
2377 if (INTEGERP (left))
2379 else if (pt.x + XINT (dx) <= 0)
2380 *root_x = 0; /* Can happen for negative dx */
2381 else if (pt.x + XINT (dx) + width
2382 <= x_display_pixel_width (FRAME_NS_DISPLAY_INFO (f)))
2383 /* It fits to the right of the pointer. */
2384 *root_x = pt.x + XINT (dx);
2385 else if (width + XINT (dx) <= pt.x)
2386 /* It fits to the left of the pointer. */
2387 *root_x = pt.x - width - XINT (dx);
2389 /* Put it left justified on the screen -- it ought to fit that way. */
2394 else if (pt.y - XINT (dy) - height >= 0)
2395 /* It fits below the pointer. */
2396 *root_y = pt.y - height - XINT (dy);
2397 else if (pt.y + XINT (dy) + height
2398 <= x_display_pixel_height (FRAME_NS_DISPLAY_INFO (f)))
2399 /* It fits above the pointer */
2400 *root_y = pt.y + XINT (dy);
2402 /* Put it on the top. */
2403 *root_y = x_display_pixel_height (FRAME_NS_DISPLAY_INFO (f)) - height;
2407 DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
2408 doc: /* Show STRING in a \"tooltip\" window on frame FRAME.
2409 A tooltip window is a small window displaying a string.
2411 This is an internal function; Lisp code should call `tooltip-show'.
2413 FRAME nil or omitted means use the selected frame.
2415 PARMS is an optional list of frame parameters which can be used to
2416 change the tooltip's appearance.
2418 Automatically hide the tooltip after TIMEOUT seconds. TIMEOUT nil
2419 means use the default timeout of 5 seconds.
2421 If the list of frame parameters PARMS contains a `left' parameter,
2422 the tooltip is displayed at that x-position. Otherwise it is
2423 displayed at the mouse position, with offset DX added (default is 5 if
2424 DX isn't specified). Likewise for the y-position; if a `top' frame
2425 parameter is specified, it determines the y-position of the tooltip
2426 window, otherwise it is displayed at the mouse position, with offset
2427 DY added (default is -10).
2429 A tooltip's maximum size is specified by `x-max-tooltip-size'.
2430 Text larger than the specified size is clipped. */)
2431 (Lisp_Object string, Lisp_Object frame, Lisp_Object parms, Lisp_Object timeout, Lisp_Object dx, Lisp_Object dy)
2434 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
2435 int count = SPECPDL_INDEX ();
2440 specbind (Qinhibit_redisplay, Qt);
2442 GCPRO4 (string, parms, frame, timeout);
2444 CHECK_STRING (string);
2445 str = SDATA (string);
2446 f = check_x_frame (frame);
2448 timeout = make_number (5);
2450 CHECK_NATNUM (timeout);
2453 dx = make_number (5);
2458 dy = make_number (-10);
2463 if (ns_tooltip == nil)
2464 ns_tooltip = [[EmacsTooltip alloc] init];
2468 [ns_tooltip setText: str];
2469 size = [ns_tooltip frame].size;
2471 /* Move the tooltip window where the mouse pointer is. Resize and
2473 compute_tip_xy (f, parms, dx, dy, (int)size.width, (int)size.height,
2476 [ns_tooltip showAtX: root_x Y: root_y for: XINT (timeout)];
2480 return unbind_to (count, Qnil);
2484 DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0,
2485 doc: /* Hide the current tooltip window, if there is any.
2486 Value is t if tooltip was open, nil otherwise. */)
2489 if (ns_tooltip == nil || ![ns_tooltip isActive])
2496 /* ==========================================================================
2498 Class implementations
2500 ========================================================================== */
2503 @implementation EmacsSavePanel
2504 #ifdef NS_IMPL_COCOA
2505 /* --------------------------------------------------------------------------
2506 These are overridden to intercept on OS X: ending panel restarts NSApp
2507 event loop if it is stopped. Not sure if this is correct behavior,
2508 perhaps should check if running and if so send an appdefined.
2509 -------------------------------------------------------------------------- */
2510 - (void) ok: (id)sender
2516 - (void) cancel: (id)sender
2518 [super cancel: sender];
2525 @implementation EmacsOpenPanel
2526 #ifdef NS_IMPL_COCOA
2527 /* --------------------------------------------------------------------------
2528 These are overridden to intercept on OS X: ending panel restarts NSApp
2529 event loop if it is stopped. Not sure if this is correct behavior,
2530 perhaps should check if running and if so send an appdefined.
2531 -------------------------------------------------------------------------- */
2532 - (void) ok: (id)sender
2538 - (void) cancel: (id)sender
2540 [super cancel: sender];
2547 @implementation EmacsFileDelegate
2548 /* --------------------------------------------------------------------------
2549 Delegate methods for Open/Save panels
2550 -------------------------------------------------------------------------- */
2551 - (BOOL)panel: (id)sender isValidFilename: (NSString *)filename
2555 - (BOOL)panel: (id)sender shouldShowFilename: (NSString *)filename
2559 - (NSString *)panel: (id)sender userEnteredFilename: (NSString *)filename
2560 confirmed: (BOOL)okFlag
2569 /* ==========================================================================
2571 Lisp interface declaration
2573 ========================================================================== */
2577 syms_of_nsfns (void)
2581 Qfontsize = intern_c_string ("fontsize");
2582 staticpro (&Qfontsize);
2584 DEFVAR_LISP ("ns-icon-type-alist", Vns_icon_type_alist,
2585 doc: /* Alist of elements (REGEXP . IMAGE) for images of icons associated to frames.
2586 If the title of a frame matches REGEXP, then IMAGE.tiff is
2587 selected as the image of the icon representing the frame when it's
2588 miniaturized. If an element is t, then Emacs tries to select an icon
2589 based on the filetype of the visited file.
2591 The images have to be installed in a folder called English.lproj in the
2592 Emacs folder. You have to restart Emacs after installing new icons.
2594 Example: Install an icon Gnus.tiff and execute the following code
2596 (setq ns-icon-type-alist
2597 (append ns-icon-type-alist
2598 '((\"^\\\\*\\\\(Group\\\\*$\\\\|Summary \\\\|Article\\\\*$\\\\)\"
2601 When you miniaturize a Group, Summary or Article frame, Gnus.tiff will
2602 be used as the image of the icon representing the frame. */);
2603 Vns_icon_type_alist = Fcons (Qt, Qnil);
2605 DEFVAR_LISP ("ns-version-string", Vns_version_string,
2606 doc: /* Toolkit version for NS Windowing. */);
2607 Vns_version_string = ns_appkit_version_str ();
2609 defsubr (&Sns_read_file_name);
2610 defsubr (&Sns_get_resource);
2611 defsubr (&Sns_set_resource);
2612 defsubr (&Sxw_display_color_p); /* this and next called directly by C code */
2613 defsubr (&Sx_display_grayscale_p);
2614 defsubr (&Sns_font_name);
2615 defsubr (&Sns_list_colors);
2616 #ifdef NS_IMPL_COCOA
2617 defsubr (&Sns_do_applescript);
2619 defsubr (&Sxw_color_defined_p);
2620 defsubr (&Sxw_color_values);
2621 defsubr (&Sx_server_max_request_size);
2622 defsubr (&Sx_server_vendor);
2623 defsubr (&Sx_server_version);
2624 defsubr (&Sx_display_pixel_width);
2625 defsubr (&Sx_display_pixel_height);
2626 defsubr (&Sns_display_usable_bounds);
2627 defsubr (&Sx_display_mm_width);
2628 defsubr (&Sx_display_mm_height);
2629 defsubr (&Sx_display_screens);
2630 defsubr (&Sx_display_planes);
2631 defsubr (&Sx_display_color_cells);
2632 defsubr (&Sx_display_visual_class);
2633 defsubr (&Sx_display_backing_store);
2634 defsubr (&Sx_display_save_under);
2635 defsubr (&Sx_create_frame);
2636 defsubr (&Sx_open_connection);
2637 defsubr (&Sx_close_connection);
2638 defsubr (&Sx_display_list);
2640 defsubr (&Sns_hide_others);
2641 defsubr (&Sns_hide_emacs);
2642 defsubr (&Sns_emacs_info_panel);
2643 defsubr (&Sns_list_services);
2644 defsubr (&Sns_perform_service);
2645 defsubr (&Sns_convert_utf8_nfd_to_nfc);
2646 defsubr (&Sx_focus_frame);
2647 defsubr (&Sns_popup_font_panel);
2648 defsubr (&Sns_popup_color_panel);
2650 defsubr (&Sx_show_tip);
2651 defsubr (&Sx_hide_tip);
2653 /* used only in fontset.c */
2654 check_window_system_func = check_ns;