Compare commits

...

24 Commits

Author SHA1 Message Date
Bjorn Winckler e4abcd6741 Snapshot 42 2009-01-12 16:35:09 +01:00
Bjorn Winckler b0f34cac04 Update appcast 2009-01-10 21:09:43 +01:00
Bjorn Winckler dd243c8ab1 Snapshot 41 2009-01-10 20:57:33 +01:00
Bjorn Winckler 02592cfe41 Prune draw queue before sending to frontend
If the draw queue fills up with lots (i.e. twice the number of max rows)
of insert/delete line commands we can remove draw commands from the
beginning of the draw queue.  This reduces the possibility of the draw
queue overflowing.
2009-01-10 17:39:29 +01:00
Bjorn Winckler e706fca4d6 Cmd-. sends SIGINT
Ctrl-C does not always work to interrupt a stuck Vim process. By making
Cmd-. send SIGINT it is more likely to succeed where Ctrl-C has failed.
(E.g. Ctrl-C may fail if a DO message is dropped, or if the Vim process
is stuck in a loop and isn't checking for new input.)
2009-01-10 17:38:11 +01:00
Bjorn Winckler 8d00a30b0a Show output from external commands as it happens
Previously, all output was sent to the frontend at once so only the last
few rows were visible.  This was a bit disconcerting when a command took
a bit of time because there was no feedback that anything was happening.
The downside to this patch is that it takes a bit longer for a command
to finish since the frontend has to do more drawing.
2009-01-10 17:37:49 +01:00
Bjorn Winckler 76200b7c03 Allow interrupt during external commands 2009-01-08 21:25:37 +01:00
Bjorn Winckler e648d3b011 Don't ignore SIGCHLD (fix automatic updating)
Ignoring SIGCHLD caused problems with automatic updating (Sparkle) since
it uses popen() (and hence implicitly uses wait4()) to unpack archives.
Now that SIGCHLD is no longer ignored we have to reap child processes
after exiting a Vim process as well as when MacVim is about to
terminate.
2009-01-08 16:11:30 +01:00
Bjorn Winckler 1db4b7903b Make no DO calls during app termination 2009-01-07 21:01:47 +01:00
Bjorn Winckler e5e129b933 Prune unnecessary code, clarify comment 2009-01-07 20:19:44 +01:00
Bjorn Winckler 354968a9b9 Add comment 2009-01-07 20:16:01 +01:00
Bjorn Winckler 87e4ef758b Clean up process termination code
Exiting immediately on TerminateNowMsgID simplifies the code a bit and
also minimizes the probability of a process not terminating before
MacVim.
2009-01-07 20:14:03 +01:00
Bjorn Winckler 2b721c9e9c New user default MMLoadDefaultFont
When enabled the default font is loaded from within the app bundle each
time MacVim is started (the default setting).  Startup times are shorter
if this is disabled.  Note that if the default font has already been
installed on the system then this may as well be disabled.
2009-01-07 14:19:27 +01:00
Bjorn Winckler c50143db47 Fix deprecated API compiler warning 2009-01-06 22:05:50 +01:00
Bjorn Winckler 2153ab22d7 Don't load default font in Vim (faster startup)
Loading and unloading a font can take a substantial amount of time so
this cuts down on the startup time.
2009-01-06 21:41:47 +01:00
Bjorn Winckler aefc975f1b Fix compiler issues on Tiger 2009-01-06 22:58:38 +01:00
Bjorn Winckler 79851d47b1 Build Debug and Release using default SDK
The Universal target still builds using the 10.4u SDK.
2009-01-06 17:51:36 +01:00
Bjorn Winckler 2c9f69f2bf Fix double free memory problem
This bug was introduced in commit:
    e162109d6f022942edb7281736f587ee79e20bfe
2009-01-06 18:31:38 +01:00
Bjorn Winckler 462fb78a85 Deprecate "redr|f" in addInput: calls
The previous commit ensures these are no longer neeeded (they used to be
there to avoid the "Press ENTER..." prompt).
2009-01-04 22:13:48 +01:00
Bjorn Winckler d2dbd62e7b Avoid "Press ENTER..." prompt
When adding input programmatically the 'silent' flag is automatically
set.  Hopefully this will mean the end of the annoying "Press ENTER..."
prompt.  This also means that it should no longer be necessary to
manually try to make commands silent (e.g. ":redr|f" should not be
needed).
2009-01-04 21:44:27 +01:00
Bjorn Winckler e1c4adc8c9 Add user default to toggle the "add tab" button
The user default MMShowAddTabButton controls whether the "add tab"
button is displayed on the tab bar or not.
2009-01-04 17:58:57 +01:00
Bjorn Winckler 2ffc552c25 Avoid switching Spaces when using 'mvim' 2009-01-04 17:46:48 +01:00
Nico Weber 7845992803 Toggle menu bar on focus change in full-screen 2009-01-02 13:55:11 -08:00
Nico Weber 1eb73428b0 Icon generation works on Tiger again 2008-12-30 23:36:50 -08:00
24 changed files with 568 additions and 326 deletions
+8 -4
View File
@@ -1,4 +1,4 @@
*gui_mac.txt* For Vim version 7.2. Last change: 2008 Oct 25
*gui_mac.txt* For Vim version 7.2. Last change: 2009 Jan 08
VIM REFERENCE MANUAL by Bjorn Winckler
@@ -260,9 +260,11 @@ Here is a list of relevant dictionary entries:
KEY VALUE ~
MMCellWidthMultiplier width of a normal glyph in em units [float]
MMDialogsTrackPwd open/save dialogs track the Vim pwd [bool]
MMLoadDefaultFont load font (disable for faster startup) [bool]
MMLoginShellArgument login shell parameter [string]
MMLoginShellCommand which shell to use to launch Vim [string]
MMNoFontSubstitution disable automatic font substitution [bool]
MMShowAddTabButton enable "add tab" button on tabline [bool]
MMTabMaxWidth maximum width of a tab [int]
MMTabMinWidth minimum width of a tab [int]
MMTabOptimumWidth default width of a tab [int]
@@ -561,9 +563,11 @@ discovered by looking through the menus (see |macvim-menus| on how to create
your own menu shortcuts). The remaining shortcuts are listed here:
*Cmd-.* *<D-.>*
Cmd-. Interrupt Vim. This is synonymous with CTRL-C and can
hence be used instead of Esc to exit insert mode (in
case you find Esc a bit hard to reach).
Cmd-. Interrupt Vim. Unlike Ctrl-C which is sent as normal
keyboard input (and hence has to be received and then
interpreted) this sends a SIGINT signal to the Vim
process. Use this shortcut if the Vim process appears
to have locked up and is not responding to key presses.
*Cmd-`* *<D-`>*
Cmd-` Cycle to the next window. On an American keyboard the
+1 -1
View File
@@ -1153,7 +1153,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>40</string>
<string>42</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
+1
View File
@@ -28,6 +28,7 @@
NSMutableArray *cachedVimControllers;
int preloadPid;
BOOL shouldActivateWhenNextWindowOpens;
int numChildProcesses;
#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4)
FSEventStreamRef fsEventStream;
+151 -53
View File
@@ -61,10 +61,6 @@ static NSTimeInterval MMReplyTimeout = 5;
static NSString *MMWebsiteString = @"http://code.google.com/p/macvim/";
// When terminating, notify Vim processes then sleep for these many
// microseconds.
static useconds_t MMTerminationSleepPeriod = 10000;
#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4)
// Latency (in s) between FS event occuring and being reported to MacVim.
// Should be small so that MacVim is notified of changes to the ~/.vim
@@ -86,8 +82,6 @@ typedef struct
#pragma options align=reset
static int executeInLoginShell(NSString *path, NSArray *args);
@interface MMAppController (MMServices)
- (void)openSelection:(NSPasteboard *)pboard userData:(NSString *)userData
@@ -128,6 +122,9 @@ static int executeInLoginShell(NSString *path, NSArray *args);
- (void)startWatchingVimDir;
- (void)stopWatchingVimDir;
- (void)handleFSEvent;
- (void)loadDefaultFont;
- (int)executeInLoginShell:(NSString *)path arguments:(NSArray *)args;
- (void)reapChildProcesses:(id)sender;
#ifdef MM_ENABLE_PLUGINS
- (void)removePlugInMenu;
@@ -154,14 +151,12 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
+ (void)initialize
{
// Avoid zombies (we fork Vim processes which we don't want to wait for).
signal(SIGCHLD, SIG_IGN);
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO], MMNoWindowKey,
[NSNumber numberWithInt:64], MMTabMinWidthKey,
[NSNumber numberWithInt:6*64], MMTabMaxWidthKey,
[NSNumber numberWithInt:132], MMTabOptimumWidthKey,
[NSNumber numberWithBool:YES], MMShowAddTabButtonKey,
[NSNumber numberWithInt:2], MMTextInsetLeftKey,
[NSNumber numberWithInt:1], MMTextInsetRightKey,
[NSNumber numberWithInt:1], MMTextInsetTopKey,
@@ -188,6 +183,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
[NSNumber numberWithBool:NO], MMVerticalSplitKey,
[NSNumber numberWithInt:0], MMPreloadCacheSizeKey,
[NSNumber numberWithInt:0], MMLastWindowClosedBehaviorKey,
[NSNumber numberWithBool:YES], MMLoadDefaultFontKey,
nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dict];
@@ -206,7 +202,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
{
if (!(self = [super init])) return nil;
fontContainerRef = loadFonts();
[self loadDefaultFont];
vimControllers = [NSMutableArray new];
cachedVimControllers = [NSMutableArray new];
@@ -457,14 +453,8 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
// Count the number of open tabs
e = [vimControllers objectEnumerator];
id vc;
while ((vc = [e nextObject])) {
NSString *eval = [vc evaluateVimExpression:@"tabpagenr('$')"];
if (eval) {
int count = [eval intValue];
if (count > 0 && count < INT_MAX)
numTabs += count;
}
}
while ((vc = [e nextObject]))
numTabs += [[vc objectForVimStateKey:@"numTabs"] intValue];
if (numWindows > 1 || numTabs > 1) {
NSAlert *alert = [[NSAlert alloc] init];
@@ -515,17 +505,34 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
if (NSTerminateNow == reply) {
e = [vimControllers objectEnumerator];
id vc;
while ((vc = [e nextObject]))
while ((vc = [e nextObject])) {
//NSLog(@"Terminate pid=%d", [vc pid]);
[vc sendMessage:TerminateNowMsgID data:nil];
}
e = [cachedVimControllers objectEnumerator];
while ((vc = [e nextObject]))
while ((vc = [e nextObject])) {
//NSLog(@"Terminate pid=%d (cached)", [vc pid]);
[vc sendMessage:TerminateNowMsgID data:nil];
}
// Give Vim processes a chance to terminate before MacVim. If they
// haven't terminated by the time applicationWillTerminate: is sent,
// they may be forced to quit (see below).
usleep(MMTerminationSleepPeriod);
// If a Vim process is being preloaded as we quit we have to forcibly
// kill it since we have not established a connection yet.
if (preloadPid > 0) {
//NSLog(@"INCOMPLETE preloaded process: preloadPid=%d", preloadPid);
kill(preloadPid, SIGKILL);
}
// If a Vim process was loading as we quit we also have to kill it.
e = [[pidArguments allKeys] objectEnumerator];
NSNumber *pidKey;
while ((pidKey = [e nextObject])) {
//NSLog(@"INCOMPLETE process: pid=%d", [pidKey intValue]);
kill([pidKey intValue], SIGKILL);
}
// Sleep a little to allow all the Vim processes to exit.
usleep(10000);
}
return reply;
@@ -549,23 +556,41 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
// connection).
[connection invalidate];
// Send a SIGINT to all running Vim processes, so that they are sure to
// receive the connectionDidDie: notification (a process has to be checking
// the run-loop for this to happen).
unsigned i, count = [vimControllers count];
for (i = 0; i < count; ++i) {
MMVimController *controller = [vimControllers objectAtIndex:i];
int pid = [controller pid];
if (-1 != pid)
kill(pid, SIGINT);
}
// Deactivate the font we loaded from the app bundle.
// NOTE: This can take quite a while (~500 ms), so termination will be
// noticeably faster if loading of the default font is disabled.
if (fontContainerRef) {
ATSFontDeactivate(fontContainerRef, NULL, kATSOptionFlagsDefault);
fontContainerRef = 0;
}
[NSApp setDelegate:nil];
// Try to wait for all child processes to avoid leaving zombies behind (but
// don't wait around for too long).
NSDate *timeOutDate = [NSDate dateWithTimeIntervalSinceNow:2];
while ([timeOutDate timeIntervalSinceNow] > 0) {
[self reapChildProcesses:nil];
if (numChildProcesses <= 0)
break;
//NSLog(@"%d processes still left, sleep a bit...", numChildProcesses);
// Run in NSConnectionReplyMode while waiting instead of calling e.g.
// usleep(). Otherwise incoming messages may clog up the DO queues and
// the outgoing TerminateNowMsgID sent earlier never reaches the Vim
// process.
// This has at least one side-effect, namely we may receive the
// annoying "dropping incoming DO message". (E.g. this may happen if
// you quickly hit Cmd-n several times in a row and then immediately
// press Cmd-q, Enter.)
while (CFRunLoopRunInMode((CFStringRef)NSConnectionReplyMode,
0.05, true) == kCFRunLoopRunHandledSource)
; // do nothing
}
if (numChildProcesses > 0)
NSLog(@"%d ZOMBIES left behind", numChildProcesses);
}
+ (MMAppController *)sharedInstance
@@ -607,6 +632,14 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
if (hide)
[NSApp hide:self];
}
// There is a small delay before the Vim process actually exits so wait a
// little before trying to reap the child process. If the process still
// hasn't exited after this wait it won't be reaped until the next time
// reapChildProcesses: is called (but this should be harmless).
[self performSelector:@selector(reapChildProcesses:)
withObject:nil
afterDelay:0.1];
}
- (void)windowControllerWillOpen:(MMWindowController *)windowController
@@ -807,7 +840,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
NSString *input = [NSString stringWithFormat:@"<C-\\><C-N>"
":let oldswb=&swb|let &swb=\"useopen,usetab\"|"
"tab sb %@|let &swb=oldswb|unl oldswb|"
"cal foreground()|redr|f<CR>", firstFile];
"cal foreground()<CR>", firstFile];
[firstController addVimInput:input];
@@ -935,7 +968,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
boolForKey:MMDialogsTrackPwdKey];
if (trackPwd) {
MMVimController *vc = [self keyVimController];
if (vc) dir = [[vc vimState] objectForKey:@"pwd"];
if (vc) dir = [vc objectForVimStateKey:@"pwd"];
}
NSOpenPanel *panel = [NSOpenPanel openPanel];
@@ -1077,7 +1110,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
// MacVim would steal the focus if another app was activated while the
// untitled window was loading.
if (!args || args != [NSNull null])
[NSApp activateIgnoringOtherApps:YES];
[self activateWhenNextWindowOpens];
if (args)
[pidArguments removeObjectForKey:pidKey];
@@ -1272,7 +1305,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
if (useLoginShell) {
// Run process with a login shell, roughly:
// echo "exec Vim -g -f args" | ARGV0=-`basename $SHELL` $SHELL [-l]
pid = executeInLoginShell(path, taskArgs);
pid = [self executeInLoginShell:path arguments:taskArgs];
} else {
// Run process directly:
// Vim -g -f args
@@ -1282,12 +1315,10 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
}
if (-1 != pid) {
// NOTE: If the process has no arguments, then add a null argument to
// the pidArguments dictionary. This is later used to detect that a
// process without arguments is being launched.
if (!args)
[pidArguments setObject:[NSNull null]
forKey:[NSNumber numberWithInt:pid]];
// Add a null argument to the pidArguments dictionary. This is later
// used to detect that a process without arguments is being launched.
[pidArguments setObject:[NSNull null]
forKey:[NSNumber numberWithInt:pid]];
} else {
NSLog(@"WARNING: %s%@ failed (useLoginShell=%d)", _cmd, args,
useLoginShell);
@@ -1523,7 +1554,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
NSEnumerator *e = [vimControllers objectEnumerator];
id vc;
while ((vc = [e nextObject])) {
if ([[[vc vimState] objectForKey:@"unusedEditor"] boolValue])
if ([[vc objectForVimStateKey:@"unusedEditor"] boolValue])
return vc;
}
@@ -1738,6 +1769,14 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
n = count;
while (n-- > 0 && [cachedVimControllers count] > 0)
[cachedVimControllers removeObjectAtIndex:0];
// There is a small delay before the Vim process actually exits so wait a
// little before trying to reap the child process. If the process still
// hasn't exited after this wait it won't be reaped until the next time
// reapChildProcesses: is called (but this should be harmless).
[self performSelector:@selector(reapChildProcesses:)
withObject:nil
afterDelay:0.1];
}
- (void)rebuildPreloadCache
@@ -1877,13 +1916,53 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
[self scheduleVimControllerPreloadAfterDelay:0.5];
}
@end // MMAppController (Private)
- (void)loadDefaultFont
{
// It is possible to set a user default to avoid loading the default font
// (this cuts down on startup time).
if (![[NSUserDefaults standardUserDefaults] boolForKey:MMLoadDefaultFontKey]
|| fontContainerRef)
return;
// Load all fonts in the Resouces folder of the app bundle.
NSString *fontsFolder = [[NSBundle mainBundle] resourcePath];
if (fontsFolder) {
NSURL *fontsURL = [NSURL fileURLWithPath:fontsFolder];
if (fontsURL) {
FSRef fsRef;
CFURLGetFSRef((CFURLRef)fontsURL, &fsRef);
#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4)
// This is the font activation API for OS X 10.5. Only compile
// this code if we're building on OS X 10.5 or later.
if (NULL != ATSFontActivateFromFileReference) { // Weakly linked
ATSFontActivateFromFileReference(&fsRef, kATSFontContextLocal,
kATSFontFormatUnspecified,
NULL, kATSOptionFlagsDefault,
&fontContainerRef);
}
#endif
#if (MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4)
// The following font activation API was deprecated in OS X 10.5.
// Don't compile this code unless we're targeting OS X 10.4.
FSSpec fsSpec;
if (fontContainerRef == 0 &&
FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL, NULL,
&fsSpec, NULL) == noErr) {
ATSFontActivateFromFileSpecification(&fsSpec,
kATSFontContextLocal, kATSFontFormatUnspecified, NULL,
kATSOptionFlagsDefault, &fontContainerRef);
}
#endif
}
}
if (!fontContainerRef)
NSLog(@"WARNING: Failed to activate the default font (the app bundle "
"may be incomplete)");
}
static int
executeInLoginShell(NSString *path, NSArray *args)
- (int)executeInLoginShell:(NSString *)path arguments:(NSArray *)args
{
// Start a login shell and execute the command 'path' with arguments 'args'
// in the shell. This ensures that user environment variables are set even
@@ -1955,10 +2034,6 @@ executeInLoginShell(NSString *path, NSArray *args)
} else if (pid == 0) {
// Child process
// We need to undo our zombie avoidance as Vim waits for and needs
// the exit statuses of processes it spawns.
signal(SIGCHLD, SIG_DFL);
if (close(ds[1]) == -1) exit(255);
if (dup2(ds[0], 0) == -1) exit(255);
@@ -1982,7 +2057,30 @@ executeInLoginShell(NSString *path, NSArray *args)
if (write(ds[1], [input UTF8String], bytes) != bytes) return -1;
if (close(ds[1]) == -1) return -1;
++numChildProcesses;
//NSLog(@"new process pid=%d (count=%d)", pid, numChildProcesses);
}
return pid;
}
- (void)reapChildProcesses:(id)sender
{
// NOTE: numChildProcesses (currently) only counts the number of Vim
// processes that have been started with executeInLoginShell::. If other
// processes are spawned this code may need to be adjusted (or
// numChildProcesses needs to be incremented when such a process is
// started).
while (numChildProcesses > 0) {
int status = 0;
int pid = waitpid(-1, &status, WNOHANG);
if (pid <= 0)
break;
//NSLog(@"WAIT for pid=%d complete", pid);
--numChildProcesses;
}
}
@end // MMAppController (Private)
+9
View File
@@ -892,10 +892,19 @@ defaultLineHeightForFont(NSFont *font)
return NSNotFound;
}
// The return type of this message changed with OS X 10.5 so we need this
// kludge in order to avoid compiler warnings on OS X 10.4.
#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4)
- (NSInteger)conversationIdentifier
{
return (NSInteger)self;
}
#else
- (long)conversationIdentifier
{
return (long)self;
}
#endif
- (NSRange)selectedRange
{
+4 -4
View File
@@ -41,12 +41,13 @@
NSMutableDictionary *clientProxyDict;
NSMutableDictionary *serverReplyDict;
NSString *alternateServerName;
ATSFontContainerRef fontContainerRef;
NSFont *oldWideFont;
GuiFont oldWideFont;
BOOL isTerminating;
BOOL waitForAck;
int initialWindowLayout;
BOOL flushDisabled;
unsigned numWholeLineChanges;
unsigned offsetForDrawDataPrune;
}
+ (MMBackend *)sharedInstance;
@@ -95,8 +96,7 @@
- (void)setScrollbarPosition:(int)pos length:(int)len identifier:(long)ident;
- (void)setScrollbarThumbValue:(long)val size:(long)size max:(long)max
identifier:(long)ident;
- (void)setFont:(NSFont *)font;
- (void)setWideFont:(NSFont *)font;
- (void)setFont:(GuiFont)font wide:(BOOL)wide;
- (void)executeActionWithName:(NSString *)name;
- (void)setMouseShape:(int)shape;
- (void)setBlinkWait:(int)wait on:(int)on off:(int)off;
+147 -101
View File
@@ -51,13 +51,6 @@ static int eventModifierFlagsToVimModMask(int modifierFlags);
static int eventModifierFlagsToVimMouseModMask(int modifierFlags);
static int eventButtonNumberToVimMouseButton(int buttonNumber);
// Before exiting process, sleep for this many microseconds. This is to allow
// any distributed object messages in transit to be received by MacVim before
// the process dies (otherwise an error message is logged by Cocoa). Note that
// this delay is only necessary if an NSConnection to MacVim has been
// established.
static useconds_t MMExitProcessDelay = 300000;
// In gui_macvim.m
vimmenu_T *menu_for_descriptor(NSArray *desc);
@@ -77,6 +70,9 @@ static NSString *MMSymlinkWarningString =
"\ta symlink, then your MacVim.app bundle is incomplete.\n\n";
extern GuiFont gui_mch_retain_font(GuiFont font);
@interface NSString (MMServerNameCompare)
- (NSComparisonResult)serverNameCompare:(NSString *)string;
@@ -86,6 +82,8 @@ static NSString *MMSymlinkWarningString =
@interface MMBackend (Private)
- (void)clearDrawData;
- (void)didChangeWholeLine;
- (void)waitForDialogReturn;
- (void)insertVimStateMessage;
- (void)processInputQueue;
@@ -138,8 +136,6 @@ static NSString *MMSymlinkWarningString =
self = [super init];
if (!self) return nil;
fontContainerRef = loadFonts();
outputQueue = [[NSMutableArray alloc] init];
inputQueue = [[NSMutableArray alloc] init];
drawData = [[NSMutableData alloc] initWithCapacity:1024];
@@ -173,7 +169,7 @@ static NSString *MMSymlinkWarningString =
//NSLog(@"%@ %s", [self className], _cmd);
[[NSNotificationCenter defaultCenter] removeObserver:self];
[oldWideFont release]; oldWideFont = nil;
gui_mch_free_font(oldWideFont); oldWideFont = NOFONT;
[blinkTimer release]; blinkTimer = nil;
[alternateServerName release]; alternateServerName = nil;
[serverReplyDict release]; serverReplyDict = nil;
@@ -370,7 +366,7 @@ static NSString *MMSymlinkWarningString =
// Any draw commands in queue are effectively obsolete since this clearAll
// will negate any effect they have, therefore we may as well clear the
// draw queue.
[drawData setLength:0];
[self clearDrawData];
[drawData appendBytes:&type length:sizeof(int)];
}
@@ -402,6 +398,9 @@ static NSString *MMSymlinkWarningString =
[drawData appendBytes:&bottom length:sizeof(int)];
[drawData appendBytes:&left length:sizeof(int)];
[drawData appendBytes:&right length:sizeof(int)];
if (left == 0 && right == gui.num_cols-1)
[self didChangeWholeLine];
}
- (void)drawString:(char*)s length:(int)len row:(int)row column:(int)col
@@ -437,6 +436,9 @@ static NSString *MMSymlinkWarningString =
[drawData appendBytes:&bottom length:sizeof(int)];
[drawData appendBytes:&left length:sizeof(int)];
[drawData appendBytes:&right length:sizeof(int)];
if (left == 0 && right == gui.num_cols-1)
[self didChangeWholeLine];
}
- (void)drawCursorAtRow:(int)row column:(int)col shape:(int)shape
@@ -472,7 +474,7 @@ static NSString *MMSymlinkWarningString =
// Keep running the run-loop until there is no more input to process.
while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true)
== kCFRunLoopRunHandledSource)
;
; // do nothing
}
- (void)flushQueue:(BOOL)force
@@ -485,10 +487,10 @@ static NSString *MMSymlinkWarningString =
if ([drawData length] > 0) {
// HACK! Detect changes to 'guifontwide'.
if (gui.wide_font != (GuiFont)oldWideFont) {
[oldWideFont release];
oldWideFont = [(NSFont*)gui.wide_font retain];
[self setWideFont:oldWideFont];
if (gui.wide_font != oldWideFont) {
gui_mch_free_font(oldWideFont);
oldWideFont = gui_mch_retain_font(gui.wide_font);
[self setFont:oldWideFont wide:YES];
}
int type = SetCursorPosDrawType;
@@ -497,7 +499,7 @@ static NSString *MMSymlinkWarningString =
[drawData appendBytes:&gui.col length:sizeof(gui.col)];
[self queueMessage:BatchDrawMsgID data:[drawData copy]];
[drawData setLength:0];
[self clearDrawData];
}
if ([outputQueue count] > 0) {
@@ -512,8 +514,7 @@ static NSString *MMSymlinkWarningString =
outputQueue);
if (![connection isValid]) {
NSLog(@"WARNING! Connection is invalid, exit now!");
NSLog(@"waitForAck=%d got_int=%d isTerminating=%d",
waitForAck, got_int, isTerminating);
NSLog(@"waitForAck=%d got_int=%d", waitForAck, got_int);
mch_exit(-1);
}
}
@@ -559,21 +560,17 @@ static NSString *MMSymlinkWarningString =
{
// NOTE: This is called if mch_exit() is called. Since we assume here that
// the process has started properly, be sure to use exit() instead of
// mch_exit() to prematurely terminate a process.
// To notify MacVim that this Vim process is exiting we could simply
// invalidate the connection and it would automatically receive a
// connectionDidDie: notification. However, this notification seems to
// take up to 300 ms to arrive which is quite a noticeable delay. Instead
// we immediately send a message to MacVim asking it to close the window
// belonging to this process, and then we invalidate the connection (in
// case the message got lost).
// mch_exit() to prematurely terminate a process (or set 'isTerminating'
// first).
// Make sure no connectionDidDie: notification is received now that we are
// already exiting.
[[NSNotificationCenter defaultCenter] removeObserver:self];
if ([connection isValid]) {
// The 'isTerminating' flag indicates that the frontend is also exiting so
// there is no need to flush any more output since the frontend won't look
// at it anyway.
if (!isTerminating && [connection isValid]) {
@try {
// Flush the entire queue in case a VimLeave autocommand added
// something to the queue.
@@ -584,7 +581,15 @@ static NSString *MMSymlinkWarningString =
NSLog(@"Exception caught when sending CloseWindowMsgID: \"%@\"", e);
}
[connection invalidate];
// NOTE: If Cmd-w was pressed to close the window the menu is briefly
// highlighted and during this pause the frontend won't receive any DO
// messages. If the Vim process exits before this highlighting has
// finished Cocoa will emit the following error message:
// *** -[NSMachPort handlePortMessage:]: dropping incoming DO message
// because the connection or ports are invalid
// To avoid this warning we delay here. If the warning still appears
// this delay may need to be increased.
usleep(150000);
}
#ifdef MAC_CLIENTSERVER
@@ -592,13 +597,6 @@ static NSString *MMSymlinkWarningString =
[[NSConnection defaultConnection] setRootObject:nil];
[[NSConnection defaultConnection] invalidate];
#endif
if (fontContainerRef) {
ATSFontDeactivate(fontContainerRef, NULL, kATSOptionFlagsDefault);
fontContainerRef = 0;
}
usleep(MMExitProcessDelay);
}
- (void)selectTab:(int)index
@@ -834,35 +832,27 @@ static NSString *MMSymlinkWarningString =
[self queueMessage:SetScrollbarThumbMsgID data:data];
}
- (void)setFont:(NSFont *)font
- (void)setFont:(GuiFont)font wide:(BOOL)wide
{
NSString *fontName = [font displayName];
float size = [font pointSize];
int len = [fontName lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
if (len > 0) {
NSMutableData *data = [NSMutableData data];
[data appendBytes:&size length:sizeof(float)];
[data appendBytes:&len length:sizeof(int)];
[data appendBytes:[fontName UTF8String] length:len];
[self queueMessage:SetFontMsgID data:data];
NSString *fontName = (NSString *)font;
float size = 0;
NSArray *components = [fontName componentsSeparatedByString:@":"];
if ([components count] == 2) {
size = [[components lastObject] floatValue];
fontName = [components objectAtIndex:0];
}
}
- (void)setWideFont:(NSFont *)font
{
NSString *fontName = [font displayName];
float size = [font pointSize];
int len = [fontName lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
NSMutableData *data = [NSMutableData data];
[data appendBytes:&size length:sizeof(float)];
[data appendBytes:&len length:sizeof(int)];
if (len > 0)
[data appendBytes:[fontName UTF8String] length:len];
else if (!wide)
return; // Only the wide font can be set to nothing
[self queueMessage:SetWideFontMsgID data:data];
[self queueMessage:(wide ? SetWideFontMsgID : SetFontMsgID) data:data];
}
- (void)executeActionWithName:(NSString *)name
@@ -1055,11 +1045,7 @@ static NSString *MMSymlinkWarningString =
// which waits on the run loop will fail to detect this message (e.g. in
// waitForConnectionAcknowledgement).
BOOL shouldClearQueue = NO;
if (InterruptMsgID == msgid) {
shouldClearQueue = YES;
got_int = TRUE;
} else if (InsertTextMsgID == msgid && data != nil) {
if (InsertTextMsgID == msgid && data != nil) {
const void *bytes = [data bytes];
bytes += sizeof(int);
int len = *((int*)bytes); bytes += sizeof(int);
@@ -1067,17 +1053,16 @@ static NSString *MMSymlinkWarningString =
char_u *str = (char_u*)bytes;
if ((str[0] == Ctrl_C && ctrl_c_interrupts) ||
(str[0] == intr_char && intr_char != Ctrl_C)) {
shouldClearQueue = YES;
got_int = TRUE;
[inputQueue removeAllObjects];
return;
}
}
} else if (TerminateNowMsgID == msgid) {
shouldClearQueue = YES;
// Terminate immediately (the frontend is about to quit or this process
// was aborted).
isTerminating = YES;
}
if (shouldClearQueue) {
[inputQueue removeAllObjects];
mch_exit(0);
return;
}
@@ -1236,11 +1221,18 @@ static NSString *MMSymlinkWarningString =
}
- (void)addInput:(in bycopy NSString *)input
client:(in byref id <MMVimClientProtocol>)client
client:(in byref id <MMVimClientProtocol>)client
{
//NSLog(@"addInput:%@ client:%@", input, (id)client);
[self addInput:input];
// NOTE: We don't call addInput: here because it differs from
// server_to_input_buf() in that it always sets the 'silent' flag and we
// don't want the MacVim client/server code to behave differently from
// other platforms.
char_u *s = [input vimStringSave];
server_to_input_buf(s);
vim_free(s);
[self addClient:(id)client];
}
@@ -1449,11 +1441,11 @@ static NSString *MMSymlinkWarningString =
{
if (!waitForAck) return;
while (waitForAck && !got_int && [connection isValid] && !isTerminating) {
while (waitForAck && !got_int && [connection isValid]) {
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
beforeDate:[NSDate distantFuture]];
//NSLog(@" waitForAck=%d got_int=%d isTerminating=%d isValid=%d",
// waitForAck, got_int, isTerminating, [connection isValid]);
//NSLog(@" waitForAck=%d got_int=%d isValid=%d",
// waitForAck, got_int, [connection isValid]);
}
if (waitForAck) {
@@ -1464,7 +1456,6 @@ static NSString *MMSymlinkWarningString =
// NOTE: We intentionally do not call mch_exit() since this in turn
// will lead to -[MMBackend exit] getting called which we want to
// avoid.
usleep(MMExitProcessDelay);
exit(0);
}
@@ -1483,6 +1474,40 @@ static NSString *MMSymlinkWarningString =
@implementation MMBackend (Private)
- (void)clearDrawData
{
[drawData setLength:0];
numWholeLineChanges = offsetForDrawDataPrune = 0;
}
- (void)didChangeWholeLine
{
// It may happen that draw queue is filled up with lots of changes that
// affect a whole row. If the number of such changes equals twice the
// number of visible rows then we can prune some commands off the queue.
//
// NOTE: If we don't perform this pruning the draw queue may grow
// indefinitely if Vim were to repeatedly send draw commands without ever
// waiting for new input (that's when the draw queue is flushed). The one
// instance I know where this can happen is when a command is executed in
// the shell (think ":grep" with thousands of matches).
++numWholeLineChanges;
if (numWholeLineChanges == gui.num_rows) {
// Remember the offset to prune up to.
offsetForDrawDataPrune = [drawData length];
} else if (numWholeLineChanges == 2*gui.num_rows) {
// Delete all the unnecessary draw commands.
NSMutableData *d = [[NSMutableData alloc]
initWithBytes:[drawData bytes] + offsetForDrawDataPrune
length:[drawData length] - offsetForDrawDataPrune];
offsetForDrawDataPrune = [d length];
numWholeLineChanges -= gui.num_rows;
[drawData release];
drawData = d;
}
}
- (void)waitForDialogReturn
{
// Keep processing the run loop until a dialog returns. To avoid getting
@@ -1493,8 +1518,7 @@ static NSString *MMSymlinkWarningString =
// items while a sheet is being displayed, so we can't just wait for the
// first message to arrive and assume that is the setDialogReturn: call.
while (nil == dialogReturn && !got_int && [connection isValid]
&& !isTerminating)
while (nil == dialogReturn && !got_int && [connection isValid])
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
beforeDate:[NSDate distantFuture]];
@@ -1536,12 +1560,16 @@ static NSString *MMSymlinkWarningString =
// to make synchronous calls from MacVim to Vim in order to get state.
BOOL mmta = curbuf ? curbuf->b_p_mmta : NO;
int numTabs = tabpage_index(NULL) - 1;
if (numTabs < 0)
numTabs = 0;
NSDictionary *vimState = [NSDictionary dictionaryWithObjectsAndKeys:
[[NSFileManager defaultManager] currentDirectoryPath], @"pwd",
[NSNumber numberWithInt:p_mh], @"p_mh",
[NSNumber numberWithBool:[self unusedEditor]], @"unusedEditor",
[NSNumber numberWithBool:mmta], @"p_mmta",
[NSNumber numberWithInt:numTabs], @"numTabs",
nil];
// Put the state before all other messages.
@@ -1982,19 +2010,15 @@ static NSString *MMSymlinkWarningString =
- (void)connectionDidDie:(NSNotification *)notification
{
// If the main connection to MacVim is lost this means that MacVim was
// either quit (by the user chosing Quit on the MacVim menu), or it has
// crashed. In the former case the flag 'isTerminating' is set and we then
// quit cleanly; in the latter case we make sure the swap files are left
// for recovery.
// If the main connection to MacVim is lost this means that either MacVim
// has crashed or this process did not receive its termination message
// properly (e.g. if the TerminateNowMsgID was dropped).
//
// NOTE: This is not called if a Vim controller invalidates its connection.
//NSLog(@"%s isTerminating=%d", _cmd, isTerminating);
if (isTerminating)
getout(0);
else
getout_preserve_modified(1);
NSLog(@"WARNING[%s]: Main connection was lost before process had a chance "
"to terminate; preserving swap files.", _cmd);
getout_preserve_modified(1);
}
- (void)blinkTimerFired:(NSTimer *)timer
@@ -2132,7 +2156,7 @@ static NSString *MMSymlinkWarningString =
bytes += sizeof(unsigned); // len not used
NSMutableString *name = [NSMutableString stringWithUTF8String:bytes];
[name appendString:[NSString stringWithFormat:@":h%.2f", pointSize]];
[name appendString:[NSString stringWithFormat:@":h%d", (int)pointSize]];
char_u *s = (char_u*)[name UTF8String];
#ifdef FEAT_MBYTE
@@ -2413,10 +2437,7 @@ static NSString *MMSymlinkWarningString =
[self addInput:@"|vert sall"];
// Restore the old value of 'suffixes'.
[self addInput:@"|let &su=mvim_oldsu|unlet mvim_oldsu"];
// Adding "|redr|f" ensures a "Hit ENTER" prompt is not shown.
[self addInput:@"|redr|f<CR>"];
[self addInput:@"|let &su=mvim_oldsu|unlet mvim_oldsu<CR>"];
} else {
// When opening one file we try to reuse the current window,
// but not if its buffer is modified or has a filename.
@@ -2447,9 +2468,7 @@ static NSString *MMSymlinkWarningString =
}
[self addInput:cmd];
// Adding "|redr|f" ensures a "Hit ENTER" prompt is not shown.
[self addInput:@"|redr|f<CR>"];
[self addInput:@"<CR>"];
}
// Force screen redraw (does it have to be this complicated?).
@@ -2524,17 +2543,44 @@ static NSString *MMSymlinkWarningString =
- (void)addInput:(NSString *)input
{
char_u *s = (char_u*)[input UTF8String];
// NOTE: This code is essentially identical to server_to_input_buf(),
// except the 'silent' flag is TRUE in the call to ins_typebuf() below.
char_u *string = [input vimStringSave];
if (!string) return;
#ifdef FEAT_MBYTE
s = CONVERT_FROM_UTF8(s);
#endif
/* Set 'cpoptions' the way we want it.
* B set - backslashes are *not* treated specially
* k set - keycodes are *not* reverse-engineered
* < unset - <Key> sequences *are* interpreted
* The last but one parameter of replace_termcodes() is TRUE so that the
* <lt> sequence is recognised - needed for a real backslash.
*/
char_u *ptr = NULL;
char_u *cpo_save = p_cpo;
p_cpo = (char_u *)"Bk";
char_u *str = replace_termcodes((char_u *)string, &ptr, FALSE, TRUE, FALSE);
p_cpo = cpo_save;
server_to_input_buf(s);
if (*ptr != NUL) /* trailing CTRL-V results in nothing */
{
/*
* Add the string to the input stream.
* Can't use add_to_input_buf() here, we now have K_SPECIAL bytes.
*
* First clear typed characters from the typeahead buffer, there could
* be half a mapping there. Then append to the existing string, so
* that multiple commands from a client are concatenated.
*/
if (typebuf.tb_maplen < typebuf.tb_len)
del_typebuf(typebuf.tb_len - typebuf.tb_maplen, typebuf.tb_maplen);
(void)ins_typebuf(str, REMAP_NONE, typebuf.tb_len, TRUE, TRUE);
#ifdef FEAT_MBYTE
CONVERT_FROM_UTF8_FREE(s);
#endif
/* Let input_available() know we inserted text in the typeahead
* buffer. */
typebuf_was_filled = TRUE;
}
vim_free(ptr);
vim_free(string);
}
- (BOOL)unusedEditor
+25 -26
View File
@@ -38,12 +38,10 @@
#define FUOPT_BGCOLOR_HLGROUP 0x004
static int numFullscreenWindows = 0;
@interface MMFullscreenWindow (Private)
- (BOOL)isOnPrimaryScreen;
- (void)hideDockIfAppropriate;
- (void)revealDockIfAppropriate;
- (void)handleWindowDidBecomeMainNotification:(NSNotification *)notification;
- (void)handleWindowDidResignMainNotification:(NSNotification *)notification;
@end
@implementation MMFullscreenWindow
@@ -79,6 +77,18 @@ static int numFullscreenWindows = 0;
[self setBackgroundColor:back];
[self setReleasedWhenClosed:NO];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(handleWindowDidBecomeMainNotification:)
name:NSWindowDidBecomeMainNotification
object:self];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(handleWindowDidResignMainNotification:)
name:NSWindowDidResignMainNotification
object:self];
return self;
}
@@ -86,6 +96,8 @@ static int numFullscreenWindows = 0;
{
LOG_DEALLOC
[[NSNotificationCenter defaultCenter] removeObserver:self];
[target release]; target = nil;
[view release]; view = nil;
@@ -94,8 +106,6 @@ static int numFullscreenWindows = 0;
- (void)enterFullscreen:(int)fuoptions
{
[self hideDockIfAppropriate];
// fade to black
Boolean didBlend = NO;
CGDisplayFadeReservationToken token;
@@ -277,8 +287,6 @@ static int numFullscreenWindows = 0;
CGReleaseDisplayFadeReservation(token);
}
[self revealDockIfAppropriate];
[self autorelease]; // Balance the above retain
}
@@ -347,38 +355,29 @@ static int numFullscreenWindows = 0;
return [self screen] == [screens objectAtIndex:0];
}
- (void)hideDockIfAppropriate
- (void)handleWindowDidBecomeMainNotification:(NSNotification *)notification
{
// Hide menu and dock, both appear on demand.
//
// Don't hide the dock if going fullscreen on a non-primary screen. Also,
// if there are several fullscreen windows on the primary screen, only
// hide dock and friends for the first fullscreen window (and display
// them again after the last fullscreen window has been closed).
//
// Another way to deal with several fullscreen windows would be to hide/
// reveal the dock each time a fullscreen window gets/loses focus, but
// this way it's less distracting.
// reveal the dock only when the first fullscreen window is created and
// show it again after the last one has been closed, but toggling on each
// focus gain/loss works better with Spaces. The downside is that the
// menu bar flashes shortly when switching between two fullscreen windows.
// XXX: If you have a fullscreen window on a secondary monitor and unplug
// the monitor, this will probably not work right.
if ([self isOnPrimaryScreen]) {
if (numFullscreenWindows == 0) {
SetSystemUIMode(kUIModeAllSuppressed, 0); //requires 10.3
}
++numFullscreenWindows;
SetSystemUIMode(kUIModeAllSuppressed, 0); //requires 10.3
}
}
- (void)revealDockIfAppropriate
- (void)handleWindowDidResignMainNotification:(NSNotification *)notification
{
// order menu and dock back in
// order menu and dock back in
if ([self isOnPrimaryScreen]) {
--numFullscreenWindows;
if (numFullscreenWindows == 0) {
SetSystemUIMode(kUIModeNormal, 0);
}
SetSystemUIMode(kUIModeNormal, 0);
}
}
+6 -3
View File
@@ -40,9 +40,12 @@ static void loadSymbols()
}
static CFStringRef ODBEDITOR = CFSTR("org.slashpunt.edit_in_odbeditor");
static CFStringRef ODB_BUNDLE_IDENTIFIER = CFSTR("ODBEditorBundleIdentifier");
static CFStringRef ODB_EDITOR_NAME = CFSTR("ODBEditorName");
// The compiler on OS X 10.4 balks at using CFSTR() for globals so we get
// around with this some ugly type casting.
static CFStringRef ODBEDITOR = (CFStringRef)@"org.slashpunt.edit_in_odbeditor";
static CFStringRef ODB_BUNDLE_IDENTIFIER =
(CFStringRef)@"ODBEditorBundleIdentifier";
static CFStringRef ODB_EDITOR_NAME = (CFStringRef)@"ODBEditorName";
static NSString *ODBEDITOR_DIR =
@"/Library/InputManagers/Edit in ODBEditor";
static NSString *ODBEDITOR_PATH =
+6 -2
View File
@@ -264,10 +264,14 @@ static float MMDragAreaSize = 73.0f;
if ([unmodchars isEqual:@"?"])
return NO;
// Cmd-. is hard-wired to send an interrupt (like Ctrl-C).
// Cmd-. is hard-wired to send SIGINT unlike Ctrl-C which is just another
// key press which Vim has to interpret. This means that Cmd-. always
// works to interrupt a Vim process whereas Ctrl-C can suffer from problems
// such as dropped DO messages (or if Vim is stuck in a loop without
// checking for keyboard input).
if ((flags & NSDeviceIndependentModifierFlagsMask) == NSCommandKeyMask &&
[unmodchars isEqual:@"."]) {
[[self vimController] sendMessage:InterruptMsgID data:nil];
kill([[self vimController] pid], SIGINT);
return YES;
}
+1
View File
@@ -49,6 +49,7 @@
- (NSString *)serverName;
- (MMWindowController *)windowController;
- (NSDictionary *)vimState;
- (id)objectForVimStateKey:(NSString *)key;
- (NSMenu *)mainMenu;
- (BOOL)isPreloading;
- (void)setIsPreloading:(BOOL)yn;
+12 -3
View File
@@ -200,6 +200,11 @@ static BOOL isUnsafeMessage(int msgid);
return vimState;
}
- (id)objectForVimStateKey:(NSString *)key
{
return [vimState objectForKey:key];
}
- (NSMenu *)mainMenu
{
return mainMenu;
@@ -859,10 +864,14 @@ static BOOL isUnsafeMessage(int msgid);
initWithBytes:(void*)bytes length:len
encoding:NSUTF8StringEncoding];
NSFont *font = [NSFont fontWithName:name size:size];
if (!font) {
// This should only happen if the default font was not loaded in
// which case we fall back on using the Cocoa default fixed width
// font.
font = [NSFont userFixedPitchFontOfSize:size];
}
if (font)
[windowController setFont:font];
[windowController setFont:font];
[name release];
} else if (SetWideFontMsgID == msgid) {
const void *bytes = [data bytes];
+3 -3
View File
@@ -88,7 +88,8 @@ enum {
// frameSizeMayHaveChanged.
[self setAutoresizesSubviews:YES];
if ([[NSUserDefaults standardUserDefaults] boolForKey:MMAtsuiRendererKey]) {
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
if ([ud boolForKey:MMAtsuiRendererKey]) {
// Use ATSUI for text rendering.
//
// HACK! 'textView' has type MMTextView, but MMAtsuiTextView is not
@@ -100,7 +101,6 @@ enum {
}
// Allow control of text view inset via MMTextInset* user defaults.
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
int left = [ud integerForKey:MMTextInsetLeftKey];
int top = [ud integerForKey:MMTextInsetTopKey];
[textView setTextContainerInset:NSMakeSize(left, top)];
@@ -129,7 +129,7 @@ enum {
[tabBarControl setCellOptimumWidth:
[ud integerForKey:MMTabOptimumWidthKey]];
[tabBarControl setShowAddTabButton:YES];
[tabBarControl setShowAddTabButton:[ud boolForKey:MMShowAddTabButtonKey]];
[[tabBarControl addTabButton] setTarget:self];
[[tabBarControl addTabButton] setAction:@selector(addNewTab:)];
[tabBarControl setAllowsDragBetweenWindows:NO];
-6
View File
@@ -174,7 +174,6 @@ enum {
SetDocumentFilenameMsgID,
OpenWithArgumentsMsgID,
CloseWindowMsgID,
InterruptMsgID,
SetFullscreenColorMsgID,
ShowFindReplaceDialogMsgID,
FindReplaceMsgID,
@@ -225,11 +224,6 @@ extern NSString *VimPBoardType;
// Loads all fonts in the Resouces folder of the app bundle and returns a font
// container reference (which should be used to deactivate the loaded fonts).
ATSFontContainerRef loadFonts();
@interface NSString (MMExtras)
- (NSString *)stringByEscapingSpecialFilenameCharacters;
-34
View File
@@ -81,7 +81,6 @@ char *MessageStrings[] =
"SetDocumentFilenameMsgID",
"OpenWithArgumentsMsgID",
"CloseWindowMsgID",
"InterruptMsgID",
"SetFullscreenColorMsgID",
"ShowFindReplaceDialogMsgID",
"FindReplaceMsgID",
@@ -100,39 +99,6 @@ NSString *VimPBoardType = @"VimPBoardType";
ATSFontContainerRef
loadFonts()
{
// This loads all fonts from the Resources folder. The fonts are only
// available to the process which loaded them, so loading has to be done
// once for MacVim and an additional time for each Vim process. The
// returned container ref should be used to deactiave the font.
//
// (Code taken from cocoadev.com)
ATSFontContainerRef fontContainerRef = 0;
NSString *fontsFolder = [[NSBundle mainBundle] resourcePath];
if (fontsFolder) {
NSURL *fontsURL = [NSURL fileURLWithPath:fontsFolder];
if (fontsURL) {
FSRef fsRef;
FSSpec fsSpec;
CFURLGetFSRef((CFURLRef)fontsURL, &fsRef);
if (FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL, NULL, &fsSpec,
NULL) == noErr) {
ATSFontActivateFromFileSpecification(&fsSpec,
kATSFontContextLocal, kATSFontFormatUnspecified, NULL,
kATSOptionFlagsDefault, &fontContainerRef);
}
}
}
return fontContainerRef;
}
@implementation NSString (MMExtras)
- (NSString *)stringByEscapingSpecialFilenameCharacters
+5 -5
View File
@@ -737,7 +737,7 @@
i386,
);
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 40;
CURRENT_PROJECT_VERSION = 42;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(FRAMEWORK_SEARCH_PATHS_QUOTED_1)",
@@ -778,7 +778,7 @@
buildSettings = {
ARCHS = "$(NATIVE_ARCH)";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 40;
CURRENT_PROJECT_VERSION = 42;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(FRAMEWORK_SEARCH_PATHS_QUOTED_1)",
@@ -797,7 +797,7 @@
HEADER_SEARCH_PATHS = PSMTabBarControl/source/;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Applications";
MACOSX_DEPLOYMENT_TARGET = 10.4;
MACOSX_DEPLOYMENT_TARGET = "";
PRODUCT_NAME = MacVim;
VERSIONING_SYSTEM = "apple-generic";
WRAPPER_EXTENSION = app;
@@ -810,7 +810,7 @@
buildSettings = {
ARCHS = "$(NATIVE_ARCH)";
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 40;
CURRENT_PROJECT_VERSION = 42;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(FRAMEWORK_SEARCH_PATHS_QUOTED_1)",
@@ -829,7 +829,7 @@
HEADER_SEARCH_PATHS = PSMTabBarControl/source/;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Applications";
MACOSX_DEPLOYMENT_TARGET = 10.4;
MACOSX_DEPLOYMENT_TARGET = "";
PRODUCT_NAME = MacVim;
VERSIONING_SYSTEM = "apple-generic";
WRAPPER_EXTENSION = app;
+2
View File
@@ -26,6 +26,7 @@
extern NSString *MMTabMinWidthKey;
extern NSString *MMTabMaxWidthKey;
extern NSString *MMTabOptimumWidthKey;
extern NSString *MMShowAddTabButtonKey;
extern NSString *MMTextInsetLeftKey;
extern NSString *MMTextInsetRightKey;
extern NSString *MMTextInsetTopKey;
@@ -53,6 +54,7 @@ extern NSString *MMOpenLayoutKey;
extern NSString *MMVerticalSplitKey;
extern NSString *MMPreloadCacheSizeKey;
extern NSString *MMLastWindowClosedBehaviorKey;
extern NSString *MMLoadDefaultFontKey;
// Enum for MMUntitledWindowKey
+2
View File
@@ -17,6 +17,7 @@
NSString *MMTabMinWidthKey = @"MMTabMinWidth";
NSString *MMTabMaxWidthKey = @"MMTabMaxWidth";
NSString *MMTabOptimumWidthKey = @"MMTabOptimumWidth";
NSString *MMShowAddTabButtonKey = @"MMShowAddTabButton";
NSString *MMTextInsetLeftKey = @"MMTextInsetLeft";
NSString *MMTextInsetRightKey = @"MMTextInsetRight";
NSString *MMTextInsetTopKey = @"MMTextInsetTop";
@@ -44,6 +45,7 @@ NSString *MMOpenLayoutKey = @"MMOpenLayout";
NSString *MMVerticalSplitKey = @"MMVerticalSplit";
NSString *MMPreloadCacheSizeKey = @"MMPreloadCacheSize";
NSString *MMLastWindowClosedBehaviorKey = @"MMLastWindowClosedBehavior";
NSString *MMLoadDefaultFontKey = @"MMLoadDefaultFont";
+112 -69
View File
@@ -22,13 +22,13 @@
// NOTE: The default font is bundled with the application.
static NSString *MMDefaultFontName = @"DejaVu Sans Mono";
static float MMDefaultFontSize = 12.0f;
static float MMMinFontSize = 6.0f;
static float MMMaxFontSize = 100.0f;
static int MMDefaultFontSize = 12;
static int MMMinFontSize = 6;
static int MMMaxFontSize = 100;
static BOOL gui_mch_init_has_finished = NO;
static NSFont *gui_macvim_font_with_name(char_u *name);
static GuiFont gui_macvim_font_with_name(char_u *name);
static int specialKeyToNSKey(int key);
static int vimModMaskToEventModifierFlags(int mods);
@@ -189,7 +189,8 @@ gui_mch_update(void)
// interrupt Vim by presssing Ctrl-C during lengthy operations (e.g. after
// entering "10gs" it would not be possible to bring Vim out of the 10 s
// sleep prematurely). As a compromise we check for Ctrl-C only once per
// second.
// second. Note that Cmd-. sends SIGINT so it has higher success rate at
// interrupting Vim.
static CFAbsoluteTime lastTime = 0;
CFAbsoluteTime nowTime = CFAbsoluteTimeGetCurrent();
@@ -210,6 +211,48 @@ gui_mch_flush(void)
}
void
gui_macvim_flush(void)
{
// This function counts how many times it is called and only flushes the
// draw queue if called sufficiently often. The first few times it is
// called it will flush often, but the more it is called the less likely is
// it that anything will be flushed. (The counter resets itself if the
// function isn't called for a second.)
//
// NOTE: Should only be used in loops where it is impossible to know how
// often Vim needs to flush. It was written to handle output from external
// commands (see mch_call_shell() in os_unix.c).
static CFAbsoluteTime lastTime = 0;
static int delay = 1;
static int counter = 0;
static int scrolls = 0;
CFAbsoluteTime nowTime = CFAbsoluteTimeGetCurrent();
CFAbsoluteTime delta = nowTime - lastTime;
if (delta > 1.0)
delay = 1;
// We assume that each call corresponds roughly to one line out output.
// When one page has scrolled by we increase the delay before the next
// flush.
if (++scrolls > gui.num_rows) {
delay <<= 1;
if (delay > 0x10000)
delay = 0x10000;
scrolls = 0;
}
if (++counter > delay) {
gui_macvim_force_flush();
counter = 0;
}
lastTime = nowTime;
}
/* Force flush output to MacVim. Do not call this method unless absolutely
* necessary. */
void
@@ -897,11 +940,18 @@ gui_mch_free_font(font)
{
if (font != NOFONT) {
//NSLog(@"gui_mch_free_font(font=0x%x)", font);
[(NSFont*)font release];
[(id)font release];
}
}
GuiFont
gui_mch_retain_font(GuiFont font)
{
return (GuiFont)[(id)font retain];
}
/*
* Get a font structure for highlighting.
*/
@@ -911,9 +961,9 @@ gui_mch_get_font(char_u *name, int giveErrorIfMissing)
//NSLog(@"gui_mch_get_font(name=%s, giveErrorIfMissing=%d)", name,
// giveErrorIfMissing);
NSFont *font = gui_macvim_font_with_name(name);
if (font)
return (GuiFont)[font retain];
GuiFont font = gui_macvim_font_with_name(name);
if (font != NOFONT)
return font;
if (giveErrorIfMissing)
EMSG2(_(e_font), name);
@@ -925,14 +975,12 @@ gui_mch_get_font(char_u *name, int giveErrorIfMissing)
#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Return the name of font "font" in allocated memory.
* Don't know how to get the actual name, thus use the provided name.
* TODO: use 'font' instead of 'name'?
*/
char_u *
gui_mch_get_fontname(GuiFont font, char_u *name)
{
if (name == NULL)
return NULL;
return vim_strsave(name);
return name ? vim_strsave(name) : NULL;
}
#endif
@@ -952,24 +1000,24 @@ gui_mch_init_font(char_u *font_name, int fontset)
return FAIL;
}
NSFont *font = gui_macvim_font_with_name(font_name);
if (font) {
[(NSFont*)gui.norm_font release];
gui.norm_font = (GuiFont)[font retain];
GuiFont font = gui_macvim_font_with_name(font_name);
if (font == NOFONT)
return FAIL;
// NOTE: MacVim keeps separate track of the normal and wide fonts.
// Unless the user changes 'guifontwide' manually, they are based on
// the same (normal) font. Also note that each time the normal font is
// set, the advancement may change so the wide font needs to be updated
// as well (so that it is always twice the width of the normal font).
[[MMBackend sharedInstance] setFont:font];
[[MMBackend sharedInstance] setWideFont:
(NOFONT == gui.wide_font ? font : (NSFont*)gui.wide_font)];
gui_mch_free_font(gui.norm_font);
gui.norm_font = font;
return OK;
}
// NOTE: MacVim keeps separate track of the normal and wide fonts.
// Unless the user changes 'guifontwide' manually, they are based on
// the same (normal) font. Also note that each time the normal font is
// set, the advancement may change so the wide font needs to be updated
// as well (so that it is always twice the width of the normal font).
[[MMBackend sharedInstance] setFont:font wide:NO];
[[MMBackend sharedInstance] setFont:(NOFONT != gui.wide_font ? gui.wide_font
: font)
wide:YES];
return FAIL;
return OK;
}
@@ -983,63 +1031,58 @@ gui_mch_set_font(GuiFont font)
}
NSFont *
/*
* Return GuiFont in allocated memory. The caller must free it using
* gui_mch_free_font().
*/
GuiFont
gui_macvim_font_with_name(char_u *name)
{
NSFont *font = nil;
NSString *fontName = MMDefaultFontName;
float size = MMDefaultFontSize;
if (!name)
return (GuiFont)[[NSString alloc] initWithFormat:@"%@:%d",
MMDefaultFontName, MMDefaultFontSize];
NSString *fontName = [NSString stringWithVimString:name];
int size = MMDefaultFontSize;
BOOL parseFailed = NO;
#ifdef FEAT_MBYTE
name = CONVERT_TO_UTF8(name);
#endif
if (name) {
fontName = [NSString stringWithUTF8String:(char*)name];
NSArray *components = [fontName componentsSeparatedByString:@":"];
if ([components count] == 2) {
NSString *sizeString = [components lastObject];
if ([sizeString length] > 0
&& [sizeString characterAtIndex:0] == 'h') {
sizeString = [sizeString substringFromIndex:1];
if ([sizeString length] > 0) {
size = [sizeString floatValue];
fontName = [components objectAtIndex:0];
}
} else {
parseFailed = YES;
NSArray *components = [fontName componentsSeparatedByString:@":"];
if ([components count] == 2) {
NSString *sizeString = [components lastObject];
if ([sizeString length] > 0
&& [sizeString characterAtIndex:0] == 'h') {
sizeString = [sizeString substringFromIndex:1];
if ([sizeString length] > 0) {
size = (int)round([sizeString floatValue]);
fontName = [components objectAtIndex:0];
}
} else if ([components count] > 2) {
} else {
parseFailed = YES;
}
} else if ([components count] > 2) {
parseFailed = YES;
}
if (!parseFailed) {
// Replace underscores with spaces.
fontName = [[fontName componentsSeparatedByString:@"_"]
componentsJoinedByString:@" "];
}
if (!parseFailed) {
// Replace underscores with spaces.
fontName = [[fontName componentsSeparatedByString:@"_"]
componentsJoinedByString:@" "];
}
if (!parseFailed && [fontName length] > 0) {
if (size < MMMinFontSize) size = MMMinFontSize;
if (size > MMMaxFontSize) size = MMMaxFontSize;
font = [NSFont fontWithName:fontName size:size];
if (!font && MMDefaultFontName == fontName) {
// If for some reason the MacVim default font is not in the app
// bundle, then fall back on the system default font.
font = [NSFont userFixedPitchFontOfSize:0];
}
// If the default font is requested we don't check if NSFont can load
// it since the font most likely isn't loaded anyway (it may only be
// available to the MacVim binary). If it is not the default font we
// ask NSFont if it can load it.
if ([fontName isEqualToString:MMDefaultFontName]
|| [NSFont fontWithName:fontName size:size])
return [[NSString alloc] initWithFormat:@"%@:%d", fontName, size];
}
#ifdef FEAT_MBYTE
CONVERT_TO_UTF8_FREE(name);
#endif
return font;
return NOFONT;
}
// -- Scrollbars ------------------------------------------------------------
+26 -11
View File
@@ -10,6 +10,7 @@ try:
dont_create = False
except:
dont_create = True # most likely because we're on tiger
NSCompositeSourceOver = 2
import math
import os
@@ -435,7 +436,7 @@ class OfficeTextRenderer(TextRenderer):
text.drawInRect_withAttributes_( ((0, 1), (31, 11)), attribs)
def createIcon(outname, s, bg, textRenderer, text, shorttext=None):
def createIcon(s, bg, textRenderer, text, shorttext=None):
# Fill in background
output = bg.backgroundAtSize(s).copy()
@@ -447,8 +448,7 @@ def createIcon(outname, s, bg, textRenderer, text, shorttext=None):
textRenderer.drawTextAtSize(text, s)
context.done()
# Save
output.save(outname)
return output
def createLinks(icons, target):
@@ -460,6 +460,25 @@ def createLinks(icons, target):
os.symlink(target, icnsName)
def saveIcns(icons, icnsName, makeIcns='./makeicns'):
"""Creates an icns file with several variants.
Params:
icons: A dict that contains icon size as key and Surface as value.
Valid keys are 512, 256, 128, 32, 16
icnsname: Name of the output file
"""
# XXX: Figure out how to call ObjC directly from Python, then this doesn't
# need to call a different process and do lots of i/o.
args = []
for s, icon in icons.items():
assert s in [512, 256, 128, 32, 16]
assert icon.size() == [s, s]
icon.save(TMPFILE % s)
args.append('-%d %s' % (s, TMPFILE % s))
os.system('%s %s -out %s' % (makeIcns, ' '.join(args), icnsName))
TMPFILE = 'make_icons_tmp_%d.png'
sizes = [512, 128, 32, 16]
def main():
@@ -505,18 +524,14 @@ def main():
if size == SMALL:
currSizes = [128, 32, 16]
args = '-128 %s -32 %s -16 %s' % (
TMPFILE % 128, TMPFILE % 32, TMPFILE % 16)
elif size == LARGE:
currSizes = [512, 128, 32, 16]
args = '-512 %s -128 %s -32 %s -16 %s' % (
TMPFILE % 512, TMPFILE % 128, TMPFILE % 32, TMPFILE % 16)
st = shorttext.get(name)
for s in currSizes:
createIcon(TMPFILE % s, s, bgRenderer, textRenderer, text, shorttext=st)
os.system('%s %s -out %s' % (makeIcns, args, icnsName))
icons = [(s, createIcon(s, bgRenderer, textRenderer, text, shorttext=st))
for s in currSizes]
icons = dict(icons)
saveIcns(icons, '%s.icns' % name, makeIcns)
del text, size, name, t
+33
View File
@@ -40,6 +40,39 @@
Sparkle supports updates in zip, tar, tbz, tgz, or dmg format.
-->
<item>
<title>Snapshot 42 released</title>
<description><![CDATA[
<h1>MacVim snapshot 42 released</h1>
<p><b>The automatic updating feature is broken in snapshots 39 and 40. If the automatic updating never finishes extracting then you are affected by this bug and will have to upgrade manually. To do so, simply go to the <a href="http://code.google.com/p/macvim/wiki/Snapshot">Snapshot page</a> to download the latest version.</b></p>
<p> Changes since snapshot 40:
<ul>
<li> The menu bar behaves better when using full-screen and switching Spaces (Nico Weber) </li>
<li> Don't switch Spaces when using "mvim" on one Space and a MacVim window is open on another Space </li>
<li> Add user default to toggle the "add tab" button on the tabline (to disable, enter "defaults org.vim.MacVim MMShowAddTabButton 0" in Terminal) </li>
<li> Avoid the "Press ENTER..." prompt when dragging and dropping </li>
<li> Faster startup (and shutdown, but you're not likely to notice that unless you are me ;-) </li>
<li> Automatic updating works again </li>
<li> Possible to interrupt external commands (e.g. you can Ctrl-C during a lenghty :grep now) </li>
<li> The output from external commands is displayed "interactively" (i.e. you don't have to wait for the command to finish before any output is drawn; try ":!ls -l /usr/lib" and compare with snap 40 to see what I mean) </li>
<li> Cmd-. sends SIGINT (so that if a Vim process is stuck you should always be able to interrupt it with Cmd-. even if Ctrl-C doesn't work) </li>
<li> Fix crashing bug: e.g. with snap 40 if you go to the src/ folder of Vim and type ":grep a *.c" MacVim would crash </li>
<li> Toggle loading of default font with user default MMLoadDefaultFont </li>
</ul>
</p>
]]></description>
<pubDate>Sat, 12 Jan 2009 16:12 CET</pubDate>
<enclosure type="application/octet-stream"
url="http://newmacvim.muskokamug.org/mirror/files/MacVim-snapshot-42.tbz"
length="8131516"
sparkle:version="42"
sparkle:shortVersionString="7.2"
/>
</item>
<item>
<title>Snapshot 40 released</title>
<description><![CDATA[
+6 -1
View File
@@ -235,7 +235,12 @@ typedef long guicolor_T; /* handle for a GUI color; for X11 this should
displays there is a tiny chance this is an
actual color */
#ifdef FEAT_GUI_GTK
#if defined(FEAT_GUI_MACVIM)
typedef void *GuiFont;
typedef void *GuiFontset;
# define NOFONT (GuiFont)NULL
# define NOFONTSET (GuiFontset)NULL
#elif defined(FEAT_GUI_GTK)
# ifdef HAVE_GTK2
typedef PangoFontDescription *GuiFont; /* handle for a GUI font */
typedef PangoFontDescription *GuiFontset; /* handle for a GUI fontset */
+6
View File
@@ -4434,6 +4434,12 @@ mch_call_shell(cmd, options)
windgoto(msg_row, msg_col);
cursor_on();
out_flush();
# if FEAT_GUI_MACVIM
if (gui.in_use) {
fast_breakcheck();
gui_macvim_flush();
}
# endif
if (got_int)
break;
}
+2
View File
@@ -14,6 +14,8 @@ gui_mch_update(void);
void
gui_mch_flush(void);
void
gui_macvim_flush(void);
void
gui_macvim_force_flush(void);
int
gui_mch_wait_for_chars(int wtime);