Skip to content

Commit

Permalink
fix GuiEscape for windows with multiple components
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmdnk committed Feb 2, 2020
1 parent 8e2d223 commit 2a0964a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 21 deletions.
3 changes: 2 additions & 1 deletion lib/vim_about.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
Gui, % this.Hwnd ":Add", Text, Y+0, % "Last update: " this.Date
Gui, % this.Hwnd ":Add", Text, , Script path:`n%A_LineFile%
Gui, % this.Hwnd ":Add", Text, , % "Setting file:`n" this.Vim.Ini.IniDir "\" this.Vim.Ini.Ini
Gui, % this.Hwnd ":Add", Button, X200 W100 Default vVimAboutOK, &OK
Gui, % this.Hwnd ":Add", Button, +HwndOK X200 W100 Default vVimAboutOK, &OK
this.HwndAll.Push(OK)
ok := ObjBindMethod(this, "OK")
GuiControl, +G, VimAboutOK, % ok
}
Expand Down
21 changes: 16 additions & 5 deletions lib/vim_gui.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ class VimGui{
__New(vim, title){
this.Vim := vim
this.Hwnd := 0
this.HwndAll := []
this.Title := title
}

ShowGui(){
if(this.hwnd == 0){
Gui, New, +HwndGuiHwnd
this.Hwnd := GuiHwnd
this.HwndAll.Push(GuiHwnd)
this.MakeGui()
Gui, % this.Hwnd ":Show", , % this.Title
OnMessage(0x112, ObjBindMethod(this, "OnClose"))
Expand All @@ -20,10 +22,10 @@ class VimGui{
}

MakeGui(){
Gui, % this.Hwnd ":Add", Button, +HwndOKHwnd X200 W100 Default, &OK
this.OKHwnd := OKHwnd
Gui, % this.Hwnd ":Add", Button, +HwndOK X200 W100 Default, &OK
this.HwndAll.Push(OK)
ok := ObjBindMethod(this, "OK")
GuiControl, +G, % OKHwnd, % ok
GuiControl, +G, % OK, % ok
}

UpdateGui(){
Expand All @@ -38,14 +40,23 @@ class VimGui{
this.Hide()
}

IsThisWindow(hwnd){
for i, h in this.HwndAll {
if(hwnd == h){
Return True
}
}
Return False
}

OnClose(wp, lp, msg, hwnd){
if(hwnd == this.Hwnd && wp == 0xF060){
if(wp == 0xF060 && hwnd == this.Hwnd){
this.Hide()
}
}

OnEscape(wp, lp, msg, hwnd){
if((hwnd == this.Hwnd || hwnd == this.OKHwnd) && wp == 27){
if(wp == 27 && this.IsThisWindow(hwnd)){
this.Hide()
}
}
Expand Down
41 changes: 26 additions & 15 deletions lib/vim_setting.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,41 @@
}else{
y := "Y+10"
}
Gui, % this.Hwnd ":Add", Checkbox, XM+10 %y% v%k%, % this.Vim.Conf[k]["description"]
Gui, % this.Hwnd ":Add", Checkbox, % "+HwndHwnd" k " XM+10 " y " v" k, % this.Vim.Conf[k]["description"]
hwnd := "Hwnd" k
this.HwndAll.Push(%hwnd%)
created := 1
kk := %k%
GuiControl, % this.Hwnd ":", % k, % kk
GuiControl, % this.Hwnd ":", % k, % %k%
}
Gui, % this.Hwnd ":Add", Text, % "XM+10 Y+15 g" this.__Class ".DisableUnusedText vVimDisableUnusedText", % this.Vim.Conf["VimDisableUnused"]["description"]
Gui, % this.Hwnd ":Add", DropDownList, % "X+5 Y+-16 W30 vVimDisableUnused Choose" VimDisableUnused, 1|2|3
Gui, % this.Hwnd ":Add", DropDownList, % "+HwndHwndDisableUnused X+5 Y+-16 W30 vVimDisableUnused Choose" VimDisableUnused, 1|2|3
this.HwndAll.Push(HwndDisableUnused)
Gui, % this.Hwnd ":Add", Text, % "XM+10 Y+15 g" this.__Class ".SetTitleMatchModeText vVimSetTitleMatchModeText", % this.Vim.Conf["VimSetTitleMatchMode"]["description"]
if(VimSetTitleMatchMode == "RegEx"){
matchmode := 4
}else{
matchmode := %VimSetTitleMatchMode%
}
Gui, % this.Hwnd ":Add", DropDownList, % "X+5 Y+-16 W60 vVimSetTitleMatchMode Choose" matchmode, 1|2|3|RegEx
Gui, % this.Hwnd ":Add", DropDownList, % "+HwndHwndSetTitleMachMode X+5 Y+-16 W60 vVimSetTitleMatchMode Choose" matchmode, 1|2|3|RegEx
this.HwndAll.Push(HwndSetTitleMachMode)
if(VimSetTitleMatchModeFS == "Fast"){
matchmodefs := 1
}else{
matchmodefs := 2
}
Gui, % this.Hwnd ":Add", DropDownList, % "X+5 Y+-20 W50 vVimSetTitleMatchModeFS Choose" matchmodefs, Fast|Slow
Gui, % this.Hwnd ":Add", DropDownList, % "+HwndHwndSetTitleMachModeFS X+5 Y+-20 W50 vVimSetTitleMatchModeFS Choose" matchmodefs, Fast|Slow
this.HwndAll.Push(HwndSetTitleMachModeFS)
Gui, % this.Hwnd ":Add", Text, % "XM+10 Y+10 g" this.__Class ".IconCheckIntervalText vVimIconCheckIntervalText", % this.Vim.Conf["VimIconCheckInterval"]["description"]
Gui, % this.Hwnd ":Add", Edit, X+5 Y+-16 W70 vVimIconCheckIntervalEdit
Gui, % this.Hwnd ":Add", UpDown, vVimIconCheckInterval Range0-1000000, % VimIconCheckInterval
Gui, % this.Hwnd ":Add", Edit, +HwndHwndIconCheckIntervalEdit X+5 Y+-16 W70 vVimIconCheckIntervalEdit
this.HwndAll.Push(HwndIconCheckIntervalEdit)
Gui, % this.Hwnd ":Add", UpDown, +HwndHwndIconCheckInterval vVimIconCheckInterval Range0-1000000, % VimIconCheckInterval
this.HwndAll.Push(HwndIconCheckInterval)
Gui, % this.Hwnd ":Add", Text, % "XM+10 Y+10 g" this.__Class ".VerboseText vVimVerboseText", % this.Vim.Conf["VimVerbose"]["description"]
Gui, % this.Hwnd ":Add", DropDownList, % "X+5 Y+-16 W30 vVimVerbose Choose"VimVerbose, 1|2|3|4
Gui, % this.Hwnd ":Add", DropDownList, % "+HwndHwndVerbose X+5 Y+-16 W30 vVimVerbose Choose"VimVerbose, 1|2|3|4
this.HwndAll.Push(HwndVerbose)
Gui, % this.Hwnd ":Add", Text, % "XM+10 Y+5 g" this.__Class ".GroupText vVimGroupText", % this.Vim.Conf["VimGroup"]["description"]
Gui, % this.Hwnd ":Add", Edit, XM+10 Y+5 R10 W300 Multi vVimGroupList, % VimGroupList
Gui, % this.Hwnd ":Add", Edit, +HwndHwndGroupList XM+10 Y+5 R10 W300 Multi vVimGroupList, % VimGroupList
this.HwndAll.Push(HwndGroupList)
Gui, % this.Hwnd ":Add", Text, XM+10 Y+10, Check
Gui, % this.Hwnd ":Font", Underline
Gui, % this.Hwnd ":Add", Text, X+5 cBlue vVimHomepage, HELP
Expand All @@ -53,15 +61,19 @@
Gui, % this.Hwnd ":Font", Norm
Gui, % this.Hwnd ":Add", Text, X+5, for further information.

Gui, % this.Hwnd ":Add", Button, vVimSettingOK X10 W100 Y+10 Default, &OK
Gui, % this.Hwnd ":Add", Button, +HwndHwndOK vVimSettingOK X10 W100 Y+10 Default, &OK
this.HwndAll.Push(HwndOK)
ok := ObjBindMethod(this, "OK")
GuiControl, +G, VimSettingOK, % ok

Gui, % this.Hwnd ":Add", Button, vVimSettingReset W100 X+10, &Reset
Gui, % this.Hwnd ":Add", Button, +HwndHwndReset vVimSettingReset W100 X+10, &Reset
this.HwndAll.Push(HwndReset)
reset := ObjBindMethod(this, "Reset")
GuiControl, +G, VimSettingReset, % reset

Gui, % this.Hwnd ":Add", Button, vVimSettingCancel W100 X+10, &Cancel
Gui, % this.Hwnd ":Add", Button, +HwndHwndCancel vVimSettingCancel W100 X+10, &Cancel
this.HwndAll.Push(HwndCancel)
this.LastHwnd := Last
cancel := ObjBindMethod(this, "Cancel")
GuiControl, +G, VimSettingCancel, % cancel
}
Expand All @@ -75,8 +87,7 @@
global VimRestoreIME, VimJJ, VimJK, VimSD
global VimDisableUnused, VimSetTitleMatchMode, VimSetTitleMatchModeFS, VimIconCheckInterval, VimVerbose, VimGroup, VimGroupList
for i, k in this.Vim.Checkboxes {
kk := %k%
GuiControl, % this.Hwnd ":", % k, % kk
GuiControl, % this.Hwnd ":", % k, % %k%
}
GuiControl, % this.Hwnd ":Choose", VimDisableUnused, % VimDisableUnused
GuiControl, % this.Hwnd ":", VimIconCheckInterval, % VimIconCheckInterval
Expand Down

0 comments on commit 2a0964a

Please sign in to comment.