Skip to content

Commit

Permalink
add VimCheckChr option: default 0, 1 to enable CheckChr function (for…
Browse files Browse the repository at this point in the history
… `a` to check it the cursor is located at the end of the line)
  • Loading branch information
rcmdnk committed Feb 13, 2022
1 parent 98759b8 commit 7772c94
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ All of these can be changed from the setting menu, too.
|VimCtrlBracketNormal|If 1, pushing Ctrl-[ sets the normal mode, while long press Ctrl-[ sends Ctrl-[.|1|
|VimSendCtrlBracketNormal|If 1, short press Ctrl-[ send Ctrl-[ in the normal mode.|0|
|VimLongCtrlBracketNormal|If 1, short press and long press of Ctrl-[ behaviors are swapped.|0|
|VimChangeCaretWidth|If 1, when entering normal mode, sets the text cursor/caret to a thick bar, then sets back to thin when exiting normal mode.|0|
|VimChangeCaretWidth|If 1, check the character under the cursor before an action. Currently this is used for: `a` in the normal mode (check if the cursor is located at the end of the line).|0|
|VimCheckChr|If 1, |0|
|VimRestoreIME|If 1, IME status is restored at entering the insert mode.|1|
|VimJJ|If 1, `jj` changes the mode to the normal mode from the insert mode.|0|
|VimTwoLetterEsc|A list of character pairs to press together during the insert mode to get to the Normal mode.<br>For example, a value of `jf` means pressing `j` and `f` at the same time will enter the Normal mode.<br>Multiple combination can be set by separated by `,`. (e.g. `jf,jk,sd`)||
Expand Down
12 changes: 9 additions & 3 deletions lib/vim_ahk.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

class VimAhk{
__About(){
this.About.Version := "v0.11.2"
this.About.Date := "11/Feb/2022"
this.About.Version := "v0.11.3"
this.About.Date := "14/Feb/2022"
this.About.Author := "rcmdnk"
this.About.Description := "Vim emulation with AutoHotkey, everywhere in Windows."
this.About.Homepage := "https://github.com/rcmdnk/vim_ahk"
Expand Down Expand Up @@ -107,6 +107,9 @@ class VimAhk{
this.AddToConf("VimChangeCaretWidth", 0, 0
, "Change to thick text caret when in normal mode"
, "When entering normal mode, sets the text cursor/caret to a thick bar, then sets back to thin when exiting normal mode.`nDoesn't work with all windows, and causes the current window to briefly lose focus when changing mode.")
this.AddToConf("VimCheckChr", 0, 0
, "Check the character before an action"
, "Check the character under the cursor before an action.`nCurrently, this is used for: 'a' in the normal mode (check if the cursor is located the end of the line).")
this.AddToConf("VimRestoreIME", 1, 1
, "Restore IME status at entering the insert mode"
, "Save the IME status in the insert mode, and restore it at entering the insert mode.")
Expand Down Expand Up @@ -138,7 +141,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", "VimCtrlBracketToEsc", "VimCtrlBracketNormal", "VimSendCtrlBracketNormal", "VimLongCtrlBracketNormal", "VimRestoreIME", "VimJJ", "VimChangeCaretWidth"]
this.CheckBoxes := ["VimEscNormal", "VimSendEscNormal", "VimLongEscNormal", "VimCtrlBracketToEsc", "VimCtrlBracketNormal", "VimSendCtrlBracketNormal", "VimLongCtrlBracketNormal", "VimRestoreIME", "VimJJ", "VimChangeCaretWidth", "VimCheckChr"]

; ToolTip Information
this.Info := {}
Expand Down Expand Up @@ -276,6 +279,9 @@ class VimAhk{

; Ref: https://www.reddit.com/r/AutoHotkey/comments/4ma5b8/identifying_end_of_line_when_typing_with_ahk_and/
CheckChr(key){
if(this.Conf["VimCheckChr"]["val"] == 0){
Return False
}
BlockInput, Send
tempClip := clipboard
clipboard := ""
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 @@ class VimSetting Extends VimGui{
}

MakeGui(){
global VimRestoreIME, VimJJ, VimEscNormal, VimSendEscNormal, VimLongEscNormal, VimCtrlBracketToEsc, VimCtrlBracketNormal, VimSendCtrlBracketNormal, VimLongCtrlBracketNormal, VimChangeCaretWidth
global VimRestoreIME, VimJJ, VimEscNormal, VimSendEscNormal, VimLongEscNormal, VimCtrlBracketToEsc, VimCtrlBracketNormal, VimSendCtrlBracketNormal, VimLongCtrlBracketNormal, VimChangeCaretWidth, VimCheckChr
global VimDisableUnused, VimSetTitleMatchMode, VimSetTitleMatchModeFS, VimIconCheckInterval, VimVerbose, VimAppList, VimGroup, VimGroupList, VimTwoLetterList
global VimDisableUnusedText, VimSetTitleMatchModeText, VimIconCheckIntervalText, VimIconCheckIntervalEdit, VimVerboseText, VimAppListText, VimGroupText, VimHomepage, VimSettingOK, VimSettingReset, VimSettingCancel, VimTwoLetterText
this.VimVal2V()
Expand Down Expand Up @@ -92,7 +92,7 @@ class VimSetting Extends VimGui{
}

UpdateGuiValue(){
global VimRestoreIME, VimJJ, VimEscNormal, VimSendEscNormal, VimLongEscNormal, VimCtrlBracketToEsc, VimCtrlBracketNormal, VimSendCtrlBracketNormal, VimLongCtrlBracketNormal, VimChangeCaretWidth
global VimRestoreIME, VimJJ, VimEscNormal, VimSendEscNormal, VimLongEscNormal, VimCtrlBracketToEsc, VimCtrlBracketNormal, VimSendCtrlBracketNormal, VimLongCtrlBracketNormal, VimChangeCaretWidth, VimCheckChr
global VimDisableUnused, VimSetTitleMatchMode, VimSetTitleMatchModeFS, VimIconCheckInterval, VimVerbose, VimAppList, VimGroup, VimGroupList, VimTwoLetter, VimTwoLetterList
for i, k in this.Vim.Checkboxes {
GuiControl, % this.Hwnd ":", % k, % %k%
Expand Down Expand Up @@ -140,7 +140,7 @@ class VimSetting Extends VimGui{
}

VimV2Conf(){
global VimRestoreIME, VimJJ, VimEscNormal, VimSendEscNormal, VimLongEscNormal, VimCtrlBracketToEsc, VimCtrlBracketNormal, VimSendCtrlBracketNormal, VimLongCtrlBracketNormal, VimChangeCaretWidth
global VimRestoreIME, VimJJ, VimEscNormal, VimSendEscNormal, VimLongEscNormal, VimCtrlBracketToEsc, VimCtrlBracketNormal, VimSendCtrlBracketNormal, VimLongCtrlBracketNormal, VimChangeCaretWidth, VimCheckChr
global VimDisableUnused, VimSetTitleMatchMode, VimSetTitleMatchModeFS, VimIconCheckInterval, VimVerbose, VimAppList, VimGroup, VimGroupList, VimTwoLetter, VimTwoLetterList
VimGroup := this.VimParseList(VimGroupList)
VimTwoLetter := this.VimParseList(VimTwoLetterList)
Expand All @@ -167,7 +167,7 @@ class VimSetting Extends VimGui{
}

VimConf2V(vd){
global VimRestoreIME, VimJJ, VimEscNormal, VimSendEscNormal, VimLongEscNormal, VimCtrlBracketToEsc, VimCtrlBracketNormal, VimSendCtrlBracketNormal, VimLongCtrlBracketNormal, VimChangeCaretWidth
global VimRestoreIME, VimJJ, VimEscNormal, VimSendEscNormal, VimLongEscNormal, VimCtrlBracketToEsc, VimCtrlBracketNormal, VimSendCtrlBracketNormal, VimLongCtrlBracketNormal, VimChangeCaretWidth, VimCheckChr
global VimDisableUnused, VimSetTitleMatchMode, VimSetTitleMatchModeFS, VimIconCheckInterval, VimVerbose, VimAppList, 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

0 comments on commit 7772c94

Please sign in to comment.