mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Add option to hide MacVim when last window closes
This commit is contained in:
Binary file not shown.
@@ -161,7 +161,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
|
||||
[NSNumber numberWithInt:1], MMTextInsetRightKey,
|
||||
[NSNumber numberWithInt:1], MMTextInsetTopKey,
|
||||
[NSNumber numberWithInt:1], MMTextInsetBottomKey,
|
||||
[NSNumber numberWithBool:NO], MMTerminateAfterLastWindowClosedKey,
|
||||
@"MMTypesetter", MMTypesetterKey,
|
||||
[NSNumber numberWithFloat:1], MMCellWidthMultiplierKey,
|
||||
[NSNumber numberWithFloat:-1], MMBaselineOffsetKey,
|
||||
@@ -183,6 +182,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
|
||||
[NSNumber numberWithInt:3], MMOpenLayoutKey,
|
||||
[NSNumber numberWithBool:NO], MMVerticalSplitKey,
|
||||
[NSNumber numberWithInt:0], MMPreloadCacheSizeKey,
|
||||
[NSNumber numberWithInt:0], MMLastWindowClosedBehaviorKey,
|
||||
nil];
|
||||
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:dict];
|
||||
@@ -537,8 +537,9 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
|
||||
|
||||
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
|
||||
{
|
||||
return [[NSUserDefaults standardUserDefaults]
|
||||
boolForKey:MMTerminateAfterLastWindowClosedKey];
|
||||
return (MMTerminateWhenLastWindowClosed ==
|
||||
[[NSUserDefaults standardUserDefaults]
|
||||
integerForKey:MMLastWindowClosedBehaviorKey]);
|
||||
}
|
||||
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:
|
||||
@@ -731,6 +732,12 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
|
||||
// The last editor window just closed so restore the main menu back to
|
||||
// its default state (which is defined in MainMenu.nib).
|
||||
[self setMainMenu:defaultMainMenu];
|
||||
|
||||
BOOL hide = (MMHideWhenLastWindowClosed ==
|
||||
[[NSUserDefaults standardUserDefaults]
|
||||
integerForKey:MMLastWindowClosedBehaviorKey]);
|
||||
if (hide)
|
||||
[NSApp hide:self];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ extern NSString *MMTextInsetLeftKey;
|
||||
extern NSString *MMTextInsetRightKey;
|
||||
extern NSString *MMTextInsetTopKey;
|
||||
extern NSString *MMTextInsetBottomKey;
|
||||
extern NSString *MMTerminateAfterLastWindowClosedKey;
|
||||
extern NSString *MMTypesetterKey;
|
||||
extern NSString *MMCellWidthMultiplierKey;
|
||||
extern NSString *MMBaselineOffsetKey;
|
||||
@@ -53,6 +52,7 @@ extern NSString *MMShowLeftPlugInContainerKey;
|
||||
extern NSString *MMOpenLayoutKey;
|
||||
extern NSString *MMVerticalSplitKey;
|
||||
extern NSString *MMPreloadCacheSizeKey;
|
||||
extern NSString *MMLastWindowClosedBehaviorKey;
|
||||
|
||||
|
||||
// Enum for MMUntitledWindowKey
|
||||
@@ -63,7 +63,6 @@ enum {
|
||||
MMUntitledWindowAlways = 3
|
||||
};
|
||||
|
||||
|
||||
// Enum for MMOpenLayoutKey (first 4 must match WIN_* defines in main.c)
|
||||
enum {
|
||||
MMLayoutArglist = 0,
|
||||
@@ -73,6 +72,13 @@ enum {
|
||||
MMLayoutWindows = 4,
|
||||
};
|
||||
|
||||
// Enum for MMLastWindowClosedBehaviorKey
|
||||
enum {
|
||||
MMDoNothingWhenLastWindowClosed = 0,
|
||||
MMHideWhenLastWindowClosed = 1,
|
||||
MMTerminateWhenLastWindowClosed = 2,
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,8 +21,6 @@ NSString *MMTextInsetLeftKey = @"MMTextInsetLeft";
|
||||
NSString *MMTextInsetRightKey = @"MMTextInsetRight";
|
||||
NSString *MMTextInsetTopKey = @"MMTextInsetTop";
|
||||
NSString *MMTextInsetBottomKey = @"MMTextInsetBottom";
|
||||
NSString *MMTerminateAfterLastWindowClosedKey
|
||||
= @"MMTerminateAfterLastWindowClosed";
|
||||
NSString *MMTypesetterKey = @"MMTypesetter";
|
||||
NSString *MMCellWidthMultiplierKey = @"MMCellWidthMultiplier";
|
||||
NSString *MMBaselineOffsetKey = @"MMBaselineOffset";
|
||||
@@ -45,6 +43,7 @@ NSString *MMShowLeftPlugInContainerKey = @"MMShowLeftPlugInContainer";
|
||||
NSString *MMOpenLayoutKey = @"MMOpenLayout";
|
||||
NSString *MMVerticalSplitKey = @"MMVerticalSplit";
|
||||
NSString *MMPreloadCacheSizeKey = @"MMPreloadCacheSize";
|
||||
NSString *MMLastWindowClosedBehaviorKey = @"MMLastWindowClosedBehavior";
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user