-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathTed2.monkey2
More file actions
339 lines (252 loc) · 7.14 KB
/
Ted2.monkey2
File metadata and controls
339 lines (252 loc) · 7.14 KB
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
#If __TARGET__="windows"
#Import "bin/wget.exe"
'to build resource.o when icon changes...
'
'windres resource.rc resource.o
#If __ARCH__="x86"
#Import "logo/resource.o"
#Elseif __ARCH__="x64"
#Import "logo/resource_x64.o"
#Endif
#Endif
'----------------------------
'#Import "<reflection>"
#Import "<std>"
#Import "<mojo>"
#Import "<mojox>"
#Import "<tinyxml2>"
#Import "<sdl2>"
#Import "action/FileActions"
#Import "action/EditActions"
#Import "action/BuildActions"
#Import "action/HelpActions"
#Import "action/FindActions"
#Import "action/GotoActions"
#Import "action/WindowActions"
#Import "action/TabActions"
#Import "action/FoldingActions"
#Import "dialog/FindDialog"
#Import "dialog/PrefsDialog"
#Import "dialog/EditProductDialog"
#Import "dialog/DialogExt"
#Import "dialog/NoTitleDialog"
#Import "dialog/FindInFilesDialog"
#Import "dialog/UpdateModulesDialog"
#Import "dialog/GenerateClassDialog"
#Import "dialog/RecentFilesDialog"
#Import "document/DocumentManager"
#Import "document/Ted2Document"
#Import "document/CodeDocument"
#Import "document/PlainTextDocument"
#Import "document/ImageDocument"
#Import "document/AudioDocument"
#Import "document/JsonDocument"
#Import "document/XmlDocument"
#Import "document/BananasDocument"
#Import "document/SceneDocument"
#Import "eventfilter/TextViewKeyEventFilter"
#Import "eventfilter/Monkey2KeyEventFilter"
#Import "parser/CodeItem"
#Import "parser/Parser"
#Import "parser/Monkey2Parser"
#Import "parser/ParserPlugin"
#Import "parser/CodeParsing"
#Import "product/BuildProduct"
#Import "product/Mx2ccEnv"
#Import "product/ModuleManager"
#Import "syntax/Keywords"
#Import "syntax/Monkey2Keywords"
#Import "syntax/Highlighter"
#Import "syntax/Monkey2Highlighter"
#Import "syntax/CppHighlighter"
#Import "syntax/CppKeywords"
#Import "syntax/JavaHighlighter"
#Import "syntax/JavaKeywords"
#Import "syntax/GlslHighlighter"
#Import "syntax/GlslKeywords"
#Import "syntax/CodeFormatter"
#Import "syntax/Monkey2Formatter"
#Import "testing/ParserTests"
#Import "utils/Extensions"
#Import "utils/JsonUtils"
#Import "utils/Utils"
#Import "utils/TextUtils"
#Import "utils/ViewUtils"
#Import "view/CodeMapView"
#Import "view/CodeTextView"
#Import "view/ConsoleViewExt"
#Import "view/ListViewExt"
#Import "view/AutocompleteView"
#Import "view/TreeViewExt"
#Import "view/CodeTreeView"
#Import "view/CodeGutterView"
#Import "view/ToolBarViewExt"
#Import "view/HintView"
#Import "view/HtmlViewExt"
#Import "view/ProjectBrowserView"
#Import "view/TabViewExt"
#Import "view/StatusBarView"
#Import "view/DebugView"
#Import "view/ProjectView"
#Import "view/HelpTreeView"
#Import "view/Ted2TextView"
#Import "view/Ted2CodeTextView"
#Import "view/JsonTreeView"
#Import "view/XmlTreeView"
#Import "view/Monkey2TreeView"
#Import "view/GutterView"
#Import "view/MenuExt"
#Import "view/ScrollableViewExt"
#Import "view/BuildErrorListViewItem"
#Import "view/TextFieldExt"
#Import "view/SpacerView"
#Import "view/FindReplaceView"
#Import "view/ViewExtensions"
#Import "view/DockingViewExt"
#Import "view/DraggableViewListener"
#Import "view/Undock"
#Import "view/TextViewExt"
#Import "view/ExamplesView"
#Import "theme/ThemeImages"
#Import "theme/ThemesInfo"
#Import "ActionsProvider"
#Import "PathsProvider"
#Import "Tree"
#Import "Tuple"
#Import "Plugin"
#Import "Prefs"
#Import "ProcessReader"
#Import "LiveTemplates"
#Import "MainWindow"
#Import "di/Di"
#Import "di/DiSetup"
Namespace ted2go
Using std..
Using mojo..
Using mojox..
Using tinyxml2..
Using sdl2..
Const MONKEY2_DOMAIN:="http://monkeycoder.co.nz"
Global AppTitle:="Ted2Go v2.14a"
Function Main()
SetupDiContainer()
Prefs.LoadLocalState()
Local root:=Prefs.MonkeyRootPath
If Not root Then root=AppDir()
root=SetupMonkeyRootPath( root,True )
If Not root libc.exit_( 1 )
If root<>Prefs.MonkeyRootPath
Prefs.MonkeyRootPath=root
Prefs.SaveLocalState()
Endif
ChangeDir( root )
'load ted2 state
'
Local jobj:=JsonObject.Load( "bin/ted2.state.json" )
If Not jobj jobj=New JsonObject
Prefs.LoadState( jobj )
ThemesInfo.Load( "theme::themes.json" )
'initial theme
'
If Not jobj.Contains( "theme" ) jobj["theme"]=New JsonString( "theme-hollow" )
If Not jobj.Contains( "themeScale" ) jobj["themeScale"]=New JsonNumber( 1 )
SetConfig( "MOJO_INITIAL_THEME",jobj.GetString( "theme" ) )
SetConfig( "MOJO_INITIAL_THEME_SCALE",jobj.GetString( "themeScale" ) )
#If __TARGET__="windows"
If Prefs.OpenGlProfile
SetConfig( "MOJO_OPENGL_PROFILE",Prefs.OpenGlProfile )
Endif
#Endif
'start the app!
'
New AppInstance
InitHotkeys()
'initial window state
'
Local flags:=WindowFlags.Resizable|WindowFlags.HighDPI
Local rect:Recti
If jobj.Contains( "windowRect" )
rect=ToRecti( jobj["windowRect"] )
Else
Local w:=Min( 1480,App.DesktopSize.x-40 )
Local h:=Min( 970,App.DesktopSize.y-64 )
rect=New Recti( 0,0,w,h )
flags|=WindowFlags.Center
Endif
New MainWindowInstance( AppTitle,rect,flags,jobj )
App.Idle+=Lambda()
' open docs from args
Local args:=AppArgs()
For Local i:=1 Until args.Length
Local arg:=args[i]
arg=arg.Replace( "\","/" )
MainWindow.OnFileDropped( arg )
Next
#If __TARGET__="macos"
App.Idle+=Lambda() ' quick fix for black screen on mojave at startup
Local dx:=MainWindow.Frame.Left Mod 2 = 0 ? -1 Else 1
MainWindow.Frame=MainWindow.Frame+New Recti( dx,0,0,0 )
MainWindow.RequestRender()
End
#Endif
End
SDL_EnableScreenSaver()
App.Run()
End
Function SetupMonkeyRootPath:String( rootPath:String,searchMode:Bool )
#If __DESKTOP_TARGET__
If searchMode
' search for desired folder
Local found:=FindBinFolder( rootPath )
' search for AddDir() folder
If Not found And rootPath<>AppDir() Then found=FindBinFolder( AppDir() )
' search for choosen-by-requester folder
While Not found
Local ok:=Confirm( "Initializing","Monkey2 root directory isn't set.~nTo continue, you should specify it." )
If Not ok
Return ""
End
Local s:=requesters.RequestDir( "Choose Monkey2 folder",AppDir() )
found=FindBinFolder( s )
Wend
rootPath=found
Else
Local ok:= (GetFileType( "bin" )=FileType.Directory And GetFileType( "modules" )=FileType.Directory)
If Not ok
Notify( "Monkey2 root folder","Incorrect folder!" )
Return ""
Endif
Endif
#Endif
Return rootPath
End
Function GetActionTextWithShortcut:String( action:Action )
Return action.Text+" ("+action.HotKeyText+")"
End
Function Exec( exePath:String,args:String="" )
#If __HOSTOS__="windows"
libc.system( exePath+" "+args )
#Else If __HOSTOS__="macos"
libc.system( "open ~q"+exePath+"~q --args "+args )
#Else If __HOSTOS__="linux"
libc.system( exePath+" "+args+" >/dev/null 2>/dev/null &" )
#Else If __HOSTOS__="raspbian"
libc.system( exePath+" "+args+" >/dev/null 2>/dev/null &" )
#Endif
End
Private
Function FindBinFolder:String( startingFolder:String )
Local cur:=CurrentDir()
Local ok:=True
ChangeDir( startingFolder )
While GetFileType( "bin" )<>FileType.Directory Or GetFileType( "modules" )<>FileType.Directory
If IsRootDir( CurrentDir() )
ok=False
Exit
Endif
ChangeDir( ExtractDir( CurrentDir() ) )
Wend
Local result:=ok ? CurrentDir() Else ""
ChangeDir( cur )
Return result
End