Skip to content

Commit

Permalink
add VimCtrlBracketToEsc option
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmdnk committed Oct 20, 2020
1 parent ffde70d commit cbb376d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
7 changes: 5 additions & 2 deletions lib/vim_ahk.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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-[.")
Expand Down Expand Up @@ -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 := {}
Expand Down
8 changes: 4 additions & 4 deletions lib/vim_setting.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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%
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
14 changes: 7 additions & 7 deletions lib/vim_state.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
}

HandleEsc(){
global Vim, VimEscNormal, VimLongEscNormal
global Vim, VimEscNormal, vimSendEscNormal, VimLongEscNormal
if (!VimEscNormal) {
Send, {Esc}
Return
Expand All @@ -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.
Expand All @@ -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, [
}
Expand Down

0 comments on commit cbb376d

Please sign in to comment.