mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-07 15:37:14 +02:00
Cmd-. sends SIGINT
Ctrl-C does not always work to interrupt a stuck Vim process. By making Cmd-. send SIGINT it is more likely to succeed where Ctrl-C has failed. (E.g. Ctrl-C may fail if a DO message is dropped, or if the Vim process is stuck in a loop and isn't checking for new input.)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
*gui_mac.txt* For Vim version 7.2. Last change: 2009 Jan 07
|
||||
*gui_mac.txt* For Vim version 7.2. Last change: 2009 Jan 08
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bjorn Winckler
|
||||
@@ -563,9 +563,11 @@ discovered by looking through the menus (see |macvim-menus| on how to create
|
||||
your own menu shortcuts). The remaining shortcuts are listed here:
|
||||
|
||||
*Cmd-.* *<D-.>*
|
||||
Cmd-. Interrupt Vim. This is synonymous with CTRL-C and can
|
||||
hence be used instead of Esc to exit insert mode (in
|
||||
case you find Esc a bit hard to reach).
|
||||
Cmd-. Interrupt Vim. Unlike Ctrl-C which is sent as normal
|
||||
keyboard input (and hence has to be received and then
|
||||
interpreted) this sends a SIGINT signal to the Vim
|
||||
process. Use this shortcut if the Vim process appears
|
||||
to have locked up and is not responding to key presses.
|
||||
|
||||
*Cmd-`* *<D-`>*
|
||||
Cmd-` Cycle to the next window. On an American keyboard the
|
||||
|
||||
+3
-11
@@ -1037,11 +1037,7 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
// which waits on the run loop will fail to detect this message (e.g. in
|
||||
// waitForConnectionAcknowledgement).
|
||||
|
||||
BOOL shouldClearQueue = NO;
|
||||
if (InterruptMsgID == msgid) {
|
||||
shouldClearQueue = YES;
|
||||
got_int = TRUE;
|
||||
} else if (InsertTextMsgID == msgid && data != nil) {
|
||||
if (InsertTextMsgID == msgid && data != nil) {
|
||||
const void *bytes = [data bytes];
|
||||
bytes += sizeof(int);
|
||||
int len = *((int*)bytes); bytes += sizeof(int);
|
||||
@@ -1049,8 +1045,9 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
char_u *str = (char_u*)bytes;
|
||||
if ((str[0] == Ctrl_C && ctrl_c_interrupts) ||
|
||||
(str[0] == intr_char && intr_char != Ctrl_C)) {
|
||||
shouldClearQueue = YES;
|
||||
got_int = TRUE;
|
||||
[inputQueue removeAllObjects];
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (TerminateNowMsgID == msgid) {
|
||||
@@ -1061,11 +1058,6 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
return;
|
||||
}
|
||||
|
||||
if (shouldClearQueue) {
|
||||
[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.
|
||||
|
||||
@@ -264,10 +264,14 @@ static float MMDragAreaSize = 73.0f;
|
||||
if ([unmodchars isEqual:@"?"])
|
||||
return NO;
|
||||
|
||||
// Cmd-. is hard-wired to send an interrupt (like Ctrl-C).
|
||||
// Cmd-. is hard-wired to send SIGINT unlike Ctrl-C which is just another
|
||||
// key press which Vim has to interpret. This means that Cmd-. always
|
||||
// works to interrupt a Vim process whereas Ctrl-C can suffer from problems
|
||||
// such as dropped DO messages (or if Vim is stuck in a loop without
|
||||
// checking for keyboard input).
|
||||
if ((flags & NSDeviceIndependentModifierFlagsMask) == NSCommandKeyMask &&
|
||||
[unmodchars isEqual:@"."]) {
|
||||
[[self vimController] sendMessage:InterruptMsgID data:nil];
|
||||
kill([[self vimController] pid], SIGINT);
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
@@ -174,7 +174,6 @@ enum {
|
||||
SetDocumentFilenameMsgID,
|
||||
OpenWithArgumentsMsgID,
|
||||
CloseWindowMsgID,
|
||||
InterruptMsgID,
|
||||
SetFullscreenColorMsgID,
|
||||
ShowFindReplaceDialogMsgID,
|
||||
FindReplaceMsgID,
|
||||
|
||||
@@ -81,7 +81,6 @@ char *MessageStrings[] =
|
||||
"SetDocumentFilenameMsgID",
|
||||
"OpenWithArgumentsMsgID",
|
||||
"CloseWindowMsgID",
|
||||
"InterruptMsgID",
|
||||
"SetFullscreenColorMsgID",
|
||||
"ShowFindReplaceDialogMsgID",
|
||||
"FindReplaceMsgID",
|
||||
|
||||
@@ -189,7 +189,8 @@ gui_mch_update(void)
|
||||
// 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.
|
||||
// second. Note that Cmd-. sends SIGINT so it has higher success rate at
|
||||
// interrupting Vim.
|
||||
static CFAbsoluteTime lastTime = 0;
|
||||
|
||||
CFAbsoluteTime nowTime = CFAbsoluteTimeGetCurrent();
|
||||
|
||||
Reference in New Issue
Block a user