- Added registering of user defaults, supported defaults: nowindow, tabminwidth, tabmaxwidth, taboptimumwidth, statuslineoff - Implemented hiding of status line via user default 'statuslineoff'

git-svn-id: http://macvim.googlecode.com/svn/trunk@37 96c4425d-ca35-0410-94e5-3396d5c13a8f
This commit is contained in:
Bjorn Winckler
2007-07-29 18:01:14 +00:00
parent 37a8aa2661
commit a02a149dc2
6 changed files with 52 additions and 9 deletions
+1
View File
@@ -6,6 +6,7 @@
CLASS = MMWindowController;
LANGUAGE = ObjC;
OUTLETS = {
statusSeparator = NSBox;
statusTextField = NSTextField;
tabBarControl = PSMTabBarControl;
tabView = NSTabView;
Binary file not shown.
+8
View File
@@ -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
+23 -1
View File
@@ -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
+1
View File
@@ -21,6 +21,7 @@
IBOutlet PSMTabBarControl *tabBarControl;
IBOutlet NSTabView *tabView;
IBOutlet NSTextField *statusTextField;
IBOutlet NSBox *statusSeparator;
MMVimController *vimController;
BOOL vimTaskSelectedTab;
+19 -8
View File
@@ -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];