From cbb376d77e13c4da86d7a2dd0cdd96e33bebafb5 Mon Sep 17 00:00:00 2001 From: rcmdnk Date: Tue, 20 Oct 2020 23:39:53 +0900 Subject: [PATCH] add VimCtrlBracketToEsc option --- lib/vim_ahk.ahk | 7 +++++-- lib/vim_setting.ahk | 8 ++++---- lib/vim_state.ahk | 14 +++++++------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/vim_ahk.ahk b/lib/vim_ahk.ahk index daeb1d0d..6325bb63 100644 --- a/lib/vim_ahk.ahk +++ b/lib/vim_ahk.ahk @@ -19,7 +19,7 @@ class VimAhk{ __About(){ - this.About.Version := "v0.8.4" + this.About.Version := "v0.8.5" this.About.Date := "20/Oct/2020" this.About.Author := "rcmdnk" this.About.Description := "Vim emulation with AutoHotkey, everywhere in Windows." @@ -79,6 +79,9 @@ class VimAhk{ this.AddToConf("VimLongEscNormal", 0, 0 , "Long press ESC to enter the normal mode" , "Swap single press and long press behaviors for ESC.`nEnable ESC to enter Normal mode first.") + this.AddToConf("VimCtrlBracketToEsc", 1, 1 + , "Ctrl-[ to ESC" + , "Send ESC by Ctrl-[.`nThis changes Ctrl-[ behavir even if Ctrl-[ to enter the normal mode is enabled.`nIf both Ctlr-[ to ESC and Ctlr-[ to enter the normal mode are enabled, long press Ctrl-[ sends ESC instead of Ctrl-[.") this.AddToConf("VimCtrlBracketNormal", 1, 1 , "Ctrl-[ to enter the normal mode" , "Use Ctrl-[ to enter the normal mode, long press Ctrl-[ to send Ctrl-[.") @@ -116,7 +119,7 @@ class VimAhk{ , "Application" , "Set one application per line.`n`nIt can be any of Window Title, Class or Process.`nYou can check these values by Window Spy (in the right click menu of tray icon).") - this.CheckBoxes := ["VimEscNormal", "VimSendEscNormal", "VimLongEscNormal", "VimCtrlBracketNormal", "VimSendCtrlBracketNormal", "VimLongCtrlBracketNormal", "VimRestoreIME", "VimJJ"] + this.CheckBoxes := ["VimEscNormal", "VimSendEscNormal", "VimLongEscNormal", "VimCtrlBracketToEsc", "VimCtrlBracketNormal", "VimSendCtrlBracketNormal", "VimLongCtrlBracketNormal", "VimRestoreIME", "VimJJ"] ; ToolTip Information this.Info := {} diff --git a/lib/vim_setting.ahk b/lib/vim_setting.ahk index f4afc04f..b2a2f5a8 100644 --- a/lib/vim_setting.ahk +++ b/lib/vim_setting.ahk @@ -5,7 +5,7 @@ } MakeGui(){ - global VimRestoreIME, VimJJ, VimEscNormal, VimSendEscNormal, VimLongEscNormal, VimCtrlBracketNormal, VimSendCtrlBracketNormal, VimLongCtrlBracketNormal + global VimRestoreIME, VimJJ, VimEscNormal, VimSendEscNormal, VimLongEscNormal, VimCtrlBracketToEsc, VimCtrlBracketNormal, VimSendCtrlBracketNormal, VimLongCtrlBracketNormal global VimDisableUnused, VimSetTitleMatchMode, VimSetTitleMatchModeFS, VimIconCheckInterval, VimVerbose, VimGroup, VimGroupList, VimTwoLetterList global VimDisableUnusedText, VimSetTitleMatchModeText, VimIconCheckIntervalText, VimIconCheckIntervalEdit, VimVerboseText, VimGroupText, VimHomepage, VimSettingOK, VimSettingReset, VimSettingCancel, VimTwoLetterText this.VimVal2V() @@ -91,7 +91,7 @@ } UpdateGuiValue(){ - global VimRestoreIME, VimJJ, VimEscNormal, VimSendEscNormal, VimLongEscNormal, VimCtrlBracketNormal, VimSendCtrlBracketNormal, VimLongCtrlBracketNormal + global VimRestoreIME, VimJJ, VimEscNormal, VimSendEscNormal, VimLongEscNormal, VimCtrlBracketToEsc, VimCtrlBracketNormal, VimSendCtrlBracketNormal, VimLongCtrlBracketNormal global VimDisableUnused, VimSetTitleMatchMode, VimSetTitleMatchModeFS, VimIconCheckInterval, VimVerbose, VimGroup, VimGroupList, VimTwoLetter, VimTwoLetterList for i, k in this.Vim.Checkboxes { GuiControl, % this.Hwnd ":", % k, % %k% @@ -135,7 +135,7 @@ } VimV2Conf(){ - global VimRestoreIME, VimJJ, VimEscNormal, VimSendEscNormal, VimLongEscNormal, VimCtrlBracketNormal, VimSendCtrlBracketNormal, VimLongCtrlBracketNormal + global VimRestoreIME, VimJJ, VimEscNormal, VimSendEscNormal, VimLongEscNormal, VimCtrlBracketToEsc, VimCtrlBracketNormal, VimSendCtrlBracketNormal, VimLongCtrlBracketNormal global VimDisableUnused, VimSetTitleMatchMode, VimSetTitleMatchModeFS, VimIconCheckInterval, VimVerbose, VimGroup, VimGroupList, VimTwoLetter, VimTwoLetterList VimGroup := this.VimParseList(VimGroupList) VimTwoLetter := this.VimParseList(VimTwoLetterList) @@ -162,7 +162,7 @@ } VimConf2V(vd){ - global VimRestoreIME, VimJJ, VimEscNormal, VimSendEscNormal, VimLongEscNormal, VimCtrlBracketNormal, VimSendCtrlBracketNormal, VimLongCtrlBracketNormal + global VimRestoreIME, VimJJ, VimEscNormal, VimSendEscNormal, VimLongEscNormal, VimCtrlBracketToEsc, VimCtrlBracketNormal, VimSendCtrlBracketNormal, VimLongCtrlBracketNormal global VimDisableUnused, VimSetTitleMatchMode, VimSetTitleMatchModeFS, VimIconCheckInterval, VimVerbose, VimGroup, VimGroupList, VimTwoLetterList StringReplace, VimGroupList, % this.Vim.Conf["VimGroup"][vd], % this.Vim.GroupDel, `n, All StringReplace, VimTwoLetterList, % this.Vim.Conf["VimTwoLetter"][vd], % this.Vim.GroupDel, `n, All diff --git a/lib/vim_state.ahk b/lib/vim_state.ahk index 8b9885db..2d685673 100644 --- a/lib/vim_state.ahk +++ b/lib/vim_state.ahk @@ -83,7 +83,7 @@ } HandleEsc(){ - global Vim, VimEscNormal, VimLongEscNormal + global Vim, VimEscNormal, vimSendEscNormal, VimLongEscNormal if (!VimEscNormal) { Send, {Esc} Return @@ -95,12 +95,12 @@ both := VimLongEscNormal && LongPress neither := !(VimLongEscNormal || LongPress) SetNormal := both or neither - if (SetNormal) { - Vim.State.SetNormal() - } if (!SetNormal or (VimSendEscNormal && Vim.State.Mode == "Vim_Normal")) { Send, {Esc} } + if (SetNormal) { + Vim.State.SetNormal() + } if (LongPress){ ; Have to ensure the key has been released, otherwise this will get ; triggered again. @@ -119,12 +119,12 @@ both := VimLongCtrlBracketNormal && LongPress neither := !(VimLongCtrlBracketNormal || LongPress) SetNormal := both or neither - if (SetNormal) { - Vim.State.SetNormal() - } if (!SetNormal or (VimSendCtrlBracketNormal && Vim.State.Mode == "Vim_Normal")) { Send, ^[ } + if (SetNormal) { + Vim.State.SetNormal() + } if (LongPress){ KeyWait, [ }