forked from livecode/livecode-ide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.livecodescript
More file actions
1885 lines (1526 loc) · 66.6 KB
/
home.livecodescript
File metadata and controls
1885 lines (1526 loc) · 66.6 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
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
script "home"
constant kImportantTextColor = "#569e54"
on startup
-- MW-2011-03-13: Make sure the externals are empty on startup
set the externals of me to empty
set the allowInterrupts to false
set the cREVLaunching of me to true
revInternal__Log "Start"
revInternal__Log "Enter", "Startup"
try
revInternal__SetupLicense
revInternal__SetupPaths
revInternal__SetupFolders
revInternal__SetupStackFiles
revInternal__SetupSplash
revInternal__SetupPreferences
revInternal__SetupCustomizationPath
revInternal__SetupExternals
catch tError
revInternal__Log "Error", tError
end try
revInternal__Log "Leave", "Startup"
end startup
on relaunch
global gREVDevelopment
if gREVDevelopment then
pass relaunch
end if
-- Pass the relaunch request through a hook
local tParameters
repeat with x = 1 to the paramCount()
put param(x) into tParameters[x]
end repeat
dispatch command "revHookLaunchInstance" to me with tParameters
if it is "handled" then
if the result is empty then
pass relaunch
else if the result is "background" then
return "background"
end if
return empty
end if
-- The hook did nothing, so do our default processing
repeat with x = 1 to the paramcount()
local tStackFile
put param(x) into tStackFile
if there is a file tStackFile then -- open it
revIDEOpenStack tStackFile
else
next repeat
end if
end repeat
end relaunch
on shutdown
end shutdown
on saveStackRequest
set the cantModify of me to true
pass saveStackRequest
end saveStackRequest
on preOpenStack
local tEdition, tSplashPath
if the short name of the owner of the target is not "Home" then
pass preOpenStack
end if
revInternal__Log "Enter", "Pre-Open Stack"
revInternal__InitialiseDefaults
revInternal__Log "Leave", "Pre-Open Stack"
end preOpenStack
on openStack
if the short name of the owner of the target is not "Home" then
pass openStack
end if
revInternal__Log "Enter", "Open Stack"
//send "revInternal__openStack" to me in 0 millisecs
revInternal__openStack
revInternal__Log "Leave", "Open Stack"
end openStack
local sSplashStartTime
on revInternal__openStack
revInternal__Log "Enter", "revInternal__openStack"
put the milliseconds into sSplashStartTime
set the cREVLaunching of stack "Home" to true
local tSuccess
put true into tSuccess
try
if tSuccess then
revInternal__setSplashStatus "Checking System Parameters..."
revInternal__InitialiseSystem
put the result into tSuccess
end if
if tSuccess then
revInternal__setSplashStatus "Loading Libraries..."
revInternal__InitialiseLibraries
put the result into tSuccess
end if
if tSuccess then
revInternal__setSplashStatus "Setting Globals..."
revInternal__InitialiseGlobals
put the result into tSuccess
end if
if tSuccess then
revInternal__setSplashStatus "Setting Preferences..."
revInternal__InitialiseOptions
put the result into tSuccess
end if
if tSuccess then
revInternal__setSplashStatus "Loading Standard Icons..."
set the visible of stack "revGeneralIcons" to false
put true into tSuccess
end if
if tSuccess then
revInternal__setSplashStatus "Loading theme data..."
revInternal__InitialiseIcons
put the result into tSuccess
end if
if tSuccess then
revInternal__setSplashStatus "Loading Patterns..."
repeat for each item tPatternStack in "revGeneralPatterns,revCompatibilityPatterns1,revCompatibilityPatterns2"
get there is a stack tPatternStack
end repeat
put true into tSuccess
end if
if tSuccess then
revInternal__setSplashStatus "Loading Script Editor..."
revInternal__InitialiseScriptEditor
put the result into tSuccess
end if
if tSuccess then
revInternal__setSplashStatus "Loading User Icon Libraries..."
revInternal__InitialiseUserLibraries
put the result into tSuccess
end if
if tSuccess then
revInternal__setSplashStatus "Loading Error Management..."
revInternal__InitialiseErrors
put the result into tSuccess
end if
if tSuccess then
revInternal__setSplashStatus "Loading Menu Bar..."
revInternal__InitialiseMenus
put the result into tSuccess
end if
if tSuccess then
revInternal__setSplashStatus "Loading Tools..."
revInternal__InitialiseTools
put the result into tSuccess
end if
if tSuccess then
revInternal__setSplashStatus "Loading Application Overview..."
revInternal__InitialiseApplicationOverview
put the result into tSuccess
end if
if tSuccess then
revInternal__setSplashStatus "Loading Message Box..."
revInternal__InitialiseMessageBox
put the result into tSuccess
end if
if tSuccess then
revInternal__setSplashStatus "Loading Debugger..."
revInternal__InitialiseDebugger
put the result into tSuccess
end if
if tSuccess then
revInternal__setSplashStatus "Loading QuickTime..."
revInternal__InitialiseQuickTime
put the result into tSuccess
end if
if tSuccess then
revInternal__setSplashStatus "Loading Plug-ins..."
revInternal__InitialisePlugIns
put the result into tSuccess
set the defaultStack to "home" -- plug ins may take away default stack
end if
if tSuccess and not revEnvironmentIsInstalled() then
revInternal__setSplashStatus "Building Dictionary"
revInternal__BuildDictionary
put the result into tSuccess
end if
if tSuccess then
revInternal__setSplashStatus "Performing Final Steps..."
revInternal__setSplashStatus ""
revInternal__InitialiseFinalSteps
put the result into tSuccess
end if
catch tError
revInternal__Log "Error", tError
end try
set the cREVLaunching of stack "Home" to false
if not tSuccess then
quit
end if
if $REV_TOOLS_PATH is empty and (revInternal__CheckFileAssociations() is true) and (the platform is "win32") then
if revIDEPrefGet("DontShowFileAssociationsDialog") is not true then
modal stack "revFileAssociations"
end if
end if
# AL-2015-07-10: Temporarily disable welcome screen
/*
if revIDEGetPreference("welcomeScreenShown") is not "true" then
revIDEOpenPalette "Welcome"
else if revIDEPrefGet("StartPageShow") is not "false" then
*/
if revIDEPrefGet("StartPageShow") is not "false" then
revIDEOpenPalette "Start Center"
end if
try
revIDEOpenPropertyInspectorControllerStacks
end try
-- MM-2011-09-27: The new auto update process is handled entirely by the installer.
-- Luanch the installer in update mode to begin update process.
--
if line 3 of revLicenseInfo is not "evaluation" then
local tCommand, tOldPath
put $PATH into tOldPath
set the itemdelimiter to "/"
switch the platform
case "MacOS"
put item 1 to -5 of the filename me & "/LiveCode Setup.app/Contents/MacOS/installer" into tCommand
put quote & tCommand & quote && "install -update" into tCommand
break
case "Win32"
put item 1 to -3 of the filename me & "/.setup.exe" into tCommand
put quote & tCommand & quote && "install -update" into tCommand
break
case "Linux"
--put item 1 to -3 of the filename me into $PATH
--put ".setup.x86 install -update" into tCommand
put item 1 to -3 of the filename me & "/.setup.x86" into tCommand
put tCommand && "install -update" into tCommand
break
end switch
set the itemDel to comma
open process tCommand for neither
put tOldPath into $PATH
end if
close stack "revSplash"
revInternal__Log "Leave", "revInternal__openStack"
revInternal__Log "End"
-- Now the home stack has loaded, we can allow interrupts..
set the allowInterrupts to true
end revInternal__openStack
on revInternal__setSplashStatus pMessage
revInternal__Log "Message", pMessage
set the statusMessage of stack "revSplash" to pMessage
end revInternal__setSplashStatus
local sLicensePlatform
local sLicenseClass
local sLicenseVersion
local sLicenseName
local sLicenseOrganization
local sLicenseMultiplicity
-- This is the path to the folder containing the IDE's folders
local sToolsPath
-- This is the path to the folder containing user preferences
local sPreferencesPath
-- This is the path to the folder containing user support files
local sCrashLogPath
local sCachePath
-- This is the path to the user-specified IDE customization folder
local sCustomizationPath
-- This is the path to the folder containing user preferences for the IDE prior to 4.5
local sOldPreferencesPath
-- This is the path to the folder containing support files for the IDE prior to 4.5
local sOldSupportPath
-- MW-2013-06-10: [[ CloneAndRun ]] This is the path containing all the binaries the IDE should
-- use. If empty it means use default installed locations, otherwise this is a git repo build
local sBinariesPath
-- MW-2013-06-10: [[ CloneAndRun ]] This is the path containing the root of the git repository.
local sRepositoryPath
//EJB
local sOverrideRuntimePath, sTestEnvironment
-- Parameterize this so it makes it easier to change.
constant kProductName = "LiveCode"
--------------------------------------------------------------------------------
-- Internal Setup Functions
--
private command revInternal__SetupLicense
revInternal__Log "Enter", "License Setup"
put line 1 of the revLicenseInfo into sLicenseName
put line 2 of the revLicenseInfo into sLicenseOrganization
put line 3 of the revLicenseInfo into sLicenseClass
put line 4 of the revLicenseInfo into sLicenseMultiplicity
if sLicenseMultiplicity is empty then
put 1 into sLicenseMultiplicity
end if
put the version && "build" && the buildnumber into sLicenseVersion
put revEnvironmentPlatform() into sLicensePlatform
revInternal__Log "Leave", "License Setup"
end revInternal__SetupLicense
private command revInternal__SetupPaths
revInternal__Log "Enter", "Path Setup"
local tHomePath
put the filename of me into tHomePath
set the itemDelimiter to "/"
put item 1 to -3 of tHomePath into sToolsPath
-- MW-2013-06-13: Extract the engine path from 'the address' (needs adjustment
-- per platform).
local tEnginePath
set the itemDelimiter to ":"
put item 2 to -1 of the address into tEnginePath
set the itemDelimiter to "/"
switch revEnvironmentPlatform()
case "Linux"
local tOldFolder
put the folder into tOldFolder
set the folder to "~"
put the folder & slash & ".runrev/revolution/enterprise/preferences" into sOldPreferencesPath
if there is no folder sOldPreferencesPath then
put the folder & slash & ".runrev/revolution/studio/preferences" into sOldPreferencesPath
end if
if there is no folder sOldPreferencesPath then
put the folder & slash & ".runrev/revolution/media/preferences" into sOldPreferencesPath
end if
put the folder & slash & ".runrev/preferences" into sPreferencesPath
put the folder & slash & ".runrev/cache" into sCachePath
put the folder & slash & ".runrev/crashlogs" into sCrashLogPath
set the folder to tOldFolder
-- MW-2013-06-13: Adjust the engine path for Linux
put item 1 to -2 of tEnginePath into tEnginePath
break
case "MacOS X"
put specialFolderPath("Preferences") & "/Runtime Revolution/Revolution Enterprise" into sOldPreferencesPath
if there is no folder sOldPreferencesPath then
put specialFolderPath("Preferences") & "/Runtime Revolution/Revolution Studio" into sOldPreferencesPath
end if
if there is no folder sOldPreferencesPath then
put specialFolderPath("Preferences") & "/Runtime Revolution/Revolution Media" into sOldPreferencesPath
end if
put specialFolderPath("Preferences") & "/RunRev" into sPreferencesPath
put specialFolderPath("cusr") & "/Library/Application Support/RunRev/Cache" into sCachePath
put specialFolderPath("cusr") & "/Library/Application Support/RunRev/Crash Logs" into sCrashLogPath
-- MW-2013-06-13: Adjust the engine path for Mac
put item 1 to -5 of tEnginePath into tEnginePath
break
case "Windows"
-- We put prefereces into the 'Roaming' AppData folder.
put specialFolderPath(0x001a) & "/Runtime Revolution/Revolution Enterprise/Preferences" into sOldPreferencesPath
if there is no folder sOldPreferencesPath then
put specialFolderPath(0x001a) & "/Runtime Revolution/Revolution Studio/Preferences" into sOldPreferencesPath
end if
if there is no folder sOldPreferencesPath then
put specialFolderPath(0x001a) & "/Runtime Revolution/Revolution Media/Preferences" into sOldPreferencesPath
end if
put specialFolderPath(0x001a) & "/RunRev/Preferences" into sPreferencesPath
-- We put everything else in the 'Local' AppData folder.
put specialFolderPath(0x001c) & "/RunRev/Cache" into sCachePath
put specialFolderPath(0x001c) & "/RunRev/Crash Logs" into sCrashLogPath
-- MW-2013-06-13: Adjust the engine path for Windows
put item 1 to -2 of tEnginePath into tEnginePath
break
end switch
-- MW-2013-06-13: [[ CloneAndRun ]] Set up the binaries path.
local tRepositoryPath
put revEnvironmentGuessRepositoryPath(tEnginePath) into tRepositoryPath
if tRepositoryPath is not empty then
put tRepositoryPath into sRepositoryPath
put tEnginePath into sBinariesPath
else
put empty into sRepositoryPath
end if
revInternal__Log "Message", "Tools Path = " & sToolsPath
revInternal__Log "Message", "Old Preferences Path = " & sOldPreferencesPath
revInternal__Log "Message", "Preferences Path = " & sPreferencesPath
revInternal__Log "Message", "Cache Path = " & sCachePath
revInternal__Log "Message", "Crash Log Path = " & sCrashLogPath
revInternal__Log "Message", "Binaries Path = " & sBinariesPath
revInternal__Log "Leave", "Path Setup"
end revInternal__SetupPaths
command revInternal__SetupCustomizationPath
revInternal__Log "Enter", "Customization Path Setup"
# If there is a customization path set in the preferences, and it exists, then use it, otherwise
# revert to old behavior.
local tUserCustomizationPath
put the cCustomizationPath of stack "revPreferences" into tUserCustomizationPath
if tUserCustomizationPath is not empty then
put tUserCustomizationPath into sCustomizationPath
else
switch revEnvironmentPlatform()
case "Linux"
local tOldFolder
put the folder into tOldFolder
set the folder to "~"
put the folder & slash & "my_livecode" into sCustomizationPath
set the folder to tOldFolder
break
case "Windows"
put specialFolderPath(0x0005) & "/My LiveCode" into sCustomizationPath
break
case "MacOS X"
put specialFolderPath("docs") & "/My LiveCode" into sCustomizationPath
break
end switch
revInternal__Log "Message", "Customization Path = " & sCustomizationPath
end if
revInternal__Log "Leave", "Customization Path Setup"
end revInternal__SetupCustomizationPath
function revInternal__StackFiles
local tPaletteFolder, tFolders
put revEnvironmentToolsetPath() & slash & "palettes" into tPaletteFolder
put tPaletteFolder into tFolders
set the defaultfolder to tPaletteFolder
repeat for each line tFolder in the folders
if char 1 of tFolder is "." then next repeat
put return & tPaletteFolder & slash & tFolder after tFolders
end repeat
put return & revEnvironmentToolsetPath() & slash & "libraries" after tFolders
if revEnvironmentIsInstalled() then
put return & revEnvironmentToolsetPath() after tFolders
else
put return & revEnvironmentRepositoryPath() & slash & "ide-support" after tFolders
end if
local tStackFiles, tStackName
local tStackFilesA, tIDEVersion
set the itemdel to "."
put item 1 of the version into tIDEVersion
repeat for each line tPath in tFolders
set the defaultfolder to tPath
repeat for each line tFile in the files
if the last item of tFile is not among the items of "rev.livecode.livecodescript" then next repeat
put item 1 to -2 of tFile into tStackName
local tVersion
put empty into tVersion
// AL-2015-02-18: [[ Named Stack Versions ]] Check if this stack should be loaded in this version.
if the number of items in tFile > 2 then
get item -2 of tFile
if it is a number then
put it into tVersion
put item 1 to -3 of tFile into tStackName
if tVersion > tIDEVersion then
next repeat
end if
end if
end if
if tStackName is "revpagesetupdialog" then put "Page Setup Dialog" into tStackName
else if tStackName is "revprintdialog" then put "Print Dialog" into tStackName
else if tStackName is "revcolorchooser" then put "Color Chooser" into tStackName
else if tStackName is "revfileselector" then put "File Selector" into tStackName
else if tStackName is "revanswerdialog" then put "Answer Dialog" into tStackName
else if tStackName is "revaskdialog" then put "Ask Dialog" into tStackName
else if tStackName is "revmessagebox" then put "Message Box" into tStackName
else if tStackName is "revideprojectbrowserview" then put "revIDEProjectBrowser" into tStackName
else if tStackName is "revscripteditor" then put "revNewScriptEditor" into tStackName
# AL-2015-03-12: [[ Bug ]] Make sure Linux stacks included in standalones have the correct name
else if tStackName is "revprinterchooser" then put "Printer Chooser" into tStackName
else if tStackName is "revpagesetup" then put "Page Setup" into tStackName
// AL-2015-02-18: [[ Named Stack Versions ]] Choose a versioned stack file name over an unversioned one, and a later version over an earlier one.
local tExistingVersion
put tStackFilesA[tStackName]["version"] into tExistingVersion
if tExistingVersion is empty or tVersion > tExistingVersion then
put tPath & slash & tFile into tStackFilesA[tStackName]["file"]
put tVersion into tStackFilesA[tStackName]["version"]
end if
end repeat
end repeat
repeat for each key tKey in tStackFilesA
put tKey & comma & tStackFilesA[tKey]["file"] & return after tStackFiles
end repeat
delete the last char of tStackFiles
return tStackFiles
/*
local tStackFiles
local tUserPath, tPath
put revEnvironmentToolsPath() into tPath
put revEnvironmentUserToolsetPath() into tUserPath
local tItem
set the itemDelimiter to tab
repeat for each line tItem in field "Toolset" of card "Data" of stack "Home"
if item 2 of tItem is "Resources" then
put item 1 of tItem, tPath & slash & item 3 of tItem & return after tStackFiles
else if item 2 of tItem is "Unsupported" then
put item 1 of tItem, tPath & "/Unsupported/" & item 3 of tItem & return after tStackFiles
else if there is a file (tUserPath & "/" & item 3 of tItem) then
put item 1 of tItem, tUserPath & "/" & item 3 of tItem & return after tStackFiles
else if not revEnvironmentIsInstalled() and (item 3 of tItem ends with ".livecodescript") then
put item 1 of tItem, (revEnvironmentRepositoryPath() & slash & "ide-support" & slash & item 3 of tItem) & return after tStackfiles
else
put item 1 of tItem, tPath & "/Toolset/" & item 3 of tItem & return after tStackFiles
end if
end repeat
return tStackFiles
*/
end revInternal__StackFiles
private command revInternal__SetupPreferences
revInternal__Log "Enter", "Preferences Setup"
local tOldPreferencesStackFile, tOldNewPreferencesStackFile
put sOldPreferencesPath & "/revpreferences.rev" into tOldPreferencesStackFile
put sPreferencesPath & "/reventerprise.rev" into tOldNewPreferencesStackFile
local tPreferencesStackFile
put sPreferencesPath & "/" & toLower(kProductName) & ".rev" into tPreferencesStackFile
local tPreferencesStackFile7
put sPreferencesPath & "/" & toLower(kProductName) & "7.rev" into tPreferencesStackFile7
local tIndex, tStackFiles
if the buildnumber < 10000 then
-- First check to see if we have a preferences stack file in the new location that
-- will not load.
if there is a file tPreferencesStackFile and there is no stack tPreferencesStackFile then
revInternal__Log "Message", "Existing Preferences Stack Corrupted"
put 1 into tIndex
repeat while there is a file (tPreferencesStackFile & ".corrupt." & tIndex)
add 1 to tIndex
end repeat
revInternal__Log "Message", "Moving Broken Stack to '" & tPreferencesStackFile & "'"
rename file tPreferencesStackFile to (tPreferencesStackFile & ".corrupt." & tIndex)
end if
-- Next check to see that if there is a preferences file in the old location, if there
-- there is no preferences stackfile in the new location.
if there is no file tPreferencesStackFile and there is a file tOldPreferencesStackFile then
revInternal__Log "Message", "Found preferences in old location, copying to new location."
put url ("binfile:" & tOldPreferencesStackFile) into url ("binfile:" & tPreferencesStackFile)
end if
-- Next check to see if there is a preferences file in the new location under the
-- name 'reventerprise'.
if there is no file tPreferencesStackFile and there is a file tOldNewPreferencesStackFile then
revInternal__Log "Message", "Found preferences in new location with old name, copying to new location."
-- MM-2012-05-03: Fixed typo - changed tOldPreferencesStackFile to tOldNewPreferencesStackFile
put url ("binfile:" & tOldNewPreferencesStackFile) into url ("binfile:" & tPreferencesStackFile)
end if
if there is no file tPreferencesStackFile then
revInternal__Log "Message", "No Existing Preferences Stack Found"
revInternal__Log "Message", "Copying template preferences to '" & tPreferencesStackFile & "'"
lock messages
if there is a stack "revpreferences" then
delete stack "revpreferences"
end if
set the filename of stack "revpreferencestemplate" to tPreferencesStackFile
set the name of stack "revpreferencestemplate" to "revpreferences"
revInternal__ResetPreferences
revInternal__SavePreferences
unlock messages
end if
put the stackFiles of stack "Home" into tStackFiles
put return & "revPreferences", tPreferencesStackFile after tStackFiles
set the stackFiles of stack "Home" to tStackFiles
revInternal__Log "Message", "Mapping Stack 'revpreferences.rev' to stackfile '" & tPreferencesStackFile & "'"
else
-- First check to see if we have a preferences stack file in the new location that
-- will not load.
if there is a file tPreferencesStackFile7 and there is no stack tPreferencesStackFile7 then
revInternal__Log "Message", "Existing Preferences 7 Stack Corrupted"
put 1 into tIndex
repeat while there is a file (tPreferencesStackFile7 & ".corrupt." & tIndex)
add 1 to tIndex
end repeat
revInternal__Log "Message", "Moving Broken Stack to '" & tPreferencesStackFile7 & "'"
rename file tPreferencesStackFile7 to (tPreferencesStackFile7 & ".corrupt." & tIndex)
end if
-- Next check to see that if there is a preferences file in the old location, if there
-- there is no preferences stackfile in the new location.
if there is no file tPreferencesStackFile7 and there is a file tPreferencesStackFile then
revInternal__Log "Message", "Found 2.7 preferences file, copying to new location."
put url ("binfile:" & tPreferencesStackFile) into url ("binfile:" & tPreferencesStackFile7)
end if
if there is no file tPreferencesStackFile7 and there is a file tOldNewPreferencesStackFile then
revInternal__Log "Message", "Found preferences in new location with old name, copying to new location."
-- MM-2012-05-03: Fixed typo - changed tOldPreferencesStackFile to tOldNewPreferencesStackFile
put url ("binfile:" & tOldNewPreferencesStackFile) into url ("binfile:" & tPreferencesStackFile7)
end if
-- Next check to see if there is a preferences file in the new location under the
-- name 'reventerprise'.
if there is no file tPreferencesStackFile7 and there is a file tOldNewPreferencesStackFile then
revInternal__Log "Message", "Found preferences in new location with old name, copying to new location."
-- MM-2012-05-03: Fixed typo - changed tOldPreferencesStackFile to tOldNewPreferencesStackFile
put url ("binfile:" & tOldNewPreferencesStackFile) into url ("binfile:" & tPreferencesStackFile7)
end if
if there is no file tPreferencesStackFile7 then
revInternal__Log "Message", "No Existing Preferences Stack Found"
revInternal__Log "Message", "Copying template preferences to '" & tPreferencesStackFile7 & "'"
lock messages
if there is a stack "revpreferences" then
delete stack "revpreferences"
end if
set the filename of stack "revpreferencestemplate" to tPreferencesStackFile7
set the name of stack "revpreferencestemplate" to "revpreferences"
revInternal__ResetPreferences
revInternal__SavePreferences
unlock messages
end if
put the stackFiles of stack "Home" into tStackFiles
put return & "revPreferences", tPreferencesStackFile7 after tStackFiles
set the stackFiles of stack "Home" to tStackFiles
revInternal__Log "Message", "Mapping Stack 'revpreferences.rev' to stackfile '" & tPreferencesStackFile & "'"
end if
revInternal__Log "Leave", "Preferences Setup"
end revInternal__SetupPreferences
private command revInternal__SetupFolders
revInternal__Log "Enter", "Folders Setup"
local tPath, tComponent
set the itemDelimiter to "/"
revInternal__Log "Message", "Setting up Preferences Path"
revInternal__EnsureFolder sPreferencesPath
revInternal__Log "Message", "Setting up Cache Path"
revInternal__EnsureFolder sCachePath
revInternal__Log "Message", "Setting up Crash Log Path"
revInternal__EnsureFolder sCrashLogPath
revInternal__Log "Leave", "Folders Setup"
end revInternal__SetupFolders
private command revInternal__SetupSplash
palette stack "revSplash"
end revInternal__SetupSplash
-- MW-2011-03-10: Ensure certain preference settings reset to what 'new' defaults should be
-- (This was easier than attempting to edit revpreferences.rev which is very very slippery!)
command revInternal__ResetPreferences
set the cREVToolsPaintToolsVisible of stack "revPreferences" to true
set the cSEHidePalettes of stack "revPreferences" to false
set the cSEHideMessageBox of stack "revPreferences" to false
end revInternal__ResetPreferences
--------------------------------------------------------------------------------
-- Internal Utility Functions
--
--
command revInternal__SavePreferences
local tPreference
local tOldStackFileVersion
put the stackFileVersion into tOldStackFileVersion
if the buildnumber < 10000 then
set the stackFileVersion to "2.7"
else
set the stackFileVersion to "7.0"
end if
lock messages
-- MM-2014-02-22: [[ Bug 11442 ]] Saving the prefs stack when security permissions is true is not possible.
try
save stack "revPreferences"
catch tError
end try
unlock messages
set the stackFileVersion to tOldStackFileVersion
end revInternal__SavePreferences
private command revInternal__EnsureFolder pFolder
revInternal__Log "Enter", "Ensuring Folder '" & pFolder & "'"
local tPath, tComponent
set the itemDelimiter to "/"
repeat for each item tComponent in pFolder
put tComponent & "/" after tPath
if there is no folder (char 1 to -2 of tPath) then
create folder char 1 to -2 of tPath
if the result is empty then
revInternal__Log "Message", "Creation of folder '" & char 1 to -2 of tPath & "' succeeded"
else
revInternal__Log "Message", "Creation of folder '" & char 1 to -2 of tPath & "' failed"
end if
end if
end repeat
revInternal__Log "Leave", "Ensuring Folder '" & pFolder & "'"
end revInternal__EnsureFolder
function revInternal__CheckFileAssociations
local tEnginePath
set the itemDelimiter to ":"
put item 2 to -1 of the address into tEnginePath
if the platform is "win32" then
-- If .rev, .livecode or .livecodescript classes are not present, then we need new assocs
# AL-2015-03-13: [[ Bug 14910 ]] Add .livecodescript to valid stack file extensions on windows
if queryRegistry("HKEY_CURRENT_USER\Software\Classes\.rev\") is not "RevolutionStack" or \
queryRegistry("HKEY_CURRENT_USER\Software\Classes\.livecode\") is not "LiveCodeStack" or \
queryRegistry("HKEY_CURRENT_USER\Software\Classes\.livecodescript\") is not "LiveCodeScriptOnlyStack"
then
return true
end if
-- If .rev, .livecode or .livecodescript classes are not present, then we need new assocs
# AL-2015-03-13: [[ Bug 14910 ]] Add .livecodescript to valid stack file extensions on windows
replace slash with backslash in tEnginePath
get queryRegistry("HKEY_CURRENT_USER\Software\Classes\RevolutionStack\Shell\Open\Command\")
if word 1 of it is not quote & tEnginePath & quote then
return true
end if
get queryRegistry("HKEY_CURRENT_USER\Software\Classes\LiveCodeStack\Shell\Open\Command\")
if word 1 of it is not quote & tEnginePath & quote then
return true
end if
get queryRegistry("HKEY_CURRENT_USER\Software\Classes\LiveCodeScriptOnlyStack\Shell\Open\Command\")
if word 1 of it is not quote & tEnginePath & quote then
return true
end if
else
-- Do Linux at some point!
end if
return false
end revInternal__CheckFileAssociations
command revInternal__InstallFileAssociations
local tEnginePath
set the itemDelimiter to ":"
put item 2 to -1 of the address into tEnginePath
if the platform is "win32" then
replace slash with backslash in tEnginePath
# AL-2015-03-13: [[ Bug 14910 ]] Add .livecodescript to valid stack file extensions on windows
get setRegistry("HKEY_CURRENT_USER\Software\Classes\.rev\", "RevolutionStack") and \
setRegistry("HKEY_CURRENT_USER\Software\Classes\RevolutionStack\Shell\Open\Command\", quote & tEnginePath & quote && quote & "%1" & quote) and \
setRegistry("HKEY_CURRENT_USER\Software\Classes\RevolutionStack\DefaultIcon\", tEnginePath & comma & "1") and \
setRegistry("HKEY_CURRENT_USER\Software\Classes\.livecode\", "LiveCodeStack") and \
setRegistry("HKEY_CURRENT_USER\Software\Classes\LiveCodeStack\Shell\Open\Command\", quote & tEnginePath & quote && quote & "%1" & quote) and \
setRegistry("HKEY_CURRENT_USER\Software\Classes\LiveCodeStack\DefaultIcon\", tEnginePath & comma & "1") and \
setRegistry("HKEY_CURRENT_USER\Software\Classes\.livecodescript\", "LiveCodeScriptOnlyStack") and \
setRegistry("HKEY_CURRENT_USER\Software\Classes\LiveCodeScriptOnlyStack\Shell\Open\Command\", quote & tEnginePath & quote && quote & "%1" & quote) and \
setRegistry("HKEY_CURRENT_USER\Software\Classes\LiveCodeScriptOnlyStack\DefaultIcon\", tEnginePath & comma & "1")
if it is false then
answer error "Failed to set file associations."
else
_internal call "notify_association_changed"
end if
else
end if
end revInternal__InstallFileAssociations
local sLogIndent, sLogPath
command revInternal__Log pType, pMessage
if pType is "Start" then
local tLogPath
put 0 into sLogIndent
switch revEnvironmentPlatform()
case "Linux"
put "~/.runrev/logs/" & toLower(kProductName) & "_tools_log.txt" into tLogPath
break
case "MacOS X"
put specialFolderPath("cusr") & "/Library/Logs/RunRev/" & kProductName & "ToolsLog.txt" into tLogPath
break
case "Windows"
-- Make sure we put logs in the 'Local' AppData section.
put specialFolderPath(0x001c) & "/RunRev/Logs/" & kProductName & "ToolsLog.txt" into tLogPath
break
end switch
set the itemDelimiter to "/"
revInternal__EnsureFolder item 1 to -2 of tLogPath
if there is no folder item 1 to -2 of tLogPath then
put empty into tLogPath
end if
set the itemDelimiter to comma
if tLogPath is not empty then
put tLogPath into sLogPath
revInternal__Log "Message", "-------- Startup Started:" && the internet date
end if
exit revInternal__Log
else if pType is "End" then
revInternal__Log "Message", "-------- Startup Ended:" && the internet date
put empty into sLogPath
exit revInternal__Log
end if
if sLogPath is empty then
exit revInternal__Log
end if
open file sLogPath for text append
if pType is "Leave" then
subtract 2 from sLogIndent
end if
if pType is not "Message" then
put pType && pMessage into pMessage
end if
repeat for each line tLine in pMessage
if sLogIndent > 0 then
write char 1 to sLogIndent of " " to file sLogPath
end if
write tLine & return to file sLogPath
end repeat
if pType is "Enter" then
add 2 to sLogIndent
end if
close file sLogPath
end revInternal__Log
--------------------------------------------------------------------------------
-- Internal Initialisation Functions
--
command revInternal__InitialiseSystem
local tSuccess
revInternal__Log "Enter", "System Initialisation"
put true into tSuccess
if tSuccess then
if the number of lines of the screenRect < 2 and item 4 of the screenRect < 600 then
answer "Revolution requires a 1024x768 display for editing (but not playback). If you continue, you may not be able to use all of the editing tools." with "Continue" or "Quit"
if it is "Quit" then
put false into tSuccess
end if
end if
end if
if tSuccess then
if the screenDepth < 15 then
answer "Revolution requires a full-colour display." with "Ok"
put false into tSuccess
end if
end if
get the cCrashReportStyle of stack "revPreferences"
if it is empty then
get "Small"
end if
if sLicensePlatform is "Windows" and the word 2 of the systemVersion >= "5.1" and it is not "None" then
local tCrashSettings, tVersion
put the version into tVersion
replace "." with "_" in tVersion
replace "-" with "_" in tVersion
put it is "Medium" into tCrashSettings["verbose"]
convert the seconds to dateItems
put format("%s/%s-%s-%04d_%02d_%02d-%02d_%02d_%02d.dmp", \
sCrashLogPath, kProductName, tVersion, item 1 of it, item 2 of it, item 3 of it, \
item 4 of it, item 5 of it, item 6 of it) into tCrashSettings["filename"]
revInternal__Log "Message", "Configuring crash log output to" && tCrashSettings["filename"]
do "set the revCrashReportSettings to tCrashSettings"
end if
revInternal__Log "Leave", "System Initialisation"
return tSuccess
end revInternal__InitialiseSystem
command revInternal__InitialiseGlobals
revInternal__Log "Enter", "Globals Initialisation"
global gREVDevelopment
put the cREVDevelopment of stack "Home" is not empty and the cREVDevelopment of stack "Home" into gREVDevelopment
# OK-2009-09-16 : I don't think the above feature very useful, so added this instead.
local tSettingsFile
set the itemDelimiter to slash
put item 1 to -2 of the filename of me & "/Development Settings.txt" into tSettingsFile
set the itemDelimiter to comma
local tSettings
put url ("file:" & tSettingsFile) into tSettings
split tSettings by return and tab
if tSettings["developmentMode"] then
put true into gREVDevelopment
end if
global gREVAccelerator
if the platform is "MacOS" then
put "Cmd" into gREVAccelerator
else
put "Cntrl+" into gREVAccelerator
end if
revInternal__SetAppIcon 210096
revInternal__SetSmallAppIcon 210096
revInternal__Log "Leave", "Globals Initialisation"
return true
end revInternal__InitialiseGlobals
private function revInternal__FilterHandlerList pList
local tNewList
repeat for each line tLine in pList
if tLine begins with "P" then
next repeat
end if
put word 2 of tLine & return after tNewList