(font-show-log): Add optional arg N to control the limit of font
[bpt/emacs.git] / src / nsterm.m
index f8000b9..3fb9905 100644 (file)
@@ -78,6 +78,7 @@ int term_trace_num = 0;
 #define KEY_NS_INSERT_WORKING_TEXT     ((1<<28)|(0<<16)|9)
 #define KEY_NS_DELETE_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)
 
 /* Convert a symbol indexed with an NSxxx value to a value as defined
    in keyboard.c (lispy_function_key). I hope this is a correct way
@@ -1458,17 +1459,13 @@ ns_get_color (const char *name, NSColor **col)
     NSEnumerator *lenum, *cenum;
     NSString *name;
     NSColorList *clist;
+
 #ifdef NS_IMPL_GNUSTEP
     /* XXX: who is wrong, the requestor or the implementation? */
     if ([nsname compare: @"Highlight" options: NSCaseInsensitiveSearch]
         == NSOrderedSame)
       nsname = @"highlightColor";
 #endif
-    if ([nsname compare: @"dark blue" options: NSCaseInsensitiveSearch]
-        == NSOrderedSame
-      || [nsname compare: @"darkblue" options: NSCaseInsensitiveSearch]
-        == NSOrderedSame)
-      nsname = @"navy blue";
 
     lenum = [[NSColorList availableColorLists] objectEnumerator];
     while ( (clist = [lenum nextObject]) && new == nil)
@@ -3884,6 +3881,7 @@ ns_term_init (Lisp_Object display_name)
     appMenu = [[EmacsMenu alloc] initWithTitle: @"Emacs"];
     [appMenu setAutoenablesItems: NO];
     mainMenu = [[EmacsMenu alloc] initWithTitle: @""];
+    dockMenu = [[EmacsMenu alloc] initWithTitle: @""];
 
     [appMenu insertItemWithTitle: @"About Emacs"
                           action: @selector (orderFrontStandardAboutPanel:)
@@ -3922,6 +3920,10 @@ ns_term_init (Lisp_Object display_name)
                            keyEquivalent: @""
                                  atIndex: 0];
     [mainMenu setSubmenu: appMenu forItem: item];
+    [dockMenu insertItemWithTitle: @"New Frame"
+                          action: @selector (newFrame:)
+                   keyEquivalent: @""
+                         atIndex: 0];
 
     [NSApp setMainMenu: mainMenu];
     [NSApp setAppleMenu: appMenu];
@@ -4030,6 +4032,20 @@ ns_term_shutdown (int sig)
 }
 
 
+- (void)newFrame: (id)sender
+{
+  struct frame *emacsframe = SELECTED_FRAME ();
+  NSEvent *theEvent = [NSApp currentEvent];
+
+  if (!emacs_event)
+    return;
+  emacs_event->kind = NON_ASCII_KEYSTROKE_EVENT;
+  emacs_event->code = KEY_NS_NEW_FRAME;
+  emacs_event->modifiers = 0;
+  EV_TRAILER (theEvent);
+}
+
+
 /* Open a file (used by below, after going into queue read by ns_read_socket) */
 - (BOOL) openFile: (NSString *)fileName
 {
@@ -4141,6 +4157,14 @@ fprintf (stderr, "res = %d\n", EQ (res, Qt)); /* FIXME */
 
 }
 
+
+/* Handle dock menu requests.  */
+- (NSMenu *)applicationDockMenu: (NSApplication *) sender
+{
+  return dockMenu;
+}
+
+
 /* TODO: these may help w/IO switching btwn terminal and NSApp */
 - (void)applicationDidBecomeActive: (NSNotification *)notification
 {
@@ -4645,17 +4669,10 @@ if (NS_KEYLOG) NSLog (@"firstRectForCharRange request");
   return rect;
 }
 
-#ifdef NS_IMPL_GNUSTEP
-- (long)conversationIdentifier
-{
-  return (long)self;
-}
-#else
 - (NSInteger)conversationIdentifier
 {
   return (NSInteger)self;
 }
-#endif
 
 /* TODO: below here not yet implemented correctly, but may not be needed */
 
@@ -4845,8 +4862,6 @@ if (NS_KEYLOG) NSLog (@"attributedSubstringFromRange request");
 
   NSTRACE (windowShouldClose);
   windowClosing = YES;
-  if (ns_window_num <= 1)
-    return NO;
   if (!emacs_event)
     return NO;
   emacs_event->kind = DELETE_WINDOW_EVENT;
@@ -4954,7 +4969,7 @@ if (NS_KEYLOG) NSLog (@"attributedSubstringFromRange request");
 
   ns_send_appdefined (-1);
 
-  /* The following line causes a crash on GNUstep.  Adrian Roberts
+  /* The following line causes a crash on GNUstep.  Adrian Robert
      says he doesn't remember why he added this line, but removing it
      doesn't seem to cause problems on OSX, either.  */
 #if 0