forked from fantaisie-software/purebasic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPureBasic.pb
More file actions
798 lines (654 loc) · 25.5 KB
/
PureBasic.pb
File metadata and controls
798 lines (654 loc) · 25.5 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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
;--------------------------------------------------------------------------------------------
; Copyright (c) Fantaisie Software. All rights reserved.
; Dual licensed under the GPL and Fantaisie Software licenses.
; See LICENSE and LICENSE-FANTAISIE in the project root for license information.
;--------------------------------------------------------------------------------------------
; Change: Now *every* file in the source tree is included from this main file
; This will reduce the number of XIncludeFile's in each file, and there is no more need to check dependencies.
; Even platform specific files are always included. Whether their code is compiled
; is decided in each file.
XIncludeFile "CompilerFlags.pb"
; Fred config, easier to handle switch between PB versions when debugging the IDE
;
CompilerIf Defined(FredLocalCompile, #PB_Constant) And Not Defined(BUILD_DIRECTORY, #PB_Constant)
CompilerIf #SpiderBasic
#FredProcessorPath = "javascript"
CompilerElseIf #PB_Compiler_Processor = #PB_Processor_x64
#FredProcessorPath = "x64"
CompilerElse
#FredProcessorPath = "x86"
CompilerEndIf
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
#BUILD_DIRECTORY = "/home/fred/svn/"+#SVNVersion+"/Build/"+#FredProcessorPath+"/ide/"
CompilerElseIf #PB_Compiler_OS = #PB_OS_MacOS
#BUILD_DIRECTORY = "/Users/fred/svn/"+#SVNVersion+"/Build/"+#FredProcessorPath+"/ide/"
CompilerElse
#BUILD_DIRECTORY = "C:\PureBasic\Svn\"+#SVNVersion+"\Build\"+#FredProcessorPath+"\ide\"
CompilerEndIf
CompilerEndIf
XIncludeFile #BUILD_DIRECTORY + "BuildInfo.pb"
XIncludeFile ".." + #Separator + "DialogManager" + #Separator + "Common.pb" ; must be before Common.pb
XIncludeFile "Common.pb" ; must be before DebuggerCommon.pb
XIncludeFile #DEFAULT_DebuggerSource + "DebuggerCommon.pb" ; must be before Declarations.pb
XIncludeFile "Declarations.pb"
XIncludeFile "Macro.pb"
XIncludeFile ".." + #Separator + "PureBasicConfigPath.pb" ; for the config directory
XIncludeFile "RemoteProcedureCall.pb"
XIncludeFile "FormDesigner/declare.pb"
; must be here to affect all OpenWindow() calls with a macro
XIncludeFile "LinuxWindowIcon.pb"
XIncludeFile "ZLib.pb"
; include the TabBarGadget. Note: It has an EnableExplicit inside
XIncludeFile "TabBarGadget.pbi"
DisableExplicit
; dialog manager
; We need the explorer and scintilla support for it (for Templates window and Projects)
#DIALOG_USE_SCINTILLA = 1
#DIALOG_USE_EXPLORER = 1
IncludePath ".." + #Separator + "DialogManager" + #Separator ; so that the dialog manager files are found
XIncludeFile "DialogManager.pb"
IncludePath ""
; debugging functions and macros (mostly active in debug mode only)
XIncludeFile "WindowsDebugging.pb"
XIncludeFile "LinuxDebugging.pb"
; should be before the debugger files, as they need some of this
XIncludeFile "WindowsExtensions.pb"
XIncludeFile "LinuxExtensions.pb"
XIncludeFile "MacExtensions.pb"
; debugger external files
XIncludeFile #DEFAULT_DebuggerSource + "Misc.pb"
XIncludeFile #DEFAULT_DebuggerSource + "VariableGadget.pb"
XIncludeFile #DEFAULT_DebuggerSource + "Communication_PipeWindows.pb"
XIncludeFile #DEFAULT_DebuggerSource + "Communication_PipeUnix.pb"
XIncludeFile #DEFAULT_DebuggerSource + "Communication_Network.pb"
XIncludeFile #DEFAULT_DebuggerSource + "Communication.pb"
XIncludeFile #DEFAULT_DebuggerSource + "DebugOutput.pb"
XIncludeFile #DEFAULT_DebuggerSource + "AsmDebug.pb"
XIncludeFile #DEFAULT_DebuggerSource + "MemoryViewer.pb"
XIncludeFile #DEFAULT_DebuggerSource + "VariableDebug.pb"
XIncludeFile #DEFAULT_DebuggerSource + "History.pb"
XIncludeFile #DEFAULT_DebuggerSource + "WatchList.pb"
XIncludeFile #DEFAULT_DebuggerSource + "DataBreakPoints.pb"
XIncludeFile #DEFAULT_DebuggerSource + "Profiler.pb"
XIncludeFile #DEFAULT_DebuggerSource + "LibraryViewer.pb"
XIncludeFile #DEFAULT_DebuggerSource + "Purifier.pb"
XIncludeFile #DEFAULT_DebuggerSource + "DebuggerGUI.pb"
; Plugins for the LibraryViewer
XIncludeFile #DEFAULT_DebuggerSource + "Plugin_Image.pb"
XIncludeFile #DEFAULT_DebuggerSource + "Plugin_Xml.pb"
; debugger ide-files
XIncludeFile "IDEDebugger.pb"
XIncludeFile "Automation.pb"
XIncludeFile "CompilerInterface.pb"
XIncludeFile "Language.pb"
XIncludeFile "ZipManagement.pb"
XIncludeFile "ToolbarManagement.pb"
XIncludeFile "ThemeManagement.pb"
XIncludeFile "HighlightingEngine.pb"
XIncludeFile "HighlightingFunctions.pb"
XIncludeFile "ShortcutManagement.pb"
XIncludeFile "ProjectManagement.pb"
XIncludeFile "FormDesigner/grid.pbi"
XIncludeFile "FormDesigner/undoredo.pb"
XIncludeFile "FormDesigner/helpingfunctions.pb"
XIncludeFile "FormDesigner/gadgetitemswindow.pb"
XIncludeFile "FormDesigner/imageslistwindow.pb"
XIncludeFile "FormDesigner/splitterwindow.pb"
XIncludeFile "FormDesigner/codeviewer.pb"
XIncludeFile "FormDesigner/mainevents.pb"
XIncludeFile "FormDesigner/copypaste.pb"
XIncludeFile "FormDesigner/opensave.pb"
XIncludeFile "FormDesigner/mainwindow.pb"
XIncludeFile "FormDesigner/FormManagement.pb"
XIncludeFile "SourceManagement.pb"
XIncludeFile "SourceParser.pb"
XIncludeFile "UserInterface.pb"
XIncludeFile "Misc.pb"
XIncludeFile "FileSystem.pb"
XIncludeFile "IDEMisc.pb"
XIncludeFile "RecentFiles.pb"
XIncludeFile "AddTools.pb"
XIncludeFile "AboutWindow.pb"
XIncludeFile "FileViewer.pb"
XIncludeFile "GotoWindow.pb"
XIncludeFile "StructureViewer.pb"
XIncludeFile "StructureFunctions.pb"
XIncludeFile "FindWindow.pb"
XIncludeFile "GrepWindow.pb"
XIncludeFile "CompilerWindow.pb"
XIncludeFile "CompilerWarnings.pb"
XIncludeFile "CompilerOptions.pb"
XIncludeFile "AddHelpFiles.pb"
XIncludeFile "AutoComplete.pb"
XIncludeFile "Preferences.pb"
XIncludeFile "Preferences.pb"
XIncludeFile "StandaloneDebuggerControl.pb"
XIncludeFile "ErrorHandler.pb"
XIncludeFile "Commandline.pb"
XIncludeFile "DiffWindow.pb"
XIncludeFile "LinuxHelp.pb"
XIncludeFile "EditHistory.pb"
XIncludeFile "UpdateCheck.pb"
CompilerIf #SpiderBasic
XIncludeFile "CreateApp.pb"
CompilerEndIf
; compiled dialogs
XIncludeFile #BUILD_DIRECTORY + "Find.pb"
XIncludeFile #BUILD_DIRECTORY + "Grep.pb"
XIncludeFile #BUILD_DIRECTORY + "Diff.pb"
XIncludeFile #BUILD_DIRECTORY + "Goto.pb"
XIncludeFile #BUILD_DIRECTORY + "AddTools.pb"
XIncludeFile #BUILD_DIRECTORY + "About.pb"
XIncludeFile #BUILD_DIRECTORY + "Preferences.pb"
XIncludeFile #BUILD_DIRECTORY + "Templates.pb"
XIncludeFile #BUILD_DIRECTORY + "StructureViewer.pb"
XIncludeFile #BUILD_DIRECTORY + "Projects.pb"
XIncludeFile #BUILD_DIRECTORY + "Build.pb"
XIncludeFile #BUILD_DIRECTORY + "FileMonitor.pb"
XIncludeFile #BUILD_DIRECTORY + "History.pb"
XIncludeFile #BUILD_DIRECTORY + "HistoryShutdown.pb"
XIncludeFile #BUILD_DIRECTORY + "Updates.pb"
CompilerIf #SpiderBasic
XIncludeFile #BUILD_DIRECTORY + "CreateApp.pb"
CompilerEndIf
; Here is the trick:
; We need two slightly different versions of the Compiler options dialog,
; so to not duplicate all the stuff, we generate the file once from the xml
; and then include it here twice, with the #IDE_ProjectCompilerOptions defined
; for only one of them to make the few changes.
;
; To not get a duplicate label error, the generated label in the file is actually
; a macro which is replaced with the real label on compilation
;
Macro Dialog_CompilerOptionsMacro()
CompilerIf Defined(IDE_ProjectCompilerOptions, #PB_Constant)
Dialog_ProjectCompilerOptions:
CompilerElse
Dialog_CompilerOptions:
CompilerEndIf
EndMacro
IncludeFile #BUILD_DIRECTORY + "CompilerOptions.pb"
#IDE_ProjectCompilerOptions = 1
IncludeFile #BUILD_DIRECTORY + "CompilerOptions.pb"
; toolspanel plugins
XIncludeFile "AsciiTable.pb"
XIncludeFile "Explorer.pb"
XIncludeFile "ProjectPanel.pb"
XIncludeFile "ColorPicker.pb"
XIncludeFile "ProcedureBrowser.pb"
XIncludeFile "VariableViewer.pb"
XIncludeFile "HelpTool.pb"
XIncludeFile "Issues.pb"
; windows specific
XIncludeFile "WindowsMisc.pb"
XIncludeFile "WindowsHelp.pb"
; linux specific
XIncludeFile "LinuxMisc.pb"
XIncludeFile "HelpViewer.pb"
; macos specific
XIncludeFile "MacMisc.pb"
; highlighting files
XIncludeFile "ScintillaHighlighting.pb"
XIncludeFile "CodeViewer.pb"
XIncludeFile "DisplayMacroError.pb"
XIncludeFile "Templates.pb"
XIncludeFile "ToolsPanel.pb"
; crossplatform debugging helpers
XIncludeFile "Debugging.pb"
;W__time.q = ElapsedMilliseconds()
;- Editor Start
; This must be before anything else, as it affects path settings and such
;
ParseCommandline()
If CommandlineBuild
OpenConsole()
EndIf
If OSStartupCode() = 0
End
EndIf
InitToolbar() ; must be before LoadPreferences() !
InitSyntaxCheckArrays() ; must be before LoadPreferences() ! (as it calls BuildFoldingVT() which needs this)
LoadPreferences()
CompilerIf #CompileMac
; Avoid to be run from the image disk, as some feature won't work.
;
If FindString(LCase(PureBasicPath$), "/apptranslocation/")
MessageRequester("Error", #ProductName$ + " can't be run directly from the dmg disk, it needs to be drag'n'dropped in Application or in any other place.", #FLAG_Error)
OSEndCode()
End 1
EndIf
CompilerEndIf
If Editor_RunOnce And CommandlineBuild = 0
; New RunOnce handling, all in one OS-specifc routine
; to allow a better method to be used on Windows (maybe also Linux)
;
If RunOnce_Startup(InitialSourceLine) ; Returns true when IDE should close
OSEndCode()
End
EndIf
EndIf
LoadLanguage() ; must be before StartCompiler()
StartCompiler(@DefaultCompiler) ; gets the compiler version for the splash screen
Procedure CloseSplashScreen()
Static IsClosed = 0
If IsClosed = 0 And NoSplashScreen = 0
IsClosed = 1
CompilerIf #PB_Compiler_Debugger
; Prevent debugger errors when missing Scintilla.dll causes early exit
If IsWindow(#WINDOW_Startup)
CloseWindow(#WINDOW_Startup)
EndIf
If IsImage(#IMAGE_Startup)
FreeImage(#IMAGE_Startup)
EndIf
CompilerElse
CloseWindow(#WINDOW_Startup)
FreeImage(#IMAGE_Startup)
CompilerEndIf
EndIf
EndProcedure
If CommandlineBuild = 0 And NoSplashScreen = 0
; display the startup logo, as loading could take a little on slower systems..
; especially when lots of sources are reloaded.
If OpenWindow(#WINDOW_Startup, 0, 0, DesktopUnscaledX(500), DesktopUnscaledY(200), #ProductName$ + " loading...", #PB_Window_ScreenCentered|#PB_Window_BorderLess|#PB_Window_Invisible)
If CatchPackedImage(#IMAGE_Startup, ?General_Images, 0)
If StartDrawing(ImageOutput(#IMAGE_Startup))
DrawingMode(1)
FrontColor($FFFFFF)
CompilerIf #CompileWindows
DrawingFont(GetGadgetFont(#PB_Default)) ; The default GFX font on Windows is a bit ugly, so use the gadget one
CompilerEndIf
; on linux, this string is too long, so move the copyright to a second line
Version$ = DefaultCompiler\VersionString$
If TextWidth(Version$) > 480 And FindString(Version$, "- (c)", 1) <> 0
CopyRight$ = Trim(Right(Version$, Len(Version$) - FindString(Version$, "- (c)", 1))) ; will still include the (c)
Version$ = Trim(Left(Version$, FindString(Version$, "- (c)", 1) - 1))
DrawText((500-TextWidth(Version$)) / 2, 145, Version$)
DrawText((500-TextWidth(CopyRight$)) / 2, 145 + TextHeight(Version$) + 1, CopyRight$)
Else
DrawText((500-TextWidth(Version$)) / 2, 145, Version$)
DrawText((500-TextWidth("00/00/0000")) / 2, 145 + TextHeight(Version$) + 1, FormatDate("%mm/%dd/%yyyy", #PB_Compiler_Date))
EndIf
StopDrawing()
EndIf
ImageGadget(#GADGET_Startup_Image, 0, 0, 500, 200, ImageID(#IMAGE_Startup))
SetWindowStayOnTop(#WINDOW_Startup, #True) ; force the window to the top ! Note: every messagerequester are now wrapped to MessageRequesterSafe() and will close this splash screen if still opened
HideWindow(#WINDOW_Startup, #False)
FlushEvents()
EndIf
EndIf
EndIf
If CommandlineBuild = 0
LoadTheme()
If NoSplashScreen = 0: FlushEvents(): EndIf
EndIf
AddTools_Init() ; those must be before CreateGUI()
If CommandlineBuild = 0 And NoSplashScreen = 0: FlushEvents(): EndIf
AddHelpFiles_Init()
If CommandlineBuild = 0 And NoSplashScreen = 0: FlushEvents(): EndIf
; CPUMonitor_Init() ; before creategui!
;- Commandline Project building
If CommandlineBuild
CommandlineProjectBuild()
; commandline building should not affect IDE prefs, so no need to save them
KillCompiler()
DeleteRegisteredFiles()
CompilerCleanup()
OSEndCode()
CloseConsole()
If CommandlineBuildSuccess
End 0
Else
End 1
EndIf
EndIf
;- GUI creation
If CreateGUI() = 0
MessageRequester(#ProductName$,"Critical Error! Can't create GUI!")
End
EndIf
If NoSplashScreen = 0: FlushEvents(): EndIf
FlushEvents()
If NoSplashScreen = 0: FlushEvents(): EndIf
CreateAutoCompleteWindow() ; prepare the autocomplete window (hidden)
EnsureWindowOnDesktop(#WINDOW_Main)
If IsWindowMaximized
ShowWindowMaximized(#WINDOW_Main)
Else
HideWindow(#WINDOW_Main, 0)
EndIf
FlushEvents() ; flush events even if no splashscreen is there, because of the main gui
; setup the timer for the file changes monitor
SetupFileMonitor()
; Calculate the hidden width of the toolspanel (for autohide)
; Can be done only after the gadget is displayed
CompilerIf #CompileLinux
ToolsPanelHiddenWidth = GetGadgetAttribute(#GADGET_ToolsPanel, #PB_Panel_TabHeight)
If ToolsPanelVisible = 0
ResizeMainWindow()
EndIf
CompilerEndIf
; apply the splitter positions now, as before all gadgets are 0 in size.
;
If ErrorLogVisible
SetGadgetState(#GADGET_LogSplitter, GadgetHeight(#GADGET_LogSplitter)-ErrorLogHeight)
Else
ErrorLogHeight_Hidden = ErrorLogHeight ; simply set the "hidden" value to the prefs one
EndIf
If ToolsPanelVisible
If ToolsPanelSide = 0
SetGadgetState(#GADGET_ToolsSplitter, GadgetWidth(#GADGET_ToolsSplitter)-ToolsPanelWidth)
Else
SetGadgetState(#GADGET_ToolsSplitter, ToolsPanelWidth)
EndIf
Else
ToolsPanelWidth_Hidden = ToolsPanelWidth
EndIf
If ToolsPanelAutoHide Or ToolsPanelMode = 0 ; hide the panel if we do not need it
ToolsPanel_Hide()
EndIf
; Initialize history session (do this before opening any files)
;
StartHistorySession()
; Now we can directly handle the OSX "open document" event
;
CompilerIf #CompileMac
ReadyForDocumentEvent = 1
CompilerEndIf
; Initialize automation (do this before opening files)
;
InitAutomation()
; First try to load a project if provided on the commandline
; Do this before opening the last open project!
; Note: if there are multiple projects, only open the last one (we can only have one project open at a time)
CommandLineProject$ = ""
ForEach OpenFilesCommandLine()
If IsProjectFile(OpenFilesCommandLine())
CommandLineProject$ = OpenFilesCommandLine()
DeleteElement(OpenFilesCommandLine())
EndIf
Next OpenFilesCommandLine()
If CommandLineProject$ <> ""
LoadProject(CommandLineProject$)
EndIf
; Now load the default project (or LastOpen one) (only if there was not a project loaded from commandline)
; Always load the project first, so it does look better as all project files are also saved as opened file
;
If IsProject = 0
; The last opened only if there is no default project!
If AutoReload And LastOpenProjectFile$ And DefaultProjectFile$ = ""
LoadProject(LastOpenProjectFile$)
ElseIf DefaultProjectFile$ <> ""
If LoadProject(DefaultProjectFile$) = 0
DefaultProjectFile$ = "" ; do not try again next time
EndIf
EndIf
; switch back to the last commandline source, if the -l option was present
If *LastLoadedSource And *LastLoadedSource <> *ActiveSource
ChangeCurrentElement(FileList(), *LastLoadedSource)
ChangeActiveSourceCode()
EndIf
EndIf
LastOpenProjectFile$ = "" ; reset after loading
; Now load any sourcefiles (both from commandline and preferences)
;
If AutoReload
ForEach OpenFiles()
LoadSourceFile(OpenFiles())
; Flush events. So when many sources are opened at once, the User can see a bit the
; progress, instead of just an unresponsive window for quite a while.
; There is almost no flicker anymore, so it actually looks quite good.
;
; Note: don't put this in the LoadSourceFile() routine as it can be call from the debugger and flushing the event will get another debug event !
FlushEvents()
Next OpenFiles()
EndIf
ClearList(OpenFiles()) ; reset after loading
ForEach OpenFilesCommandLine()
LoadSourceFile(OpenFilesCommandLine())
; Flush events. So when many sources are opened at once, the User can see a bit the
; progress, instead of just an unresponsive window for quite a while.
; There is almost no flicker anymore, so it actually looks quite good.
;
; Note: don't put this in the LoadSourceFile() routine as it can be call from the debugger and flushing the event will get another debug event !
FlushEvents()
Next OpenFilesCommandLine()
ClearList(OpenFilesCommandLine())
; apply the -l option (do this before opening the default project
;
If *ActiveSource And InitialSourceLine > 0 And InitialSourceLine < GetLinesCount(*ActiveSource)
ChangeActiveLine(InitialSourceLine, -5)
*LastLoadedSource = *ActiveSource
Else
*LastLoadedSource = 0
EndIf
; Open a new source if nothing was loaded
;
If ListSize(FileList()) = 0 Or (ListSize(FileList()) = 1 And *ProjectInfo)
NewSource("", #True)
HistoryEvent(*ActiveSource, #HISTORY_Create)
EndIf
FlushEvents()
CloseSplashScreen()
FlushEvents()
CompilerIf #Demo
DemoText$ = "This is the free version of "+DefaultCompiler\VersionString$+#NewLine
DemoText$ + "Please have a look at the 'Examples' folder for test programs."+#NewLine+#NewLine
DemoText$ + "Free version limitations:"+#NewLine
CompilerIf #SpiderBasic
DemoText$ + "- Program size limited to about 800 lines."+#NewLine+#NewLine
CompilerElse
CompilerIf #CompileWindows
DemoText$ + "- No Win32 API support"+#NewLine
DemoText$ + "- No DLL creation"+#NewLine
CompilerEndIf
DemoText$ + "- Code size limitation (about 800 lines)"+#NewLine+#NewLine
CompilerEndIf
DemoText$ + "Thanks a lot for using " + #ProductName$ + " !"+#NewLine+#NewLine
DemoText$ + "The Fantaisie Software Team."
MessageRequester("Information", DemoText$, #FLAG_INFO)
FlushEvents()
CompilerEndIf
AddTools_Execute(#TRIGGER_EditorStart, 0)
;MessageRequester("startup time", Str(ElapsedMilliseconds()-__time))
; Detect possible crashed session and display info if so
DetectCrashedHistorySession()
; Wait for the compiler to be loaded. (calls FlushEvents(), so the user can already start editing)
WaitForCompilerReady()
CompilerIf #CompileMacCocoa
; Oddly enough, the main window isn't activated on Cocoa after loading all the files
ActivateMainWindow()
CompilerEndIf
; Check for updates
; Do this after the WaitForCompilerReady() so we know the compiler version for the check!
CheckForUpdatesSchedule()
; Display a warm welcome :)
;
AddGadgetItem(#GADGET_ErrorLog, -1, Language("Misc", "Welcome"))
;- Main loop
QuitIDE = 0
Repeat
DispatchEvent(WaitWindowEvent())
EventLoopCallback()
; On Linux x64 and Cocoa, opening the files from the RunOnce message filter causes the IDE to lock up
; So check for new files in this list (a ListSize() is a really fast check, so this is ok)
;
CompilerIf #CompileLinux | #CompileMacCocoa
If ListSize(OpenFilesCommandLine()) > 0
ForEach OpenFilesCommandLine()
FileName$ = OpenFilesCommandLine()
If Left(FileName$, 7) = "--LINE "
; apply the current line commandline option
InitialSourceLine = Val(Right(FileName$, Len(FileName$)-7))
If InitialSourceLine > 0 And InitialSourceLine < GetLinesCount(*ActiveSource) ; apply the -l option
ChangeActiveLine(InitialSourceLine, -5)
EndIf
ElseIf FileName$ <> ""
LoadSourceFile(FileName$)
; Flush events. So when many sources are opened at once, the User can see a bit the
; progress, instead of just an unresponsive window for quite a while.
; There is almost no flicker anymore, so it actually looks quite good.
;
; Note: don't put this in the LoadSourceFile() routine as it can be call from the debugger and flushing the event will get another debug event !
FlushEvents()
EndIf
Next OpenFilesCommandLine()
; Empty list and make sure the IDE is in the foreground now
;
ClearList(OpenFilesCommandLine())
SetWindowForeground(#WINDOW_Main)
ResizeMainWindow()
EndIf
CompilerEndIf
Until QuitIDE
;- Editor end
ShutdownIDE()
; ; Gtk Object debugging: to inspect remaining leaked objects with g-insprctor
; ;
; PrintN("Calling Endfunctions, invoking gtk_main() - kill the program to quit!")
; !CALL PB_EndFunctions
; gtk_main_() ; the g-inspector can send a gtk_main_quit() for this to end
; !PUSH dword 0
; !CALL exit
End
Procedure ShutdownIDE()
; This is now packed in a procedure, so the #WM_ENDSESSION message
; can call it as well for an orderly shutdown.
; (maybe this can be implemented for #SIGTERM on unix as well)
AddTools_Execute(#TRIGGER_EditorEnd, 0)
; make sure the project is saved and all related windows closed
;
If IsProject
LastOpenProjectFile$ = ProjectFile$
EndIf
CloseProject(#True)
; Write close events for any remaining open files
HistoryShutdownEvents()
; make sure all window settings are saved by closing them if they are open
;
If IsWindow(#WINDOW_FileViewer)
FileViewerWindowEvents(#PB_Event_CloseWindow)
EndIf
If IsWindow(#WINDOW_Find)
FindWindowEvents(#PB_Event_CloseWindow)
EndIf
If IsWindow(#WINDOW_StructureViewer)
StructureViewerWindowEvents(#PB_Event_CloseWindow)
EndIf
If IsWindow(#WINDOW_Grep)
GrepWindowEvents(#PB_Event_CloseWindow)
EndIf
If IsWindow(#WINDOW_GrepOutput)
GrepOutputWindowEvents(#PB_Event_CloseWindow)
EndIf
If IsWindow(#WINDOW_EditTools)
AddTools_EditWindowEvents(#PB_Event_CloseWindow) ; close this one before the AddTools Window!
EndIf
If IsWindow(#WINDOW_AddTools)
AddTools_WindowEvents(#PB_Event_CloseWindow)
EndIf
;
; If IsWindow(#WINDOW_CPUMonitor)
; CPUMonitorWindowEvents(#PB_Event_CloseWindow)
; EndIf
If IsWindow(#WINDOW_Template)
TemplateWindowEvents(#PB_Event_CloseWindow)
EndIf
If IsWindow(#WINDOW_MacroError)
MacroErrorWindowEvents(#PB_Event_CloseWindow)
EndIf
If IsWindow(#WINDOW_Warnings)
WarningWindowEvents(#PB_Event_CloseWindow)
EndIf
If IsWindow(#WINDOW_Diff)
DiffWindowEvents(#PB_Event_CloseWindow)
EndIf
If IsWindow(#WINDOW_DiffDialog)
DiffDialogWindowEvents(#PB_Event_CloseWindow)
EndIf
If IsWindow(#WINDOW_FileMonitor)
FileMonitorWindowEvents(#PB_Event_CloseWindow)
EndIf
; OptionWindow is closed when the source is closed
CompilerIf #CompileLinux | #CompileMac
If IsWindow(#WINDOW_Help)
HelpWindowevents(#PB_Event_CloseWindow)
EndIf
CompilerEndIf
; call the destroy function for all ToolsPanel items that have one
;
ForEach UsedPanelTools()
*PanelToolData.ToolsPanelEntry = UsedPanelTools()
If *PanelToolData\NeedDestroyFunction
PanelTool.ToolsPanelInterface = UsedPanelTools()
PanelTool\DestroyFunction()
EndIf
Next UsedPanelTools()
; Close any tools in external tool windows
;
ForEach AvailablePanelTools()
If AvailablePanelTools()\IsSeparateWindow
If AvailablePanelTools()\NeedDestroyFunction
Tool.ToolsPanelInterface = @AvailablePanelTools()
Tool\DestroyFunction()
EndIf
If MemorizeWindow And IsWindowMinimized(AvailablePanelTools()\ToolWindowID) = 0
Window = AvailablePanelTools()\ToolWindowID
AvailablePanelTools()\ToolWindowX = WindowX(Window)
AvailablePanelTools()\ToolWindowY = WindowY(Window)
AvailablePanelTools()\ToolWindowWidth = WindowWidth(Window)
AvailablePanelTools()\ToolWindowHeight = WindowHeight(Window)
EndIf
CloseWindow(AvailablePanelTools()\ToolWindowID)
AvailablePanelTools()\ToolWindowID = -1
AvailablePanelTools()\IsSeparateWindow = 0
EndIf
Next AvailablePanelTools()
; memorize main window settings
;
If MemorizeWindow And IsWindowMinimized(#Window_Main) = 0
IsWindowMaximized = IsWindowMaximized(#WINDOW_Main)
EditorWindowWidth = Save_EditorWidth
EditorWindowHeight = Save_EditorHeight
EditorWindowX = Save_EditorX
EditorWindowY = Save_EditorY
Else
EditorWindowWidth = Memorize_EditorWidth
EditorWindowHeight = Memorize_EditorHeight
EndIf
; Save the splitter positions if the PB splitters are used.
; This is done also when MemorizeWindow is off, to be the same as the non-PB splitters
;
If ErrorLogVisible
ErrorLogHeight = GadgetHeight(#GADGET_LogSplitter) - GetGadgetState(#GADGET_LogSplitter)
Else
ErrorLogHeight = ErrorLogHeight_Hidden
EndIf
If ToolsPanelVisible
If ToolsPanelSide = 0
ToolsPanelWidth = GadgetWidth(#GADGET_ToolsSplitter) - GetGadgetState(#GADGET_ToolsSplitter)
Else
ToolsPanelWidth = GetGadgetState(#GADGET_ToolsSplitter)
EndIf
Else
ToolsPanelWidth = ToolsPanelWidth_Hidden
EndIf
; Close main window
CloseWindow(#WINDOW_Main)
; Fix IDE crash on macOS Big Sur
FlushEvents()
; end history session. this could take a bit if many files were open (will display a small wait screen if so)
EndHistorySession()
ShutdownAutomation()
Debugger_Quit() ; kills all running debugger programs (should be before SavePreferences())
LibraryViewer_End() ; unload all libraryviewer plugin dlls
SavePreferences()
KillCompiler()
DeleteRegisteredFiles()
CompilerCleanup()
OSEndCode()
EndProcedure
DataSection
General_Images:
IncludeBinary #BUILD_DIRECTORY + "images.pak"
EndDataSection