/
vim_gui.ahk
63 lines (55 loc) · 1.14 KB
/
vim_gui.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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"))
OnMessage(0x100, ObjBindMethod(this, "OnEscape"))
}
this.UpdateGui()
Gui, % this.Hwnd ":Show", , % this.Title
Return
}
MakeGui(){
Gui, % this.Hwnd ":Add", Button, +HwndOK X200 W100 Default, &OK
this.HwndAll.Push(OK)
ok := ObjBindMethod(this, "OK")
GuiControl, +G, % OK, % ok
}
UpdateGui(){
}
Hide(){
this.Vim.VimToolTip.RemoveToolTip()
Gui, % this.Hwnd ":Hide"
}
OK(){
this.Hide()
}
IsThisWindow(hwnd){
for i, h in this.HwndAll {
if(hwnd == h){
Return True
}
}
Return False
}
OnClose(wp, lp, msg, hwnd){
if(wp == 0xF060 && hwnd == this.Hwnd){
this.Hide()
}
}
OnEscape(wp, lp, msg, hwnd){
if(wp == 27 && this.IsThisWindow(hwnd)){
this.Hide()
}
}
}