mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-07 15:37:14 +02:00
Command queue if flushed more often so that there are no long pauses of (seeming) inactivity when Vim is doing lengthy processing.
git-svn-id: http://macvim.googlecode.com/svn/trunk@135 96c4425d-ca35-0410-94e5-3396d5c13a8f
This commit is contained in:
+2
-2
@@ -26,6 +26,7 @@
|
||||
int foregroundColor;
|
||||
int defaultBackgroundColor;
|
||||
int defaultForegroundColor;
|
||||
NSDate *lastFlushDate;
|
||||
}
|
||||
|
||||
+ (MMBackend *)sharedInstance;
|
||||
@@ -45,8 +46,7 @@
|
||||
flags:(int)flags;
|
||||
- (void)insertLinesFromRow:(int)row count:(int)count
|
||||
scrollBottom:(int)bottom left:(int)left right:(int)right;
|
||||
- (void)flush;
|
||||
- (void)flushQueue;
|
||||
- (void)flushQueue:(BOOL)force;
|
||||
- (BOOL)waitForInput:(int)milliseconds;
|
||||
- (void)exit;
|
||||
- (void)selectTab:(int)index;
|
||||
|
||||
+18
-7
@@ -13,6 +13,9 @@
|
||||
|
||||
|
||||
|
||||
static float MMFlushTimeoutInterval = 0.1f;
|
||||
|
||||
|
||||
// TODO: Move to separate file.
|
||||
static int eventModifierFlagsToVimModMask(int modifierFlags);
|
||||
static int vimModMaskToEventModifierFlags(int mods);
|
||||
@@ -243,24 +246,29 @@ static int specialKeyToNSKey(int key);
|
||||
[drawData appendBytes:&right length:sizeof(int)];
|
||||
}
|
||||
|
||||
- (void)flush
|
||||
- (void)flushQueue:(BOOL)force
|
||||
{
|
||||
// NOTE! This method gets called a lot; if we were to flush every time it
|
||||
// was called MacVim would feel unresponsive. So there is a time out which
|
||||
// ensures that the queue isn't flushed too often.
|
||||
if (!force && lastFlushDate && -[lastFlushDate timeIntervalSinceNow]
|
||||
< MMFlushTimeoutInterval)
|
||||
return;
|
||||
|
||||
if ([drawData length] > 0) {
|
||||
[self queueMessage:BatchDrawMsgID data:[drawData copy]];
|
||||
[drawData setLength:0];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)flushQueue
|
||||
{
|
||||
[self flush];
|
||||
|
||||
if ([drawData length] > 0 || [queue count] > 0) {
|
||||
if ([queue count] > 0) {
|
||||
// TODO: Come up with a better way to handle the insertion point.
|
||||
[self updateInsertionPoint];
|
||||
|
||||
[frontendProxy processCommandQueue:queue];
|
||||
[queue removeAllObjects];
|
||||
|
||||
[lastFlushDate release];
|
||||
lastFlushDate = [[NSDate date] retain];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -674,6 +682,9 @@ static int specialKeyToNSKey(int key);
|
||||
|
||||
- (oneway void)processInput:(int)msgid data:(in NSData *)data
|
||||
{
|
||||
[lastFlushDate release];
|
||||
lastFlushDate = [[NSDate date] retain];
|
||||
|
||||
[self handleMessage:msgid data:data];
|
||||
inputReceived = YES;
|
||||
}
|
||||
|
||||
+5
-11
@@ -133,8 +133,7 @@ gui_mch_open(void)
|
||||
void
|
||||
gui_mch_update(void)
|
||||
{
|
||||
// HACK! Nothing to do here since we tend to the run loop (which holds
|
||||
// incoming events) in gui_mch_wait_for_chars().
|
||||
[[MMBackend sharedInstance] flushQueue:NO];
|
||||
}
|
||||
|
||||
|
||||
@@ -142,13 +141,7 @@ gui_mch_update(void)
|
||||
void
|
||||
gui_mch_flush(void)
|
||||
{
|
||||
// HACK! This function is called so often that draw performance suffers.
|
||||
// Instead of actually flushing the output it is placed on a queue and
|
||||
// flushed in gui_mch_wait_for_chars(), which makes the program feel much
|
||||
// more responsive. This might have unintended side effects though; if
|
||||
// so, another solution might have to be found.
|
||||
|
||||
//[[MMBackend sharedInstance] flush];
|
||||
[[MMBackend sharedInstance] flushQueue:NO];
|
||||
}
|
||||
|
||||
|
||||
@@ -164,8 +157,9 @@ gui_mch_flush(void)
|
||||
int
|
||||
gui_mch_wait_for_chars(int wtime)
|
||||
{
|
||||
// HACK! See comment in gui_mch_flush().
|
||||
[[MMBackend sharedInstance] flushQueue];
|
||||
// NOTE! In all likelyhood Vim will take a nap when waitForInput: is
|
||||
// called, so force a flush of the command queue here.
|
||||
[[MMBackend sharedInstance] flushQueue:YES];
|
||||
|
||||
return [[MMBackend sharedInstance] waitForInput:wtime];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user