From e4bc4ba1bc9764a95102b452e6c83db6393de41b Mon Sep 17 00:00:00 2001 From: "bjorn.winckler" Date: Sat, 13 Oct 2007 13:17:02 +0000 Subject: [PATCH] Red close button indicates if any buffer is modified git-svn-id: http://macvim.googlecode.com/svn/trunk@312 96c4425d-ca35-0410-94e5-3396d5c13a8f --- MMBackend.h | 2 ++ MMBackend.m | 10 ++++++++++ MMVimController.m | 4 ++++ MacVim.h | 2 ++ MacVim.m | 2 ++ gui_macvim.m | 10 ++++++++++ 6 files changed, 30 insertions(+) diff --git a/MMBackend.h b/MMBackend.h index af48b5b6..a432225c 100644 --- a/MMBackend.h +++ b/MMBackend.h @@ -119,6 +119,8 @@ - (void)enterFullscreen; - (void)leaveFullscreen; +- (void)updateModifiedFlag; + - (void)registerServerWithName:(NSString *)name; - (BOOL)sendToServer:(NSString *)name string:(NSString *)string reply:(char_u **)reply port:(int *)port expression:(BOOL)expr diff --git a/MMBackend.m b/MMBackend.m index 70e34c93..462ad882 100644 --- a/MMBackend.m +++ b/MMBackend.m @@ -1018,6 +1018,16 @@ enum { [self queueMessage:LeaveFullscreenMsgID data:nil]; } +- (void)updateModifiedFlag +{ + // Notify MacVim if _any_ buffer has changed from unmodified to modified or + // vice versa. + int msgid = [self checkForModifiedBuffers] + ? BuffersModifiedMsgID : BuffersNotModifiedMsgID; + + [self queueMessage:msgid data:nil]; +} + - (oneway void)processInput:(int)msgid data:(in bycopy NSData *)data { // NOTE: This method might get called whenever the run loop is tended to. diff --git a/MMVimController.m b/MMVimController.m index 19fa0d84..91ffdaf2 100644 --- a/MMVimController.m +++ b/MMVimController.m @@ -790,6 +790,10 @@ static NSMenuItem *findMenuItemWithTagInMenu(NSMenu *root, int tag) [windowController enterFullscreen]; } else if (LeaveFullscreenMsgID == msgid) { [windowController leaveFullscreen]; + } else if (BuffersNotModifiedMsgID == msgid) { + [[windowController window] setDocumentEdited:NO]; + } else if (BuffersModifiedMsgID == msgid) { + [[windowController window] setDocumentEdited:YES]; } else { NSLog(@"WARNING: Unknown message received (msgid=%d)", msgid); } diff --git a/MacVim.h b/MacVim.h index 81420eb0..ebbd9c0e 100644 --- a/MacVim.h +++ b/MacVim.h @@ -154,6 +154,8 @@ enum { SetServerNameMsgID, EnterFullscreenMsgID, LeaveFullscreenMsgID, + BuffersNotModifiedMsgID, + BuffersModifiedMsgID, }; diff --git a/MacVim.m b/MacVim.m index 4342c9fa..814faec1 100644 --- a/MacVim.m +++ b/MacVim.m @@ -61,6 +61,8 @@ char *MessageStrings[] = "SetServerNameMsgID", "EnterFullscreenMsgID", "LeaveFullscreenMsgID", + "BuffersNotModifiedMsgID", + "BuffersModifiedMsgID", }; diff --git a/gui_macvim.m b/gui_macvim.m index bbc211cf..c5171f09 100644 --- a/gui_macvim.m +++ b/gui_macvim.m @@ -1367,12 +1367,14 @@ gui_macvim_is_valid_action(NSString *action) return [actionDict objectForKey:action] != nil; } + void gui_mch_enter_fullscreen() { [[MMBackend sharedInstance] enterFullscreen]; } + void gui_mch_leave_fullscreen() { @@ -1380,6 +1382,14 @@ gui_mch_leave_fullscreen() } + void +gui_macvim_update_modified_flag() +{ + [[MMBackend sharedInstance] updateModifiedFlag]; +} + + + // -- Client/Server --------------------------------------------------------- -- 2.11.4.GIT