Use 'header-line-highlight' face in proced and erc
[emacs.git] / src / nsterm.h
blob0f1b36db7b263491600fb7db05e1f2106e86c5ba
1 /* Definitions and headers for communication with NeXT/Open/GNUstep API.
2 Copyright (C) 1989, 1993, 2005, 2008-2017 Free Software Foundation,
3 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 (at
10 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 #include "dispextern.h"
22 #include "frame.h"
23 #include "character.h"
24 #include "font.h"
25 #include "sysselect.h"
27 #ifdef HAVE_NS
29 #ifdef NS_IMPL_COCOA
30 #ifndef MAC_OS_X_VERSION_10_6
31 #define MAC_OS_X_VERSION_10_6 1060
32 #endif
33 #ifndef MAC_OS_X_VERSION_10_7
34 #define MAC_OS_X_VERSION_10_7 1070
35 #endif
36 #ifndef MAC_OS_X_VERSION_10_8
37 #define MAC_OS_X_VERSION_10_8 1080
38 #endif
39 #ifndef MAC_OS_X_VERSION_10_9
40 #define MAC_OS_X_VERSION_10_9 1090
41 #endif
42 #ifndef MAC_OS_X_VERSION_10_12
43 #define MAC_OS_X_VERSION_10_12 101200
44 #endif
46 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
47 #define HAVE_NATIVE_FS
48 #endif
50 #endif /* NS_IMPL_COCOA */
52 #ifdef __OBJC__
54 /* CGFloat on GNUstep may be 4 or 8 byte, but functions expect float* for some
55 versions.
56 On Cocoa >= 10.5, functions expect CGFloat *. Make compatible type. */
57 #ifdef NS_IMPL_COCOA
58 typedef CGFloat EmacsCGFloat;
59 #elif GNUSTEP_GUI_MAJOR_VERSION > 0 || GNUSTEP_GUI_MINOR_VERSION >= 22
60 typedef CGFloat EmacsCGFloat;
61 #else
62 typedef float EmacsCGFloat;
63 #endif
65 /* ==========================================================================
67 Trace support
69 ========================================================================== */
71 /* Uncomment the following line to enable trace.
73 Uncomment suitable NSTRACE_GROUP_xxx lines to trace more.
75 Hint: keep the trailing whitespace -- the version control system
76 will reject accidental commits. */
78 /* #define NSTRACE_ENABLED 1 */
81 /* When non-zero, trace output is enabled for all parts, except those
82 explicitly disabled. */
83 /* #define NSTRACE_ALL_GROUPS 1 */
85 /* When non-zero, trace output is enabled in the corresponding part. */
86 /* #define NSTRACE_GROUP_EVENTS 1 */
87 /* #define NSTRACE_GROUP_UPDATES 1 */
88 /* #define NSTRACE_GROUP_FRINGE 1 */
89 /* #define NSTRACE_GROUP_COLOR 1 */
90 /* #define NSTRACE_GROUP_GLYPHS 1 */
91 /* #define NSTRACE_GROUP_FOCUS 1 */
94 /* Print a call tree containing all annotated functions.
96 The call structure of the functions is represented using
97 indentation and vertical lines. Extra information is printed using
98 horizontal lines that connect to the vertical line.
100 The return value is represented using the arrow "->>". For simple
101 functions, the arrow can be printed on the same line as the
102 function name. If more output is printed, it is connected to the
103 vertical line of the function.
105 The first column contains the file name, the second the line
106 number, and the third a number increasing for each trace line.
108 Note, when trace output from several threads are mixed, the output
109 can become misaligned, as all threads (currently) share one state.
110 This is post prominent when the EVENTS part is enabled.
112 Note that the trace system, when enabled, use the GCC/Clang
113 "cleanup" extension. */
115 /* For example, the following is the output of `M-x
116 toggle-frame-maximized RET'.
118 (Long lines manually split to reduced width):
120 nsterm.m : 1608: [ 354] ns_fullscreen_hook
121 nsterm.m : 7180: [ 355] | [EmacsView handleFS]
122 nsterm.m : 7209: [ 356] | +--- FULLSCREEN_MAXIMIZED
123 nsterm.m : 7706: [ 357] | | [EmacsWindow performZoom:]
124 nsterm.m : 7715: [ 358] | | | [EmacsWindow zoom:]
125 nsterm.m : 882: [ 359] | | | | ns_update_auto_hide_menu_bar
126 nsterm.m : 6752: [ 360] | | | |
127 [EmacsView windowWillUseStandardFrame:defaultFrame:(X:0 Y:0)/(W:1600 H:1177)]
128 nsterm.m : 6753: [ 361] | | | | +--- fs_state: FULLSCREEN_NONE
129 nsterm.m : 6754: [ 362] | | | | +--- fs_before_fs: -1
130 nsterm.m : 6755: [ 363] | | | | +--- next_maximized: FULLSCREEN_MAXIMIZED
131 nsterm.m : 6756: [ 364] | | | | +--- ns_userRect: (X:0 Y:0)/(W:0 H:0)
132 nsterm.m : 6757: [ 365] | | | | +---
133 [sender frame]: (X:0 Y:626)/(W:595 H:551)
134 nsterm.m : 6781: [ 366] | | | | +---
135 ns_userRect (2): (X:0 Y:626)/(W:595 H:551)
136 nsterm.m : 6821: [ 367] | | | | +--- FULLSCREEN_MAXIMIZED
137 nsterm.m : 7232: [ 368] | | | | |
138 [EmacsView setFSValue:FULLSCREEN_MAXIMIZED]
139 nsterm.m : 6848: [ 369] | | | | +---
140 Final ns_userRect: (X:0 Y:626)/(W:595 H:551)
141 nsterm.m : 6849: [ 370] | | | | +--- Final maximized_width: 1600
142 nsterm.m : 6850: [ 371] | | | | +--- Final maximized_height: 1177
143 nsterm.m : 6851: [ 372] | | | | +--- Final next_maximized: -1
144 nsterm.m : 6322: [ 373] | | | | |
145 [EmacsView windowWillResize:toSize: (W:1600 H:1177)]
146 nsterm.m : 6323: [ 374] | | | | | +---
147 [sender frame]: (X:0 Y:626)/(W:595 H:551)
148 nsterm.m : 6324: [ 375] | | | | | +--- fs_state: FULLSCREEN_MAXIMIZED
149 nsterm.m : 7027: [ 376] | | | | | | [EmacsView isFullscreen]
150 nsterm.m : 6387: [ 377] | | | | | +--- cols: 223 rows: 79
151 nsterm.m : 6412: [ 378] | | | | | +->> (W:1596 H:1167)
152 nsterm.m : 6855: [ 379] | | | | +->> (X:0 Y:0)/(W:1600 H:1177)
155 #ifndef NSTRACE_ENABLED
156 #define NSTRACE_ENABLED 0
157 #endif
159 #if NSTRACE_ENABLED
161 #ifndef NSTRACE_ALL_GROUPS
162 #define NSTRACE_ALL_GROUPS 0
163 #endif
165 #ifndef NSTRACE_GROUP_EVENTS
166 #define NSTRACE_GROUP_EVENTS NSTRACE_ALL_GROUPS
167 #endif
169 #ifndef NSTRACE_GROUP_UPDATES
170 #define NSTRACE_GROUP_UPDATES NSTRACE_ALL_GROUPS
171 #endif
173 #ifndef NSTRACE_GROUP_FRINGE
174 #define NSTRACE_GROUP_FRINGE NSTRACE_ALL_GROUPS
175 #endif
177 #ifndef NSTRACE_GROUP_COLOR
178 #define NSTRACE_GROUP_COLOR NSTRACE_ALL_GROUPS
179 #endif
181 #ifndef NSTRACE_GROUP_GLYPHS
182 #define NSTRACE_GROUP_GLYPHS NSTRACE_ALL_GROUPS
183 #endif
185 #ifndef NSTRACE_GROUP_FOCUS
186 #define NSTRACE_GROUP_FOCUS NSTRACE_ALL_GROUPS
187 #endif
189 extern volatile int nstrace_num;
190 extern volatile int nstrace_depth;
191 extern volatile int nstrace_enabled_global;
193 void nstrace_leave(int *);
194 void nstrace_restore_global_trace_state(int *);
195 char const * nstrace_fullscreen_type_name (int);
197 /* printf-style trace output. Output is aligned with contained heading. */
198 #define NSTRACE_MSG_NO_DASHES(...) \
199 do \
201 if (nstrace_enabled) \
203 fprintf (stderr, "%-10s:%5d: [%5d]%.*s", \
204 __FILE__, __LINE__, nstrace_num++, \
205 2*nstrace_depth, " | | | | | | | | | | | | | | | .."); \
206 fprintf (stderr, __VA_ARGS__); \
207 fprintf (stderr, "\n"); \
210 while(0)
212 #define NSTRACE_MSG(...) NSTRACE_MSG_NO_DASHES("+--- " __VA_ARGS__)
216 /* Macros for printing complex types.
218 NSTRACE_FMT_what -- Printf format string for "what".
219 NSTRACE_ARG_what(x) -- Printf argument for "what". */
221 #define NSTRACE_FMT_SIZE "(W:%.0f H:%.0f)"
222 #define NSTRACE_ARG_SIZE(elt) (elt).width, (elt).height
224 #define NSTRACE_FMT_POINT "(X:%.0f Y:%.0f)"
225 #define NSTRACE_ARG_POINT(elt) (elt).x, (elt).y
227 #define NSTRACE_FMT_RECT NSTRACE_FMT_POINT "/" NSTRACE_FMT_SIZE
228 #define NSTRACE_ARG_RECT(elt) \
229 NSTRACE_ARG_POINT((elt).origin), NSTRACE_ARG_SIZE((elt).size)
231 #define NSTRACE_FMT_FSTYPE "%s"
232 #define NSTRACE_ARG_FSTYPE(elt) nstrace_fullscreen_type_name(elt)
235 /* Macros for printing complex types as extra information. */
237 #define NSTRACE_SIZE(str,size) \
238 NSTRACE_MSG (str ": " NSTRACE_FMT_SIZE, \
239 NSTRACE_ARG_SIZE (size));
241 #define NSTRACE_POINT(str,point) \
242 NSTRACE_MSG (str ": " NSTRACE_FMT_POINT, \
243 NSTRACE_ARG_POINT (point));
245 #define NSTRACE_RECT(str,rect) \
246 NSTRACE_MSG (str ": " NSTRACE_FMT_RECT, \
247 NSTRACE_ARG_RECT (rect));
249 #define NSTRACE_FSTYPE(str,fs_type) \
250 NSTRACE_MSG (str ": " NSTRACE_FMT_FSTYPE, \
251 NSTRACE_ARG_FSTYPE (fs_type));
254 /* Return value macros.
256 NSTRACE_RETURN(fmt, ...) - Print a return value, support printf-style
257 format string and arguments.
259 NSTRACE_RETURN_what(obj) - Print a return value of kind WHAT.
261 NSTRACE_FMT_RETURN - A string literal representing a returned
262 value. Useful when creating a format string
263 to printf-like constructs like NSTRACE(). */
265 #define NSTRACE_FMT_RETURN "->>"
267 #define NSTRACE_RETURN(...) \
268 NSTRACE_MSG_NO_DASHES ("+" NSTRACE_FMT_RETURN " " __VA_ARGS__)
270 #define NSTRACE_RETURN_SIZE(size) \
271 NSTRACE_RETURN(NSTRACE_FMT_SIZE, NSTRACE_ARG_SIZE(size))
273 #define NSTRACE_RETURN_POINT(point) \
274 NSTRACE_RETURN(NSTRACE_FMT_POINT, NSTRACE_ARG_POINT(point))
276 #define NSTRACE_RETURN_RECT(rect) \
277 NSTRACE_RETURN(NSTRACE_FMT_RECT, NSTRACE_ARG_RECT(rect))
280 /* Function enter macros.
282 NSTRACE (fmt, ...) -- Enable trace output in current block
283 (typically a function). Accepts printf-style
284 arguments.
286 NSTRACE_WHEN (cond, fmt, ...) -- Enable trace output when COND is true.
288 NSTRACE_UNLESS (cond, fmt, ...) -- Enable trace output unless COND is
289 true. */
293 #define NSTRACE_WHEN(cond, ...) \
294 __attribute__((cleanup(nstrace_restore_global_trace_state))) \
295 int nstrace_saved_enabled_global = nstrace_enabled_global; \
296 __attribute__((cleanup(nstrace_leave))) \
297 int nstrace_enabled = nstrace_enabled_global && (cond); \
298 if (nstrace_enabled) { ++nstrace_depth; } \
299 else { nstrace_enabled_global = 0; } \
300 NSTRACE_MSG_NO_DASHES(__VA_ARGS__);
302 /* Unsilence called functions.
304 Concretely, this us used to allow "event" functions to be silenced
305 while trace output can be printed for functions they call. */
306 #define NSTRACE_UNSILENCE() do { nstrace_enabled_global = 1; } while(0)
308 #endif /* NSTRACE_ENABLED */
310 #define NSTRACE(...) NSTRACE_WHEN(1, __VA_ARGS__)
311 #define NSTRACE_UNLESS(cond, ...) NSTRACE_WHEN(!(cond), __VA_ARGS__)
313 /* Non-trace replacement versions. */
314 #ifndef NSTRACE_WHEN
315 #define NSTRACE_WHEN(...)
316 #endif
318 #ifndef NSTRACE_MSG
319 #define NSTRACE_MSG(...)
320 #endif
322 #ifndef NSTRACE_SIZE
323 #define NSTRACE_SIZE(str,size)
324 #endif
326 #ifndef NSTRACE_POINT
327 #define NSTRACE_POINT(str,point)
328 #endif
330 #ifndef NSTRACE_RECT
331 #define NSTRACE_RECT(str,rect)
332 #endif
334 #ifndef NSTRACE_FSTYPE
335 #define NSTRACE_FSTYPE(str,fs_type)
336 #endif
338 #ifndef NSTRACE_RETURN_SIZE
339 #define NSTRACE_RETURN_SIZE(size)
340 #endif
342 #ifndef NSTRACE_RETURN_POINT
343 #define NSTRACE_RETURN_POINT(point)
344 #endif
346 #ifndef NSTRACE_RETURN_RECT
347 #define NSTRACE_RETURN_RECT(rect)
348 #endif
350 #ifndef NSTRACE_RETURN_FSTYPE
351 #define NSTRACE_RETURN_FSTYPE(fs_type)
352 #endif
354 #ifndef NSTRACE_UNSILENCE
355 #define NSTRACE_UNSILENCE()
356 #endif
359 /* If the compiler doesn't support instancetype, map it to id. */
360 #ifndef NATIVE_OBJC_INSTANCETYPE
361 typedef id instancetype;
362 #endif
365 /* ==========================================================================
367 NSColor, EmacsColor category.
369 ========================================================================== */
370 @interface NSColor (EmacsColor)
371 + (NSColor *)colorForEmacsRed:(CGFloat)red green:(CGFloat)green
372 blue:(CGFloat)blue alpha:(CGFloat)alpha;
373 - (NSColor *)colorUsingDefaultColorSpace;
375 @end
377 /* ==========================================================================
379 The Emacs application
381 ========================================================================== */
383 /* We override sendEvent: as a means to stop/start the event loop */
384 @interface EmacsApp : NSApplication
386 #ifdef NS_IMPL_COCOA
387 BOOL shouldKeepRunning;
388 BOOL isFirst;
389 #endif
390 #ifdef NS_IMPL_GNUSTEP
391 BOOL applicationDidFinishLaunchingCalled;
392 #endif
393 @public
394 int nextappdefined;
396 - (void)logNotification: (NSNotification *)notification;
397 - (void)antialiasThresholdDidChange:(NSNotification *)notification;
398 - (void)sendEvent: (NSEvent *)theEvent;
399 - (void)showPreferencesWindow: (id)sender;
400 - (BOOL) openFile: (NSString *)fileName;
401 - (void)fd_handler: (id)unused;
402 - (void)timeout_handler: (NSTimer *)timedEntry;
403 - (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg;
404 #ifdef NS_IMPL_GNUSTEP
405 - (void)sendFromMainThread:(id)unused;
406 #endif
407 @end
409 #ifdef NS_IMPL_GNUSTEP
410 /* Dummy class to get rid of startup warnings. */
411 @interface EmacsDocument : NSDocument
414 @end
415 #endif
417 /* ==========================================================================
419 The main Emacs view
421 ========================================================================== */
423 @class EmacsToolbar;
425 #ifdef NS_IMPL_COCOA
426 @interface EmacsView : NSView <NSTextInput, NSWindowDelegate>
427 #else
428 @interface EmacsView : NSView <NSTextInput>
429 #endif
431 #ifdef NS_IMPL_COCOA
432 char *old_title;
433 BOOL maximizing_resize;
434 #endif
435 BOOL windowClosing;
436 NSString *workingText;
437 BOOL processingCompose;
438 int fs_state, fs_before_fs, next_maximized;
439 int bwidth;
440 int maximized_width, maximized_height;
441 NSWindow *nonfs_window;
442 BOOL fs_is_native;
443 @public
444 struct frame *emacsframe;
445 int rows, cols;
446 int scrollbarsNeedingUpdate;
447 EmacsToolbar *toolbar;
448 NSRect ns_userRect;
449 BOOL wait_for_tool_bar;
452 /* AppKit-side interface */
453 - (instancetype)menuDown: (id)sender;
454 - (instancetype)toolbarClicked: (id)item;
455 - (instancetype)toggleToolbar: (id)sender;
456 - (void)keyDown: (NSEvent *)theEvent;
457 - (void)mouseDown: (NSEvent *)theEvent;
458 - (void)mouseUp: (NSEvent *)theEvent;
459 - (instancetype)setMiniwindowImage: (BOOL)setMini;
461 /* Emacs-side interface */
462 - (instancetype) initFrameFromEmacs: (struct frame *) f;
463 - (void) createToolbar: (struct frame *)f;
464 - (void) setRows: (int) r andColumns: (int) c;
465 - (void) setWindowClosing: (BOOL)closing;
466 - (EmacsToolbar *) toolbar;
467 - (void) deleteWorkingText;
468 - (void) updateFrameSize: (BOOL) delay;
469 - (void) handleFS;
470 - (void) setFSValue: (int)value;
471 - (void) toggleFullScreen: (id) sender;
472 - (BOOL) fsIsNative;
473 - (BOOL) isFullscreen;
474 #ifdef HAVE_NATIVE_FS
475 - (void) updateCollectionBehavior;
476 #endif
478 #ifdef NS_IMPL_GNUSTEP
479 - (void)windowDidMove: (id)sender;
480 #endif
481 - (int)fullscreenState;
483 /* Non-notification versions of NSView methods. Used for direct calls. */
484 - (void)windowWillEnterFullScreen;
485 - (void)windowDidEnterFullScreen;
486 - (void)windowWillExitFullScreen;
487 - (void)windowDidExitFullScreen;
488 - (void)windowDidBecomeKey;
489 @end
492 /* Small utility used for processing resize events under Cocoa. */
493 @interface EmacsWindow : NSWindow
495 NSPoint grabOffset;
497 @end
500 /* Fullscreen version of the above. */
501 @interface EmacsFSWindow : EmacsWindow
504 @end
506 /* ==========================================================================
508 The main menu implementation
510 ========================================================================== */
512 #ifdef NS_IMPL_COCOA
513 @interface EmacsMenu : NSMenu <NSMenuDelegate>
514 #else
515 @interface EmacsMenu : NSMenu
516 #endif
518 struct frame *frame;
519 unsigned long keyEquivModMask;
522 - (instancetype)initWithTitle: (NSString *)title frame: (struct frame *)f;
523 - (void)setFrame: (struct frame *)f;
524 - (void)menuNeedsUpdate: (NSMenu *)menu; /* (delegate method) */
525 - (NSString *)parseKeyEquiv: (const char *)key;
526 - (NSMenuItem *)addItemWithWidgetValue: (void *)wvptr;
527 - (void)fillWithWidgetValue: (void *)wvptr;
528 - (void)fillWithWidgetValue: (void *)wvptr frame: (struct frame *)f;
529 - (EmacsMenu *)addSubmenuWithTitle: (const char *)title forFrame: (struct frame *)f;
530 - (void) clear;
531 - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f
532 keymaps: (bool)keymaps;
533 @end
536 /* ==========================================================================
538 Toolbar
540 ========================================================================== */
542 @class EmacsImage;
544 #ifdef NS_IMPL_COCOA
545 @interface EmacsToolbar : NSToolbar <NSToolbarDelegate>
546 #else
547 @interface EmacsToolbar : NSToolbar
548 #endif
550 EmacsView *emacsView;
551 NSMutableDictionary *identifierToItem;
552 NSMutableArray *activeIdentifiers;
553 NSArray *prevIdentifiers;
554 unsigned long enablement, prevEnablement;
556 - (instancetype) initForView: (EmacsView *)view withIdentifier: (NSString *)identifier;
557 - (void) clearActive;
558 - (void) clearAll;
559 - (BOOL) changed;
560 - (void) addDisplayItemWithImage: (EmacsImage *)img
561 idx: (int)idx
562 tag: (int)tag
563 helpText: (const char *)help
564 enabled: (BOOL)enabled;
566 /* delegate methods */
567 - (NSToolbarItem *)toolbar: (NSToolbar *)toolbar
568 itemForItemIdentifier: (NSString *)itemIdentifier
569 willBeInsertedIntoToolbar: (BOOL)flag;
570 - (NSArray *)toolbarDefaultItemIdentifiers: (NSToolbar *)toolbar;
571 - (NSArray *)toolbarAllowedItemIdentifiers: (NSToolbar *)toolbar;
572 @end
575 /* ==========================================================================
577 Message / question windows
579 ========================================================================== */
581 @interface EmacsDialogPanel : NSPanel
583 NSTextField *command;
584 NSTextField *title;
585 NSMatrix *matrix;
586 int rows, cols;
587 BOOL timer_fired, window_closed;
588 Lisp_Object dialog_return;
589 Lisp_Object *button_values;
591 - (instancetype)initFromContents: (Lisp_Object)menu isQuestion: (BOOL)isQ;
592 - (void)process_dialog: (Lisp_Object)list;
593 - (void)addButton: (char *)str value: (int)tag row: (int)row;
594 - (void)addString: (char *)str row: (int)row;
595 - (void)addSplit;
596 - (Lisp_Object)runDialogAt: (NSPoint)p;
597 - (void)timeout_handler: (NSTimer *)timedEntry;
598 @end
600 #ifdef NS_IMPL_COCOA
601 @interface EmacsTooltip : NSObject <NSWindowDelegate>
602 #else
603 @interface EmacsTooltip : NSObject
604 #endif
606 NSWindow *win;
607 NSTextField *textField;
608 NSTimer *timer;
610 - (instancetype) init;
611 - (void) setText: (char *)text;
612 - (void) showAtX: (int)x Y: (int)y for: (int)seconds;
613 - (void) hide;
614 - (BOOL) isActive;
615 - (NSRect) frame;
616 @end
619 /* ==========================================================================
621 File open/save panels
622 This and next override methods to handle keyboard input in panels.
624 ========================================================================== */
626 @interface EmacsSavePanel : NSSavePanel
629 @end
630 @interface EmacsOpenPanel : NSOpenPanel
633 @end
635 @interface EmacsFileDelegate : NSObject
638 - (BOOL)panel: (id)sender isValidFilename: (NSString *)filename;
639 - (BOOL)panel: (id)sender shouldShowFilename: (NSString *)filename;
640 - (NSString *)panel: (id)sender userEnteredFilename: (NSString *)filename
641 confirmed: (BOOL)okFlag;
642 @end
645 /* ==========================================================================
647 Images and stippling
649 ========================================================================== */
651 @interface EmacsImage : NSImage
653 NSBitmapImageRep *bmRep; /* used for accessing pixel data */
654 unsigned char *pixmapData[5]; /* shortcut to access pixel data */
655 NSColor *stippleMask;
656 unsigned long xbm_fg;
658 + (instancetype)allocInitFromFile: (Lisp_Object)file;
659 - (void)dealloc;
660 - (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h
661 fg: (unsigned long)fg bg: (unsigned long)bg;
662 - (instancetype)setXBMColor: (NSColor *)color;
663 - (instancetype)initForXPMWithDepth: (int)depth width: (int)width height: (int)height;
664 - (void)setPixmapData;
665 - (unsigned long)getPixelAtX: (int)x Y: (int)y;
666 - (void)setPixelAtX: (int)x Y: (int)y toRed: (unsigned char)r
667 green: (unsigned char)g blue: (unsigned char)b
668 alpha:(unsigned char)a;
669 - (void)setAlphaAtX: (int)x Y: (int)y to: (unsigned char)a;
670 - (NSColor *)stippleMask;
671 @end
674 /* ==========================================================================
676 Scrollbars
678 ========================================================================== */
680 @interface EmacsScroller : NSScroller
682 struct window *window;
683 struct frame *frame;
684 NSResponder *prevResponder;
686 /* offset to the bottom of knob of last mouse down */
687 CGFloat last_mouse_offset;
688 float min_portion;
689 int pixel_length;
690 enum scroll_bar_part last_hit_part;
692 BOOL condemned;
694 BOOL horizontal;
696 /* optimize against excessive positioning calls generated by emacs */
697 int em_position;
698 int em_portion;
699 int em_whole;
702 - (instancetype) initFrame: (NSRect )r window: (Lisp_Object)win;
703 - (void)setFrame: (NSRect)r;
705 - (instancetype) setPosition: (int) position portion: (int) portion whole: (int) whole;
706 - (int) checkSamePosition: (int)position portion: (int)portion
707 whole: (int)whole;
708 - (void) sendScrollEventAtLoc: (float)loc fromEvent: (NSEvent *)e;
709 - (instancetype)repeatScroll: (NSTimer *)sender;
710 - (instancetype)condemn;
711 - (instancetype)reprieve;
712 - (bool)judge;
713 + (CGFloat)scrollerWidth;
714 @end
717 /* ==========================================================================
719 Rendering
721 ========================================================================== */
723 #ifdef NS_IMPL_COCOA
724 /* rendering util */
725 @interface EmacsGlyphStorage : NSObject <NSGlyphStorage>
727 @public
728 NSAttributedString *attrStr;
729 NSMutableDictionary *dict;
730 CGGlyph *cglyphs;
731 unsigned long maxChar, maxGlyph;
732 long i, len;
734 - (instancetype)initWithCapacity: (unsigned long) c;
735 - (void) setString: (NSString *)str font: (NSFont *)font;
736 @end
737 #endif /* NS_IMPL_COCOA */
739 extern NSArray *ns_send_types, *ns_return_types;
740 extern NSString *ns_app_name;
741 extern EmacsMenu *svcsMenu;
743 /* Apple removed the declaration, but kept the implementation */
744 #if defined (NS_IMPL_COCOA)
745 @interface NSApplication (EmacsApp)
746 - (void)setAppleMenu: (NSMenu *)menu;
747 @end
748 #endif
750 #endif /* __OBJC__ */
754 /* ==========================================================================
756 Non-OO stuff
758 ========================================================================== */
760 /* Special keycodes that we pass down the event chain */
761 #define KEY_NS_POWER_OFF ((1<<28)|(0<<16)|1)
762 #define KEY_NS_OPEN_FILE ((1<<28)|(0<<16)|2)
763 #define KEY_NS_OPEN_TEMP_FILE ((1<<28)|(0<<16)|3)
764 #define KEY_NS_CHANGE_FONT ((1<<28)|(0<<16)|7)
765 #define KEY_NS_OPEN_FILE_LINE ((1<<28)|(0<<16)|8)
766 #define KEY_NS_PUT_WORKING_TEXT ((1<<28)|(0<<16)|9)
767 #define KEY_NS_UNPUT_WORKING_TEXT ((1<<28)|(0<<16)|10)
768 #define KEY_NS_SPI_SERVICE_CALL ((1<<28)|(0<<16)|11)
769 #define KEY_NS_NEW_FRAME ((1<<28)|(0<<16)|12)
770 #define KEY_NS_TOGGLE_TOOLBAR ((1<<28)|(0<<16)|13)
771 #define KEY_NS_SHOW_PREFS ((1<<28)|(0<<16)|14)
773 /* could use list to store these, but rest of emacs has a big infrastructure
774 for managing a table of bitmap "records" */
775 struct ns_bitmap_record
777 #ifdef __OBJC__
778 EmacsImage *img;
779 #else
780 void *img;
781 #endif
782 char *file;
783 int refcount;
784 int height, width, depth;
787 /* this to map between emacs color indices and NSColor objects */
788 struct ns_color_table
790 ptrdiff_t size;
791 ptrdiff_t avail;
792 #ifdef __OBJC__
793 NSColor **colors;
794 NSMutableSet *empty_indices;
795 #else
796 void **items;
797 void *availIndices;
798 #endif
800 #define NS_COLOR_CAPACITY 256
802 #define RGB_TO_ULONG(r, g, b) (((r) << 16) | ((g) << 8) | (b))
803 #define ARGB_TO_ULONG(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
805 #define ALPHA_FROM_ULONG(color) ((color) >> 24)
806 #define RED_FROM_ULONG(color) (((color) >> 16) & 0xff)
807 #define GREEN_FROM_ULONG(color) (((color) >> 8) & 0xff)
808 #define BLUE_FROM_ULONG(color) ((color) & 0xff)
810 /* Do not change `* 0x101' in the following lines to `<< 8'. If
811 changed, image masks in 1-bit depth will not work. */
812 #define RED16_FROM_ULONG(color) (RED_FROM_ULONG(color) * 0x101)
813 #define GREEN16_FROM_ULONG(color) (GREEN_FROM_ULONG(color) * 0x101)
814 #define BLUE16_FROM_ULONG(color) (BLUE_FROM_ULONG(color) * 0x101)
816 /* this extends font backend font */
817 struct nsfont_info
819 struct font font;
821 char *name; /* PostScript name, uniquely identifies on NS systems */
823 /* The following metrics are stored as float rather than int. */
825 float width; /* Maximum advance for the font. */
826 float height;
827 float underpos;
828 float underwidth;
829 float size;
830 #ifdef __OBJC__
831 NSFont *nsfont;
832 #if defined (NS_IMPL_COCOA)
833 CGFontRef cgfont;
834 #else /* GNUstep */
835 void *cgfont;
836 #endif
837 #else /* ! OBJC */
838 void *nsfont;
839 void *cgfont;
840 #endif
841 char bold, ital; /* convenience flags */
842 char synthItal;
843 XCharStruct max_bounds;
844 /* we compute glyph codes and metrics on-demand in blocks of 256 indexed
845 by hibyte, lobyte */
846 unsigned short **glyphs; /* map Unicode index to glyph */
847 struct font_metrics **metrics;
851 /* init'd in ns_initialize_display_info () */
852 struct ns_display_info
854 /* Chain of all ns_display_info structures. */
855 struct ns_display_info *next;
857 /* The generic display parameters corresponding to this NS display. */
858 struct terminal *terminal;
860 /* This is a cons cell of the form (NAME . FONT-LIST-CACHE). */
861 Lisp_Object name_list_element;
863 /* The number of fonts loaded. */
864 int n_fonts;
866 /* Minimum width over all characters in all fonts in font_table. */
867 int smallest_char_width;
869 /* Minimum font height over all fonts in font_table. */
870 int smallest_font_height;
872 struct ns_bitmap_record *bitmaps;
873 ptrdiff_t bitmaps_size;
874 ptrdiff_t bitmaps_last;
876 struct ns_color_table *color_table;
878 /* DPI resolution of this screen */
879 double resx, resy;
881 /* Mask of things that cause the mouse to be grabbed */
882 int grabbed;
884 int n_planes;
886 int color_p;
888 Window root_window;
890 /* Xism */
891 XrmDatabase xrdb;
893 /* The cursor to use for vertical scroll bars. */
894 Cursor vertical_scroll_bar_cursor;
896 /* The cursor to use for horizontal scroll bars. */
897 Cursor horizontal_scroll_bar_cursor;
899 /* Information about the range of text currently shown in
900 mouse-face. */
901 Mouse_HLInfo mouse_highlight;
903 struct frame *x_highlight_frame;
904 struct frame *x_focus_frame;
906 /* The frame where the mouse was last time we reported a mouse event. */
907 struct frame *last_mouse_frame;
909 /* The frame where the mouse was last time we reported a mouse motion. */
910 struct frame *last_mouse_motion_frame;
912 /* Position where the mouse was last time we reported a motion.
913 This is a position on last_mouse_motion_frame. */
914 int last_mouse_motion_x;
915 int last_mouse_motion_y;
917 /* Where the mouse was last time we reported a mouse position. */
918 NSRect last_mouse_glyph;
920 /* Time of last mouse movement. */
921 Time last_mouse_movement_time;
923 /* The scroll bar in which the last motion event occurred. */
924 #ifdef __OBJC__
925 EmacsScroller *last_mouse_scroll_bar;
926 #else
927 void *last_mouse_scroll_bar;
928 #endif
931 /* This is a chain of structures for all the NS displays currently in use. */
932 extern struct ns_display_info *x_display_list;
934 struct ns_output
936 #ifdef __OBJC__
937 EmacsView *view;
938 id miniimage;
939 NSColor *cursor_color;
940 NSColor *foreground_color;
941 NSColor *background_color;
942 EmacsToolbar *toolbar;
943 #else
944 void *view;
945 void *miniimage;
946 void *cursor_color;
947 void *foreground_color;
948 void *background_color;
949 void *toolbar;
950 #endif
952 /* NSCursors init'ed in initFrameFromEmacs */
953 Cursor text_cursor;
954 Cursor nontext_cursor;
955 Cursor modeline_cursor;
956 Cursor hand_cursor;
957 Cursor hourglass_cursor;
958 Cursor horizontal_drag_cursor;
959 Cursor vertical_drag_cursor;
960 Cursor left_edge_cursor;
961 Cursor top_left_corner_cursor;
962 Cursor top_edge_cursor;
963 Cursor top_right_corner_cursor;
964 Cursor right_edge_cursor;
965 Cursor bottom_right_corner_cursor;
966 Cursor bottom_edge_cursor;
967 Cursor bottom_left_corner_cursor;
969 /* NS-specific */
970 Cursor current_pointer;
972 /* lord knows why Emacs needs to know about our Window ids.. */
973 Window window_desc, parent_desc;
974 char explicit_parent;
976 struct font *font;
977 int baseline_offset;
979 /* If a fontset is specified for this frame instead of font, this
980 value contains an ID of the fontset, else -1. */
981 int fontset; /* only used with font_backend */
983 int icon_top;
984 int icon_left;
986 /* The size of the extra width currently allotted for vertical
987 scroll bars, in pixels. */
988 int vertical_scroll_bar_extra;
990 /* The height of the titlebar decoration (included in NSWindow's frame). */
991 int titlebar_height;
993 /* The height of the toolbar if displayed, else 0. */
994 int toolbar_height;
996 /* This is the Emacs structure for the NS display this frame is on. */
997 struct ns_display_info *display_info;
999 /* Non-zero if we are zooming (maximizing) the frame. */
1000 int zooming;
1002 /* Non-zero if we are doing an animation, e.g. toggling the tool bar. */
1003 int in_animation;
1006 /* this dummy decl needed to support TTYs */
1007 struct x_output
1009 int unused;
1013 /* This gives the ns_display_info structure for the display F is on. */
1014 #define FRAME_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
1015 #define FRAME_X_OUTPUT(f) ((f)->output_data.ns)
1016 #define FRAME_NS_WINDOW(f) ((f)->output_data.ns->window_desc)
1017 #define FRAME_X_WINDOW(f) ((f)->output_data.ns->window_desc)
1019 /* This is the `Display *' which frame F is on. */
1020 #define FRAME_NS_DISPLAY(f) (0)
1021 #define FRAME_X_DISPLAY(f) (0)
1022 #define FRAME_X_SCREEN(f) (0)
1023 #define FRAME_X_VISUAL(f) FRAME_DISPLAY_INFO(f)->visual
1025 #define FRAME_FOREGROUND_COLOR(f) ((f)->output_data.ns->foreground_color)
1026 #define FRAME_BACKGROUND_COLOR(f) ((f)->output_data.ns->background_color)
1028 #define NS_FACE_FOREGROUND(f) ((f)->foreground)
1029 #define NS_FACE_BACKGROUND(f) ((f)->background)
1031 #define FRAME_DEFAULT_FACE(f) FACE_FROM_ID_OR_NULL (f, DEFAULT_FACE_ID)
1033 #define FRAME_NS_VIEW(f) ((f)->output_data.ns->view)
1034 #define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->cursor_color)
1035 #define FRAME_POINTER_TYPE(f) ((f)->output_data.ns->current_pointer)
1037 #define FRAME_FONT(f) ((f)->output_data.ns->font)
1039 #ifdef __OBJC__
1040 #define XNS_SCROLL_BAR(vec) ((id) XSAVE_POINTER (vec, 0))
1041 #else
1042 #define XNS_SCROLL_BAR(vec) XSAVE_POINTER (vec, 0)
1043 #endif
1045 /* Compute pixel height of the frame's titlebar. */
1046 #define FRAME_NS_TITLEBAR_HEIGHT(f) \
1047 (NSHeight([FRAME_NS_VIEW (f) frame]) == 0 ? \
1049 : (int)(NSHeight([FRAME_NS_VIEW (f) window].frame) \
1050 - NSHeight([NSWindow contentRectForFrameRect: \
1051 [[FRAME_NS_VIEW (f) window] frame] \
1052 styleMask:[[FRAME_NS_VIEW (f) window] styleMask]])))
1054 /* Compute pixel height of the toolbar. */
1055 #define FRAME_TOOLBAR_HEIGHT(f) \
1056 (([[FRAME_NS_VIEW (f) window] toolbar] == nil \
1057 || ! [[FRAME_NS_VIEW (f) window] toolbar].isVisible) ? \
1059 : (int)(NSHeight([NSWindow contentRectForFrameRect: \
1060 [[FRAME_NS_VIEW (f) window] frame] \
1061 styleMask:[[FRAME_NS_VIEW (f) window] styleMask]]) \
1062 - NSHeight([[[FRAME_NS_VIEW (f) window] contentView] frame])))
1064 /* Compute pixel size for vertical scroll bars */
1065 #define NS_SCROLL_BAR_WIDTH(f) \
1066 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
1067 ? rint (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0 \
1068 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
1069 : (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f))) \
1070 : 0)
1072 /* Compute pixel size for horizontal scroll bars */
1073 #define NS_SCROLL_BAR_HEIGHT(f) \
1074 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
1075 ? rint (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) > 0 \
1076 ? FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) \
1077 : (FRAME_SCROLL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f))) \
1078 : 0)
1080 /* Difference btwn char-column-calculated and actual SB widths.
1081 This is only a concern for rendering when SB on left. */
1082 #define NS_SCROLL_BAR_ADJUST(w, f) \
1083 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) ? \
1084 (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f) \
1085 - NS_SCROLL_BAR_WIDTH (f)) : 0)
1087 /* Difference btwn char-line-calculated and actual SB heights.
1088 This is only a concern for rendering when SB on top. */
1089 #define NS_SCROLL_BAR_ADJUST_HORIZONTALLY(w, f) \
1090 (WINDOW_HAS_HORIZONTAL_SCROLL_BARS (w) ? \
1091 (FRAME_SCROLL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f) \
1092 - NS_SCROLL_BAR_HEIGHT (f)) : 0)
1094 /* Calculate system coordinates of the left and top of the parent
1095 window or, if there is no parent window, the screen. */
1096 #define NS_PARENT_WINDOW_LEFT_POS(f) \
1097 (FRAME_PARENT_FRAME (f) != NULL \
1098 ? [[FRAME_NS_VIEW (f) window] parentWindow].frame.origin.x : 0)
1099 #define NS_PARENT_WINDOW_TOP_POS(f) \
1100 (FRAME_PARENT_FRAME (f) != NULL \
1101 ? ([[FRAME_NS_VIEW (f) window] parentWindow].frame.origin.y \
1102 + [[FRAME_NS_VIEW (f) window] parentWindow].frame.size.height \
1103 - FRAME_NS_TITLEBAR_HEIGHT (FRAME_PARENT_FRAME (f))) \
1104 : [[[NSScreen screens] objectAtIndex: 0] frame].size.height)
1106 #define FRAME_NS_FONT_TABLE(f) (FRAME_DISPLAY_INFO (f)->font_table)
1108 #define FRAME_FONTSET(f) ((f)->output_data.ns->fontset)
1110 #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.ns->baseline_offset)
1111 #define BLACK_PIX_DEFAULT(f) 0x000000
1112 #define WHITE_PIX_DEFAULT(f) 0xFFFFFF
1114 /* First position where characters can be shown (instead of scrollbar, if
1115 it is on left. */
1116 #define FIRST_CHAR_POSITION(f) \
1117 (! (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) ? 0 \
1118 : FRAME_SCROLL_BAR_COLS (f))
1120 extern struct ns_display_info *ns_term_init (Lisp_Object display_name);
1121 extern void ns_term_shutdown (int sig);
1123 /* constants for text rendering */
1124 #define NS_DUMPGLYPH_NORMAL 0
1125 #define NS_DUMPGLYPH_CURSOR 1
1126 #define NS_DUMPGLYPH_FOREGROUND 2
1127 #define NS_DUMPGLYPH_MOUSEFACE 3
1131 /* In nsfont, called from fontset.c */
1132 extern void nsfont_make_fontset_for_font (Lisp_Object name,
1133 Lisp_Object font_object);
1135 /* In nsfont, for debugging */
1136 struct glyph_string;
1137 void ns_dump_glyphstring (struct glyph_string *s) EXTERNALLY_VISIBLE;
1139 /* Implemented in nsterm, published in or needed from nsfns. */
1140 extern Lisp_Object ns_list_fonts (struct frame *f, Lisp_Object pattern,
1141 int size, int maxnames);
1142 extern void ns_clear_frame (struct frame *f);
1144 extern const char *ns_xlfd_to_fontname (const char *xlfd);
1146 extern Lisp_Object ns_map_event_to_object (void);
1147 #ifdef __OBJC__
1148 extern Lisp_Object ns_string_from_pasteboard (id pb);
1149 extern void ns_string_to_pasteboard (id pb, Lisp_Object str);
1150 #endif
1151 extern Lisp_Object ns_get_local_selection (Lisp_Object selection_name,
1152 Lisp_Object target_type);
1153 extern void nxatoms_of_nsselect (void);
1154 extern void ns_set_doc_edited (void);
1156 extern bool
1157 ns_defined_color (struct frame *f,
1158 const char *name,
1159 XColor *color_def, bool alloc,
1160 bool makeIndex);
1161 extern void
1162 ns_query_color (void *col, XColor *color_def, int setPixel);
1164 #ifdef __OBJC__
1165 extern int ns_lisp_to_color (Lisp_Object color, NSColor **col);
1166 extern NSColor *ns_lookup_indexed_color (unsigned long idx, struct frame *f);
1167 extern unsigned long ns_index_color (NSColor *color, struct frame *f);
1168 extern const char *ns_get_pending_menu_title (void);
1169 extern void ns_check_menu_open (NSMenu *menu);
1170 extern void ns_check_pending_open_menu (void);
1171 #endif
1173 /* C access to ObjC functionality */
1174 extern void ns_release_object (void *obj);
1175 extern void ns_retain_object (void *obj);
1176 extern void *ns_alloc_autorelease_pool (void);
1177 extern void ns_release_autorelease_pool (void *);
1178 extern const char *ns_get_defaults_value (const char *key);
1179 extern void ns_init_locale (void);
1182 /* in nsmenu */
1183 extern void update_frame_tool_bar (struct frame *f);
1184 extern void free_frame_tool_bar (struct frame *f);
1185 extern Lisp_Object find_and_return_menu_selection (struct frame *f,
1186 bool keymaps,
1187 void *client_data);
1188 extern Lisp_Object ns_popup_dialog (struct frame *, Lisp_Object header,
1189 Lisp_Object contents);
1191 #define NSAPP_DATA2_RUNASSCRIPT 10
1192 extern void ns_run_ascript (void);
1194 #define NSAPP_DATA2_RUNFILEDIALOG 11
1195 extern void ns_run_file_dialog (void);
1197 extern const char *ns_etc_directory (void);
1198 extern const char *ns_exec_path (void);
1199 extern const char *ns_load_path (void);
1200 extern void syms_of_nsterm (void);
1201 extern void syms_of_nsfns (void);
1202 extern void syms_of_nsmenu (void);
1203 extern void syms_of_nsselect (void);
1205 /* From nsimage.m, needed in image.c */
1206 struct image;
1207 extern void *ns_image_from_XBM (char *bits, int width, int height,
1208 unsigned long fg, unsigned long bg);
1209 extern void *ns_image_for_XPM (int width, int height, int depth);
1210 extern void *ns_image_from_file (Lisp_Object file);
1211 extern bool ns_load_image (struct frame *f, struct image *img,
1212 Lisp_Object spec_file, Lisp_Object spec_data);
1213 extern int ns_image_width (void *img);
1214 extern int ns_image_height (void *img);
1215 extern unsigned long ns_get_pixel (void *img, int x, int y);
1216 extern void ns_put_pixel (void *img, int x, int y, unsigned long argb);
1217 extern void ns_set_alpha (void *img, int x, int y, unsigned char a);
1219 extern int x_display_pixel_height (struct ns_display_info *);
1220 extern int x_display_pixel_width (struct ns_display_info *);
1222 /* This in nsterm.m */
1223 extern float ns_antialias_threshold;
1224 extern void x_destroy_window (struct frame *f);
1225 extern void x_set_undecorated (struct frame *f, Lisp_Object new_value,
1226 Lisp_Object old_value);
1227 extern void x_set_parent_frame (struct frame *f, Lisp_Object new_value,
1228 Lisp_Object old_value);
1229 extern void x_set_no_focus_on_map (struct frame *f, Lisp_Object new_value,
1230 Lisp_Object old_value);
1231 extern void x_set_no_accept_focus (struct frame *f, Lisp_Object new_value,
1232 Lisp_Object old_value);
1233 extern void x_set_z_group (struct frame *f, Lisp_Object new_value,
1234 Lisp_Object old_value);
1235 extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds,
1236 fd_set *exceptfds, struct timespec *timeout,
1237 sigset_t *sigmask);
1238 #ifdef HAVE_PTHREAD
1239 extern void ns_run_loop_break (void);
1240 #endif
1241 extern unsigned long ns_get_rgb_color (struct frame *f,
1242 float r, float g, float b, float a);
1244 struct input_event;
1245 extern void ns_init_events (struct input_event *);
1246 extern void ns_finish_events (void);
1248 #ifdef __OBJC__
1249 /* Needed in nsfns.m. */
1250 extern void
1251 ns_set_represented_filename (NSString *fstr, struct frame *f);
1253 #endif
1255 #ifdef NS_IMPL_GNUSTEP
1256 extern char gnustep_base_version[]; /* version tracking */
1257 #endif
1259 #define MINWIDTH 10
1260 #define MINHEIGHT 10
1262 /* Screen max coordinate
1263 Using larger coordinates causes movewindow/placewindow to abort */
1264 #define SCREENMAX 16000
1266 #define NS_SCROLL_BAR_WIDTH_DEFAULT [EmacsScroller scrollerWidth]
1267 #define NS_SCROLL_BAR_HEIGHT_DEFAULT [EmacsScroller scrollerHeight]
1268 /* This is to match emacs on other platforms, ugly though it is. */
1269 #define NS_SELECTION_BG_COLOR_DEFAULT @"LightGoldenrod2";
1270 #define NS_SELECTION_FG_COLOR_DEFAULT @"Black";
1271 #define RESIZE_HANDLE_SIZE 12
1273 /* Little utility macros */
1274 #define IN_BOUND(min, x, max) (((x) < (min)) \
1275 ? (min) : (((x)>(max)) ? (max) : (x)))
1276 #define SCREENMAXBOUND(x) (IN_BOUND (-SCREENMAX, x, SCREENMAX))
1278 /* macOS 10.12 deprecates a bunch of constants. */
1279 #if !defined (NS_IMPL_COCOA) || \
1280 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
1281 #define NSEventModifierFlagCommand NSCommandKeyMask
1282 #define NSEventModifierFlagControl NSControlKeyMask
1283 #define NSEventModifierFlagHelp NSHelpKeyMask
1284 #define NSEventModifierFlagNumericPad NSNumericPadKeyMask
1285 #define NSEventModifierFlagOption NSAlternateKeyMask
1286 #define NSEventModifierFlagShift NSShiftKeyMask
1287 #define NSCompositingOperationSourceOver NSCompositeSourceOver
1288 #define NSEventMaskApplicationDefined NSApplicationDefinedMask
1289 #define NSEventTypeApplicationDefined NSApplicationDefined
1290 #define NSEventTypeCursorUpdate NSCursorUpdate
1291 #define NSEventTypeMouseMoved NSMouseMoved
1292 #define NSEventTypeLeftMouseDown NSLeftMouseDown
1293 #define NSEventTypeRightMouseDown NSRightMouseDown
1294 #define NSEventTypeOtherMouseDown NSOtherMouseDown
1295 #define NSEventTypeLeftMouseUp NSLeftMouseUp
1296 #define NSEventTypeRightMouseUp NSRightMouseUp
1297 #define NSEventTypeOtherMouseUp NSOtherMouseUp
1298 #define NSEventTypeLeftMouseDragged NSLeftMouseDragged
1299 #define NSEventTypeRightMouseDragged NSRightMouseDragged
1300 #define NSEventTypeOtherMouseDragged NSOtherMouseDragged
1301 #define NSEventTypeScrollWheel NSScrollWheel
1302 #define NSEventTypeKeyDown NSKeyDown
1303 #define NSEventTypeKeyUp NSKeyUp
1304 #define NSEventTypeFlagsChanged NSFlagsChanged
1305 #define NSEventMaskAny NSAnyEventMask
1306 #define NSWindowStyleMaskBorderless NSBorderlessWindowMask
1307 #define NSWindowStyleMaskClosable NSClosableWindowMask
1308 #define NSWindowStyleMaskFullScreen NSFullScreenWindowMask
1309 #define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
1310 #define NSWindowStyleMaskResizable NSResizableWindowMask
1311 #define NSWindowStyleMaskTitled NSTitledWindowMask
1312 #define NSWindowStyleMaskUtilityWindow NSUtilityWindowMask
1313 #define NSAlertStyleCritical NSCriticalAlertStyle
1314 #define NSControlSizeRegular NSRegularControlSize
1316 /* And adds NSWindowStyleMask. */
1317 #ifdef __OBJC__
1318 typedef NSUInteger NSWindowStyleMask;
1319 #endif
1320 #endif
1322 #endif /* HAVE_NS */