From e96d3bd1797554a42b848562df0c619c3c953899 Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Fri, 10 Apr 2009 19:05:49 +0200 Subject: [PATCH] Add function to print message queue --- src/MacVim/MMAppController.m | 13 +++---------- src/MacVim/MacVim.h | 10 +++++++++- src/MacVim/MacVim.m | 29 +++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/MacVim/MMAppController.m b/src/MacVim/MMAppController.m index 2dbefa85..0aad826f 100644 --- a/src/MacVim/MMAppController.m +++ b/src/MacVim/MMAppController.m @@ -1148,21 +1148,14 @@ fsEventCallback(ConstFSEventStreamRef streamRef, return; } + //NSLog(@"[%s] QUEUE for identifier=%d: <<< %@>>>", _cmd, identifier, + // debugStringForMessageQueue(queue)); + NSNumber *key = [NSNumber numberWithUnsignedInt:identifier]; NSArray *q = [inputQueues objectForKey:key]; if (q) { q = [q arrayByAddingObjectsFromArray:queue]; [inputQueues setObject:q forKey:key]; - - //NSLog(@"[%s] Appending queue id=%d", _cmd, identifier); -#if 0 // More debug logging info - unsigned i, count = [q count]; - for (i = 0; i < count; i += 2) { - NSData *value = [q objectAtIndex:i]; - int msgid = *((int*)[value bytes]); - NSLog(@" %s", MessageStrings[msgid]); - } -#endif } else { [inputQueues setObject:queue forKey:key]; } diff --git a/src/MacVim/MacVim.h b/src/MacVim/MacVim.h index 0a93c1d4..0f0b791e 100644 --- a/src/MacVim/MacVim.h +++ b/src/MacVim/MacVim.h @@ -101,7 +101,7 @@ extern char *MessageStrings[]; enum { - OpenWindowMsgID = 1, + OpenWindowMsgID = 1, // NOTE: FIRST IN ENUM MUST BE 1 InsertTextMsgID, KeyDownMsgID, CmdKeyMsgID, @@ -173,6 +173,7 @@ enum { DeactivateKeyScriptID, BrowseForFileMsgID, ShowDialogMsgID, + LastMsgID // NOTE: MUST BE LAST MESSAGE IN ENUM! }; @@ -211,6 +212,13 @@ enum { MMTabInfoCount }; + +// Create a string holding the labels of all messages in message queue for +// debugging purposes (condense some messages since there may typically be LOTS +// of them on a queue). +NSString *debugStringForMessageQueue(NSArray *queue); + + // Argument used to stop MacVim from opening an empty window on startup // (techincally this is a user default but should not be used as such). extern NSString *MMNoWindowKey; diff --git a/src/MacVim/MacVim.m b/src/MacVim/MacVim.m index 93a9d1ba..a40b93f5 100644 --- a/src/MacVim/MacVim.m +++ b/src/MacVim/MacVim.m @@ -88,6 +88,7 @@ char *MessageStrings[] = "DeactivateKeyScriptID", "BrowseForFileMsgID", "ShowDialogMsgID", + "END OF MESSAGE IDs" // NOTE: Must be last! }; @@ -102,6 +103,34 @@ NSString *VimPBoardType = @"VimPBoardType"; +// Create a string holding the labels of all messages in message queue for +// debugging purposes (condense some messages since there may typically be LOTS +// of them on a queue). + NSString * +debugStringForMessageQueue(NSArray *queue) +{ + NSMutableString *s = [NSMutableString new]; + unsigned i, count = [queue count]; + int item = 0, menu = 0, enable = 0; + for (i = 0; i < count; i += 2) { + NSData *value = [queue objectAtIndex:i]; + int msgid = *((int*)[value bytes]); + if (msgid < 1 || msgid >= LastMsgID) + continue; + if (msgid == AddMenuItemMsgID) ++item; + else if (msgid == AddMenuMsgID) ++menu; + else if (msgid == EnableMenuItemMsgID) ++enable; + else [s appendFormat:@"%s ", MessageStrings[msgid]]; + } + if (item > 0) [s appendFormat:@"AddMenuItemMsgID(%d) ", item]; + if (menu > 0) [s appendFormat:@"AddMenuMsgID(%d) ", menu]; + if (enable > 0) [s appendFormat:@"EnableMenuItemMsgID(%d) ", enable]; + + return [s autorelease]; +} + + + @implementation NSString (MMExtras) -- 2.11.4.GIT