Skip to content

Commit

Permalink
remove AddToTwoLetterMap, which has been deprecated since 7f50dc5
Browse files Browse the repository at this point in the history
add HandleCtrlBracket
  • Loading branch information
rcmdnk committed Oct 17, 2020
1 parent d7d9a25 commit f3fe527
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ All of these can be changed from setting menu, too.
|:-----|:----------|:------|
|VimRestoreIME|If 1, IME status is restored at entering insert mode.|1|
|VimJJ|If 1, `jj` changes mode to Normal from Insert.|0|
|VimLongEscNormal|If 1, pushing escape sends escape to the underlying application, while holding escape sets normal mode.|0|
|VimLongEscNormal|If 1, pushing escape/Ctrl-[ sends escape to the underlying application, while holding escape sets normal mode.|0|

This comment has been minimized.

Copy link
@BlueDrink9

BlueDrink9 Oct 17, 2020

Contributor

I think this is a very bad change.

The whole point of the LongEscNormal option is for people that prefer to use <c-[> anyway, so don't want to sacrifice the normal functionality of the escape key.

Holding a key to enter normal mode is a nuisance if you use it frequently. While ESC commonly has other uses, eg in Word, <c-[> almost never has other uses.

With this change, the only option people have is to use a twolettermap, which might not always be desirable. I think you should revert this change @rcmdnk .

This comment has been minimized.

Copy link
@BlueDrink9

BlueDrink9 Oct 17, 2020

Contributor

Or possibly add another option, might be a better and simpler way to do it.

This comment has been minimized.

Copy link
@BlueDrink9

BlueDrink9 Oct 17, 2020

Contributor

As an aside, the commit message should have specified add HandleCtrlBracket as the first part of the message, because it actually changes behaviour, whereas removing the deprecated function isn't user-facing and does nothing.

I only saw the behaviour change because I looked closely at the commit

This comment has been minimized.

Copy link
@rcmdnk

rcmdnk Oct 18, 2020

Author Owner

ok, I added new options for ESC/Ctrl-[ separately.
You can choose enabling ESC/Ctrl-[,
and if long press is setting normal or not for each.

|VimTwoLetterEsc|A list of character pairs to press together during insert mode to get to normal mode. For example, a value of `jf` means pressing `j` and `f` at the same time will enter normal mode.|""|
|VimDisableUnused|Disable level of unused keys in normal mode (see below for details).|3|
|VimSetTitleMatchMode|SetTitleMatchMode: 1: Start with, 2: Contain, 3: Exact match|2|
Expand Down Expand Up @@ -191,7 +191,7 @@ Here are the main modes.
|Visual Mode|There are three visual mode: Character-wise, Line-wise, and Block-wise. Block-wise visual mode is valid only for applications which support block-wise selection (such TeraPad).|
|Command Mode|Can be used for saving file/quitting.|

The initial state is `Insert Mode`, then `Esc` or `Ctrl-[` brings you to Normal Mode.
The initial state is `Insert Mode`, then `ESC` or `Ctrl-[` brings you to Normal Mode.

In Normal Mode, `i` is the key to be back to Insert Mode.

Expand All @@ -212,6 +212,11 @@ ESC/Ctrl-[ switch off IME if IME is on.
ESC acts as ESC when IME is on and converting instructions.
Ctrl-[ switches off IME and enters Normal Mode even if IME is on.

Long press ESC/Ctrl-[ will send these original keys, if `VimLongEscNormal` is not enabled (0).
If `VimLongEscNormal` is enabled,
short press these keys will send these original
and long press these keys will change the mode to the normal mode.

If using a custom two-letter hotkey to enter normal mode, the two letters must be different.

## Available commands in Normal Mode
Expand Down
2 changes: 1 addition & 1 deletion lib/bind/vim_enter_normal.ahk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#If WinActive("ahk_group " . Vim.GroupName)
Esc::Vim.State.HandleEsc()
^[::Vim.State.SetNormal()
^[::Vim.State.HandleCtrlBracket()

#If WinActive("ahk_group " . Vim.GroupName) and (Vim.State.StrIsInCurrentVimMode( "Insert")) and (Vim.Conf["VimJJ"]["val"] == 1)
~j up:: ; jj: go to Normal mode.
Expand Down
8 changes: 2 additions & 6 deletions lib/vim_ahk.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

class VimAhk{
__About(){
this.About.Version := "v0.8.0"
this.About.Date := "15/Oct/2020"
this.About.Version := "v0.8.1"
this.About.Date := "17/Oct/2020"
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 @@ -227,8 +227,4 @@ class VimAhk{
}
Return DefaultGroup
}

AddToTwoLetterMap(l1, l2){
this.Conf["VimTwoLetter"]["val"] := this.Conf["VimTwoLetter"]["val"] . this.GroupDel . l1 . l2
}
}
17 changes: 17 additions & 0 deletions lib/vim_state.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,23 @@
}
}

HandleCtrlBracket(){
KeyWait, [, T0.5
LongPress := ErrorLevel
global Vim, VimLongEscNormal
both := VimLongEscNormal && LongPress
neither := !(VimLongEscNormal || LongPress)
SetNormal := both or neither
if (SetNormal) {
Vim.State.SetNormal()
} else {
Send, ^[
}
if (LongPress){
KeyWait, [
}
}

IsCurrentVimMode(mode){
this.CheckValidMode(mode)
Return (mode == this.Mode)
Expand Down

0 comments on commit f3fe527

Please sign in to comment.