diff --git a/src/MacVim/MMTextView.m b/src/MacVim/MMTextView.m index ff661b160e..e48bb6659b 100644 --- a/src/MacVim/MMTextView.m +++ b/src/MacVim/MMTextView.m @@ -766,10 +766,20 @@ static NSString *MMKeypadEnterString = @"KA"; // The font panel is updated whenever the font is set. } +- (void)viewWillStartLiveResize +{ + id windowController = [[self window] windowController]; + [windowController liveResizeWillStart]; + + [super viewWillStartLiveResize]; +} + - (void)viewDidEndLiveResize { id windowController = [[self window] windowController]; [windowController liveResizeDidEnd]; + + [super viewDidEndLiveResize]; } @end // MMTextView diff --git a/src/MacVim/MMWindowController.h b/src/MacVim/MMWindowController.h index 9977bbe1f4..ff1bcd8d50 100644 --- a/src/MacVim/MMWindowController.h +++ b/src/MacVim/MMWindowController.h @@ -27,6 +27,7 @@ BOOL shouldUpdateWindowSize; NSString *windowAutosaveKey; MMFullscreenWindow *fullscreenWindow; + NSString *lastSetTitle; } - (id)initWithVimController:(MMVimController *)controller; @@ -55,6 +56,7 @@ - (void)showToolbar:(BOOL)on size:(int)size mode:(int)mode; - (void)setMouseShape:(int)shape; - (void)adjustLinespace:(int)linespace; +- (void)liveResizeWillStart; - (void)liveResizeDidEnd; - (void)placeViews; diff --git a/src/MacVim/MMWindowController.m b/src/MacVim/MMWindowController.m index d3efe1f6fb..16ef1a109d 100644 --- a/src/MacVim/MMWindowController.m +++ b/src/MacVim/MMWindowController.m @@ -72,7 +72,6 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) - (id)initWithVimController:(MMVimController *)controller { if ((self = [super initWithWindowNibName:@"EmptyWindow"])) { - fullscreenWindow = nil; vimController = controller; // Window cascading is handled by MMAppController. @@ -365,6 +364,14 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) } } +- (void)liveResizeWillStart +{ + // Save the original title, if we haven't already. + if (lastSetTitle == nil) { + lastSetTitle = [[[self window] title] retain]; + } +} + - (void)liveResizeDidEnd { // TODO: Don't duplicate code from placeViews. @@ -407,6 +414,13 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) // MacVim will have inconsistent states. [self resizeWindowToFit:self]; } + + // If we saved the original title while resizing, restore it. + if (lastSetTitle != nil) { + [[self window] setTitle:lastSetTitle]; + [lastSetTitle release]; + lastSetTitle = nil; + } } - (void)placeViews @@ -421,16 +435,25 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) NSRect textViewRect = [self textViewRectForContentSize:contentRect.size]; NSSize tsSize = [self textStorageSizeForTextViewSize:textViewRect.size]; + // If our optimal (rows,cols) do not match our current (rows,cols), resize + // ourselves and tell the Vim process to sync up. int dim[2], rows, cols; [[vimView textStorage] getMaxRows:&rows columns:&cols]; [[vimView textStorage] fitToSize:tsSize rows:&dim[0] columns:&dim[1]]; if (dim[0] != rows || dim[1] != cols) { - //NSLog(@"Notify Vim that text storage dimensions changed to %dx%d", - // dim[0], dim[1]); + //NSLog(@"Notify Vim that text storage dimensions changed " + // @"from %dx%d to %dx%d", cols, rows, dim[1], dim[0]); NSData *data = [NSData dataWithBytes:dim length:2*sizeof(int)]; [vimController sendMessage:SetTextDimensionsMsgID data:data]; + + // We only want to set the window title if this resize came from + // a live-resize, not (for example) setting 'columns' or 'lines'. + if ([[self textView] inLiveResize]) { + [win setTitle:[NSString stringWithFormat:@"%dx%d", + dim[1], dim[0]]]; + } } // XXX: put vimView resizing logic in vimView @@ -447,8 +470,6 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) if ([vimView rightScrollbarVisible]) vimViewRect.size.width += [NSScroller scrollerWidth]; - - [vimView setFrame:vimViewRect]; [vimView placeScrollbars];