From 2a70805ffbfde6e8611177e5484431d91bec52b5 Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Fri, 19 Sep 2008 20:17:01 +0200 Subject: [PATCH] Put cursor back on cmdline after Cmd-= Changing the font size up/down while the cursor was on the command line would cause the cursor to jump away from the cmdline. This is no longer the case. Also fixes a similar problem when showing/hiding the toolbar by clicking the "pill button". --- src/MacVim/MMBackend.m | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/MacVim/MMBackend.m b/src/MacVim/MMBackend.m index 7cf376c19e..ae4064f56c 100644 --- a/src/MacVim/MMBackend.m +++ b/src/MacVim/MMBackend.m @@ -63,6 +63,7 @@ vimmenu_T *menu_for_descriptor(NSArray *desc); static id evalExprCocoa(NSString * expr, NSString ** errstr); + enum { MMBlinkStateNone = 0, MMBlinkStateOn, @@ -107,6 +108,7 @@ static NSString *MMSymlinkWarningString = - (BOOL)checkForModifiedBuffers; - (void)addInput:(NSString *)input; - (BOOL)unusedEditor; +- (void)redrawScreen; @end @@ -1991,13 +1993,7 @@ static NSString *MMSymlinkWarningString = set_option_value((char_u*)"guioptions", 0, go, 0); - // Force screen redraw (does it have to be this complicated?). - redraw_all_later(CLEAR); - update_screen(NOT_VALID); - setcursor(); - out_flush(); - gui_update_cursor(FALSE, FALSE); - gui_mch_flush(); + [self redrawScreen]; } - (void)handleScrollbarEvent:(NSData *)data @@ -2089,13 +2085,7 @@ static NSString *MMSymlinkWarningString = CONVERT_FROM_UTF8_FREE(s); #endif - // Force screen redraw (does it have to be this complicated?). - redraw_all_later(CLEAR); - update_screen(NOT_VALID); - setcursor(); - out_flush(); - gui_update_cursor(FALSE, FALSE); - gui_mch_flush(); + [self redrawScreen]; } - (void)handleDropFiles:(NSData *)data @@ -2411,7 +2401,6 @@ static NSString *MMSymlinkWarningString = maketitle(); flushDisabled = NO; - gui_mch_flush(); } } @@ -2504,6 +2493,21 @@ static NSString *MMSymlinkWarningString = return onlyOneTab && oneWindowInTab && !bufChanged && !bufHasFilename; } +- (void)redrawScreen +{ + // Force screen redraw (does it have to be this complicated?). + redraw_all_later(CLEAR); + update_screen(NOT_VALID); + setcursor(); + out_flush(); + gui_update_cursor(FALSE, FALSE); + + // HACK! The cursor is not put back at the command line by the above + // "redraw commands". The following test seems to do the trick though. + if (State & CMDLINE) + redrawcmdline(); +} + @end // MMBackend (Private) @@ -2847,7 +2851,6 @@ static id evalExprCocoa(NSString * expr, NSString ** errstr) - @implementation NSString (VimStrings) + (id)stringWithVimString:(char_u *)s