/* NeXT/Open/GNUstep / MacOSX communication module.
- Copyright (C) 1989, 1993, 1994, 2005, 2006, 2008, 2009
+ Copyright (C) 1989, 1993, 1994, 2005, 2006, 2008, 2009, 2010
Free Software Foundation, Inc.
This file is part of GNU Emacs.
/* This should be the first include, as it may set up #defines affecting
interpretation of even the system includes. */
-#include "config.h"
+#include <config.h>
#include <math.h>
#include <sys/types.h>
#include <time.h>
#include <signal.h>
#include <unistd.h>
+#include <setjmp.h>
#include "lisp.h"
#include "blockinput.h"
Lisp_Object ns_input_spi_name, ns_input_spi_arg;
Lisp_Object Vx_toolkit_scroll_bars;
static Lisp_Object Qmodifier_value;
-/* TODO: unsure why these defined in term files, anyway we need in keymap.c */
-Lisp_Object Qalt, Qcontrol, Qhyper, Qmeta, Qsuper;
+Lisp_Object Qalt, Qcontrol, Qhyper, Qmeta, Qsuper, Qnone;
extern Lisp_Object Qcursor_color, Qcursor_type, Qns;
/* Specifies which emacs modifier should be generated when NS receives
Lisp_Object ns_confirm_quit;
NSArray *ns_send_types =0, *ns_return_types =0, *ns_drag_types =0;
+NSString *ns_app_name = @"Emacs"; /* default changed later */
/* Display variables */
struct ns_display_info *x_display_list; /* Chain of existing displays */
/* NOTE: previously this would generate wrong result if toolbar not
yet displayed and fixing toolbar_height=32 helped, but
now (200903) seems no longer needed */
- FRAME_NS_TOOLBAR_HEIGHT (f) =
+ FRAME_TOOLBAR_HEIGHT (f) =
NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)])
- FRAME_NS_TITLEBAR_HEIGHT (f);
else
- FRAME_NS_TOOLBAR_HEIGHT (f) = 0;
+ FRAME_TOOLBAR_HEIGHT (f) = 0;
wr.size.width = pixelwidth + f->border_width;
wr.size.height = pixelheight + FRAME_NS_TITLEBAR_HEIGHT (f)
- + FRAME_NS_TOOLBAR_HEIGHT (f);
+ + FRAME_TOOLBAR_HEIGHT (f);
/* constrain to screen if we can */
if (screen)
}
else if (!strncmp(name, "rgb:", 4)) /* A newer X11 format -- rgb:r/g/b */
{
- strcpy(hex, name + 4);
+ strncpy (hex, name + 4, 19);
+ hex[19] = '\0';
scaling = (strlen(hex) - 2) / 3;
}
else if (name[0] == '#') /* An old X11 format; convert to newer */
Convert a color to a lisp string with the RGB equivalent
-------------------------------------------------------------------------- */
{
- float red, green, blue, alpha, gray;
+ CGFloat red, green, blue, alpha, gray;
char buf[1024];
const char *str;
NSTRACE (ns_color_to_lisp);
{
[[col colorUsingColorSpaceName: NSCalibratedWhiteColorSpace]
getWhite: &gray alpha: &alpha];
- snprintf (buf, sizeof (buf), "#%02.2lx%02.2lx%02.2lx",
+ snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx",
lrint (gray * 0xff), lrint (gray * 0xff), lrint (gray * 0xff));
UNBLOCK_INPUT;
return build_string (buf);
}
- snprintf (buf, sizeof (buf), "#%02.2lx%02.2lx%02.2lx",
+ snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx",
lrint (red*0xff), lrint (green*0xff), lrint (blue*0xff));
UNBLOCK_INPUT;
and set color_def pixel to the resulting index.
-------------------------------------------------------------------------- */
{
- float r, g, b, a;
+ CGFloat r, g, b, a;
[((NSColor *)col) getRed: &r green: &g blue: &b alpha: &a];
color_def->red = r * 65535;
Return 0 if not found
-------------------------------------------------------------------------- */
{
- NSColor *temp;
- int notFound = ns_get_color (name, &temp);
-
+ NSColor *col;
NSTRACE (ns_defined_color);
- if (notFound)
- return 0;
-
+ BLOCK_INPUT;
+ if (ns_get_color (name, &col) != 0) /* Color not found */
+ {
+ UNBLOCK_INPUT;
+ return 0;
+ }
if (makeIndex && alloc)
- color_def->pixel = ns_index_color(temp, f); /* [temp retain]; */
-
- ns_query_color (temp, color_def, !makeIndex);
-
+ color_def->pixel = ns_index_color (col, f);
+ ns_query_color (col, color_def, !makeIndex);
+ UNBLOCK_INPUT;
return 1;
}
{
EmacsImage **newBimgs
= xmalloc (max_used_fringe_bitmap * sizeof (EmacsImage *));
- bzero (newBimgs, max_used_fringe_bitmap * sizeof (EmacsImage *));
+ memset (newBimgs, 0, max_used_fringe_bitmap * sizeof (EmacsImage *));
if (nBimgs)
{
- bcopy (bimgs, newBimgs, nBimgs * sizeof (EmacsImage *));
+ memcpy (newBimgs, bimgs, nBimgs * sizeof (EmacsImage *));
xfree (bimgs);
}
/* Must clip because of partially visible lines. */
rowY = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
- if (p->y < rowY)
- {
- /* Adjust position of "bottom aligned" bitmap on partially
- visible last row. */
- int oldY = row->y;
- int oldVH = row->visible_height;
- row->visible_height = p->h;
- row->y -= rowY - p->y;
- ns_clip_to_row (w, row, -1, NO);
- row->y = oldY;
- row->visible_height = oldVH;
- }
- else
- ns_clip_to_row (w, row, -1, YES);
+ ns_clip_to_row (w, row, -1, YES);
if (p->bx >= 0 && !p->overlay_p)
{
}
-static void
-ns_set_default_prefs ()
-/* --------------------------------------------------------------------------
- Initialize preference variables to defaults
- -------------------------------------------------------------------------- */
-{
- ns_alternate_modifier = Qmeta;
- ns_command_modifier = Qsuper;
- ns_control_modifier = Qcontrol;
- ns_function_modifier = Qnone;
- ns_antialias_text = Qt;
- ns_antialias_threshold = 10.0; /* not exposed to lisp side */
- ns_confirm_quit = Qnil;
-}
-
-
static void
ns_default (const char *parameter, Lisp_Object *result,
Lisp_Object yesval, Lisp_Object noval,
name: nil object: nil]; */
dpyinfo = (struct ns_display_info *)xmalloc (sizeof (struct ns_display_info));
- bzero (dpyinfo, sizeof (struct ns_display_info));
+ memset (dpyinfo, 0, sizeof (struct ns_display_info));
ns_initialize_display_info (dpyinfo);
terminal = ns_create_terminal (dpyinfo);
UNBLOCK_INPUT;
- /* Read various user defaults. */
- ns_set_default_prefs ();
if (!inhibit_x_resources)
{
ns_default ("GSFontAntiAlias", &ns_antialias_text,
delete_keyboard_wait_descriptor (0);
+ ns_app_name = [[NSProcessInfo processInfo] processName];
+
/* Set up OS X app menu */
#ifdef NS_IMPL_COCOA
{
keyEquivalent: @""
atIndex: 4];
[appMenu setSubmenu: svcsMenu forItem: item];
-/* [svcsMenu setSupercell: item]; */
[appMenu insertItem: [NSMenuItem separatorItem] atIndex: 5];
[appMenu insertItemWithTitle: @"Hide Emacs"
action: @selector (hide:)
keyEquivalent: @"q"
atIndex: 9];
- item = [mainMenu insertItemWithTitle: @"Emacs"
+ item = [mainMenu insertItemWithTitle: ns_app_name
action: @selector (menuDown:)
keyEquivalent: @""
atIndex: 0];
if (NILP (ns_confirm_quit)) // || ns_shutdown_properly --> TO DO
return NSTerminateNow;
- ret = NSRunAlertPanel([[NSProcessInfo processInfo] processName],
+ ret = NSRunAlertPanel(ns_app_name,
[NSString stringWithUTF8String:"Exit requested. Would you like to Save Buffers and Exit, or Cancel the request?"],
@"Save Buffers and Exit", @"Cancel", nil);
ns_send_appdefined (-2);
}
-extern void update_window_cursor (struct window *w, int on);
-
- (void)fd_handler: (NSTimer *) fdEntry
/* --------------------------------------------------------------------------
Check data waiting on file descriptors and terminate if so
}
-- (NSInteger)conversationIdentifier
+- (long)conversationIdentifier
{
- return (NSInteger)self;
+ return (long)self;
}
return NSMakeRange (NSNotFound, 0);
}
-- (unsigned int)characterIndexForPoint: (NSPoint)thePoint
+- (NSUInteger)characterIndexForPoint: (NSPoint)thePoint
{
if (NS_KEYLOG)
NSLog (@"characterIndexForPoint request");
rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (emacsframe, frameSize.height
#ifdef NS_IMPL_GNUSTEP
- FRAME_NS_TITLEBAR_HEIGHT (emacsframe) + 3
- - FRAME_NS_TOOLBAR_HEIGHT (emacsframe));
+ - FRAME_TOOLBAR_HEIGHT (emacsframe));
#else
- FRAME_NS_TITLEBAR_HEIGHT (emacsframe)
- - FRAME_NS_TOOLBAR_HEIGHT (emacsframe));
+ - FRAME_TOOLBAR_HEIGHT (emacsframe));
#endif
if (rows < MINHEIGHT)
rows = MINHEIGHT;
frameSize.height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (emacsframe, rows)
+ FRAME_NS_TITLEBAR_HEIGHT (emacsframe)
- + FRAME_NS_TOOLBAR_HEIGHT (emacsframe);
+ + FRAME_TOOLBAR_HEIGHT (emacsframe);
#ifdef NS_IMPL_COCOA
{
/* this sets window title to have size in it; the wm does this under GS */
[toggleButton setTarget: self];
[toggleButton setAction: @selector (toggleToolbar: )];
#endif
- FRAME_NS_TOOLBAR_HEIGHT (f) = 0;
+ FRAME_TOOLBAR_HEIGHT (f) = 0;
tem = f->icon_name;
if (!NILP (tem))
/* NSDraggingDestination protocol methods. Actually this is not really a
protocol, but a category of Object. O well... */
--(unsigned int) draggingEntered: (id <NSDraggingInfo>) sender
+-(NSUInteger) draggingEntered: (id <NSDraggingInfo>) sender
{
NSTRACE (draggingEntered);
return NSDragOperationGeneric;
#define SCROLL_BAR_FIRST_DELAY 0.5
#define SCROLL_BAR_CONTINUOUS_DELAY (1.0 / 15)
-+ (float) scrollerWidth
++ (CGFloat) scrollerWidth
{
/* TODO: if we want to allow variable widths, this is the place to do it,
however neither GNUstep nor Cocoa support it very well */
case NSScrollerKnobSlot: /* GNUstep-only */
last_hit_part = scroll_bar_move_ratio; break;
default: /* NSScrollerNoPart? */
- fprintf (stderr, "EmacsScoller-mouseDown: unexpected part %d\n", part);
+ fprintf (stderr, "EmacsScoller-mouseDown: unexpected part %ld\n",
+ (long) part);
return;
}
syms_of_nsterm ()
{
NSTRACE (syms_of_nsterm);
+
+ ns_antialias_threshold = 10.0;
+
+ /* from 23+ we need to tell emacs what modifiers there are.. */
+ DEFSYM (Qmodifier_value, "modifier-value");
+ DEFSYM (Qalt, "alt");
+ DEFSYM (Qhyper, "hyper");
+ DEFSYM (Qmeta, "meta");
+ DEFSYM (Qsuper, "super");
+ DEFSYM (Qcontrol, "control");
+ DEFSYM (Qnone, "none");
+ Fput (Qalt, Qmodifier_value, make_number (alt_modifier));
+ Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier));
+ Fput (Qmeta, Qmodifier_value, make_number (meta_modifier));
+ Fput (Qsuper, Qmodifier_value, make_number (super_modifier));
+ Fput (Qcontrol, Qmodifier_value, make_number (ctrl_modifier));
+
DEFVAR_LISP ("ns-input-file", &ns_input_file,
"The file specified in the last NS event.");
ns_input_file =Qnil;
Set to control, meta, alt, super, or hyper means it is taken to be that key.\n\
Set to none means that the alternate / option key is not interpreted by Emacs\n\
at all, allowing it to be used at a lower level for accented character entry.");
+ ns_alternate_modifier = Qmeta;
DEFVAR_LISP ("ns-command-modifier", &ns_command_modifier,
"This variable describes the behavior of the command key.\n\
Set to control, meta, alt, super, or hyper means it is taken to be that key.");
+ ns_command_modifier = Qsuper;
DEFVAR_LISP ("ns-control-modifier", &ns_control_modifier,
"This variable describes the behavior of the control key.\n\
Set to control, meta, alt, super, or hyper means it is taken to be that key.");
+ ns_control_modifier = Qcontrol;
DEFVAR_LISP ("ns-function-modifier", &ns_function_modifier,
"This variable describes the behavior of the function key (on laptops).\n\
Set to control, meta, alt, super, or hyper means it is taken to be that key.\n\
Set to none means that the function key is not interpreted by Emacs at all,\n\
allowing it to be used at a lower level for accented character entry.");
+ ns_function_modifier = Qnone;
DEFVAR_LISP ("ns-antialias-text", &ns_antialias_text,
"Non-nil (the default) means to render text antialiased. Only has an effect on OS X Panther and above.");
+ ns_antialias_text = Qt;
DEFVAR_LISP ("ns-confirm-quit", &ns_confirm_quit,
"Whether to confirm application quit using dialog.");
+ ns_confirm_quit = Qnil;
staticpro (&ns_display_name_list);
ns_display_name_list = Qnil;
staticpro (&last_mouse_motion_frame);
last_mouse_motion_frame = Qnil;
- /* from 23+ we need to tell emacs what modifiers there are.. */
- Qmodifier_value = intern ("modifier-value");
- Qalt = intern ("alt");
- Fput (Qalt, Qmodifier_value, make_number (alt_modifier));
- Qhyper = intern ("hyper");
- Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier));
- Qmeta = intern ("meta");
- Fput (Qmeta, Qmodifier_value, make_number (meta_modifier));
- Qsuper = intern ("super");
- Fput (Qsuper, Qmodifier_value, make_number (super_modifier));
- Qcontrol = intern ("control");
- Fput (Qcontrol, Qmodifier_value, make_number (ctrl_modifier));
-
/* TODO: move to common code */
DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
doc: /* If not nil, Emacs uses toolkit scroll bars. */);