X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/4f9d7df139695e97cd1772d41940500480585df7..8f1d2ef658f95549eb33fe5265f8f11c5129bece:/src/nsterm.h diff --git a/src/nsterm.h b/src/nsterm.h index 2a70ae31d5..09ec8c19b1 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -1,5 +1,5 @@ /* Definitions and headers for communication with NeXT/Open/GNUstep API. - Copyright (C) 1989, 1993, 2005, 2008 Free Software Foundation, Inc. + Copyright (C) 1989, 1993, 2005, 2008-2011 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -21,6 +21,7 @@ along with GNU Emacs. If not, see . */ #include "frame.h" #include "character.h" #include "font.h" +#include "sysselect.h" #ifdef HAVE_NS @@ -36,8 +37,13 @@ along with GNU Emacs. If not, see . */ @interface EmacsApp : NSApplication { } +- (void)logNotification: (NSNotification *)notification; - (void)sendEvent: (NSEvent *)theEvent; - (void)showPreferencesWindow: (id)sender; +- (BOOL) openFile: (NSString *)fileName; +- (void)fd_handler: (NSTimer *) fdEntry; +- (void)timeout_handler: (NSTimer *)timedEntry; +- (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg; @end @@ -49,7 +55,7 @@ along with GNU Emacs. If not, see . */ @class EmacsToolbar; -@interface EmacsView : NSView +@interface EmacsView : NSView /* 10.6+: NSWindowDelegate */ { char *old_title; BOOL windowClosing; @@ -60,6 +66,7 @@ along with GNU Emacs. If not, see . */ int rows, cols; int scrollbarsNeedingUpdate; EmacsToolbar *toolbar; + NSRect ns_userRect; } /* AppKit-side interface */ @@ -77,6 +84,11 @@ along with GNU Emacs. If not, see . */ - (void) setWindowClosing: (BOOL)closing; - (EmacsToolbar *) toolbar; - (void) deleteWorkingText; + +#ifdef NS_IMPL_GNUSTEP +/* Not declared, but useful. */ +- (void) unlockFocusNeedsFlush: (BOOL)needs; +#endif @end @@ -94,7 +106,7 @@ along with GNU Emacs. If not, see . */ ========================================================================== */ -@interface EmacsMenu : NSMenu +@interface EmacsMenu : NSMenu /* 10.6+: */ { struct frame *frame; unsigned long keyEquivModMask; @@ -103,10 +115,10 @@ along with GNU Emacs. If not, see . */ - initWithTitle: (NSString *)title frame: (struct frame *)f; - (void)setFrame: (struct frame *)f; - (void)menuNeedsUpdate: (NSMenu *)menu; /* (delegate method) */ -- (NSString *)parseKeyEquiv: (char *)key; -- (id )addItemWithWidgetValue: (void *)wvptr; +- (NSString *)parseKeyEquiv: (const char *)key; +- (NSMenuItem *)addItemWithWidgetValue: (void *)wvptr; - (void)fillWithWidgetValue: (void *)wvptr; -- (EmacsMenu *)addSubmenuWithTitle: (char *)title forFrame: (struct frame *)f; +- (EmacsMenu *)addSubmenuWithTitle: (const char *)title forFrame: (struct frame *)f; - (void) clear; - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f keymaps: (int)keymaps; @@ -121,7 +133,7 @@ along with GNU Emacs. If not, see . */ @class EmacsImage; -@interface EmacsToolbar : NSToolbar +@interface EmacsToolbar : NSToolbar /* 10.6+: */ { EmacsView *emacsView; NSMutableDictionary *identifierToItem; @@ -133,7 +145,7 @@ along with GNU Emacs. If not, see . */ - (void) clearActive; - (BOOL) changed; - (void) addDisplayItemWithImage: (EmacsImage *)img idx: (int)idx - helpText: (char *)help + helpText: (const char *)help enabled: (BOOL)enabled; /* delegate methods */ - (NSToolbarItem *)toolbar: (NSToolbar *)toolbar @@ -164,7 +176,7 @@ along with GNU Emacs. If not, see . */ - (Lisp_Object)runDialogAt: (NSPoint)p; @end -@interface EmacsTooltip : NSObject +@interface EmacsTooltip : NSObject /* 10.6+: */ { NSWindow *win; NSTextField *textField; @@ -307,57 +319,29 @@ along with GNU Emacs. If not, see . */ @end #endif /* NS_IMPL_COCOA */ - -/* ========================================================================== - - Running the preferences window - - ========================================================================== */ - -@interface EmacsPrefsController : NSObject -{ - struct frame *frame; - IBOutlet NSWindow *prefsWindow; - IBOutlet NSPopUpButton *alternateModMenu; - IBOutlet NSPopUpButton *commandModMenu; -#ifdef NS_IMPL_COCOA - IBOutlet NSPopUpButton *controlModMenu; - IBOutlet NSPopUpButton *functionModMenu; -#endif - IBOutlet NSMatrix *cursorTypeMatrix; - IBOutlet NSSlider *cursorBlinkSlider; - IBOutlet NSSlider *expandSpaceSlider; -#ifdef NS_IMPL_COCOA - IBOutlet NSButton *smoothFontsCheck; - IBOutlet NSButton *useQuickdrawCheck; - IBOutlet NSButton *useSysHiliteCheck; - BOOL prevUseHighlightColor; -#endif - float prevExpandSpace; - float prevBlinkRate; -} -- (IBAction)cancel: (id)sender; -- (IBAction)ok: (id)sender; -- (IBAction)resetToDefaults: (id)sender; -- (IBAction)runHelp: (id)sender; -- (IBAction)setColors: (id)sender; -- (IBAction)setDefaultFont: (id)sender; - -- (void) showForFrame: (struct frame *)f; -- (void) setPanelFromValues; -- (void) setValuesFromPanel; -@end - extern NSArray *ns_send_types, *ns_return_types; -extern EmacsMenu *mainMenu, *svcsMenu; +extern NSString *ns_app_name; +extern EmacsMenu *mainMenu, *svcsMenu, *dockMenu; /* Apple removed the declaration, but kept the implementation */ -#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 @interface NSApplication (EmacsApp) - (void)setAppleMenu: (NSMenu *)menu; @end #endif +#ifndef NS_HAVE_NSINTEGER +#if defined(__LP64__) && __LP64__ +typedef double CGFloat; +typedef long NSInteger; +typedef unsigned long NSUInteger; +#else +typedef float CGFloat; +typedef int NSInteger; +typedef unsigned int NSUInteger; +#endif /* not LP64 */ +#endif /* not NS_HAVE_NSINTEGER */ + #endif /* __OBJC__ */ @@ -368,15 +352,21 @@ extern EmacsMenu *mainMenu, *svcsMenu; ========================================================================== */ -enum ns_cursor_types -{ - no_highlight =0, - filled_box, - hollow_box, - underscore, - bar -}; - +/* Special keycodes that we pass down the event chain */ +#define KEY_NS_POWER_OFF ((1<<28)|(0<<16)|1) +#define KEY_NS_OPEN_FILE ((1<<28)|(0<<16)|2) +#define KEY_NS_OPEN_TEMP_FILE ((1<<28)|(0<<16)|3) +#define KEY_NS_DRAG_FILE ((1<<28)|(0<<16)|4) +#define KEY_NS_DRAG_COLOR ((1<<28)|(0<<16)|5) +#define KEY_NS_DRAG_TEXT ((1<<28)|(0<<16)|6) +#define KEY_NS_CHANGE_FONT ((1<<28)|(0<<16)|7) +#define KEY_NS_OPEN_FILE_LINE ((1<<28)|(0<<16)|8) +#define KEY_NS_PUT_WORKING_TEXT ((1<<28)|(0<<16)|9) +#define KEY_NS_UNPUT_WORKING_TEXT ((1<<28)|(0<<16)|10) +#define KEY_NS_SPI_SERVICE_CALL ((1<<28)|(0<<16)|11) +#define KEY_NS_NEW_FRAME ((1<<28)|(0<<16)|12) +#define KEY_NS_TOGGLE_TOOLBAR ((1<<28)|(0<<16)|13) +#define KEY_NS_SHOW_PREFS ((1<<28)|(0<<16)|14) /* could use list to store these, but rest of emacs has a big infrastructure for managing a table of bitmap "records" */ @@ -447,7 +437,7 @@ struct nsfont_info char bold, ital; /* convenience flags */ char synthItal; float voffset; /* mean of ascender/descender offsets */ - XCharStruct max_bounds; /* 23 */ + XCharStruct max_bounds; /* we compute glyph codes and metrics on-demand in blocks of 256 indexed by hibyte, lobyte */ unsigned short **glyphs; /* map unicode index to glyph */ @@ -477,73 +467,46 @@ struct ns_display_info /* Minimum font height over all fonts in font_table. */ int smallest_font_height; - struct kboard *kboard; - - /*/23 */ struct ns_bitmap_record *bitmaps; int bitmaps_size; int bitmaps_last; - /* 23 */ struct image_cache *image_cache; struct ns_color_table *color_table; - /* 23: Dimensions and DPI resolution of this screen */ - int height, width; + /* DPI resolution of this screen */ double resx, resy; - /* 23: Mask of things that cause the mouse to be grabbed */ + /* Mask of things that cause the mouse to be grabbed */ int grabbed; - /* 23 */ int n_planes; - /* 23 */ int color_p; - /* 23 */ Window root_window; - /* 23: Xism */ + /* Xism */ XrmDatabase xrdb; - /* 23: The cursor to use for vertical scroll bars. */ + /* The cursor to use for vertical scroll bars. */ Cursor vertical_scroll_bar_cursor; - /* 23: most mouse face stuff moved in here (and reasonably so) */ - int mouse_face_beg_row, mouse_face_beg_col; - int mouse_face_end_row, mouse_face_end_col; - int mouse_face_beg_x, mouse_face_beg_y; - int mouse_face_end_x, mouse_face_end_y; - int mouse_face_past_end; - Lisp_Object mouse_face_window; - int mouse_face_face_id; - int mouse_face_deferred_gc; - Lisp_Object mouse_face_overlay; - FRAME_PTR mouse_face_mouse_frame; - int mouse_face_mouse_x, mouse_face_mouse_y; - int mouse_face_defer; - int mouse_face_hidden; - int mouse_face_image_state; - - /* these are general, but we redefine due to Xism */ - struct frame *ns_highlight_frame; - struct frame *ns_focus_frame; -#define x_highlight_frame ns_highlight_frame -#define x_focus_frame ns_focus_frame + /* Information about the range of text currently shown in + mouse-face. */ + Mouse_HLInfo mouse_highlight; + + struct frame *x_highlight_frame; + struct frame *x_focus_frame; }; /* This is a chain of structures for all the NS displays currently in use. */ -extern struct ns_display_info *ns_display_list; -/* handle Xism */ -#define x_display_list ns_display_list +extern struct ns_display_info *x_display_list; extern Lisp_Object ns_display_name_list; extern struct ns_display_info *ns_display_info_for_name (); -/* 23: FIXME: these functions (we defined in nsfns) are used in various - places, but no prototypes are provided */ struct ns_display_info *check_x_display_info (Lisp_Object frame); FRAME_PTR check_x_frame (Lisp_Object frame); @@ -553,22 +516,20 @@ struct ns_output #ifdef __OBJC__ EmacsView *view; id miniimage; - NSColor *current_cursor_color; - NSColor *desired_cursor_color; + NSColor *cursor_color; NSColor *foreground_color; NSColor *background_color; EmacsToolbar *toolbar; #else void *view; void *miniimage; - void *current_cursor_color; - void *desired_cursor_color; + void *cursor_color; void *foreground_color; void *background_color; void *toolbar; #endif - /* 23: NSCursors init'ed in initFrameFromEmacs */ + /* NSCursors init'ed in initFrameFromEmacs */ Cursor text_cursor; Cursor nontext_cursor; Cursor modeline_cursor; @@ -576,10 +537,10 @@ struct ns_output Cursor hourglass_cursor; Cursor horizontal_drag_cursor; - /* 23: NS-specific */ + /* NS-specific */ Cursor current_pointer; - /* 23: lord knows why Emacs needs to know about our Window ids.. */ + /* lord knows why Emacs needs to know about our Window ids.. */ Window window_desc, parent_desc; char explicit_parent; @@ -592,8 +553,6 @@ struct ns_output Lisp_Object icon_top; Lisp_Object icon_left; - enum ns_cursor_types current_cursor, desired_cursor; - unsigned char last_inactive; /* The size of the extra width currently allotted for vertical scroll bars, in pixels. */ @@ -607,9 +566,15 @@ struct ns_output /* This is the Emacs structure for the NS display this frame is on. */ struct ns_display_info *display_info; + + /* Non-zero if we want to constrain the frame to the screen. */ + int dont_constrain; + + /* Non-zero if we are zooming (maximizing) the frame. */ + int zooming; }; -/* 23: this dummy decl now needed to support TTYs */ +/* this dummy decl needed to support TTYs */ struct x_output { unsigned long background_pixel; @@ -637,7 +602,7 @@ struct x_output #define NS_FACE_FOREGROUND(f) ((f)->foreground) #define NS_FACE_BACKGROUND(f) ((f)->background) #define FRAME_NS_TITLEBAR_HEIGHT(f) ((f)->output_data.ns->titlebar_height) -#define FRAME_NS_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height) +#define FRAME_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height) #define FONT_WIDTH(f) ((f)->max_width) #define FONT_HEIGHT(f) ((f)->height) @@ -649,12 +614,8 @@ struct x_output #define FRAME_DEFAULT_FACE(f) FACE_FROM_ID (f, DEFAULT_FACE_ID) #define FRAME_NS_VIEW(f) ((f)->output_data.ns->view) -#define FRAME_CURSOR(f) ((f)->output_data.ns->current_cursor) -#define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->current_cursor_color) -#define FRAME_NEW_CURSOR_COLOR(f) ((f)->output_data.ns->desired_cursor_color) -#define FRAME_NEW_CURSOR(f) ((f)->output_data.ns->desired_cursor) +#define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->cursor_color) #define FRAME_POINTER_TYPE(f) ((f)->output_data.ns->current_pointer) -#define FRAME_LAST_INACTIVE(f) ((f)->output_data.ns->last_inactive) #define FRAME_FONT(f) ((f)->output_data.ns->font) @@ -690,7 +651,6 @@ struct x_output #define FRAME_FONTSET(f) ((f)->output_data.ns->fontset) -/* 23 */ #define FRAME_SMALLEST_CHAR_WIDTH(f) \ (FRAME_NS_DISPLAY_INFO (f)->smallest_char_width) #define FRAME_SMALLEST_FONT_HEIGHT(f) \ @@ -726,7 +686,7 @@ extern void nsfont_make_fontset_for_font (Lisp_Object name, /* In nsfont, for debugging */ struct glyph_string; -void dump_glyphstring (struct glyph_string *s); +void ns_dump_glyphstring (struct glyph_string *s); /* Implemented in nsterm, published in or needed from nsfns. */ extern Lisp_Object Qfontsize; @@ -734,10 +694,6 @@ extern Lisp_Object ns_list_fonts (FRAME_PTR f, Lisp_Object pattern, int size, int maxnames); extern void ns_clear_frame (struct frame *f); -#ifdef __OBJC__ -extern const char *ns_font_to_xlfd (NSFont *font); -#endif -extern const char *ns_fontname_to_xlfd (const char *name); extern const char *ns_xlfd_to_fontname (const char *xlfd); extern void check_ns (void); @@ -748,12 +704,16 @@ extern void nxatoms_of_nsselect (); extern int ns_lisp_to_cursor_type (); extern Lisp_Object ns_cursor_type_to_lisp (int arg); extern Lisp_Object Qnone; +extern void ns_set_name_as_filename (struct frame *f); +extern void ns_set_doc_edited (struct frame *f, Lisp_Object arg); -/* XColor defined in dispextern.h (we use color_def->pixel = NSColor id), but - this causes an #include snafu, so we can't declare it. */ extern int -ns_defined_color (struct frame *f, char *name, XColor *color_def, int alloc, +ns_defined_color (struct frame *f, + const char *name, + XColor *color_def, int alloc, char makeIndex); +extern void +ns_query_color (void *col, XColor *color_def, int setPixel); #ifdef __OBJC__ extern Lisp_Object ns_color_to_lisp (NSColor *col); @@ -773,17 +733,41 @@ extern void ns_release_autorelease_pool (); extern void update_frame_tool_bar (FRAME_PTR f); extern void free_frame_tool_bar (FRAME_PTR f); extern void find_and_call_menu_selection (FRAME_PTR f, - EMACS_INT menu_bar_items_used, Lisp_Object vector, void *client_data); + int menu_bar_items_used, Lisp_Object vector, void *client_data); extern Lisp_Object find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data); extern Lisp_Object ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header); -/* two more prototypes that should be moved to a more general include file */ +/* More prototypes that should be moved to a more general include file */ extern void set_frame_menubar (struct frame *f, int first_time, int deep_p); extern void x_set_window_size (struct frame *f, int change_grav, int cols, int rows); +extern void x_sync (struct frame *); +extern Lisp_Object x_get_focus_frame (struct frame *); +extern void x_set_mouse_position (struct frame *f, int h, int v); +extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y); +extern void x_make_frame_visible (struct frame *f); +extern void x_make_frame_invisible (struct frame *f); +extern void x_iconify_frame (struct frame *f); +extern int x_char_width (struct frame *f); +extern int x_char_height (struct frame *f); +extern int x_pixel_width (struct frame *f); +extern int x_pixel_height (struct frame *f); +extern void x_set_frame_alpha (struct frame *f); +extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object); +extern void x_set_tool_bar_lines (struct frame *f, + Lisp_Object value, + Lisp_Object oldval); +extern void x_activate_menubar (struct frame *); +extern void free_frame_menubar (struct frame *); + +extern void ns_init_paths (void); +extern void syms_of_nsterm (void); +extern void syms_of_nsfns (void); +extern void syms_of_nsmenu (void); +extern void syms_of_nsselect (void); /* From nsimage.m, needed in image.c */ struct image; @@ -798,7 +782,12 @@ extern unsigned long ns_get_pixel (void *img, int x, int y); extern void ns_put_pixel (void *img, int x, int y, unsigned long argb); extern void ns_set_alpha (void *img, int x, int y, unsigned char a); +extern int x_display_pixel_height (struct ns_display_info *); +extern int x_display_pixel_width (struct ns_display_info *); + /* This in nsterm.m */ +extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, struct timeval *timeout); extern unsigned long ns_get_rgb_color (struct frame *f, float r, float g, float b, float a); extern NSPoint last_mouse_motion_position; @@ -824,11 +813,9 @@ extern char gnustep_base_version[]; /* version tracking */ ? (min) : (((x)>(max)) ? (max) : (x))) #define SCREENMAXBOUND(x) (IN_BOUND (-SCREENMAX, x, SCREENMAX)) -/* 23: needed somewhere... */ +/* needed somewhere... */ #define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0) #endif /* HAVE_NS */ -/* arch-tag: 0a28b142-4ac1-4a81-a243-abcd82d9c4e5 - (do not change this comment) */