diff --git a/MMAppController.h b/MMAppController.h index 56cad8ab95..85b0b8a57b 100644 --- a/MMAppController.h +++ b/MMAppController.h @@ -12,23 +12,6 @@ #import "MacVim.h" -// NSUserDefaults keys -extern NSString *MMNoWindowKey; -extern NSString *MMTabMinWidthKey; -extern NSString *MMTabMaxWidthKey; -extern NSString *MMTabOptimumWidthKey; -extern NSString *MMStatuslineOffKey; -extern NSString *MMTextInsetLeftKey; -extern NSString *MMTextInsetRightKey; -extern NSString *MMTextInsetTopKey; -extern NSString *MMTextInsetBottomKey; -extern NSString *MMTerminateAfterLastWindowClosedKey; -extern NSString *MMTypesetterKey; -extern NSString *MMCellWidthMultiplierKey; -extern NSString *MMBaselineOffsetKey; -extern NSString *MMTranslateCtrlClickKey; - - @class MMWindowController; diff --git a/MMAppController.m b/MMAppController.m index 00798ca6c1..df3356be3c 100644 --- a/MMAppController.m +++ b/MMAppController.m @@ -14,28 +14,6 @@ -// NSUserDefaults keys -NSString *MMNoWindowKey = @"nowindow"; -NSString *MMTabMinWidthKey = @"tabminwidth"; -NSString *MMTabMaxWidthKey = @"tabmaxwidth"; -NSString *MMTabOptimumWidthKey = @"taboptimumwidth"; -NSString *MMStatuslineOffKey = @"statuslineoff"; -NSString *MMTextInsetLeftKey = @"insetleft"; -NSString *MMTextInsetRightKey = @"insetright"; -NSString *MMTextInsetTopKey = @"insettop"; -NSString *MMTextInsetBottomKey = @"insetbottom"; -NSString *MMTerminateAfterLastWindowClosedKey - = @"terminateafterlastwindowclosed"; -NSString *MMTypesetterKey = @"typesetter"; -NSString *MMCellWidthMultiplierKey = @"cellwidthmultiplier"; -NSString *MMBaselineOffsetKey = @"baselineoffset"; -NSString *MMTranslateCtrlClickKey = @"translatectrlclick"; - - -// Key in user defaults for autosave data. -NSString *MMAutosaveKey = @"DefaultWindow"; - - @interface MMAppController (MMServices) - (void)openSelection:(NSPasteboard *)pboard userData:(NSString *)userData @@ -270,18 +248,10 @@ NSString *MMAutosaveKey = @"DefaultWindow"; NSRect frame = [keyWin frame]; topLeft = NSMakePoint(frame.origin.x, NSMaxY(frame)); } else { - NSDictionary *dict = [[NSUserDefaults standardUserDefaults] - dictionaryForKey:MMAutosaveKey]; - if (dict) { - id x = [dict objectForKey:@"x"]; - id y = [dict objectForKey:@"y"]; - - if (x && [x isKindOfClass:[NSNumber class]] && - y && [y isKindOfClass:[NSNumber class]]) { - topLeft.x = [x floatValue]; - topLeft.y = [y floatValue]; - } - } + NSString *topLeftString = [[NSUserDefaults standardUserDefaults] + stringForKey:MMTopLeftPointKey]; + if (topLeftString) + topLeft = NSPointFromString(topLeftString); } if (!NSEqualPoints(topLeft, NSZeroPoint)) { @@ -361,7 +331,7 @@ NSString *MMAutosaveKey = @"DefaultWindow"; // The first window autosaves its position. (The autosaving features // of Cocoa are not used because we need more control over what is // autosaved and when it is restored.) - [[vc windowController] setWindowAutosaveKey:MMAutosaveKey]; + [[vc windowController] setWindowAutosaveKey:MMTopLeftPointKey]; } [vimControllers addObject:vc]; diff --git a/MMBackend.h b/MMBackend.h index a0e4b3afcf..353112c7c5 100644 --- a/MMBackend.h +++ b/MMBackend.h @@ -12,7 +12,6 @@ #import "MacVim.h" - @interface MMBackend : NSObject { NSMutableArray *queue; NSMutableData *drawData; diff --git a/MMBackend.m b/MMBackend.m index 1b415b1ac8..ab438ac24e 100644 --- a/MMBackend.m +++ b/MMBackend.m @@ -113,8 +113,8 @@ static int specialKeyToNSKey(int key); // that the GUI won't be activated (or raised) so there is a hack in // MMWindowController which always raises the app when a new window is // opened. - NSMutableArray *args = [NSMutableArray arrayWithObjects:@"-nowindow", - @"yes", nil]; + NSMutableArray *args = [NSMutableArray arrayWithObjects: + MMNoWindowKey, @"yes", nil]; NSString *exeName = [[mainBundle infoDictionary] objectForKey:@"CFBundleExecutable"]; NSString *path = [mainBundle pathForAuxiliaryExecutable:exeName]; diff --git a/MMTextStorage.m b/MMTextStorage.m index 4b174fc4b4..5011f6c63f 100644 --- a/MMTextStorage.m +++ b/MMTextStorage.m @@ -9,7 +9,9 @@ */ #import "MMTextStorage.h" -#import "MMAppController.h" +#import "MacVim.h" + + // If 0 DRAW_TRANSP flag will be ignored. Setting it to 1 causes the cursor // background to be drawn in white. diff --git a/MMTextView.m b/MMTextView.m index 8a8f12aa90..1a973314d2 100644 --- a/MMTextView.m +++ b/MMTextView.m @@ -12,7 +12,6 @@ #import "MMTextStorage.h" #import "MMWindowController.h" #import "MMVimController.h" -#import "MMAppController.h" #import "MacVim.h" diff --git a/MMTypesetter.m b/MMTypesetter.m index ed4e778bec..388107dd9c 100644 --- a/MMTypesetter.m +++ b/MMTypesetter.m @@ -10,7 +10,7 @@ #import "MMTypesetter.h" #import "MMTextStorage.h" -#import "MMAppController.h" +#import "MacVim.h" diff --git a/MMVimController.h b/MMVimController.h index 943a897917..7024e04cee 100644 --- a/MMVimController.h +++ b/MMVimController.h @@ -11,6 +11,7 @@ #import #import "MacVim.h" + @class MMWindowController; diff --git a/MMVimController.m b/MMVimController.m index c4db2642bd..41fddbf8f7 100644 --- a/MMVimController.m +++ b/MMVimController.m @@ -10,8 +10,8 @@ #import "MMVimController.h" #import "MMWindowController.h" -#import "MMAppController.h" #import "MMTextView.h" +#import "MMAppController.h" #import "MMTextStorage.h" diff --git a/MMWindowController.m b/MMWindowController.m index 22d867d097..445ed9f150 100644 --- a/MMWindowController.m +++ b/MMWindowController.m @@ -67,7 +67,6 @@ static float StatusLineHeight = 16.0f; - (void)placeScrollbars; - (void)scroll:(id)sender; - (void)placeViews; -- (NSDictionary *)windowAutosaveDict; @end @@ -585,11 +584,13 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) - (void)windowDidMove:(NSNotification *)notification { - if (windowAutosaveKey) { - NSDictionary *dict = [self windowAutosaveDict]; - if (dict) - [[NSUserDefaults standardUserDefaults] - setObject:dict forKey:windowAutosaveKey]; + if (setupDone && windowAutosaveKey) { + NSRect frame = [[self window] frame]; + NSPoint topLeft = { frame.origin.x, NSMaxY(frame) }; + NSString *topLeftString = NSStringFromPoint(topLeft); + + [[NSUserDefaults standardUserDefaults] + setObject:topLeftString forKey:windowAutosaveKey]; } } @@ -1091,30 +1092,6 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) [self placeScrollbars]; } -- (NSDictionary *)windowAutosaveDict -{ - if (!setupDone) - return nil; - - int rows = 0, cols = 0; - if (textStorage) - [textStorage getMaxRows:&rows columns:&cols]; - - NSPoint origin = NSZeroPoint; - if (setupDone) { - NSRect frame = [[self window] frame]; - origin = NSMakePoint(frame.origin.x, NSMaxY(frame)); - } - - NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithInt:rows], @"Rows", - [NSNumber numberWithInt:cols], @"Columns", - [NSNumber numberWithFloat:origin.x], @"x", - [NSNumber numberWithFloat:origin.y], @"y", nil]; - - return dict; -} - @end // MMWindowController (Private) diff --git a/MacVim.h b/MacVim.h index 7ce529323b..a4e80cf3ee 100644 --- a/MacVim.h +++ b/MacVim.h @@ -133,4 +133,24 @@ enum { }; +// NSUserDefaults keys +extern NSString *MMNoWindowKey; +extern NSString *MMTabMinWidthKey; +extern NSString *MMTabMaxWidthKey; +extern NSString *MMTabOptimumWidthKey; +extern NSString *MMStatuslineOffKey; +extern NSString *MMTextInsetLeftKey; +extern NSString *MMTextInsetRightKey; +extern NSString *MMTextInsetTopKey; +extern NSString *MMTextInsetBottomKey; +extern NSString *MMTerminateAfterLastWindowClosedKey; +extern NSString *MMTypesetterKey; +extern NSString *MMCellWidthMultiplierKey; +extern NSString *MMBaselineOffsetKey; +extern NSString *MMTranslateCtrlClickKey; +extern NSString *MMTopLeftPointKey; + + + + // vim: set ft=objc: diff --git a/MacVim.m b/MacVim.m index f156621ba2..0d02be4e8a 100644 --- a/MacVim.m +++ b/MacVim.m @@ -60,3 +60,23 @@ char *MessageStrings[] = "ShowPopupMenuMsgID", }; + + + +// NSUserDefaults keys +NSString *MMNoWindowKey = @"MMNoWindow"; +NSString *MMTabMinWidthKey = @"MMTabMinWidth"; +NSString *MMTabMaxWidthKey = @"MMTabMaxWidth"; +NSString *MMTabOptimumWidthKey = @"MMTabOptimumWidth"; +NSString *MMStatuslineOffKey = @"MMStatuslineOff"; +NSString *MMTextInsetLeftKey = @"MMTextInsetLeft"; +NSString *MMTextInsetRightKey = @"MMTextInsetRight"; +NSString *MMTextInsetTopKey = @"MMTextInsetTop"; +NSString *MMTextInsetBottomKey = @"MMTextInsetBottom"; +NSString *MMTerminateAfterLastWindowClosedKey + = @"MMTerminateAfterLastWindowClosed"; +NSString *MMTypesetterKey = @"MMTypesetter"; +NSString *MMCellWidthMultiplierKey = @"MMCellWidthMultiplier"; +NSString *MMBaselineOffsetKey = @"MMBaselineOffset"; +NSString *MMTranslateCtrlClickKey = @"MMTranslateCtrlClick"; +NSString *MMTopLeftPointKey = @"MMTopLeftPoint";