mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Check for Ctrl-C when gui_mch_update() is called
Since gui_mch_update() is called so frequently we only check for interrupts at most once per second.
This commit is contained in:
+18
-12
@@ -466,6 +466,10 @@ static NSString *MMSymlinkWarningString =
|
||||
|
||||
- (void)update
|
||||
{
|
||||
// Keep running the run-loop until there is no more input to process.
|
||||
while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true)
|
||||
== kCFRunLoopRunHandledSource)
|
||||
;
|
||||
}
|
||||
|
||||
- (void)flushQueue:(BOOL)force
|
||||
@@ -1034,6 +1038,20 @@ static NSString *MMSymlinkWarningString =
|
||||
|
||||
- (oneway void)processInput:(int)msgid data:(in bycopy NSData *)data
|
||||
{
|
||||
// Look for Ctrl-C immediately instead of waiting until the input queue is
|
||||
// processed since that only happens in waitForInput: (and Vim regularly
|
||||
// checks for Ctrl-C in between waiting for input).
|
||||
|
||||
if (InsertTextMsgID == msgid && data != nil && [data length] == 1) {
|
||||
char_u *str = (char_u*)[data bytes];
|
||||
if ((str[0] == Ctrl_C && ctrl_c_interrupts) ||
|
||||
(str[0] == intr_char && intr_char != Ctrl_C)) {
|
||||
got_int = TRUE;
|
||||
[inputQueue removeAllObjects];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove all previous instances of this message from the input queue, else
|
||||
// the input queue may fill up as a result of Vim not being able to keep up
|
||||
// with the speed at which new messages are received. This avoids annoying
|
||||
@@ -1737,12 +1755,6 @@ static NSString *MMSymlinkWarningString =
|
||||
}
|
||||
#endif
|
||||
|
||||
if (len == 1 && ((str[0] == Ctrl_C && ctrl_c_interrupts)
|
||||
|| (str[0] == intr_char && intr_char != Ctrl_C))) {
|
||||
trash_input_buf();
|
||||
got_int = TRUE;
|
||||
}
|
||||
|
||||
for (i = 0; i < len; ++i) {
|
||||
add_to_input_buf(str+i, 1);
|
||||
if (CSI == str[i]) {
|
||||
@@ -1831,12 +1843,6 @@ static NSString *MMSymlinkWarningString =
|
||||
//NSLog(@"non-special: %@ (hex=%x, mods=%d)", key,
|
||||
// [key characterAtIndex:0], mods);
|
||||
|
||||
if (length == 1 && ((c == Ctrl_C && ctrl_c_interrupts)
|
||||
|| (c == intr_char && intr_char != Ctrl_C))) {
|
||||
trash_input_buf();
|
||||
got_int = TRUE;
|
||||
}
|
||||
|
||||
// HACK! In most circumstances the Ctrl and Shift modifiers should be
|
||||
// cleared since they are already added to the key by the AppKit.
|
||||
// Unfortunately, the only way to deal with when to clear the modifiers
|
||||
|
||||
+13
-4
@@ -184,10 +184,19 @@ gui_mch_open(void)
|
||||
void
|
||||
gui_mch_update(void)
|
||||
{
|
||||
// This function is called extremely often. By doing nothing here the
|
||||
// frame-rate is increased dramatically in certain situations. However,
|
||||
// the downside is that it is often not possible to interrupt Vim with
|
||||
// Ctrl-C when it is busy processing.
|
||||
// This function is called extremely often. It is tempting to do nothing
|
||||
// here to avoid reduced frame-rates but then it would not be possible to
|
||||
// interrupt Vim by presssing Ctrl-C during lengthy operations (e.g. after
|
||||
// entering "10gs" it would not be possible to bring Vim out of the 10 s
|
||||
// sleep prematurely). As a compromise we check for Ctrl-C only once per
|
||||
// second.
|
||||
static CFAbsoluteTime lastTime = 0;
|
||||
|
||||
CFAbsoluteTime nowTime = CFAbsoluteTimeGetCurrent();
|
||||
if (nowTime - lastTime > 1.0) {
|
||||
[[MMBackend sharedInstance] update];
|
||||
lastTime = nowTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user