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 */
struct nsfont_info *ns_tmp_font; /* FIXME */
/*static int debug_lock = 0; */
-#ifdef NS_IMPL_COCOA
-/* This undocumented Quartz function controls how fonts are anti-aliased.
- (Found from code in Mac wxWindows impl, discovered by running `nm' on
- the "QD" framework.)
- Mode 0 is normal anti-aliasing, mode 1 is no anti-aliasing, and mode 2 is
- 4-bit pixel-aligned anti-aliasing (the old QuickDraw standard). */
-extern void CGContextSetFontRenderingMode (CGContextRef cg, int v);
-#endif
-
-
/* event loop */
static BOOL send_appdefined = YES;
static NSEvent *last_appdefined_event = 0;
[e buttonNumber] - 1)
/* Convert the time field to a timestamp in milliseconds. */
-#ifdef NS_IMPL_GNUSTEP
-/* Apple says timestamp is in seconds, but GNUstep seems to be returning msec */
-#define EV_TIMESTAMP(e) ([e timestamp])
-#else
#define EV_TIMESTAMP(e) ([e timestamp] * 1000)
-#endif /* not gnustep */
/* This is a piece of code which is common to all the event handling
methods. Maybe it should even be a function. */
}
if ([resourcePaths length] > 0)
setenv ("EMACSLOADPATH", [resourcePaths UTF8String], 1);
-/*NSLog (@"loadPath: '%s'\n", resourcePaths); */
+/*NSLog (@"loadPath: '%@'\n", resourcePaths); */
}
if (!getenv ("EMACSPATH"))
NSTRACE (ns_reset_terminal_modes);
}
+
static void
ns_set_terminal_modes (struct terminal *terminal)
/* Externally called as hook */
/* If we have a toolbar, take its height into account. */
if (tb)
+ /* 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) =
- /* XXX: GNUstep has not yet implemented the first method below, added
- in Panther, however the second is incorrect under Cocoa. */
-#ifdef NS_IMPL_COCOA
NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)])
- /* 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 */
-#else
- NSHeight ([NSWindow frameRectForContentRect: NSMakeRect (0, 0, 0, 0)
- styleMask: [window styleMask]])
-#endif
- - FRAME_NS_TITLEBAR_HEIGHT (f);
+ - FRAME_NS_TITLEBAR_HEIGHT (f);
else
FRAME_NS_TOOLBAR_HEIGHT (f) = 0;
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;
If we're being called outside of that, it's also OK to return quickly
after one iteration through the event loop, since other terms do
this and emacs expects it. */
- if (!(inNsSelect && expected)) // (!inNsSelect || !expected)
+ if (!(inNsSelect && expected))
{
/* Post an application defined event on the event queue. When this is
received the [NXApp run] will return, thus having processed all
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);
while ((file = [files nextObject]) != nil)
[ns_pending_files addObject: file];
-/* TODO: when GNUstep implements this (and we require that version of
- GNUstep), remove. */
-#ifndef NS_IMPL_GNUSTEP
[self replyToOpenOrPrint: NSApplicationDelegateReplySuccess];
-#endif /* !NS_IMPL_GNUSTEP */
}
return NSMakeRange (NSNotFound, 0);
}
-- (unsigned int)characterIndexForPoint: (NSPoint)thePoint
+- (NSUInteger)characterIndexForPoint: (NSPoint)thePoint
{
if (NS_KEYLOG)
NSLog (@"characterIndexForPoint request");
r = NSMakeRect (0, 0, FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, f->text_cols),
FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, f->text_lines));
[self initWithFrame: r];
+ [self setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
FRAME_NS_VIEW (f) = self;
emacsframe = f;
/* 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 */
[self setEnabled: YES];
/* Ensure auto resizing of scrollbars occurs within the emacs frame's view
- locked against the right, top and bottom edges. */
+ locked against the top and bottom edges, and right edge on OS X, where
+ scrollers are on right. */
+#ifdef NS_IMPL_GNUSTEP
+ [self setAutoresizingMask: NSViewMaxXMargin | NSViewHeightSizable];
+#else
[self setAutoresizingMask: NSViewMinXMargin | NSViewHeightSizable];
+#endif
win = nwin;
condemned = NO;
por = (float)portion/whole;
[self setFloatValue: pos knobProportion: por];
}
-#ifdef NS_IMPL_GNUSTEP
- [self display];
-#endif
return self;
}
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;
}
/* set a timer to repeat, as we can't let superclass do this modally */
scroll_repeat_entry
- = [[NSTimer scheduledTimerWithTimeInterval: 0.5
+ = [[NSTimer scheduledTimerWithTimeInterval: SCROLL_BAR_FIRST_DELAY
target: self
selector: @selector (repeatScroll:)
userInfo: 0