Improve <D-w> behaviour

With this patch <D-w> works as follows:
- if in Ex-mode, exit by sending "^U:vi<CR>"
- if the command-line window is open, close it using CTRL-\_CTRL-N
- otherwise go to normal mode and add ":q<CR>" to the input buffer
This commit is contained in:
Bjorn Winckler
2008-03-19 19:56:19 +01:00
parent ba210fdada
commit 3292e01a82
4 changed files with 23 additions and 5 deletions
+18
View File
@@ -1648,6 +1648,24 @@ static NSString *MMSymlinkWarningString =
[self handleOdbEdit:data];
} else if (XcodeModMsgID == msgid) {
[self handleXcodeMod:data];
} else if (CloseMsgID == msgid) {
// If in Ex mode, then simply exit Ex mode (^U:vi<CR>). Otherwise
// try to close one (Vim-)window by going to Normal mode first
// (CTRL-\_CTRL-N) and then sending ":q<CR>", but only if the
// command-line window is not open. If the command-line window is open
// then we just go back to normal mode (since CTRL-\_CTRL-N closes the
// command-line window).
if (exmode_active) {
// Exit Ex mode
add_to_input_buf((char_u*)"\x15:vi\n", 5);
} else {
// Go to normal mode
add_to_input_buf((char_u*)"\x1c\xe", 2);
if (0 == cmdwin_type) {
// Command-line window was not open, so :q
add_to_input_buf((char_u*)":q\n", 3);
}
}
} else {
NSLog(@"WARNING: Unknown message received (msgid=%d)", msgid);
}
+3 -5
View File
@@ -593,11 +593,9 @@
- (IBAction)performClose:(id)sender
{
// NOTE: File->Close is bound to this action message instead binding it
// directly to the below vim input so that File->Close also works for
// auxiliary windows such as the About dialog. (If we were to bind the
// below, then <D-w> will not close e.g. the About dialog.)
[vimController addVimInput:@"<C-\\><C-N>:conf q<CR>"];
// NOTE: File->Close is bound to this action message so that File->Close
// also works for auxiliary windows such as the About dialog.
[vimController sendMessage:CloseMsgID data:nil];
}
- (IBAction)findNext:(id)sender
+1
View File
@@ -162,6 +162,7 @@ enum {
LiveResizeMsgID,
EnableAntialiasMsgID,
DisableAntialiasMsgID,
CloseMsgID,
};
+1
View File
@@ -75,6 +75,7 @@ char *MessageStrings[] =
"LiveResizeMsgID",
"EnableAntialiasMsgID",
"DisableAntialiasMsgID",
"CloseMsgID",
};