/* Functions for the NeXT/Open/GNUstep and MacOSX window system.
- Copyright (C) 1989, 1992, 1993, 1994, 2005, 2006, 2008
+ Copyright (C) 1989, 1992, 1993, 1994, 2005, 2006, 2008, 2009
Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
*/
+/* This should be the first include, as it may set up #defines affecting
+ interpretation of even the system includes. */
+#include "config.h"
+
#include <signal.h>
#include <math.h>
-#include "config.h"
+
#include "lisp.h"
#include "blockinput.h"
#include "nsterm.h"
#include "keyboard.h"
#include "termhooks.h"
#include "fontset.h"
-
#include "character.h"
#include "font.h"
extern Lisp_Object Qunsplittable, Qmenu_bar_lines, Qbuffer_predicate, Qtitle;
Lisp_Object Qnone;
-Lisp_Object Qns_frame_parameter;
Lisp_Object Qbuffered;
Lisp_Object Qfontsize;
/* Alist of elements (REGEXP . IMAGE) for images of icons associated
to frames.*/
-Lisp_Object Vns_icon_type_alist;
+static Lisp_Object Vns_icon_type_alist;
+
+/* Toolkit version support. */
+static Lisp_Object Vns_version_string;
EmacsTooltip *ns_tooltip;
/* Need forward declaration here to preserve organizational integrity of file */
-Lisp_Object Fns_open_connection (Lisp_Object, Lisp_Object, Lisp_Object);
+Lisp_Object Fx_open_connection (Lisp_Object, Lisp_Object, Lisp_Object);
extern BOOL ns_in_resize;
f = XFRAME (frame);
}
if (! FRAME_NS_P (f))
- error ("non-NS frame used");
+ error ("non-Nextstep frame used");
return f;
}
-/* Let the user specify an NS display with a frame.
- nil stands for the selected frame--or, if that is not an NS frame,
- the first NS display on the list. */
+/* Let the user specify an Nextstep display with a frame.
+ nil stands for the selected frame--or, if that is not an Nextstep frame,
+ the first Nextstep display on the list. */
static struct ns_display_info *
check_ns_display_info (Lisp_Object frame)
{
struct frame *f = SELECTED_FRAME ();
if (FRAME_NS_P (f) && FRAME_LIVE_P (f) )
return FRAME_NS_DISPLAY_INFO (f);
- else if (ns_display_list != 0)
- return ns_display_list;
+ else if (x_display_list != 0)
+ return x_display_list;
else
- error ("NS windows are not in use or not initialized");
+ error ("Nextstep windows are not in use or not initialized");
}
else if (INTEGERP (frame))
{
struct terminal *t = get_terminal (frame, 1);
if (t->type != output_ns)
- error ("Terminal %d is not an NS display", XINT (frame));
+ error ("Terminal %d is not a Nextstep display", XINT (frame));
return t->display_info.ns;
}
CHECK_LIVE_FRAME (frame);
f = XFRAME (frame);
if (! FRAME_NS_P (f))
- error ("non-NS frame used");
+ error ("non-Nextstep frame used");
return FRAME_NS_DISPLAY_INFO (f);
}
return NULL; /* shut compiler up */
static NSScreen *
-ns_get_screen (Lisp_Object anythingUnderTheSun)
-{
- id window =nil;
- NSScreen *screen = 0;
-
- struct terminal *terminal;
- struct ns_display_info *dpyinfo;
- struct frame *f = NULL;
- Lisp_Object frame;
-
- if (INTEGERP (anythingUnderTheSun)) {
- /* we got a terminal */
- terminal = get_terminal (anythingUnderTheSun, 1);
- dpyinfo = terminal->display_info.ns;
- f = dpyinfo->ns_focus_frame;
- if (!f)
- f = dpyinfo->ns_highlight_frame;
-
- } else if (FRAMEP (anythingUnderTheSun) &&
- FRAME_NS_P (XFRAME (anythingUnderTheSun))) {
- /* we got a frame */
- f = XFRAME (anythingUnderTheSun);
-
- } else if (STRINGP (anythingUnderTheSun)) { /* FIXME/cl for multi-display */
- }
-
- if (!f)
- f = SELECTED_FRAME ();
- if (f)
+ns_get_screen (Lisp_Object screen)
+{
+ struct terminal *terminal = get_terminal (screen, 1);
+ if (terminal->type != output_ns)
+ // Not sure if this special case for nil is needed. It does seem to be
+ // important in xfns.c for the make-frame call in frame-initialize,
+ // so let's keep it here for now.
+ return (NILP (screen) ? [NSScreen mainScreen] : NULL);
+ else
{
- XSETFRAME (frame, f);
- window = ns_get_window (frame);
+ struct ns_display_info *dpyinfo = terminal->display_info.ns;
+ struct frame *f = dpyinfo->x_focus_frame;
+ if (!f)
+ f = dpyinfo->x_highlight_frame;
+ if (!f)
+ return NULL;
+ else
+ {
+ id window = nil;
+ Lisp_Object frame;
+ eassert (FRAME_NS_P (f));
+ XSETFRAME (frame, f);
+ window = ns_get_window (frame);
+ return window ? [window screen] : NULL;
+ }
}
-
- if (window)
- screen = [window screen];
- if (!screen)
- screen = [NSScreen mainScreen];
-
- return screen;
}
CHECK_STRING (name);
- for (dpyinfo = ns_display_list, names = ns_display_name_list;
+ for (dpyinfo = x_display_list, names = ns_display_name_list;
dpyinfo;
dpyinfo = dpyinfo->next, names = XCDR (names))
{
error ("Emacs for OpenStep does not yet support multi-display.");
- Fns_open_connection (name, Qnil, Qnil);
- dpyinfo = ns_display_list;
+ Fx_open_connection (name, Qnil, Qnil);
+ dpyinfo = x_display_list;
if (dpyinfo == 0)
error ("OpenStep on %s not responding.\n", SDATA (name));
-------------------------------------------------------------------------- */
{
int i, count;
- id<NSMenuItem> item;
+ NSMenuItem *item;
const char *name;
Lisp_Object nameStr;
unsigned short key;
static void
-ns_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
NSColor *col;
static void
-ns_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
struct face *face;
NSColor *col;
[[view window] setBackgroundColor: col];
alpha = [col alphaComponent];
-#ifdef NS_IMPL_COCOA
- /* the alpha code below only works on 10.4, so we need to do something
- else (albeit less good) otherwise.
- Check NSApplication.h for useful NSAppKitVersionNumber values. */
- if (NSAppKitVersionNumber < 744.0)
- [[view window] setAlphaValue: alpha];
-#endif
-
if (alpha != 1.0)
[[view window] setOpaque: NO];
else
face = FRAME_DEFAULT_FACE (f);
if (face)
{
- col = NS_FACE_BACKGROUND (face);
+ col = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), f);
face->background
= (EMACS_UINT) [[col colorWithAlphaComponent: alpha] retain];
[col release];
static void
-ns_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+x_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
NSColor *col;
error ("Unknown color");
}
- [f->output_data.ns->desired_cursor_color release];
- f->output_data.ns->desired_cursor_color = [col retain];
+ [FRAME_CURSOR_COLOR (f) release];
+ FRAME_CURSOR_COLOR (f) = [col retain];
if (FRAME_VISIBLE_P (f))
{
static void
-ns_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
NSView *view = FRAME_NS_VIEW (f);
- NSTRACE (ns_set_icon_name);
+ NSTRACE (x_set_icon_name);
if (ns_in_resize)
return;
specified a name for the frame; the name will override any set by the
redisplay code. */
static void
-ns_explicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval)
+x_explicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval)
{
- NSTRACE (ns_explicitly_set_name);
+ NSTRACE (x_explicitly_set_name);
ns_set_name_iconic (f, arg, 1);
ns_set_name (f, arg, 1);
}
suggesting a new name, which lisp code should override; if
F->explicit_name is set, ignore the new name; otherwise, set it. */
static void
-ns_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
+x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
{
- NSTRACE (ns_set_title);
+ NSTRACE (x_set_title);
/* Don't change the title if it's already NAME. */
if (EQ (name, f->title))
return;
}
-static void
-ns_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
+void
+x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
{
int nlines;
int olines = FRAME_MENU_BAR_LINES (f);
if (nlines)
{
FRAME_EXTERNAL_MENU_BAR (f) = 1;
-/* does for all frames, whereas we just want for one frame
- [NSMenu setMenuBarVisible: YES]; */
+ /* does for all frames, whereas we just want for one frame
+ [NSMenu setMenuBarVisible: YES]; */
}
else
{
if (FRAME_EXTERNAL_MENU_BAR (f) == 1)
free_frame_menubar (f);
-/* [NSMenu setMenuBarVisible: NO]; */
+ /* [NSMenu setMenuBarVisible: NO]; */
FRAME_EXTERNAL_MENU_BAR (f) = 0;
}
}
-/* 23: XXX: there is an erroneous direct call in window.c to this fn */
+/* toolbar support */
void
-x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
-{
- ns_set_menu_bar_lines (f, value, oldval);
-}
-
-
-/* 23: toolbar support */
-static void
-ns_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
+x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
{
int nlines;
Lisp_Object root_window;
}
-/* 23: XXX: there is an erroneous direct call in window.c to this fn */
-void
-x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
-{
- ns_set_tool_bar_lines (f, value, oldval);
-}
-
-
void
ns_implicitly_set_icon_type (struct frame *f)
{
static void
-ns_set_icon_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+x_set_icon_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
EmacsView *view = FRAME_NS_VIEW (f);
id image = nil;
BOOL setMini = YES;
- NSTRACE (ns_set_icon_type);
+ NSTRACE (x_set_icon_type);
if (!NILP (arg) && SYMBOLP (arg))
{
}
-/* 23: added Xism; we stub out (we do implement this in ns-win.el) */
+/* Xism; we stub out (we do implement this in ns-win.el) */
int
XParseGeometry (char *string, int *x, int *y,
unsigned int *width, unsigned int *height)
else if (XTYPE (arg) == Lisp_Symbol)
str = SDATA (SYMBOL_NAME (arg));
else return -1;
- if (!strcmp (str, "box")) return filled_box;
- if (!strcmp (str, "hollow")) return hollow_box;
- if (!strcmp (str, "underscore")) return underscore;
- if (!strcmp (str, "bar")) return bar;
- if (!strcmp (str, "no")) return no_highlight;
+ if (!strcmp (str, "box")) return FILLED_BOX_CURSOR;
+ if (!strcmp (str, "hollow")) return HOLLOW_BOX_CURSOR;
+ if (!strcmp (str, "hbar")) return HBAR_CURSOR;
+ if (!strcmp (str, "bar")) return BAR_CURSOR;
+ if (!strcmp (str, "no")) return NO_CURSOR;
return -1;
}
{
switch (arg)
{
- case filled_box: return Qbox;
- case hollow_box: return intern ("hollow");
- case underscore: return intern ("underscore");
- case bar: return intern ("bar");
- case no_highlight:
- default: return intern ("no");
+ case FILLED_BOX_CURSOR: return Qbox;
+ case HOLLOW_BOX_CURSOR: return intern ("hollow");
+ case HBAR_CURSOR: return intern ("hbar");
+ case BAR_CURSOR: return intern ("bar");
+ case NO_CURSOR:
+ default: return intern ("no");
}
}
+/* This is the same as the xfns.c definition. */
+void
+x_set_cursor_type (f, arg, oldval)
+ FRAME_PTR f;
+ Lisp_Object arg, oldval;
+{
+ set_frame_cursor_types (f, arg);
+
+ /* Make sure the cursor gets redrawn. */
+ cursor_type_changed = 1;
+}
+\f
+/* called to set mouse pointer color, but all other terms use it to
+ initialize pointer types (and don't set the color ;) */
static void
-ns_set_cursor_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
- int val;
+ /* don't think we can do this on Nextstep */
+}
- val = ns_lisp_to_cursor_type (arg);
- if (val >= 0)
- {
- f->output_data.ns->desired_cursor =val;
- }
- else
- {
- store_frame_param (f, Qcursor_type, oldval);
- error ("the `cursor-type' frame parameter should be either `no', `box', \
-`hollow', `underscore' or `bar'.");
- }
- update_mode_lines++;
+#define Str(x) #x
+#define Xstr(x) Str(x)
+
+static Lisp_Object
+ns_appkit_version_str ()
+{
+ char tmp[80];
+
+#ifdef NS_IMPL_GNUSTEP
+ sprintf(tmp, "gnustep-gui-%s", Xstr(GNUSTEP_GUI_VERSION));
+#elif defined(NS_IMPL_COCOA)
+ sprintf(tmp, "apple-appkit-%.2f", NSAppKitVersionNumber);
+#else
+ tmp = "ns-unknown";
+#endif
+ return build_string (tmp);
}
-/* 23: called to set mouse pointer color, but all other terms use it to
- initialize pointer types (and don't set the color ;) */
-static void
-ns_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+/* This is for use by x-server-version and collapses all version info we
+ have into a single int. For a better picture of the implementation
+ running, use ns_appkit_version_str.*/
+static int
+ns_appkit_version_int ()
{
- /* don't think we can do this on NS */
+#ifdef NS_IMPL_GNUSTEP
+ return GNUSTEP_GUI_MAJOR_VERSION * 100 + GNUSTEP_GUI_MINOR_VERSION;
+#elif defined(NS_IMPL_COCOA)
+ return (int)NSAppKitVersionNumber;
+#endif
+ return 0;
}
static void
-ns_icon (struct frame *f, Lisp_Object parms)
+x_icon (struct frame *f, Lisp_Object parms)
/* --------------------------------------------------------------------------
Strangely-named function to set icon position parameters in frame.
This is irrelevant under OS X, but might be needed under GNUstep,
}
-/* 23 Note: commented out ns_... entries are no longer used in 23.
- commented out x_... entries have not been implemented yet.
- see frame.c for template, also where all generic OK functions are impl */
+/* Note: see frame.c for template, also where generic functions are impl */
frame_parm_handler ns_frame_parm_handlers[] =
{
x_set_autoraise, /* generic OK */
x_set_autolower, /* generic OK */
- ns_set_background_color,
- 0, /* x_set_border_color, may be impossible under NS */
- 0, /* x_set_border_width, may be impossible under NS */
- ns_set_cursor_color,
- ns_set_cursor_type,
+ x_set_background_color,
+ 0, /* x_set_border_color, may be impossible under Nextstep */
+ 0, /* x_set_border_width, may be impossible under Nextstep */
+ x_set_cursor_color,
+ x_set_cursor_type,
x_set_font, /* generic OK */
- ns_set_foreground_color,
- ns_set_icon_name,
- ns_set_icon_type,
+ x_set_foreground_color,
+ x_set_icon_name,
+ x_set_icon_type,
x_set_internal_border_width, /* generic OK */
- ns_set_menu_bar_lines,
- ns_set_mouse_color,
- ns_explicitly_set_name,
+ x_set_menu_bar_lines,
+ x_set_mouse_color,
+ x_explicitly_set_name,
x_set_scroll_bar_width, /* generic OK */
- ns_set_title,
+ x_set_title,
x_set_unsplittable, /* generic OK */
x_set_vertical_scroll_bars, /* generic OK */
x_set_visibility, /* generic OK */
- ns_set_tool_bar_lines,
+ x_set_tool_bar_lines,
0, /* x_set_scroll_bar_foreground, will ignore (not possible on NS) */
0, /* x_set_scroll_bar_background, will ignore (not possible on NS) */
x_set_screen_gamma, /* generic OK */
x_set_fringe_width, /* generic OK */
0, /* x_set_wait_for_wm, will ignore */
0, /* x_set_fullscreen will ignore */
- x_set_font_backend /* generic OK */
+ x_set_font_backend, /* generic OK */
+ x_set_alpha
};
-DEFUN ("x-create-frame", Fns_create_frame, Sns_create_frame,
+
+/* ==========================================================================
+
+ Lisp definitions
+
+ ========================================================================== */
+
+DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
1, 1, 0,
- "Make a new NS window, which is called a \"frame\" in Emacs terms.\n\
-Return an Emacs frame object representing the X window.\n\
-ALIST is an alist of frame parameters.\n\
-If the parameters specify that the frame should not have a minibuffer,\n\
-and do not specify a specific minibuffer window to use,\n\
-then `default-minibuffer-frame' must be a frame whose minibuffer can\n\
-be shared by the new frame.")
+ doc: /* Make a new Nextstep window, called a \"frame\" in Emacs terms.
+Return an Emacs frame object.
+PARMS is an alist of frame parameters.
+If the parameters specify that the frame should not have a minibuffer,
+and do not specify a specific minibuffer window to use,
+then `default-minibuffer-frame' must be a frame whose minibuffer can
+be shared by the new frame. */)
(parms)
Lisp_Object parms;
{
check_ns ();
+ /* Seems a little strange, but other terms do it. Perhaps the code below
+ is modifying something? */
+ parms = Fcopy_alist (parms);
+
display = x_get_arg (dpyinfo, parms, Qterminal, 0, 0, RES_TYPE_STRING);
if (EQ (display, Qunbound))
display = Qnil;
if (STRINGP (name))
Vx_resource_name = name;
+ else
+ Vx_resource_name = Vinvocation_name;
parent = x_get_arg (dpyinfo, parms, Qparent_id, 0, 0, RES_TYPE_NUMBER);
if (EQ (parent, Qunbound))
f->icon_name = x_get_arg (dpyinfo, parms, Qicon_name, "iconName", "Title",
RES_TYPE_STRING);
- if (EQ (f->icon_name, Qunbound) || (XTYPE (f->icon_name) != Lisp_String))
+ if (! STRINGP (f->icon_name))
f->icon_name = Qnil;
FRAME_NS_DISPLAY_INFO (f) = dpyinfo;
"background", "Background", RES_TYPE_STRING);
x_default_parameter (f, parms, Qcursor_color, build_string ("grey"),
"cursorColor", "CursorColor", RES_TYPE_STRING);
- /* FIXME: not suppported yet in NS */
+ /* FIXME: not suppported yet in Nextstep */
x_default_parameter (f, parms, Qline_spacing, Qnil,
"lineSpacing", "LineSpacing", RES_TYPE_NUMBER);
x_default_parameter (f, parms, Qleft_fringe, Qnil,
f->no_split = minibuffer_only || (!EQ (tem, Qunbound) && !EQ (tem, Qnil));
/* NOTE: on other terms, this is done in set_mouse_color, however this
- was not getting called under NS */
+ was not getting called under Nextstep */
f->output_data.ns->text_cursor = [NSCursor IBeamCursor];
f->output_data.ns->nontext_cursor = [NSCursor arrowCursor];
f->output_data.ns->modeline_cursor = [NSCursor pointingHandCursor];
[[EmacsView alloc] initFrameFromEmacs: f];
- ns_icon (f, parms);
+ x_icon (f, parms);
/* It is now ok to make the frame official even if we get an error below.
The frame needs to be on Vframe_list or making it visible won't work. */
Vframe_list = Fcons (frame, Vframe_list);
/*FRAME_NS_DISPLAY_INFO (f)->reference_count++; */
- x_default_parameter (f, parms, Qcursor_type, Qbox, "cursorType", "CursorType",
- RES_TYPE_SYMBOL);
- x_default_parameter (f, parms, Qscroll_bar_width, Qnil, "scrollBarWidth",
- "ScrollBarWidth", RES_TYPE_NUMBER);
x_default_parameter (f, parms, Qicon_type, Qnil, "bitmapIcon", "BitmapIcon",
RES_TYPE_SYMBOL);
- x_default_parameter (f, parms, Qauto_raise, Qnil, "autoRaise", "AutoRaise",
+ x_default_parameter (f, parms, Qauto_raise, Qnil, "autoRaise", "AutoRaiseLower",
RES_TYPE_BOOLEAN);
x_default_parameter (f, parms, Qauto_lower, Qnil, "autoLower", "AutoLower",
RES_TYPE_BOOLEAN);
- x_default_parameter (f, parms, Qbuffered, Qt, "buffered", "Buffered",
- RES_TYPE_BOOLEAN);
+ x_default_parameter (f, parms, Qcursor_type, Qbox, "cursorType", "CursorType",
+ RES_TYPE_SYMBOL);
+ x_default_parameter (f, parms, Qscroll_bar_width, Qnil, "scrollBarWidth",
+ "ScrollBarWidth", RES_TYPE_NUMBER);
+ x_default_parameter (f, parms, Qalpha, Qnil, "alpha", "Alpha",
+ RES_TYPE_NUMBER);
width = FRAME_COLS (f);
height = FRAME_LINES (f);
if (! f->output_data.ns->explicit_parent)
{
- tem = x_get_arg (dpyinfo, parms, Qvisibility, 0, 0, RES_TYPE_BOOLEAN);
- if (EQ (tem, Qunbound))
- tem = Qnil;
-
- x_set_visibility (f, tem, Qnil);
- if (EQ (tem, Qt))
- [[FRAME_NS_VIEW (f) window] makeKeyWindow];
+ tem = x_get_arg (dpyinfo, parms, Qvisibility, 0, 0, RES_TYPE_SYMBOL);
+ if (EQ (tem, Qunbound))
+ tem = Qt;
+ x_set_visibility (f, tem, Qnil);
+ if (EQ (tem, Qicon))
+ x_iconify_frame (f);
+ else if (! NILP (tem))
+ {
+ x_make_frame_visible (f);
+ f->async_visible = 1;
+ [[FRAME_NS_VIEW (f) window] makeKeyWindow];
+ }
+ else
+ f->async_visible = 0;
}
if (FRAME_HAS_MINIBUF_P (f)
}
-/* ==========================================================================
-
- Lisp definitions
-
- ========================================================================== */
-
-DEFUN ("ns-focus-frame", Fns_focus_frame, Sns_focus_frame, 1, 1, 0,
+DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0,
doc: /* Set the input focus to FRAME.
FRAME nil means use the selected frame. */)
(frame)
struct frame *f = check_ns_frame (frame);
struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f);
- if (dpyinfo->ns_focus_frame != f)
+ if (dpyinfo->x_focus_frame != f)
{
EmacsView *view = FRAME_NS_VIEW (f);
BLOCK_INPUT;
}
-DEFUN ("ns-popup-prefs-panel", Fns_popup_prefs_panel, Sns_popup_prefs_panel,
- 0, 0, "", "Pop up the preferences panel.")
- ()
-{
- check_ns ();
- [(EmacsApp *)NSApp showPreferencesWindow: NSApp];
- return Qnil;
-}
-
-
DEFUN ("ns-popup-font-panel", Fns_popup_font_panel, Sns_popup_font_panel,
- 0, 1, "", "Pop up the font panel.")
+ 0, 1, "",
+ doc: /* Pop up the font panel. */)
(frame)
Lisp_Object frame;
{
}
-DEFUN ("ns-popup-color-panel", Fns_popup_color_panel, Sns_popup_color_panel,
- 0, 1, "", "Pop up the color panel.")
+DEFUN ("ns-popup-color-panel", Fns_popup_color_panel, Sns_popup_color_panel,
+ 0, 1, "",
+ doc: /* Pop up the color panel. */)
(frame)
Lisp_Object frame;
{
DEFUN ("ns-read-file-name", Fns_read_file_name, Sns_read_file_name, 1, 4, 0,
- "As read-file-name except that NS panels are used for querying, and\n\
-args are slightly different. Nil returned if no selection made.\n\
-Set ISLOAD non-nil if file being read for a save.")
+ doc: /* Use a graphical panel to read a file name, using prompt PROMPT.
+Optional arg DIR, if non-nil, supplies a default directory.
+Optional arg ISLOAD, if non-nil, means read a file name for saving.
+Optional arg INIT, if non-nil, provides a default file name to use. */)
(prompt, dir, isLoad, init)
Lisp_Object prompt, dir, isLoad, init;
{
static id fileDelegate = nil;
int ret;
id panel;
- NSString *fname;
+ Lisp_Object fname;
NSString *promptS = NILP (prompt) || !STRINGP (prompt) ? nil :
[NSString stringWithUTF8String: SDATA (prompt)];
dirS = [dirS stringByExpandingTildeInPath];
panel = NILP (isLoad) ?
- [EmacsSavePanel savePanel] : [EmacsOpenPanel openPanel];
+ (id)[EmacsSavePanel savePanel] : (id)[EmacsOpenPanel openPanel];
[panel setTitle: promptS];
[panel setDelegate: fileDelegate];
panelOK = 0;
+ BLOCK_INPUT;
if (NILP (isLoad))
{
ret = [panel runModalForDirectory: dirS file: initS];
ret = [panel runModalForDirectory: dirS file: initS types: nil];
}
- ret = (ret = NSOKButton) || panelOK;
+ ret = (ret == NSOKButton) || panelOK;
- fname = [panel filename];
+ if (ret)
+ fname = build_string ([[panel filename] UTF8String]);
[[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow];
+ UNBLOCK_INPUT;
- return ret ? build_string ([fname UTF8String]) : Qnil;
+ return ret ? fname : Qnil;
}
DEFUN ("ns-get-resource", Fns_get_resource, Sns_get_resource, 2, 2, 0,
- "Return the value of the property NAME of OWNER from the defaults database.\n\
-If OWNER is nil, Emacs is assumed.")
+ doc: /* Return the value of the property NAME of OWNER from the defaults database.
+If OWNER is nil, Emacs is assumed. */)
(owner, name)
Lisp_Object owner, name;
{
if (value)
return build_string (value);
-/*fprintf (stderr, "Nothing found for NS resource '%s'.\n", SDATA (name)); */
return Qnil;
}
DEFUN ("ns-set-resource", Fns_set_resource, Sns_set_resource, 3, 3, 0,
- "Set property NAME of OWNER to VALUE, from the defaults database.\n\
-If OWNER is nil, Emacs is assumed.\n\
-If VALUE is nil, the default is removed.")
+ doc: /* Set property NAME of OWNER to VALUE, from the defaults database.
+If OWNER is nil, Emacs is assumed.
+If VALUE is nil, the default is removed. */)
(owner, name, value)
Lisp_Object owner, name, value;
{
DEFUN ("ns-set-alpha", Fns_set_alpha, Sns_set_alpha, 2, 2, 0,
- "Return a color same as given with alpha set to given value\n\
-from 0 to 1, where 1 is fully opaque.")
+ doc: /* Return a color equivalent to COLOR with alpha setting ALPHA.
+The argument ALPHA should be a number between 0 and 1, where 0 is full
+transparency and 1 is opaque. */)
(color, alpha)
Lisp_Object color;
Lisp_Object alpha;
CHECK_NUMBER_OR_FLOAT (alpha);
if (ns_lisp_to_color (color, &col))
- error ("Unknown color.");
+ error ("Unknown color");
a = XFLOATINT (alpha);
if (a < 0.0 || a > 1.0)
- error ("Alpha value should be between 0 and 1 inclusive.");
+ error ("Alpha value should be between 0 and 1 inclusive");
col = [col colorWithAlphaComponent: a];
return ns_color_to_lisp (col);
}
-DEFUN ("ns-server-max-request-size", Fns_server_max_request_size,
- Sns_server_max_request_size,
+DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
+ Sx_server_max_request_size,
0, 1, 0,
- "This function is only present for completeness. It does not return\n\
-a usable result for NS windows.")
+ doc: /* This function is a no-op. It is only present for completeness. */)
(display)
Lisp_Object display;
{
}
-DEFUN ("ns-server-vendor", Fns_server_vendor, Sns_server_vendor, 0, 1, 0,
- "Returns the vendor ID string of the NS server of display DISPLAY.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame or a display name (a string).\n\
-If omitted or nil, that stands for the selected frame's display.")
+DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
+ doc: /* Return the vendor ID string of Nextstep display server DISPLAY.
+DISPLAY should be either a frame or a display name (a string).
+If omitted or nil, the selected frame's display is used. */)
(display)
Lisp_Object display;
{
- check_ns ();
#ifdef NS_IMPL_GNUSTEP
return build_string ("GNU");
#else
}
-DEFUN ("ns-server-version", Fns_server_version, Sns_server_version, 0, 1, 0,
- "Returns the version number of the NS release of display DISPLAY.\n\
-See also the function `ns-server-vendor'.\n\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame or a display name (a string).\n\
-If omitted or nil, that stands for the selected frame's display.")
+DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0,
+ doc: /* Return the version numbers of the server of DISPLAY.
+The value is a list of three integers: the major and minor
+version numbers of the X Protocol in use, and the distributor-specific
+release number. See also the function `x-server-vendor'.
+
+The optional argument DISPLAY specifies which display to ask about.
+DISPLAY should be either a frame or a display name (a string).
+If omitted or nil, that stands for the selected frame's display. */)
(display)
Lisp_Object display;
{
- /* FIXME: return GUI version on GNUSTEP, ?? on OS X */
- return build_string ("1.0");
+ /*NOTE: it is unclear what would best correspond with "protocol";
+ we return 10.3, meaning Panther, since this is roughly the
+ level that GNUstep's APIs correspond to.
+ The last number is where we distinguish between the Apple
+ and GNUstep implementations ("distributor-specific release
+ number") and give int'ized versions of major.minor. */
+ return Fcons (make_number (10),
+ Fcons (make_number (3),
+ Fcons (make_number (ns_appkit_version_int()), Qnil)));
}
-DEFUN ("ns-display-screens", Fns_display_screens, Sns_display_screens, 0, 1, 0,
- "Returns the number of screens on the NS server of display DISPLAY.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame, a display name (a string), or terminal ID.\n\
-If omitted or nil, that stands for the selected frame's display.")
+DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0,
+ doc: /* Return the number of screens on Nextstep display server DISPLAY.
+DISPLAY should be a frame, the display name as a string, or a terminal ID.
+If omitted or nil, the selected frame's display is used. */)
(display)
Lisp_Object display;
{
}
-DEFUN ("ns-display-mm-height", Fns_display_mm_height, Sns_display_mm_height,
+DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height,
0, 1, 0,
- "Returns the height in millimeters of the NS display DISPLAY.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame, a display name (a string), or terminal ID.\n\
-If omitted or nil, that stands for the selected frame's display.")
+ doc: /* Return the height of Nextstep display server DISPLAY, in millimeters.
+DISPLAY should be a frame, the display name as a string, or a terminal ID.
+If omitted or nil, the selected frame's display is used. */)
(display)
Lisp_Object display;
{
}
-DEFUN ("ns-display-mm-width", Fns_display_mm_width, Sns_display_mm_width,
+DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width,
0, 1, 0,
- "Returns the width in millimeters of the NS display DISPLAY.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame, a display name (a string), or terminal ID.\n\
-If omitted or nil, that stands for the selected frame's display.")
+ doc: /* Return the width of Nextstep display server DISPLAY, in millimeters.
+DISPLAY should be a frame, the display name as a string, or a terminal ID.
+If omitted or nil, the selected frame's display is used. */)
(display)
Lisp_Object display;
{
}
-DEFUN ("ns-display-backing-store", Fns_display_backing_store,
- Sns_display_backing_store, 0, 1, 0,
- "Returns an indication of whether NS display DISPLAY does backing store.\n\
-The value may be `buffered', `retained', or `non-retained'.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame, display name (a string), or terminal ID.\n\
-If omitted or nil, that stands for the selected frame's display.\n\
-Under NS, this may differ for each frame.")
+DEFUN ("x-display-backing-store", Fx_display_backing_store,
+ Sx_display_backing_store, 0, 1, 0,
+ doc: /* Return whether the Nexstep display DISPLAY supports backing store.
+The value may be `buffered', `retained', or `non-retained'.
+DISPLAY should be a frame, the display name as a string, or a terminal ID.
+If omitted or nil, the selected frame's display is used. */)
(display)
Lisp_Object display;
{
}
-DEFUN ("ns-display-visual-class", Fns_display_visual_class,
- Sns_display_visual_class, 0, 1, 0,
- "Returns the visual class of the NS display DISPLAY.\n\
-The value is one of the symbols `static-gray', `gray-scale',\n\
-`static-color', `pseudo-color', `true-color', or `direct-color'.\n\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame, a display name (a string), or terminal ID.\n\
-If omitted or nil, that stands for the selected frame's display.")
+DEFUN ("x-display-visual-class", Fx_display_visual_class,
+ Sx_display_visual_class, 0, 1, 0,
+ doc: /* Return the visual class of the Nextstep display server DISPLAY.
+The value is one of the symbols `static-gray', `gray-scale',
+`static-color', `pseudo-color', `true-color', or `direct-color'.
+DISPLAY should be a frame, the display name as a string, or a terminal ID.
+If omitted or nil, the selected frame's display is used. */)
(display)
Lisp_Object display;
{
else if ( depth == NSBestDepth (NSCalibratedRGBColorSpace, 8, 24, NO, NULL))
return intern ("direct-color");
else
- /* color mgmt as far as we do it is really handled by NS itself anyway */
+ /* color mgmt as far as we do it is really handled by Nextstep itself anyway */
return intern ("direct-color");
}
-DEFUN ("ns-display-save-under", Fns_display_save_under,
- Sns_display_save_under, 0, 1, 0,
- "Returns t if the NS display DISPLAY supports the save-under feature.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame, a display name (a string), or terminal ID.\n\
-If omitted or nil, that stands for the selected frame's display.\n\
-Under NS, this may differ for each frame.")
+DEFUN ("x-display-save-under", Fx_display_save_under,
+ Sx_display_save_under, 0, 1, 0,
+ doc: /* Non-nil if the Nextstep display server supports the save-under feature.
+The optional argument DISPLAY specifies which display to ask about.
+DISPLAY should be a frame, the display name as a string, or a terminal ID.
+If omitted or nil, the selected frame's display is used. */)
(display)
Lisp_Object display;
{
}
-DEFUN ("ns-open-connection", Fns_open_connection, Sns_open_connection,
- 1, 3, 0, "Open a connection to a NS server.\n\
-DISPLAY is the name of the display to connect to.\n\
-Optional arguments XRM-STRING and MUST-SUCCEED are currently ignored.")
+DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection,
+ 1, 3, 0,
+ doc: /* Open a connection to a Nextstep display server.
+DISPLAY is the name of the display to connect to.
+Optional arguments XRM-STRING and MUST-SUCCEED are currently ignored. */)
(display, resource_string, must_succeed)
Lisp_Object display, resource_string, must_succeed;
{
}
-DEFUN ("ns-close-connection", Fns_close_connection, Sns_close_connection,
- 1, 1, 0, "Close the connection to the current NS server.\n\
-The second argument DISPLAY is currently ignored, but nil would stand for\n\
-the selected frame's display.")
+DEFUN ("x-close-connection", Fx_close_connection, Sx_close_connection,
+ 1, 1, 0,
+ doc: /* Close the connection to the current Nextstep display server.
+The argument DISPLAY is currently ignored. */)
(display)
Lisp_Object display;
{
}
-DEFUN ("ns-display-list", Fns_display_list, Sns_display_list, 0, 0, 0,
- "Return the list of display names that Emacs has connections to.")
+DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0,
+ doc: /* Return the list of display names that Emacs has connections to. */)
()
{
Lisp_Object tail, result;
DEFUN ("ns-hide-others", Fns_hide_others, Sns_hide_others,
- 0, 0, 0, "Hides all applications other than emacs.")
+ 0, 0, 0,
+ doc: /* Hides all applications other than Emacs. */)
()
{
check_ns ();
}
DEFUN ("ns-hide-emacs", Fns_hide_emacs, Sns_hide_emacs,
- 1, 1, 0, "If ON is non-nil, the entire emacs application is hidden.\n\
-Otherwise if emacs is hidden, it is unhidden.\n\
-If ON is equal to 'activate, emacs is unhidden and becomes\n\
-the active application.")
+ 1, 1, 0,
+ doc: /* If ON is non-nil, the entire Emacs application is hidden.
+Otherwise if Emacs is hidden, it is unhidden.
+If ON is equal to `activate', Emacs is unhidden and becomes
+the active application. */)
(on)
Lisp_Object on;
{
DEFUN ("ns-emacs-info-panel", Fns_emacs_info_panel, Sns_emacs_info_panel,
- 0, 0, 0, "Shows the 'Info' or 'About' panel for Emacs.")
+ 0, 0, 0,
+ doc: /* Shows the 'Info' or 'About' panel for Emacs. */)
()
{
check_ns ();
}
-DEFUN ("x-list-fonts", Fns_list_fonts, Sns_list_fonts, 1, 4, 0,
- doc: /* Return a list of the names of available fonts matching PATTERN.
-If optional arguments FACE and FRAME are specified, return only fonts
-the same size as FACE on FRAME.
-If optional argument MAX is specified, return at most MAX matches.
-
-PATTERN is a regular expression; FACE is a face name - a symbol.
-
-The return value is a list of strings, suitable as arguments to
-set-face-font.
-
-The font names are _NOT_ X names. */)
- (pattern, face, frame, max)
- Lisp_Object pattern, face, frame, max;
-{
- Lisp_Object flist, olist = Qnil, tem;
- struct frame *f;
- int maxnames;
-
- /* We can't simply call check_x_frame because this function may be
- called before any frame is created. */
- if (NILP (frame))
- f = SELECTED_FRAME ();
- else
- {
- CHECK_LIVE_FRAME (frame);
- f = XFRAME (frame);
- }
- if (! FRAME_WINDOW_P (f))
- {
- /* Perhaps we have not yet created any frame. */
- f = NULL;
- }
-
- if (NILP (max))
- maxnames = 4;
- else
- {
- CHECK_NATNUM (max);
- maxnames = XFASTINT (max);
- }
-
- /* get XLFD names */
- flist = ns_list_fonts (f, pattern, 0, maxnames);
-
- /* convert list into regular names */
- for (tem = flist; CONSP (tem); tem = XCDR (tem))
- {
- Lisp_Object fname = XCAR (tem);
- olist = Fcons (build_string (ns_xlfd_to_fontname (SDATA (fname))),
- olist);
- }
-
- return olist;
-}
-
-
DEFUN ("ns-font-name", Fns_font_name, Sns_font_name, 1, 1, 0,
- "Determine font postscript or family name from a font name string or\n\
-XLFD string. If string contains fontset' and not 'fontset-startup' it is\n\
-left alone.")
+ doc: /* Determine font postscript or family name for font NAME.
+NAME should be a string containing either the font name or an XLFD
+font descriptor. If string contains `fontset' and not
+`fontset-startup', it is left alone. */)
(name)
Lisp_Object name;
{
DEFUN ("ns-list-colors", Fns_list_colors, Sns_list_colors, 0, 1, 0,
- "Return a list of all available colors.\n\
-The optional argument FRAME is currently ignored.")
+ doc: /* Return a list of all available colors.
+The optional argument FRAME is currently ignored. */)
(frame)
Lisp_Object frame;
{
{
CHECK_FRAME (frame);
if (! FRAME_NS_P (XFRAME (frame)))
- error ("non-NS frame used in `ns-list-colors'");
+ error ("non-Nextstep frame used in `ns-list-colors'");
}
BLOCK_INPUT;
DEFUN ("ns-list-services", Fns_list_services, Sns_list_services, 0, 0, 0,
- "List NS services by querying NSApp.")
+ doc: /* List available Nextstep services by querying NSApp. */)
()
{
Lisp_Object ret = Qnil;
DEFUN ("ns-perform-service", Fns_perform_service, Sns_perform_service,
- 2, 2, 0, "Perform NS SERVICE on SEND which is either a string or nil.\n\
-Returns result of service as string or nil if no result.")
+ 2, 2, 0,
+ doc: /* Perform Nextstep SERVICE on SEND.
+SEND should be either a string or nil.
+The return value is the result of the service, as string, or nil if
+there was no result. */)
(service, send)
Lisp_Object service, send;
{
DEFUN ("ns-convert-utf8-nfd-to-nfc", Fns_convert_utf8_nfd_to_nfc,
Sns_convert_utf8_nfd_to_nfc, 1, 1, 0,
- "Composes character sequences in UTF-8 normal form NFD string STR to produce a normal (composed normal form NFC) string.")
+ doc: /* Return an NFC string that matches the UTF-8 NFD string STR. */)
(str)
Lisp_Object str;
{
+/* TODO: If GNUstep ever implements precomposedStringWithCanonicalMapping,
+ remove this. */
NSString *utfStr;
CHECK_STRING (str);
- utfStr = [[NSString stringWithUTF8String: SDATA (str)]
- precomposedStringWithCanonicalMapping];
+ utfStr = [NSString stringWithUTF8String: SDATA (str)];
+ if (![utfStr respondsToSelector:
+ @selector (precomposedStringWithCanonicalMapping)])
+ {
+ message1
+ ("Warning: ns-convert-utf8-nfd-to-nfc unsupported under GNUstep.\n");
+ return Qnil;
+ }
+ else
+ utfStr = [utfStr precomposedStringWithCanonicalMapping];
return build_string ([utfStr UTF8String]);
}
+#ifdef NS_IMPL_COCOA
+
+/* Compile and execute the AppleScript SCRIPT and return the error
+ status as function value. A zero is returned if compilation and
+ execution is successful, in which case *RESULT is set to a Lisp
+ string or a number containing the resulting script value. Otherwise,
+ 1 is returned. */
+static int
+ns_do_applescript (script, result)
+ Lisp_Object script, *result;
+{
+ NSAppleEventDescriptor *desc;
+ NSDictionary* errorDict;
+ NSAppleEventDescriptor* returnDescriptor = NULL;
+
+ NSAppleScript* scriptObject =
+ [[NSAppleScript alloc] initWithSource:
+ [NSString stringWithUTF8String: SDATA (script)]];
+
+ returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
+ [scriptObject release];
+
+ *result = Qnil;
+
+ if (returnDescriptor != NULL)
+ {
+ // successful execution
+ if (kAENullEvent != [returnDescriptor descriptorType])
+ {
+ *result = Qt;
+ // script returned an AppleScript result
+ if ((typeUnicodeText == [returnDescriptor descriptorType]) ||
+#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
+ (typeUTF16ExternalRepresentation
+ == [returnDescriptor descriptorType]) ||
+#endif
+ (typeUTF8Text == [returnDescriptor descriptorType]) ||
+ (typeCString == [returnDescriptor descriptorType]))
+ {
+ desc = [returnDescriptor coerceToDescriptorType: typeUTF8Text];
+ if (desc)
+ *result = build_string([[desc stringValue] UTF8String]);
+ }
+ else
+ {
+ /* use typeUTF16ExternalRepresentation? */
+ // coerce the result to the appropriate ObjC type
+ desc = [returnDescriptor coerceToDescriptorType: typeUTF8Text];
+ if (desc)
+ *result = make_number([desc int32Value]);
+ }
+ }
+ }
+ else
+ {
+ // no script result, return error
+ return 1;
+ }
+ return 0;
+}
+
+DEFUN ("ns-do-applescript", Fns_do_applescript, Sns_do_applescript, 1, 1, 0,
+ doc: /* Execute AppleScript SCRIPT and return the result.
+If compilation and execution are successful, the resulting script value
+is returned as a string, a number or, in the case of other constructs, t.
+In case the execution fails, an error is signaled. */)
+ (script)
+ Lisp_Object script;
+{
+ Lisp_Object result;
+ long status;
+
+ CHECK_STRING (script);
+ check_ns ();
+
+ BLOCK_INPUT;
+ status = ns_do_applescript (script, &result);
+ UNBLOCK_INPUT;
+ if (status == 0)
+ return result;
+ else if (!STRINGP (result))
+ error ("AppleScript error %d", status);
+ else
+ error ("%s", SDATA (result));
+}
+#endif
+
+
+
/* ==========================================================================
Miscellaneous functions not called through hooks
========================================================================== */
-/* 23: call in image.c */
+/* called from image.c */
FRAME_PTR
check_x_frame (Lisp_Object frame)
{
return check_ns_frame (frame);
}
-/* 23: added, due to call in frame.c */
+
+/* called from frame.c */
struct ns_display_info *
check_x_display_info (Lisp_Object frame)
{
}
-/* 23: new function; we don't have much in the way of flexibility though */
void
x_set_scroll_bar_default_width (f)
struct frame *f;
}
-/* 23: terms now impl this instead of x-get-resource directly */
+/* terms impl this instead of x-get-resource directly */
const char *
x_get_string_resource (XrmDatabase rdb, char *name, char *class)
{
toCheck = name + (!strncmp (name, "emacs.", 6) ? 6 : 0);
/*fprintf (stderr, "Checking '%s'\n", toCheck); */
-
- res = [[[NSUserDefaults standardUserDefaults] objectForKey:
- [NSString stringWithUTF8String: toCheck]] UTF8String];
+
+ res = ns_no_defaults ? NULL :
+ [[[NSUserDefaults standardUserDefaults] objectForKey:
+ [NSString stringWithUTF8String: toCheck]] UTF8String];
return !res ? NULL :
(!strncasecmp (res, "YES", 3) ? "true" :
(!strncasecmp (res, "NO", 2) ? "false" : res));
struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (frame);
Lisp_Object nsfocus;
- if (!dpyinfo->ns_focus_frame)
+ if (!dpyinfo->x_focus_frame)
return Qnil;
- XSETFRAME (nsfocus, dpyinfo->ns_focus_frame);
+ XSETFRAME (nsfocus, dpyinfo->x_focus_frame);
return nsfocus;
}
========================================================================== */
-DEFUN ("xw-color-defined-p", Fns_color_defined_p, Sns_color_defined_p, 1, 2, 0,
- "Return t if the current NS display supports the color named COLOR.\n\
-The optional argument FRAME is currently ignored.")
+DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
+ doc: /* Return t if the current Nextstep display supports the color COLOR.
+The optional argument FRAME is currently ignored. */)
(color, frame)
Lisp_Object color, frame;
{
}
-DEFUN ("xw-color-values", Fns_color_values, Sns_color_values, 1, 2, 0,
- "Return a description of the color named COLOR.\n\
-The value is a list of integer RGBA values--(RED GREEN BLUE ALPHA).\n\
-These values appear to range from 0 to 65280; white is (65280 65280 65280 0).\n\
-The optional argument FRAME is currently ignored.")
+DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
+ doc: /* Return a description of the color named COLOR.
+The value is a list of integer RGBA values--(RED GREEN BLUE ALPHA).
+These values appear to range from 0 to 65280; white is (65280 65280 65280 0).
+The optional argument FRAME is currently ignored. */)
(color, frame)
Lisp_Object color, frame;
{
DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
- "Return t if the NS display supports color.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame, a display name (a string), or terminal ID.\n\
-If omitted or nil, that stands for the selected frame's display.")
+ doc: /* Return t if the Nextstep display supports color.
+The optional argument DISPLAY specifies which display to ask about.
+DISPLAY should be either a frame, a display name (a string), or terminal ID.
+If omitted or nil, that stands for the selected frame's display. */)
(display)
Lisp_Object display;
{
DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p,
Sx_display_grayscale_p, 0, 1, 0,
- "Return t if the NS display supports shades of gray.\n\
-Note that color displays do support shades of gray.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame, a display name (a string), or terminal ID.\n\
-If omitted or nil, that stands for the selected frame's display.")
+ doc: /* Return t if the Nextstep display supports shades of gray.
+Note that color displays do support shades of gray.
+The optional argument DISPLAY specifies which display to ask about.
+DISPLAY should be either a frame, a display name (a string), or terminal ID.
+If omitted or nil, that stands for the selected frame's display. */)
(display)
Lisp_Object display;
{
}
-DEFUN ("x-display-pixel-width", Fns_display_pixel_width, Sns_display_pixel_width,
+DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width,
0, 1, 0,
- "Returns the width in pixels of the NS display DISPLAY.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame, a display name (a string), or terminal ID.\n\
-If omitted or nil, that stands for the selected frame's display.")
+ doc: /* Return the width in pixels of the Nextstep display DISPLAY.
+The optional argument DISPLAY specifies which display to ask about.
+DISPLAY should be either a frame, a display name (a string), or terminal ID.
+If omitted or nil, that stands for the selected frame's display. */)
(display)
Lisp_Object display;
{
}
-DEFUN ("x-display-pixel-height", Fns_display_pixel_height,
- Sns_display_pixel_height, 0, 1, 0,
- "Returns the height in pixels of the NS display DISPLAY.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame, a display name (a string), or terminal ID.\n\
-If omitted or nil, that stands for the selected frame's display.")
+DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
+ Sx_display_pixel_height, 0, 1, 0,
+ doc: /* Return the height in pixels of the Nextstep display DISPLAY.
+The optional argument DISPLAY specifies which display to ask about.
+DISPLAY should be either a frame, a display name (a string), or terminal ID.
+If omitted or nil, that stands for the selected frame's display. */)
(display)
Lisp_Object display;
{
return make_number ((int) [ns_get_screen (display) frame].size.height);
}
+
DEFUN ("display-usable-bounds", Fns_display_usable_bounds,
Sns_display_usable_bounds, 0, 1, 0,
- "Returns a list of integers in form (left top width height) describing the \
-usable screen area excluding reserved areas such as the Mac menu and doc, or \
-the Windows task bar.\n \
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame, a display name (a string), or terminal ID.\n\
-If omitted or nil, that stands for the selected frame's display.")
+ doc: /* Return the bounds of the usable part of the screen.
+The return value is a list of integers (LEFT TOP WIDTH HEIGHT), which
+are the boundaries of the usable part of the screen, excluding areas
+reserved for the Mac menu, dock, and so forth.
+
+The screen queried corresponds to DISPLAY, which should be either a
+frame, a display name (a string), or terminal ID. If omitted or nil,
+that stands for the selected frame's display. */)
(display)
Lisp_Object display;
{
}
-DEFUN ("x-display-planes", Fx_display_planes, Sns_display_planes,
+DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes,
0, 1, 0,
- "Returns the number of bitplanes of the NS display DISPLAY.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame, a display name (a string), or terminal ID.\n\
-If omitted or nil, that stands for the selected frame's display.")
+ doc: /* Return the number of bitplanes of the Nextstep display DISPLAY.
+The optional argument DISPLAY specifies which display to ask about.
+DISPLAY should be either a frame, a display name (a string), or terminal ID.
+If omitted or nil, that stands for the selected frame's display. */)
(display)
Lisp_Object display;
{
check_ns ();
return make_number
- (NSBitsPerSampleFromDepth ([ns_get_screen (display) depth]));
+ (NSBitsPerPixelFromDepth ([ns_get_screen (display) depth]));
}
-DEFUN ("x-display-color-cells", Fns_display_color_cells,
- Sns_display_color_cells, 0, 1, 0,
- "Returns the number of color cells of the NS display DISPLAY.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame, a display name (a string), or terminal ID.\n\
-If omitted or nil, that stands for the selected frame's display.")
+DEFUN ("x-display-color-cells", Fx_display_color_cells,
+ Sx_display_color_cells, 0, 1, 0,
+ doc: /* Returns the number of color cells of the Nextstep display DISPLAY.
+The optional argument DISPLAY specifies which display to ask about.
+DISPLAY should be either a frame, a display name (a string), or terminal ID.
+If omitted or nil, that stands for the selected frame's display. */)
(display)
Lisp_Object display;
{
Lisp_Object left, top;
EmacsView *view = FRAME_NS_VIEW (f);
NSPoint pt;
-
+
/* Start with user-specified or mouse position. */
left = Fcdr (Fassq (Qleft, parms));
if (INTEGERP (left))
/* Ensure in bounds. (Note, screen origin = lower left.) */
if (pt.x + XINT (dx) <= 0)
*root_x = 0; /* Can happen for negative dx */
- else if (pt.x + XINT (dx) + width <= FRAME_NS_DISPLAY_INFO (f)->width)
+ else if (pt.x + XINT (dx) + width
+ <= x_display_pixel_width (FRAME_NS_DISPLAY_INFO (f)))
/* It fits to the right of the pointer. */
*root_x = pt.x + XINT (dx);
else if (width + XINT (dx) <= pt.x)
if (pt.y - XINT (dy) - height >= 0)
/* It fits below the pointer. */
*root_y = pt.y - height - XINT (dy);
- else if (pt.y + XINT (dy) + height <= FRAME_NS_DISPLAY_INFO (f)->height)
+ else if (pt.y + XINT (dy) + height
+ <= x_display_pixel_height (FRAME_NS_DISPLAY_INFO (f)))
/* It fits above the pointer */
*root_y = pt.y + XINT (dy);
else
/* Put it on the top. */
- *root_y = FRAME_NS_DISPLAY_INFO (f)->height - height;
+ *root_y = x_display_pixel_height (FRAME_NS_DISPLAY_INFO (f)) - height;
}
DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
- doc: /* Show STRING in a "tooltip" window on frame FRAME.
+ doc: /* Show STRING in a \"tooltip\" window on frame FRAME.
A tooltip window is a small window displaying a string.
FRAME nil or omitted means use the selected frame.
}
-/* ==========================================================================
-
- Lisp interface declaration
-
- ========================================================================== */
-
-
-void
-syms_of_nsfns ()
-{
- int i;
-
- Qns_frame_parameter = intern ("ns-frame-parameter");
- staticpro (&Qns_frame_parameter);
- Qnone = intern ("none");
- staticpro (&Qnone);
- Qbuffered = intern ("bufferd");
- staticpro (&Qbuffered);
- Qfontsize = intern ("fontsize");
- staticpro (&Qfontsize);
-
- DEFVAR_LISP ("ns-icon-type-alist", &Vns_icon_type_alist,
- "Alist of elements (REGEXP . IMAGE) for images of icons associated to\n\
-frames. If the title of a frame matches REGEXP, then IMAGE.tiff is\n\
-selected as the image of the icon representing the frame when it's\n\
-miniaturized. If an element is t, then Emacs tries to select an icon\n\
-based on the filetype of the visited file.\n\
-\n\
-The images have to be installed in a folder called English.lproj in the\n\
-Emacs.app folder. You have to restart Emacs after installing new icons.\n\
-\n\
-Example: Install an icon Gnus.tiff and execute the following code\n\
-\n\
- (setq ns-icon-type-alist\n\
- (append ns-icon-type-alist\n\
- '((\"^\\\\*\\\\(Group\\\\*$\\\\|Summary \\\\|Article\\\\*$\\\\)\"\n\
- . \"Gnus\"))))\n\
-\n\
-When you miniaturize a Group, Summary or Article frame, Gnus.tiff will\n\
-be used as the image of the icon representing the frame.");
- Vns_icon_type_alist = Fcons (Qt, Qnil);
-
- defsubr (&Sns_read_file_name);
- defsubr (&Sns_get_resource);
- defsubr (&Sns_set_resource);
- defsubr (&Sxw_display_color_p); /* this and next called directly by C code */
- defsubr (&Sx_display_grayscale_p);
- defsubr (&Sns_list_fonts);
- defsubr (&Sns_font_name);
- defsubr (&Sns_list_colors);
- defsubr (&Sns_color_defined_p);
- defsubr (&Sns_color_values);
- defsubr (&Sns_server_max_request_size);
- defsubr (&Sns_server_vendor);
- defsubr (&Sns_server_version);
- defsubr (&Sns_display_pixel_width);
- defsubr (&Sns_display_pixel_height);
- defsubr (&Sns_display_usable_bounds);
- defsubr (&Sns_display_mm_width);
- defsubr (&Sns_display_mm_height);
- defsubr (&Sns_display_screens);
- defsubr (&Sns_display_planes);
- defsubr (&Sns_display_color_cells);
- defsubr (&Sns_display_visual_class);
- defsubr (&Sns_display_backing_store);
- defsubr (&Sns_display_save_under);
- defsubr (&Sns_create_frame);
- defsubr (&Sns_set_alpha);
- defsubr (&Sns_open_connection);
- defsubr (&Sns_close_connection);
- defsubr (&Sns_display_list);
-
- defsubr (&Sns_hide_others);
- defsubr (&Sns_hide_emacs);
- defsubr (&Sns_emacs_info_panel);
- defsubr (&Sns_list_services);
- defsubr (&Sns_perform_service);
- defsubr (&Sns_convert_utf8_nfd_to_nfc);
- defsubr (&Sns_focus_frame);
- defsubr (&Sns_popup_prefs_panel);
- defsubr (&Sns_popup_font_panel);
- defsubr (&Sns_popup_color_panel);
-
- defsubr (&Sx_show_tip);
- defsubr (&Sx_hide_tip);
-
- /* used only in fontset.c */
- check_window_system_func = check_ns;
-
-}
-
-
-
/* ==========================================================================
Class implementations
#endif
+
+/* ==========================================================================
+
+ Lisp interface declaration
+
+ ========================================================================== */
+
+
+void
+syms_of_nsfns ()
+{
+ int i;
+
+ Qnone = intern ("none");
+ staticpro (&Qnone);
+ Qfontsize = intern ("fontsize");
+ staticpro (&Qfontsize);
+
+ DEFVAR_LISP ("ns-icon-type-alist", &Vns_icon_type_alist,
+ doc: /* Alist of elements (REGEXP . IMAGE) for images of icons associated to frames.
+If the title of a frame matches REGEXP, then IMAGE.tiff is
+selected as the image of the icon representing the frame when it's
+miniaturized. If an element is t, then Emacs tries to select an icon
+based on the filetype of the visited file.
+
+The images have to be installed in a folder called English.lproj in the
+Emacs folder. You have to restart Emacs after installing new icons.
+
+Example: Install an icon Gnus.tiff and execute the following code
+
+ (setq ns-icon-type-alist
+ (append ns-icon-type-alist
+ '((\"^\\\\*\\\\(Group\\\\*$\\\\|Summary \\\\|Article\\\\*$\\\\)\"
+ . \"Gnus\"))))
+
+When you miniaturize a Group, Summary or Article frame, Gnus.tiff will
+be used as the image of the icon representing the frame. */);
+ Vns_icon_type_alist = Fcons (Qt, Qnil);
+
+ DEFVAR_LISP ("ns-version-string", &Vns_version_string,
+ doc: /* Toolkit version for NS Windowing. */);
+ Vns_version_string = ns_appkit_version_str ();
+
+ defsubr (&Sns_read_file_name);
+ defsubr (&Sns_get_resource);
+ defsubr (&Sns_set_resource);
+ defsubr (&Sxw_display_color_p); /* this and next called directly by C code */
+ defsubr (&Sx_display_grayscale_p);
+ defsubr (&Sns_font_name);
+ defsubr (&Sns_list_colors);
+#ifdef NS_IMPL_COCOA
+ defsubr (&Sns_do_applescript);
+#endif
+ defsubr (&Sxw_color_defined_p);
+ defsubr (&Sxw_color_values);
+ defsubr (&Sx_server_max_request_size);
+ defsubr (&Sx_server_vendor);
+ defsubr (&Sx_server_version);
+ defsubr (&Sx_display_pixel_width);
+ defsubr (&Sx_display_pixel_height);
+ defsubr (&Sns_display_usable_bounds);
+ defsubr (&Sx_display_mm_width);
+ defsubr (&Sx_display_mm_height);
+ defsubr (&Sx_display_screens);
+ defsubr (&Sx_display_planes);
+ defsubr (&Sx_display_color_cells);
+ defsubr (&Sx_display_visual_class);
+ defsubr (&Sx_display_backing_store);
+ defsubr (&Sx_display_save_under);
+ defsubr (&Sx_create_frame);
+ defsubr (&Sns_set_alpha);
+ defsubr (&Sx_open_connection);
+ defsubr (&Sx_close_connection);
+ defsubr (&Sx_display_list);
+
+ defsubr (&Sns_hide_others);
+ defsubr (&Sns_hide_emacs);
+ defsubr (&Sns_emacs_info_panel);
+ defsubr (&Sns_list_services);
+ defsubr (&Sns_perform_service);
+ defsubr (&Sns_convert_utf8_nfd_to_nfc);
+ defsubr (&Sx_focus_frame);
+ defsubr (&Sns_popup_font_panel);
+ defsubr (&Sns_popup_color_panel);
+
+ defsubr (&Sx_show_tip);
+ defsubr (&Sx_hide_tip);
+
+ /* used only in fontset.c */
+ check_window_system_func = check_ns;
+
+}
+
// arch-tag: dc2a3f74-1123-4daa-8eed-fb78db6a5642