Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Refactor #40

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
5b34264
Refactor components into separate scripts
BlueDrink9 Jan 23, 2020
6845b63
Create FUNDING.yml
rcmdnk Oct 31, 2019
f7068eb
add note for OneNote
rcmdnk Nov 26, 2019
e246de4
fix typo
rcmdnk Jan 24, 2020
fe452b2
implement VimConf, migrage Labels to Functions
rcmdnk Jan 26, 2020
67afb2b
use VimIcons
rcmdnk Jan 26, 2020
668f235
add VimAhk class
rcmdnk Jan 26, 2020
f9958ba
split classes
rcmdnk Jan 26, 2020
be1b596
add VimAhkGroup
rcmdnk Jan 26, 2020
d28b2ec
add SetIcon in VimAhkIcon, remove Vim prefix from VimGroupName
rcmdnk Jan 26, 2020
06aae76
move classes after auto execution, add ReadIni/WriteIni in VimAhkIni
rcmdnk Jan 26, 2020
25e4a50
minimize global
rcmdnk Jan 26, 2020
b5c6dd0
put VimCheckValidMode in VimAhkDebug, use class method (ReadIni/Write…
rcmdnk Jan 26, 2020
1ed1412
add VimAhkState
rcmdnk Jan 26, 2020
0a62e66
add VimAhkConf class
rcmdnk Jan 26, 2020
00c3241
remove Ahk from names
rcmdnk Jan 26, 2020
e4cba0a
separate files for classes into lib
rcmdnk Jan 26, 2020
3fd66ac
add VimMenu
rcmdnk Jan 26, 2020
534874a
fix icon path
rcmdnk Jan 26, 2020
f38b3ae
fix encoding
rcmdnk Jan 26, 2020
ca869e0
move About Menu in VimMenu
rcmdnk Jan 26, 2020
10b3fed
enable Close/Escape by using label
rcmdnk Jan 26, 2020
3fc593d
make lib/vim_menu.ahk, add VimSetting class
rcmdnk Jan 26, 2020
d1b989f
fix VimState after tooltip
rcmdnk Jan 26, 2020
6da8a42
add VimSetting and VimCheck
rcmdnk Jan 26, 2020
9200abc
Revert "Refactor components into separate scripts"
BlueDrink9 Jan 27, 2020
759e6c3
Merge remote-tracking branch 'upstream/class' into refactor
BlueDrink9 Jan 27, 2020
fcd3911
add vim_ime.ahk
rcmdnk Jan 27, 2020
7cbd369
add vim_ime.ahk
rcmdnk Jan 27, 2020
47b9d02
move VimGitHub to vim_about, change to OpenHomepage
rcmdnk Jan 27, 2020
58a3696
try to remove fully global function: for VimSetting.Menu(), use globa…
rcmdnk Jan 27, 2020
8140a09
move mode check functions in vim_state
rcmdnk Jan 27, 2020
dbd1285
unify vim_debug to vim_state, move all functions in lib
rcmdnk Jan 27, 2020
bce998d
remove vim_debug from include
rcmdnk Jan 27, 2020
2da42cd
minimize auto execute section, add vim_ahk_setting.ahk
rcmdnk Jan 27, 2020
3fdc68f
move VimSetNormal to vim_state (SetNormal)
rcmdnk Jan 27, 2020
2dadf49
add bind files
rcmdnk Jan 27, 2020
15980fb
Merge remote-tracking branch 'upstream/class' into refactor
BlueDrink9 Jan 27, 2020
3105e2b
Merge branch 'master' into refactor
BlueDrink9 Jan 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions lib/vim_about.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class VimAbout{
static Version := "v0.5.0"
static Date := "24/Sep/2019"
static Author := "rcmdnk"
static Description := "Vim emulation with AutoHotkey, everywhere in Windows."
static Homepage := "https://github.com/rcmdnk/vim_ahk"

Menu(){
Gui, New, % "+HwndVimGuiAbout +Label" . VimAbout.__Class . ".Menu"
VimAbout.VimGuiAbout := VimGuiAbout
Gui, %VimGuiAbout%:-MinimizeBox
Gui, %VimGuiAbout%:-Resize
Gui, %VimGuiAbout%:Add, Text, , % "Vim Ahk (vim_ahk):`n" VimAbout.Description
Gui, %VimGuiAbout%:Font, Underline
Gui, %VimGuiAbout%:Add, Text, % "Y+0 cBlue g" . VimAbout.__Class . ".OpenHomepage", Homepage
Gui, %VimGuiAbout%:Font, Norm
Gui, %VimGuiAbout%:Add, Text, , % "Author: " VimAbout.Author
Gui, %VimGuiAbout%:Add, Text, , % "Version: " VimAbout.Version
Gui, %VimGuiAbout%:Add, Text, Y+0, % "Last update: " VimAbout.Date
Gui, %VimGuiAbout%:Add, Text, , Script path:`n%A_LineFile%
Gui, %VimGuiAbout%:Add, Text, , % "Setting file:`n" VimIni.Ini
Gui, %VimGuiAbout%:Add, Button, +HwndVimGuiAboutOKId X200 W100 Default, &OK
VimGuiAboutOK := ObjBindMethod(VimAbout, "MenuOK")
GuiControl, +G, % VimGuiAboutOKId, % VimGuiAboutOK
Gui, %VimGuiAbout%:Show, W500, Vim Ahk
}

MenuOK(){
Gui, % VimAbout.VimGuiAbout . ":Destroy"
}
MenuClose(){
Gui, % VimAbout.VimGuiAbout . ":Destroy"
}
MenuEscape(){
Gui, % VimAbout.VimGuiAbout . ":Destroy"
}

OpenHomepage(){
Run % VimAbout.Homepage
}
}
6 changes: 6 additions & 0 deletions lib/vim_ahk_setting.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#UseHook On ; Make it a bit slow, but can avoid infinitude loop
; Same as "$" for each hotkey
#InstallKeybdHook ; For checking key history
; Use ~500kB memory?
#HotkeyInterval 2000 ; Hotkey interval (default 2000 milliseconds).
#MaxHotkeysPerInterval 70 ; Max hotkeys per interval (default 50).
33 changes: 33 additions & 0 deletions lib/vim_bind_command.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#If WinActive("ahk_group " . VimConfObj.GroupName) and (VimState.Mode == "Vim_Normal")
:::VimState.SetMode("Command") ;(:)
`;::VimState.SetMode("Command") ;(;)
#If WinActive("ahk_group " . VimConfObj.GroupName) and (VimState.Mode == "Command")
w::VimState.SetMode("Command_w")
q::VimState.SetMode("Command_q")
h::
Send, {F1}
VimState.SetMode("Vim_Normal")
Return

#If WinActive("ahk_group " . VimConfObj.GroupName) and (VimState.Mode == "Command_w")
Return::
Send, ^s
VimState.SetMode("Vim_Normal")
Return

q::
Send, ^s
Send, !{F4}
VimState.SetMode("Insert")
Return

Space::
Send, !fa
VimState.SetMode("Insert")
Return

#If WinActive("ahk_group " . VimConfObj.GroupName) and (VimState.Mode == "Command_q")
Return::
Send, !{F4}
VimState.SetMode("Insert")
Return
236 changes: 236 additions & 0 deletions lib/vim_bind_disable.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
#If WinActive("ahk_group " . VimConfObj.GroupName) and (VimState.StrIsInCurrentVimMode( "ydc") or VimState.StrIsInCurrentVimMode( "Command") or (VimState.Mode == "Z"))
*a::
*b::
*c::
*d::
*e::
*f::
*g::
*h::
*i::
*j::
*k::
*l::
*m::
*n::
*o::
*p::
*q::
*r::
*s::
*t::
*u::
*v::
*w::
*x::
*y::
*z::
0::
1::
2::
3::
4::
5::
6::
7::
8::
9::
`::
~::
!::
@::
#::
$::
%::
^::
&::
*::
(::
)::
-::
_::
=::
+::
[::
{::
]::
}::
\::
|::
:::
`;::
'::
"::
,::
<::
.::
>::
Space::
VimState.SetMode("Vim_Normal")
Return

#If WinActive("ahk_group " . VimConfObj.GroupName) and VimState.StrIsInCurrentVimMode("Vim_") and (VimConfObj.Conf["VimDisableUnused"]["val"] == 2)
a::
b::
c::
d::
e::
f::
g::
h::
i::
j::
k::
l::
m::
n::
o::
p::
q::
r::
s::
t::
u::
v::
w::
x::
y::
z::
+a::
+b::
+c::
+d::
+e::
+f::
+g::
+h::
+i::
+j::
+k::
+l::
+m::
+n::
+o::
+p::
+q::
+r::
+s::
+t::
+u::
+v::
+w::
+x::
+y::
+z::
0::
1::
2::
3::
4::
5::
6::
7::
8::
9::
`::
~::
!::
@::
#::
$::
%::
^::
&::
*::
(::
)::
-::
_::
=::
+::
[::
{::
]::
}::
\::
|::
:::
`;::
'::
"::
,::
<::
.::
>::
Space::
Return

#If WinActive("ahk_group " . VimConfObj.GroupName) and VimState.StrIsInCurrentVimMode("Vim_") and (VimConfObj.Conf["VimDisableUnused"]["val"] == 3)
*a::
*b::
*c::
*d::
*e::
*f::
*g::
*h::
*i::
*j::
*k::
*l::
*m::
*n::
*o::
*p::
*q::
*r::
*s::
*t::
*u::
*v::
*w::
*x::
*y::
*z::
0::
1::
2::
3::
4::
5::
6::
7::
8::
9::
`::
~::
!::
@::
#::
$::
%::
^::
&::
*::
(::
)::
-::
_::
=::
+::
[::
{::
]::
}::
\::
|::
:::
`;::
'::
"::
,::
<::
.::
>::
Space::
Return
27 changes: 27 additions & 0 deletions lib/vim_bind_enter_insert.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#If WinActive("ahk_group " . VimConfObj.GroupName) && (VimState.Mode == "Vim_Normal")
i::VimState.SetMode("Insert")

+i::
Send, {Home}
VimState.SetMode("Insert")
Return

a::
Send, {Right}
VimState.SetMode("Insert")
Return

+a::
Send, {End}
VimState.SetMode("Insert")
Return

o::
Send,{End}{Enter}
VimState.SetMode("Insert")
Return

+o::
Send, {Up}{End}{Enter}
VimState.SetMode("Insert")
Return
33 changes: 33 additions & 0 deletions lib/vim_bind_enter_normal.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#If WinActive("ahk_group " . VimConfObj.GroupName)
Esc:: ; Just send Esc at converting, long press for normal Esc.
^[:: ; Go to Normal mode (for vim) with IME off even at converting.
KeyWait, Esc, T0.5
if(ErrorLevel){ ; long press to Esc
Send,{Esc}
Return
}
VimState.SetNormal()
Return

#If WinActive("ahk_group " . VimConfObj.GroupName) and (VimState.StrIsInCurrentVimMode( "Insert")) and (VimConfObj.Conf["VimJJ"]["val"] == 1)
~j up:: ; jj: go to Normal mode.
Input, jout, I T0.1 V L1, j
if(ErrorLevel == "EndKey:J"){
SendInput, {BackSpace 2}
VimState.SetNormal()
}
Return

#If WinActive("ahk_group " . VimConfObj.GroupName) and (VimState.StrIsInCurrentVimMode( "Insert")) and (VimConfObj.Conf["VimJK"]["val"] == 1)
j & k::
k & j::
SendInput, {BackSpace 1}
VimState.SetNormal()
Return

#If WinActive("ahk_group " . VimConfObj.GroupName) and (VimState.StrIsInCurrentVimMode( "Insert")) and (VimConfObj.Conf["VimSD"]["val"] == 1)
s & d::
d & s::
SendInput, {BackSpace 1}
VimState.SetNormal()
Return
Loading