diff --git a/English.lproj/VimWindow.nib/classes.nib b/English.lproj/VimWindow.nib/classes.nib index 368d0f93b8..0757bf563a 100644 --- a/English.lproj/VimWindow.nib/classes.nib +++ b/English.lproj/VimWindow.nib/classes.nib @@ -6,6 +6,7 @@ CLASS = MMWindowController; LANGUAGE = ObjC; OUTLETS = { + statusSeparator = NSBox; statusTextField = NSTextField; tabBarControl = PSMTabBarControl; tabView = NSTabView; diff --git a/English.lproj/VimWindow.nib/keyedobjects.nib b/English.lproj/VimWindow.nib/keyedobjects.nib index ff924b86ca..a6dd744811 100644 Binary files a/English.lproj/VimWindow.nib/keyedobjects.nib and b/English.lproj/VimWindow.nib/keyedobjects.nib differ diff --git a/MMAppController.h b/MMAppController.h index 680330882e..20161306a2 100644 --- a/MMAppController.h +++ b/MMAppController.h @@ -12,6 +12,14 @@ #import "MacVim.h" +// NSUserDefaults keys +extern NSString *MMNoWindowKey; +extern NSString *MMTabMinWidthKey; +extern NSString *MMTabMaxWidthKey; +extern NSString *MMTabOptimumWidthKey; +extern NSString *MMStatuslineOffKey; + + @interface MMAppController : NSObject #if MM_USE_DO diff --git a/MMAppController.m b/MMAppController.m index 43ec804862..8a3e82f6d8 100644 --- a/MMAppController.m +++ b/MMAppController.m @@ -13,8 +13,30 @@ +// NSUserDefaults keys +NSString *MMNoWindowKey = @"nowindow"; +NSString *MMTabMinWidthKey = @"tabminwidth"; +NSString *MMTabMaxWidthKey = @"tabmaxwidth"; +NSString *MMTabOptimumWidthKey = @"taboptimumwidth"; +NSString *MMStatuslineOffKey = @"statuslineoff"; + + + @implementation MMAppController ++ (void)initialize +{ + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:NO], MMNoWindowKey, + [NSNumber numberWithInt:64], MMTabMinWidthKey, + [NSNumber numberWithInt:6*64], MMTabMaxWidthKey, + [NSNumber numberWithInt:132], MMTabOptimumWidthKey, + [NSNumber numberWithBool:NO], MMStatuslineOffKey, + nil]; + + [[NSUserDefaults standardUserDefaults] registerDefaults:dict]; +} + - (id)init { if ((self = [super init])) { @@ -77,7 +99,7 @@ { // NOTE! This way it possible to start the app with the command-line // argument '-nowindow yes' and no window will be opened by default. - return ![[NSUserDefaults standardUserDefaults] boolForKey:@"nowindow"]; + return ![[NSUserDefaults standardUserDefaults] boolForKey:MMNoWindowKey]; } - (BOOL)applicationOpenUntitledFile:(NSApplication *)sender diff --git a/MMWindowController.h b/MMWindowController.h index fbe82d2803..81945d26f5 100644 --- a/MMWindowController.h +++ b/MMWindowController.h @@ -21,6 +21,7 @@ IBOutlet PSMTabBarControl *tabBarControl; IBOutlet NSTabView *tabView; IBOutlet NSTextField *statusTextField; + IBOutlet NSBox *statusSeparator; MMVimController *vimController; BOOL vimTaskSelectedTab; diff --git a/MMWindowController.m b/MMWindowController.m index 08187e2e02..214be880a0 100644 --- a/MMWindowController.m +++ b/MMWindowController.m @@ -14,6 +14,7 @@ #import "MMTextStorage.h" #import "MMVimController.h" #import "MacVim.h" +#import "MMAppController.h" // Scroller type; these must match SBAR_* in gui.h @@ -23,9 +24,9 @@ enum { MMScrollerTypeBottom }; -// TODO! Implement hiding/showing of status line. +// NOTE! This value must match the actual position of the status line +// separator in VimWindow.nib. static float StatusLineHeight = 16.0f; -static BOOL statusLineIsVisible = NO; // NO is _not_ supported at the moment! // TODO: Move! @@ -138,7 +139,10 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) // NOTE: Size to fit looks good, but not many tabs will fit and there are // quite a few drawing bugs in this code, so it is disabled for now. //[tabBarControl setSizeCellsToFit:YES]; - [tabBarControl setCellMinWidth:64]; + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + [tabBarControl setCellMinWidth:[ud integerForKey:MMTabMinWidthKey]]; + [tabBarControl setCellMaxWidth:[ud integerForKey:MMTabMaxWidthKey]]; + [tabBarControl setCellOptimumWidth:[ud integerForKey:MMTabOptimumWidthKey]]; [tabBarControl setAllowsDragBetweenWindows:NO]; [tabBarControl setShowAddTabButton:YES]; [[tabBarControl addTabButton] setTarget:self]; @@ -276,7 +280,10 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) [[self window] makeKeyAndOrderFront:self]; - [statusTextField setHidden:!statusLineIsVisible]; + BOOL statusOff = [[NSUserDefaults standardUserDefaults] + boolForKey:MMStatuslineOffKey]; + [statusTextField setHidden:statusOff]; + [statusSeparator setHidden:statusOff]; [self flashStatusText:@"Welcome to MacVim!"]; } @@ -369,7 +376,8 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) - (void)flashStatusText:(NSString *)text { - if (!statusLineIsVisible) return; + if ([[NSUserDefaults standardUserDefaults] boolForKey:MMStatuslineOffKey]) + return; [self setStatusText:text]; @@ -577,7 +585,7 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) if (![tabBarControl isHidden]) size.height += [tabBarControl frame].size.height; - if (statusLineIsVisible) + if (![[NSUserDefaults standardUserDefaults] boolForKey:MMStatuslineOffKey]) size.height += StatusLineHeight; if ([self bottomScrollbarVisible]) @@ -596,7 +604,8 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) if (![tabBarControl isHidden]) rect.size.height -= [tabBarControl frame].size.height; - if (statusLineIsVisible) { + if (![[NSUserDefaults standardUserDefaults] + boolForKey:MMStatuslineOffKey]) { rect.size.height -= StatusLineHeight; rect.origin.y += StatusLineHeight; } @@ -776,6 +785,8 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) NSRect tabViewFrame = [tabView frame]; NSView *contentView = [[self window] contentView]; BOOL lsbVisible = [self leftScrollbarVisible]; + BOOL statusVisible = ![[NSUserDefaults standardUserDefaults] + boolForKey:MMStatuslineOffKey]; // HACK! Find the lowest left&right vertical scrollbars, as well as the // leftmost horizontal scrollbar. This hack continues further down. @@ -814,7 +825,7 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) if ([scroller type] == MMScrollerTypeBottom) { rect = [textStorage rectForColumnsInRange:[scroller range]]; rect.size.height = [NSScroller scrollerWidth]; - if (statusLineIsVisible) + if (statusVisible) rect.origin.y += StatusLineHeight; if (lsbVisible) rect.origin.x += [NSScroller scrollerWidth];