-
Notifications
You must be signed in to change notification settings - Fork 7
/
Prefs.monkey2
243 lines (190 loc) · 7.61 KB
/
Prefs.monkey2
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
Namespace ted2go
Const Prefs:=New PrefsInstance
Class PrefsInstance
' AutoCompletion
Field AcEnabled:=True
Field AcKeywordsOnly:=False
Field AcShowAfter:=2
Field AcUseTab:=True
Field AcUseEnter:=True
Field AcUseSpace:=False
Field AcUseDot:=False
Field AcNewLineByEnter:=False
Field AcStrongFirstChar:=True
Field AcUseLiveTemplates:=True
'
Field MainToolBarVisible:=True
Field MainToolBarSide:=True
Field MainToolBarSimple:=True
Field MainProjectIcons:=True
Field MainProjectAutoscrollToFile:=False
Field MainProjectSingleClickExpanding:=False
Field MainPlaceDocsAtBegin:=False
'
Field EditorToolBarVisible:=False
Field EditorGutterVisible:=True
Field EditorShowWhiteSpaces:=False
Field EditorFontPath:String
Field EditorFontSize:=16
Field EditorShowEvery10LineNumber:=True
Field EditorCodeMapVisible:=True
Field EditorAutoIndent:=True
Field EditorAutoPairs:=True
Field EditorSurroundSelection:=True
Field EditorShowParamsHint:=True
Field EditorUseSpacesAsTabs:=False
Field EditorTabSize:=4
Field EditorRemoveLinesTrailing:=False
Field EditorLineSpacing:=1.0
'
Field SourceSortByType:=True
Field SourceShowInherited:=False
'
Field MonkeyRootPath:String
Field IdeHomeDir:String
Field OpenGlProfile:="es"
Field HotkeysFilePath:String
'
Field TemplatesInsertByEnter:=True
Field SiblyMode:Bool
Property FindFilesFilter:String()
Return _findFilter
Setter( value:String )
_findFilter=value
SaveLocalState()
End
Method LoadState( json:JsonObject )
If json.Contains( "main" )
Local j2:=json["main"].ToObject()
MainToolBarVisible=Json_GetBool( j2,"toolBarVisible",MainToolBarVisible )
MainToolBarSide=Json_GetBool( j2,"toolBarSide",MainToolBarSide )
MainToolBarSimple=Json_GetBool( j2,"toolBarSimple",MainToolBarSimple )
MainProjectIcons=Json_GetBool( j2,"projectIcons",MainProjectIcons )
MainProjectAutoscrollToFile=Json_GetBool( j2,"projectScrollToFile",MainProjectAutoscrollToFile )
MainProjectSingleClickExpanding=Json_GetBool( j2,"singleClickExpanding",MainProjectSingleClickExpanding )
MainPlaceDocsAtBegin=Json_GetBool( j2,"placeDocsAtBegin",MainPlaceDocsAtBegin )
OpenGlProfile=Json_GetString( j2,"openglProfile",OpenGlProfile )
Endif
If json.Contains( "completion" )
Local j2:=json["completion"].ToObject()
AcEnabled=j2["enabled"].ToBool()
AcKeywordsOnly=j2["keywordsOnly"].ToBool()
AcShowAfter=j2["showAfter"].ToNumber()
AcUseTab=j2["useTab"].ToBool()
AcUseEnter=j2["useEnter"].ToBool()
AcUseSpace=Json_GetBool( j2,"useSpace",AcUseSpace )
AcUseDot=Json_GetBool( j2,"useDot",AcUseDot )
AcNewLineByEnter=Json_GetBool( j2,"newLineByEnter",AcNewLineByEnter )
AcUseLiveTemplates=Json_GetBool( j2,"useLiveTemplates",AcUseLiveTemplates )
Endif
If json.Contains( "editor" )
Local j2:=json["editor"].ToObject()
EditorToolBarVisible=j2["toolBarVisible"].ToBool()
EditorGutterVisible=j2["gutterVisible"].ToBool()
EditorShowWhiteSpaces=Json_GetBool( j2,"showWhiteSpaces",EditorShowWhiteSpaces )
EditorFontPath=Json_GetString( j2,"fontPath", EditorFontPath )
EditorFontSize=Json_GetInt( j2,"fontSize",EditorFontSize )
EditorShowEvery10LineNumber=Json_GetBool( j2,"showEvery10",EditorShowEvery10LineNumber )
EditorCodeMapVisible=Json_GetBool( j2,"codeMapVisible",EditorCodeMapVisible )
EditorAutoIndent=Json_GetBool( j2,"autoIndent",EditorAutoIndent )
EditorAutoPairs=Json_GetBool( j2,"autoPairs",EditorAutoPairs )
EditorSurroundSelection=Json_GetBool( j2,"surroundSelection",EditorSurroundSelection )
EditorShowParamsHint=Json_GetBool( j2,"showParamsHint",EditorShowParamsHint )
EditorUseSpacesAsTabs=Json_GetBool( j2,"useSpacesAsTabs",EditorUseSpacesAsTabs )
EditorTabSize=Json_GetInt( j2,"tabSize",EditorTabSize )
EditorRemoveLinesTrailing=Json_GetBool( j2,"removeLinesTrailing",EditorRemoveLinesTrailing )
EditorLineSpacing=Json_GetFloat( j2,"lineSpacing",EditorLineSpacing )
Endif
If json.Contains( "source" )
Local j2:=json["source"].ToObject()
SourceSortByType=j2["sortByType"].ToBool()
SourceShowInherited=j2["showInherited"].ToBool()
Endif
If json.Contains( "templates" )
Local j2:=json["templates"].ToObject()
TemplatesInsertByEnter=Json_GetBool( j2,"insertByEnter",TemplatesInsertByEnter )
Endif
If json.Contains( "siblyMode" )
SiblyMode=json["siblyMode"].ToBool()
End
End
Method SaveState( json:JsonObject )
Local j:=New JsonObject
json["main"]=j
j["toolBarVisible"]=New JsonBool( MainToolBarVisible )
j["toolBarSide"]=New JsonBool( MainToolBarSide )
j["toolBarSimple"]=New JsonBool( MainToolBarSimple )
j["projectIcons"]=New JsonBool( MainProjectIcons )
j["projectScrollToFile"]=New JsonBool( MainProjectAutoscrollToFile )
j["singleClickExpanding"]=New JsonBool( MainProjectSingleClickExpanding )
j["placeDocsAtBegin"]=New JsonBool( MainPlaceDocsAtBegin )
j["openglProfile"]=New JsonString( OpenGlProfile )
j=New JsonObject
json["completion"]=j
j["enabled"]=New JsonBool( AcEnabled )
j["keywordsOnly"]=New JsonBool( AcKeywordsOnly )
j["showAfter"]=New JsonNumber( AcShowAfter )
j["useTab"]=New JsonBool( AcUseTab )
j["useEnter"]=New JsonBool( AcUseEnter )
j["useSpace"]=New JsonBool( AcUseSpace )
j["useDot"]=New JsonBool( AcUseDot )
j["newLineByEnter"]=New JsonBool( AcNewLineByEnter )
j["useLiveTemplates"]=New JsonBool( AcUseLiveTemplates )
j=New JsonObject
json["editor"]=j
j["toolBarVisible"]=New JsonBool( EditorToolBarVisible )
j["gutterVisible"]=New JsonBool( EditorGutterVisible )
j["showWhiteSpaces"]=New JsonBool( EditorShowWhiteSpaces )
j["fontPath"]=New JsonString( EditorFontPath )
j["fontSize"]=New JsonNumber( EditorFontSize )
j["showEvery10"]=New JsonBool( EditorShowEvery10LineNumber )
j["codeMapVisible"]=New JsonBool( EditorCodeMapVisible )
j["autoIndent"]=New JsonBool( EditorAutoIndent )
j["autoPairs"]=New JsonBool( EditorAutoPairs )
j["surroundSelection"]=New JsonBool( EditorSurroundSelection )
j["showParamsHint"]=New JsonBool( EditorShowParamsHint )
j["useSpacesAsTabs"]=New JsonBool( EditorUseSpacesAsTabs )
j["tabSize"]=New JsonNumber( EditorTabSize )
j["removeLinesTrailing"]=New JsonBool( EditorRemoveLinesTrailing )
j["lineSpacing"]=New JsonNumber( EditorLineSpacing )
j=New JsonObject
json["source"]=j
j["sortByType"]=New JsonBool( SourceSortByType )
j["showInherited"]=New JsonBool( SourceShowInherited )
j=New JsonObject
json["templates"]=j
j["insertByEnter"]=New JsonBool( TemplatesInsertByEnter )
If SiblyMode json["siblyMode"]=JsonBool.TrueValue
End
Method LoadLocalState()
IdeHomeDir=HomeDir()+".Ted2Go/"
CreateDir( IdeHomeDir )
HotkeysFilePath=IdeHomeDir+"hotkeys.json"
Local json:=JsonObject.Load( AppDir()+"state.json" )
If Not json Return
MonkeyRootPath=Json_GetString( json.Data,"rootPath","" )
If Not MonkeyRootPath.EndsWith( "/" ) Then MonkeyRootPath+="/"
FindFilesFilter=Json_GetString( json.Data,"findFilesFilter","monkey2,txt" )
End
Method SaveLocalState()
If Not MonkeyRootPath.EndsWith( "/" ) Then MonkeyRootPath+="/"
Local json:=New JsonObject
json["rootPath"]=New JsonString( MonkeyRootPath )
json["findFilesFilter"]=New JsonString( FindFilesFilter )
json.Save( AppDir()+"state.json" )
End
Method GetCustomFontPath:String()
If Not EditorFontPath Return ""
If Not EditorFontPath.Contains( ".ttf" ) Return ""
Local path:=EditorFontPath
If Not path.Contains( ":" ) 'relative asset path
path=AssetsDir()+path
Endif
Return path
End
Method GetCustomFontSize:Int()
Return Max( EditorFontSize,6 ) '6 is a minimum
End
Private
Field _findFilter:String
End