forked from gphilippot/purebasic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IDEMisc.pb
202 lines (150 loc) · 6.1 KB
/
IDEMisc.pb
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
;--------------------------------------------------------------------------------------------
; 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.
;--------------------------------------------------------------------------------------------
; ide specific misc stuff (not shared with the Debugger)
;
Procedure.s CheckPureBasicKeyWords(CurrentWord$)
If Right(CurrentWord$, 1) = "$"
CurrentWord$ = Left(CurrentWord$, Len(CurrentWord$)-1)
EndIf
Select UCase(CurrentWord$)
Case "FOR", "TO", "STEP", "NEXT"
Topic$ = "Reference/for_next"
Case "FOREACH"
Topic$ = "Reference/foreach_next"
Case "GOSUB", "RETURN", "FAKERETURN"
Topic$ = "Reference/gosub_return"
Case "IF", "ELSEIF", "ELSE", "ENDIF"
Topic$ = "Reference/if_endif"
Case "REPEAT", "UNTIL", "FOREVER"
Topic$ = "Reference/repeat_until"
Case "SELECT", "CASE", "DEFAULT", "ENDSELECT"
Topic$ = "Reference/select_endselect"
Case "WHILE", "WEND"
Topic$ = "Reference/while_wend"
Case "GOTO", "END", "SWAP"
Topic$ = "Reference/others"
Case "DEFINE"
Topic$ = "Reference/define"
Case "DIM", "REDIM", "ARRAY"
Topic$ = "Reference/dim"
Case "MACRO", "ENDMACRO", "UNDEFINEMACRO", "MACROEXPANDEDCOUNT"
Topic$ = "Reference/macros"
Case "IMPORT", "IMPORTC", "ENDIMPORT"
Topic$ = "Reference/import_endimport"
Case "WITH", "ENDWITH"
Topic$ = "Reference/with_endwith"
Case "PROTOTYPE", "PROTOTYPEC"
Topic$ = "Reference/prototypes"
Case "NEWLIST", "LIST"
Topic$ = "Reference/newlist"
Case "NEWMAP", "MAP"
Topic$ = "Reference/newmap"
Case "STRUCTURE", "STRUCTUREUNION", "ENDSTRUCTUREUNION", "ENDSTRUCTURE"
Topic$ = "Reference/structures"
Case "INTERFACE", "ENDINTERFACE", "EXTENDS"
Topic$ = "Reference/interfaces"
Case "ENUMERATION", "ENUMERATIONBINARY", "ENDENUMERATION"
Topic$ = "Reference/enumerations"
Case "MODULE", "ENDMODULE", "DECLAREMODULE", "ENDDECLAREMODULE", "USEMODULE", "UNUSEMODULE"
Topic$ = "Reference/module"
Case "BREAK", "CONTINUE"
Topic$ = "Reference/break_continue"
Case "RUNTIME"
Topic$ = "Reference/runtime"
Case "GLOBAL"
Topic$ = "Reference/global"
Case "PROCEDURE", "ENDPROCEDURE", "PROCEDURERETURN", "DECLARE"
Topic$ = "Reference/procedures"
Case "PROCEDUREDLL", "PROCEDURECDLL", "DECLAREDLL", "DECLARECDLL"
Topic$ = "Reference/dll"
Case "SHARED"
Topic$ = "Reference/shared"
Case "STATIC"
Topic$ = "Reference/static"
Case "THREADED"
Topic$ = "Reference/threaded"
Case "PROTECTED"
Topic$ = "Reference/protected"
Case "DATASECTION", "ENDDATASECTION", "DATA", "RESTORE", "READ"
Topic$ = "Reference/data"
Case "CALLDEBUGGER", "DEBUG", "DEBUGLEVEL", "DISABLEDEBUGGER", "ENABLEDEBUGGER"
Topic$ = "Reference/debugger"
Case "INCLUDEFILE", "XINCLUDEFILE", "INCLUDEBINARY", "INCLUDEPATH"
Topic$ = "Reference/includes"
Case "COMPILERIF", "COMPILERELSE", "COMPILERENDIF", "COMPILERSELECT", "COMPILERCASE", "COMPILERDEFAULT", "COMPILERENDSELECT", "COMPILERERROR", "COMPILERWARNING", "ENABLEEXPLICIT", "DISABLEEXPLICIT"
Topic$ = "Reference/compilerdirectives"
CompilerIf #SpiderBasic
Case "ENABLEJS", "DISABLEJS"
Topic$ = "Reference/compilerdirectives"
CompilerElse
Case "ENABLEASM", "DISABLEASM"
Topic$ = "Reference/compilerdirectives"
CompilerEndIf
Case "SIZEOF", "OFFSETOF", "TYPEOF", "SUBSYSTEM", "DEFINED", "CLEARSTRUCTURE", "COPYSTRUCTURE", "RESETSTRUCTURE", "INITIALIZESTRUCTURE", "BOOL"
Topic$ = "Reference/compilerfunctions"
EndSelect
ProcedureReturn Topic$
EndProcedure
; Register a filename for deletion an IDE shutdown.
; Done for all temp files, so proper cleanup is ensured
; Can be called for the same file multiple times without problem
;
Global NewList TempFiles.s()
Procedure RegisterDeleteFile(FileName$)
; prevent double entries
ForEach TempFiles()
If IsEqualFile(TempFiles(), FileName$)
ProcedureReturn
EndIf
Next TempFiles()
AddElement(TempFiles())
TempFiles() = FileName$
EndProcedure
; Delete all registered tempfiles (called at shutdown)
Procedure DeleteRegisteredFiles()
ForEach TempFiles()
CompilerIf #CompileMac
If GetExtensionPart(TempFiles()) = "app"
DeleteDirectory(TempFiles(), "*", #PB_FileSystem_Recursive) ; a .app is a directory!
Else
DeleteFile(TempFiles())
EndIf
CompilerElse
DeleteFile(TempFiles())
CompilerEndIf
Next TempFiles()
EndProcedure
; Compare two directories like strings, but give the common sublevels priority
;
Procedure CompareDirectories(Directory1$, Directory2$)
Item1$ = StringField(Directory1$, 1, #Separator)
Item2$ = StringField(Directory2$, 1, #Separator)
If Item1$ = "" And Item2$ = ""
ProcedureReturn #PB_String_Equal
ElseIf Item1$ = ""
ProcedureReturn #PB_String_Lower
ElseIf Item2$ = ""
ProcedureReturn #PB_String_Greater
Else
Result = CompareMemoryString(@Item1$, @Item2$, #PATH_CaseInsensitive)
If Result <> #PB_String_Equal
; if one has further subdirectories and the other does not, put the one with the directory above
Index1 = FindString(Directory1$, #Separator, 1)
Index2 = FindString(Directory2$, #Separator, 1)
If Index1 <> 0 And Index2 = 0
ProcedureReturn #PB_String_Lower
ElseIf Index1 = 0 And Index2 <> 0
ProcedureReturn #PB_String_Greater
Else
ProcedureReturn Result
EndIf
Else
Directory1$ = Right(Directory1$, Len(Directory1$)-Len(Item1$)-1)
Directory2$ = Right(Directory2$, Len(Directory2$)-Len(Item2$)-1)
ProcedureReturn CompareDirectories(Directory1$, Directory2$)
EndIf
EndIf
EndProcedure