IMmmKI / mintty

Automatically exported from code.google.com/p/mintty
GNU General Public License v3.0
0 stars 0 forks source link

Application escape key mode using Ctrl - [ (Ctrl-Bracket) #405

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I absolutely love mintty--it's worked wonders for so many years. I've switched 
over to mintty & cygwin vim as my default IDE for all my projects. 

Over the past few months I've got accustomed to escaping insert mode via 
'Ctrl-[' which essentially is the raw ESCAPE code.

Anyway, I was recently reading how to enable Application escape key mode for 
Vim and this works great when using the ESC key, but not with 'Ctrl-['. 

Is there anyway please to support Ctrl-[ sending the application escape code? 
(\e0[)?

Original issue reported on code.google.com by saama...@gmail.com on 12 Sep 2013 at 6:36

GoogleCodeExporter commented 8 years ago
In wininput.c: if ESC is pressed AND term.app_escape_key is enabled then the 
ss3('[') code is sent (\e0[). 

    when VK_ESCAPE:
      term.app_escape_key
      ? ss3('[')
      : ctrl_ch(term.escape_sends_fs ? CTRL('\\') : CTRL('['));

Andy could you please show me where to hack this term.app_escape_key ternary 
condition if CTRL + [ is pressed? Any concerns with doing this?

Original comment by saama...@gmail.com on 12 Sep 2013 at 4:28

GoogleCodeExporter commented 8 years ago
Got it working!

--- wininput.c  (revision 1321)
+++ wininput.c  (working copy)
@@ -599,6 +599,12 @@
   bool ctrl_key(void) {
     bool try_key(void) {
       wchar wc = undead_keycode();
+
+      if (wc == '[' && term.app_escape_key) {
+        ss3('[');
+        return true;
+      }
+
       char c;
       switch (wc) {
         when '@' or '[' ... '_' or 'a' ... 'z': c = CTRL(wc);

Let me know if this is the right place to hack it, and if you possibly plan on 
integrating this? 

For the most part this works great, but intermittently an escape to normal mode 
by Ctrl-[ quickly switches to normal mode and then instantly back into insert 
mode with a '[' character. However, this intermittent issue is also 
reproducible on released stable mintty using the ESC key--maybe it's one of my 
VIM plugins but anyway I found the fix for this. Just unset the timeout option 
in vim (set notimeout). With vim 'notimeout' option set I haven't run into any 
other issues.

For those interested, take a look at my vim config:
https://github.com/saamalik/dotvim/blob/master/init/mintty.vim
https://github.com/saamalik/dotvim/blob/master/init/options.vim
https://code.google.com/p/mintty/wiki/Tips#Avoiding_escape_timeout_issues_in_vim

Original comment by saama...@gmail.com on 13 Sep 2013 at 4:48

GoogleCodeExporter commented 8 years ago
Added some more instructions: 
https://plus.google.com/110860299900460184325/posts/bJWrtA7Kh9C

Original comment by saama...@gmail.com on 13 Sep 2013 at 7:13

GoogleCodeExporter commented 8 years ago
Answered on https://github.com/mintty/mintty/issues/405

Original comment by towom...@googlemail.com on 19 Jun 2015 at 11:15