@@ -7,6 +7,9 @@ class VimSetting Extends VimGui{
77
88 this.ResetObj := ObjBindMethod(this, " Reset" )
99 this.CancelObj := ObjBindMethod(this, " Cancel" )
10+ this.ApplyObj := ObjBindMethod(this, " Apply" )
11+ this.ImportObj := ObjBindMethod(this, " ImportIni" )
12+ this.ExportObj := ObjBindMethod(this, " ExportIni" )
1013 }
1114
1215 AddConf (ControlType, Key, Options, Text:="", V:=False ){
@@ -25,65 +28,91 @@ class VimSetting Extends VimGui{
2528 }
2629
2730 MakeGui (){
28- this.Obj.Opt(" -MinimizeBox -Resize" )
29- created := 0
31+ this.Obj.Opt(" -Resize -MinimizeBox -MaximizeBox" )
32+ this.Tab := this.Obj.Add(" Tab3" , " X+0 Y+0 W480 H360" , [" Keys" , " Applications" , " Status" , " Configuration file" ])
33+
34+ ; Tab 1: Keys
35+ this.Tab .UseTab(1 )
36+ this.Obj.AddText(" X+0 Y+0 Section" , "" )
3037 for i, k in this.Vim.Checkboxes {
31- if (created == 0 ){
32- y := " YM"
33- created := 1
34- }else {
35- y := " Y+10"
36- }
37- if (inStr (k, " Long" ) or inStr (k, " Send" )) {
38- x := " 30"
39- }else {
40- x := " 10"
41- }
42- this.AddConf(" Checkbox" , k, " XM+" x " " y, this.Vim.GetDescription(k), True )
38+ x := (inStr (k, " Long" ) or inStr (k, " Send" )) ? " 30" : " 10"
39+ this.AddConf(" Checkbox" , k, " XS+" x " Y+6" , this.Vim.GetDescription(k), True )
4340 this.Obj[k].Value := this.Vim.GetVal(k)
4441 }
45- this.AddConf(" Text" , " VimTwoLetter" , " XM+10 Y+15" )
46- this.AddConf(" Edit" , " VimTwoLetter" , " XM+10 Y+5 R4 W100 Multi" , StrReplace (this.Vim.GetVal(" VimTwoLetter" ), this.Vim.GroupDel, " `n" , 0 , , - 1 ), True )
47- this.AddConf(" Text" , " VimDisableUnused" , " XM+10 Y+15" )
48- this.AddConf(" DDL" , " VimDisableUnused" , " X+5 Y+-16 W30 Choose" this.Vim.GetVal(" VimDisableUnused" ), [1 , 2 , 3 ], True )
49- this.AddConf(" Text" , " VimSetTitleMatchMode" , " XM+10 Y+15" )
42+ this.AddConf(" Text" , " VimTwoLetter" , " XS+10 Y+15" )
43+ this.AddConf(" Edit" , " VimTwoLetter" , " XS+10 Y+5 R4 W100 Multi" , StrReplace (this.Vim.GetVal(" VimTwoLetter" ), this.Vim.GroupDel, " `n" , 0 , , - 1 ), True )
44+ this.AddConf(" Text" , " VimDisableUnused" , " XS+10 Y+15" )
45+ this.AddConf(" DDL" , " VimDisableUnused" , " X+5 YP-4 W40 Choose" this.Vim.GetVal(" VimDisableUnused" ), [1 , 2 , 3 ], True )
46+
47+ ; Tab 2: Applications (Merged with Matching & Lists)
48+ this.Tab .UseTab(2 )
49+ this.Obj.AddText(" X+0 Y+0 Section" , "" )
50+ ; (Disabled unused keys moved to Keys tab)
51+ this.AddConf(" Text" , " VimSetTitleMatchMode" , " XS+10 Y+10" )
5052 if (this.Vim.GetVal(" VimSetTitleMatchMode" ) == " RegEx" ){
5153 matchmode := 4
5254 }else {
5355 matchmode := this.Vim.GetVal(" VimSetTitleMatchMode" )
5456 }
55- this.AddConf(" DDL" ," VimSetTitleMatchMode" , " X+5 Y+-16 W60 Choose" matchmode, [1 , 2 , 3 , " RegEx" ], True )
57+ this.AddConf(" DDL" ," VimSetTitleMatchMode" , " X+5 YP-4 W60 Choose" matchmode, [1 , 2 , 3 , " RegEx" ], True )
5658 if (this.Vim.GetVal(" VimSetTitleMatchModeFS" ) == " Fast" ){
5759 matchmodefs := 1
5860 }else {
5961 matchmodefs := 2
6062 }
61- this.AddConf(" DDL" , " VimSetTitleMatchModeFS" , " X+5 Y+-20 W50 Choose" matchmodefs, [" Fast" , " Slow" ], True )
62- this.AddConf(" Text" , " VimIconCheckInterval" , " XM+10 Y+10" )
63- this.AddConf(" Edit" , " VimIconCheckInterval" , " X+5 Y+-16 W70" )
64- this.AddConf(" UpDown" , " VimIconCheckInterval" , " Range0-1000000" , this.Vim.GetVal(" VimIconCheckInterval" ), True )
65- this.AddConf(" Text" , " VimVerbose" , " XM+10 Y+10" )
66- this.AddConf(" DDL" , " VimVerbose" , " X+5 Y+-16 W30 Choose" this.Vim.GetVal(" VimVerbose" ), [1 , 2 , 3 , 4 ], True )
67- this.AddConf(" Text" , " VimAppList" , " XM+10 Y+10" )
63+ this.AddConf(" DDL" , " VimSetTitleMatchModeFS" , " X+5 YP+0 W50 Choose" matchmodefs, [" Fast" , " Slow" ], True )
64+
65+ ; Applications specific
66+ this.AddConf(" Text" , " VimAppList" , " XS+10 Y+15" )
6867 if (this.Vim.GetVal(" VimAppList" ) == " All" ){
6968 matchapplist := 1
7069 }else if(this.Vim.GetVal(" VimAppList" ) == " Allow List" ){
7170 matchapplist := 2
7271 }else {
7372 matchapplist := 3
7473 }
75- this.AddConf(" DDL" , " VimAppList" , " X+5 Y+-16 W100 Choose" matchapplist, [" All" , " Allow List" , " Deny List" ], True )
76- this.AddConf(" Text" , " VimGroup" , " XM+10 Y+5" )
77- this.AddConf(" Edit" , " VimGroup" , " XM+10 Y+5 R10 W300 Multi" , StrReplace (this.Vim.GetVal(" VimGroup" ), this.Vim.GroupDel, " `n" , 0 , , - 1 ), True )
78- this.Obj.AddText(" XM+10 Y+10" , " Check" )
74+ this.AddConf(" DDL" , " VimAppList" , " X+5 YP-4 W100 Choose" matchapplist, [" All" , " Allow List" , " Deny List" ], True )
75+ this.AddConf(" Text" , " VimGroup" , " XS+10 Y+5" )
76+ this.AddConf(" Edit" , " VimGroup" , " XS+10 Y+5 R10 W300 Multi" , StrReplace (this.Vim.GetVal(" VimGroup" ), this.Vim.GroupDel, " `n" , 0 , , - 1 ), True )
77+
78+ ; Tab 3: Status
79+ this.Tab .UseTab(3 )
80+ this.Obj.AddText(" X+0 Y+0 Section" , "" )
81+ this.AddConf(" Text" , " VimIconCheckInterval" , " XS+10 Y+10" )
82+ this.AddConf(" Edit" , " VimIconCheckInterval" , " X+5 YP-4 W70" )
83+ this.AddConf(" UpDown" , " VimIconCheckInterval" , " Range0-1000000" , this.Vim.GetVal(" VimIconCheckInterval" ), True )
84+ this.AddConf(" Text" , " VimVerbose" , " XS+10 Y+10" )
85+ this.AddConf(" DDL" , " VimVerbose" , " X+5 YP-4 W30 Choose" this.Vim.GetVal(" VimVerbose" ), [1 , 2 , 3 , 4 ], True )
86+
87+ ; Tab 4: Configuration file
88+ this.Tab .UseTab(4 )
89+ this.Obj.AddText(" X+0 Y+0 Section" , "" )
90+ SplitPath (this.Vim.Ini.Ini, & fileName, & iniDir)
91+ this.Obj.AddText(" XS+10 Y+10" , " Current configuration directory:" )
92+ this.AddClick(" Text" , " XS+10 cBlue" , iniDir, this.Vim.Ini.OpenIniDirObj)
93+ this.Obj.AddText(" XS+10 Y+10" , " Current configuration file:" )
94+ this.AddClick(" Text" , " XS+10 cBlue" , fileName, this.Vim.Ini.OpenIniObj)
95+ this.AddClick(" Button" , " XS+10 Y+10 W120" , " Import" , this.ImportObj, " Load settings from an INI file" )
96+ this.AddClick(" Button" , " X+10 W120" , " Export" , this.ExportObj, " Save current settings to an INI file" )
97+
98+ ; End tabs; add help and buttons below the tab
99+ this.Tab .UseTab()
100+
101+ ; Add contents below the tab
102+ this.Tab .GetPos(& tabX, & tabY, & tabW, & tabH)
103+ underTab := tabY + tabH + 10
104+
105+ ; ; Create help controls and measure
106+ this.Obj.AddText(" X15 Y" underTab, " Check" )
79107 this.Obj.SetFont(" Underline" )
80108 this.AddClick(" Text" , " X+5 cBlue" , " HELP" , this.Vim.about.OpenHomepageObj, this.Vim.About.Homepage)
81109 this.Obj.SetFont(" Norm" )
82110 this.Obj.AddText(" X+5" , " for further information." )
83111
84- this.AddClick(" Button" , " X10 W100 Y+10 Default" , " OK" , this.OKObj, " Reflect changes and exit" )
112+ this.AddClick(" Button" , " X15 W100 Y+10 Default" , " OK" , this.OKObj, " Apply changes and close" )
113+ this.AddClick(" Button" , " X+10 W100" , " Apply" , this.ApplyObj, " Apply changes without closing" )
85114 this.AddClick(" Button" , " X+10 W100" , " Reset" , this.ResetObj, " Reset to the default values" )
86- this.AddClick(" Button" , " X+10 W100" , " Cancel" , this.CancelObj, " Don't change and exit " )
115+ this.AddClick(" Button" , " X+10 W100" , " Cancel" , this.CancelObj, " Discard changes and close " )
87116 }
88117
89118 UpdateGui (){
@@ -171,6 +200,14 @@ class VimSetting Extends VimGui{
171200 this.Hide(Obj)
172201 }
173202
203+ Apply (Obj, Info ){
204+ this.Obj.Submit(false )
205+ this.VimV2Conf()
206+ this.Vim.Setup()
207+ this.Vim.Ini.WriteIni()
208+ this.Vim.VimToolTip.RemoveToolTip()
209+ }
210+
174211 Cancel (Obj, Info ){
175212 this.Hide(Obj)
176213 }
@@ -179,4 +216,72 @@ class VimSetting Extends VimGui{
179216 this.Vim.SetConfDefault()
180217 this.UpdateGuiValue()
181218 }
219+
220+ ImportIni (Obj, Info ){
221+ try {
222+ path := FileSelect("" , "" , " Import INI (staged; Apply to confirm)" , " INI (*.ini)" )
223+ if (path == "" )
224+ return
225+ ; Read selected INI into a temporary conf map without touching runtime conf
226+ tmpConf := Map()
227+ for k, v in this.Vim.Conf {
228+ tmpConf[k] := Map(" default" , v[" default" ], " val" , v[" val" ], " description" , v[" description" ], " info" , v[" info" ])
229+ }
230+ SplitPath (path, & fileName, & dir)
231+ tmpIni := VimIni(this.Vim, dir, fileName)
232+ tmpIni.ReadIni()
233+
234+ ; Update GUI controls from tmpConf only
235+ ; Checkboxes
236+ for i, k in this.Vim.Checkboxes {
237+ if this.Obj.HasProp(k) && tmpConf.Has(k)
238+ this.Obj[k].Value := tmpConf[k][" val" ]
239+ }
240+ ; Text/DDL fields with conversions
241+ if this.Obj.HasProp(" VimTwoLetter" )
242+ this.Obj[" VimTwoLetter" ].Value := StrReplace (tmpConf[" VimTwoLetter" ][" val" ], this.Vim.GroupDel, " `n" , 0 , , - 1 )
243+ if this.Obj.HasProp(" VimDisableUnused" )
244+ this.Obj[" VimDisableUnused" ].Value := tmpConf[" VimDisableUnused" ][" val" ]
245+ if this.Obj.HasProp(" VimIconCheckInterval" )
246+ this.Obj[" VimIconCheckInterval" ].Value := tmpConf[" VimIconCheckInterval" ][" val" ]
247+ ; Title match mode
248+ if this.Obj.HasProp(" VimSetTitleMatchMode" ) {
249+ matchmode := tmpConf[" VimSetTitleMatchMode" ][" val" ]
250+ this.Obj[" VimSetTitleMatchMode" ].Value := (matchmode == " RegEx" ) ? 4 : matchmode
251+ }
252+ if this.Obj.HasProp(" VimSetTitleMatchModeFS" ) {
253+ matchmodefs := tmpConf[" VimSetTitleMatchModeFS" ][" val" ]
254+ this.Obj[" VimSetTitleMatchModeFS" ].Value := (matchmodefs == " Fast" ) ? 1 : 2
255+ }
256+ if this.Obj.HasProp(" VimVerbose" )
257+ this.Obj[" VimVerbose" ].Value := tmpConf[" VimVerbose" ][" val" ]
258+ if this.Obj.HasProp(" VimAppList" ) {
259+ ap := tmpConf[" VimAppList" ][" val" ]
260+ this.Obj[" VimAppList" ].Value := (ap == " All" ) ? 1 : (ap == " Allow List" ) ? 2 : 3
261+ }
262+ if this.Obj.HasProp(" VimGroup" )
263+ this.Obj[" VimGroup" ].Value := StrReplace (tmpConf[" VimGroup" ][" val" ], this.Vim.GroupDel, " `n" , 0 , , - 1 )
264+
265+ ; Do not write to the main INI nor apply runtime yet — waits for Apply
266+ MsgBox (" Imported settings staged from:`n" path " `nClick Apply to apply them." , " Vim Ahk" )
267+ } catch as e {
268+ MsgBox (" Failed to import: " e.Message, " Vim Ahk" , " Iconx" )
269+ }
270+ }
271+
272+ ExportIni (Obj, Info ){
273+ try {
274+ path := FileSelect(" S" , "" , " Export INI" , " INI (*.ini)" )
275+ if (path == "" )
276+ return
277+ ; Ensure current settings are saved before export
278+ this.Obj.Submit(false )
279+ this.VimV2Conf()
280+ this.Vim.Ini.WriteIni()
281+ FileCopy (this.Vim.Ini.Ini, path, true )
282+ MsgBox (" Exported settings to: `n" path, " Vim Ahk" )
283+ } catch as e {
284+ MsgBox (" Failed to export: " e.Message, " Vim Ahk" , " Iconx" )
285+ }
286+ }
182287}
0 commit comments