-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathstack_ScriptTracker_button_id_1009.livecodescript
More file actions
147 lines (119 loc) · 4.6 KB
/
stack_ScriptTracker_button_id_1009.livecodescript
File metadata and controls
147 lines (119 loc) · 4.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
Script "stack_ScriptTracker_button_id_1009"
/*
# Name: button "Automatic" of card "Tracker" of stack "ScriptTracker"
# ID: button id 1009 of card id 1002 of stack "ScriptTracker"
# Behavior: button id 1003 of stack "ScriptTracker"
*/
//>LOCALS
local sDataA, sFiles, sFolderToWatch, sLastDirContentsMD5, sMessage
on mouseUp
local tStackName, tStartMS, tStartTime
if the hilite of me is true then
-- Verify that stack exists
put field "StackName" of this card into tStackName
if there is not a stack tStackName then
anwswer "Stack not found: " & _q(tStackName)
set the hilite of me to false
exit mouseUp
end if
-- Do an initial sync:
put the milliseconds into tStartMS
put the long time into tStartTime
clearLog
buildMainStackArray tStackName, sDataA
exportMainStackScripts tStackName, sDataA
addToLog "Start time:" && tStartTime && "Finish time:" && the long time
addToLog "Elapsed time:" && (the milliseconds - tStartMS) && "ms"
-- Subscribe to edit script messages
ideSubscribe "ideEditScript"
insert the script of button "AutoExternalEditor" of card "ScriptTracker" \
of stack "ScriptTrackerPrefs" of stack "ScriptTracker" into front
-- Start watching:
put sDataA["ExportPath"] into sFolderToWatch
WatchFolder "UpdateScripts"
else
-- Stop watching:
put empty into sFolderToWatch
put empty into sLastDirContentsMD5
revIDEUnsubscribe "ideEditScript"
remove the script of button "AutoExternalEditor" of card "ScriptTracker" \
of stack "ScriptTrackerPrefs" of stack "ScriptTracker" from front
end if
end mouseUp
on WatchFolder pCallbackHandlerName
local tDirContentsMD5, tMessages
-- Make sure there are not additional messages queued
if sMessage is not empty then
cancel sMessage
put empty into sMessage
end if
if sFolderToWatch is empty then
set the hilite of me to false
exit WatchFolder
end if
if there is not a folder sFolderToWatch then
answer "Folder does not exist: " & _q(sFolderToWatch)
set the hilite of me to false
exit WatchFolder
end if
-- Get file list:
put files(sFolderToWatch,"detailed") into sFiles
-- Put MD5 digest of file list into tmp, comparing it to old one:
put md5Digest(sFiles) into tDirContentsMD5
if sLastDirContentsMD5 is not empty \
and tDirContentsMD5 <> sLastDirContentsMD5 then
send pCallbackHandlerName
else
put tDirContentsMD5 into sLastDirContentsMD5
send "WatchFolder "&pCallbackHandlerName to me in 500 millisecs
put the result into sMessage
end if
end WatchFolder
on UpdateScripts
local tFile, tStackName, tStart, tStartMS, tStartTime, tTime
clearLog
-- Make sure there are not additional messages queued
if sMessage is not empty then
cancel sMessage
put empty into sMessage
end if
put empty into sLastDirContentsMD5
put the milliseconds into tStartMS
put the long time into tStartTime
put field "StackName" of this card into tStackName
filter sFiles with "stack*"
repeat for each line tLine in sFiles
put item 1 of tLine into tFile
put item 5 of tLine into tTime
if tTime > sDataA["files"][tFile] then
loadScriptFile sFolderToWatch & tFile, sDataA
end if
end repeat
if sDataA["diff"] is not empty then
saveDiffFile sDataA
end if
if the text of field "log" of stack "ScriptTrackerLog" is empty then
restoreLog
else
addToLog "Start time:" && tStartTime && "Finish time:" && the long time
addToLog "Elapsed time:" && (the milliseconds - tStartMS) && "ms"
end if
send "WatchFolder" && _q("UpdateScripts") to me in 1000 millisecs
put the result into sMessage
end UpdateScripts
constant kEditScriptButton = "button id 1037 of card id 1034"
on ideEditScript pObject
local tContext, tOpenExternalEditor
put the executionContexts into tContext
-- attempt to avoid externally editing a script if it is being opened
-- for the debugger, if in browse mode then request should come from
-- the "AutoExternalEditor" button script that is placed in front
put (word 1 of the tool is "pointer") or \
(kEditScriptButton is in tContext) into tOpenExternalEditor
if the hilite of button "AutoExternalEditor" of card "ScriptTracker" \
of stack "ScriptTrackerPrefs" of stack "ScriptTracker" \
and tOpenExternalEditor then
editScriptFile pObject, sDataA
return the result
end if
end ideEditScript