Skip to content

Commit

Permalink
fix: tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmdnk committed Sep 29, 2024
1 parent fddc975 commit 55cdbf9
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 146 deletions.
27 changes: 12 additions & 15 deletions lib/vim_about.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ class VimAbout Extends VimGui{
__New(Vim){
super.__New(Vim, "Vim Ahk")

this.Vim := Vim

this.Version := ""
this.Date := ""
this.Author := ""
Expand All @@ -16,21 +14,20 @@ class VimAbout Extends VimGui{
}

MakeGui(){
this.Hwnd.Opt("-MinimizeBox -Resize")
this.Hwnd.AddText(, "Vim Ahk (vim_ahk):`n" this.Description)
this.Hwnd.SetFont("Underline")
this.Hwnd.AddText("Y+0 cBlue vVimHomepage", this.Homepage).OnEvent("Click", this.OpenHomepageObj)
this.Hwnd.SetFont("Norm")
this.Hwnd.AddText(, "Author: " this.Author)
this.Hwnd.AddText(, "Version: " this.Version)
this.Hwnd.AddText("Y+0", "Last update: " this.Date)
this.Hwnd.AddText(, "Script path:`n%this.Vim.ScriptPath%")
this.Hwnd.AddText(, "Setting file:`n" this.Vim.Ini.Ini)
this.Hwnd.AddButton("X200 W100 Default vVimAboutOK", "OK").OnEvent("Click", this.OKObj)
this.HwndAll.Push(this.Hwnd["VimAboutOK"])
this.Obj.Opt("-MinimizeBox -Resize")
this.Obj.AddText(, "Vim Ahk (vim_ahk):`n" this.Description)
this.Obj.SetFont("Underline")
this.AddClick("Text", "Y+0 cBlue", this.Homepage, this.Vim.about.OpenHomepageObj, this.Homepage)
this.Obj.SetFont("Norm")
this.Obj.AddText(, "Author: " this.Author)
this.Obj.AddText(, "Version: " this.Version)
this.Obj.AddText("Y+0", "Last update: " this.Date)
this.Obj.AddText(, "Script path:`n%this.Vim.ScriptPath%")
this.Obj.AddText(, "Setting file:`n" this.Vim.Ini.Ini)
this.AddClick("Button", "X200 W100 Default", "OK", this.OKObj)
}

OpenHomepage(Btn, Info){
OpenHomepage(Obj, Info){
this.Vim.VimToolTip.RemoveToolTip()
Run(this.Homepage)
}
Expand Down
40 changes: 16 additions & 24 deletions lib/vim_ahk.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class VimAhk{
this.About.Author := "rcmdnk"
this.About.Description := "Vim emulation with AutoHotkey, everywhere in Windows."
this.About.Homepage := "https://github.com/rcmdnk/vim_ahk"
this.Info["VimHomepage"] := this.About.Homepage
}

__New(ScriptPath){
Expand Down Expand Up @@ -149,21 +148,6 @@ class VimAhk{

this.CheckBoxes := ["VimEscNormal", "VimSendEscNormal", "VimLongEscNormal", "VimCtrlBracketToEsc", "VimCtrlBracketNormal", "VimSendCtrlBracketNormal", "VimLongCtrlBracketNormal", "VimRestoreIME", "VimJJ", "VimChangeCaretWidth"]

; ToolTip Information
this.Info := Map()
for k, v in this.Conf {
info := k ":`n" v["info"]
this.Info[k] := info
for i, t_type in ["Text", "List", "Value", "Edit"] {
textKey := k t_type
this.Info[textKey] := info
}
}

this.Info["VimSettingOK"] := "Reflect changes and exit"
this.Info["VimSettingReset"] := "Reset to the default values"
this.Info["VimSettingCancel"] := "Don't change and exit"

; Initialize
this.Initialize()
}
Expand All @@ -189,20 +173,24 @@ class VimAhk{
;}
}

GetConf(Name, Key){
return this.Conf[Name][Key]
GetConf(Key, Data){
return this.Conf[Key][Data]
}

GetVal(Name){
return this.GetConf(Name, "val")
GetVal(Key){
return this.GetConf(Key, "val")
}

GetDefault(Name){
return this.GetConf(Name, "default")
GetDefault(Key){
return this.GetConf(Key, "default")
}

GetDescription(name){
return this.GetConf(Name, "description")
GetDescription(Key){
return this.GetConf(Key, "description")
}

GetInfo(Key){
return this.GetConf(Key, "info")
}

SetGroup(){
Expand Down Expand Up @@ -292,4 +280,8 @@ class VimAhk{
BlockInput("Off")
Return ret
}

AddToolTip(Hwnd, Text){
this.VimToolTip.Info[Hwnd] := Text
}
}
64 changes: 25 additions & 39 deletions lib/vim_gui.ahk
Original file line number Diff line number Diff line change
@@ -1,60 +1,46 @@
class VimGui{
__New(Vim, Title){
this.Vim := Vim
this.Hwnd := 0
this.HwndAll := []
this.Obj := 0
this.Title := Title
this.HideObj := ObjBindMethod(this, "Hide")
this.OKObj := ObjBindMethod(this, "OK")
}

ShowGui(ItemName, ItemPos, MyMenu){
if(this.Hwnd == 0){
this.Hwnd := Gui("", this.Title)
this.HwndAll.Push(this.Hwnd)
this.MakeGui()
OnMessage(0x112, ObjBindMethod(this, "OnClose"))
OnMessage(0x100, ObjBindMethod(this, "OnEscape"))
}else{
this.UpdateGui()
}
this.Hwnd.Show()
}

MakeGui(){
this.Hwnd.AddButton("X200 W100 Default vGuiOK", "OK").OnEvent("Click", this.OKObj)
this.HwndAll.Push(this.Hwnd["GuiOK"])
Hide(Obj){
this.Vim.VimToolTip.RemoveToolTip()
this.Obj.Hide()
}

UpdateGui(){
OK(Obj, Info){
this.Hide(Obj)
}

Hide(){
this.Vim.VimToolTip.RemoveToolTip()
this.Hwnd.Hide()
AddClick(ControlType, Option, Text, Callback, ToolTipText:=""){
Obj := this.Obj.Add(ControlType, Option, Text)
Obj.OnEvent("Click", Callback)
if(ToolTipText != ""){
this.Vim.AddToolTip(Obj.Hwnd, ToolTipText)
}
}

OK(Btn, Info){
this.Hide()
MakeGui(){
this.AddClick("Button", "X200 W100 Default", "OK", this.OKObj)
}

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

OnClose(Wp, Lp, Msg, Hwnd){
if(Wp == 0xF060 && Hwnd == this.Hwnd){
this.Hide()
ShowGui(ItemName, ItemPos, MyMenu){
if(this.Obj == 0){
this.Obj := Gui("", this.Title)
this.MakeGui()
this.Obj.OnEvent("Close", this.HideObj)
this.Obj.OnEvent("Escape", this.HideObj)
}else{
this.UpdateGui()
}
this.Obj.Show()
}

OnEscape(Wp, Lp, Msg, Hwnd){
if(Wp == 27 && this.IsThisWindow(Hwnd)){
this.Hide()
}
}
}
Loading

0 comments on commit 55cdbf9

Please sign in to comment.