-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathos.pbi
322 lines (289 loc) · 7.11 KB
/
os.pbi
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
; +--------+
; | os.pbi |
; +--------+
; | 2014.01.01 . Added character constants/macros
; | .09 . Added SameFile and NotS
; | .17 . Added requester constants (such as #OS_YesNoCancel)
; | .24 . Removed NotS macro (moved to common.pbi)
; | .07.03 . Cleaned up OS macros, Win/Mac Elses, character constants
; | 2016.04.08 . Added OnWindows/OnLinux/OnMac single-statement macros
; | 2017.02.02 . Made multiple-include safe
; | 2024.09.20 . Added Backend info for PB 6.00+ (C vs ASM)
CompilerIf (Not Defined(__OS_Included, #PB_Constant))
#__OS_Included = #True
;-
;- OS Macros
CompilerSelect (#PB_Compiler_OS)
CompilerCase (#PB_OS_Windows)
Macro WLMO(Windows, Linux, Mac, Other)
Windows
EndMacro
CompilerCase (#PB_OS_Linux)
Macro WLMO(Windows, Linux, Mac, Other)
Linux
EndMacro
CompilerCase (#PB_OS_MacOS)
Macro WLMO(Windows, Linux, Mac, Other)
Mac
EndMacro
CompilerDefault
Macro WLMO(Windows, Linux, Mac, Other)
Other
EndMacro
CompilerEndSelect
CompilerIf (#PB_Compiler_OS = #PB_OS_Windows)
Macro WindowsElse(This, That)
This
EndMacro
Macro OnWindows(_Statement)
_Statement
EndMacro
CompilerElse
Macro WindowsElse(This, That)
That
EndMacro
Macro OnWindows(_Statement)
;
EndMacro
CompilerEndIf
CompilerIf (#PB_Compiler_OS = #PB_OS_Linux)
Macro LinuxElse(This, That)
This
EndMacro
Macro OnLinux(_Statement)
_Statement
EndMacro
CompilerElse
Macro LinuxElse(This, That)
That
EndMacro
Macro OnLinux(_Statement)
;
EndMacro
CompilerEndIf
CompilerIf (#PB_Compiler_OS = #PB_OS_MacOS)
Macro MacElse(This, That)
This
EndMacro
Macro OnMac(_Statement)
_Statement
EndMacro
Macro LaunchFile(FileName)
RunProgram("open", Quote(FileName), GetPathPart(FileName))
EndMacro
Macro EditTextFile(FileName)
RunProgram("open", "-e " + Quote(FileName), GetPathPart(FileName))
EndMacro
CompilerElse
Macro MacElse(This, That)
That
EndMacro
Macro OnMac(_Statement)
;
EndMacro
Macro LaunchFile(FileName)
RunProgram(FileName, "", GetPathPart(FileName))
EndMacro
Macro EditTextFile(FileName)
LaunchFile(FileName)
EndMacro
CompilerEndIf
;-
;- OS Constants
#Windows = WindowsElse(#True, #False)
#Linux = LinuxElse(#True, #False)
#Mac = MacElse(#True, #False)
;
#OpenGL = WLMO(Subsystem("opengl"), Subsystem("opengl"), #False, #False)
#DirectX = WLMO((1 - #OpenGL), #False, #False, #False)
#SDL = WLMO(#False, (1 - #OpenGL), #False, #False)
#Carbon = WLMO(#False, #False, Subsystem("carbon"), #False)
#Cocoa = WLMO(#False, #False, (1 - #Carbon), #False)
;
#OS = WLMO(#PB_OS_Windows, #PB_OS_Linux, #PB_OS_MacOS, #Null)
#OS$ = WLMO("Windows", "Linux", "Mac", "")
#PS$ = WindowsElse("\", "/")
#NPS$ = WindowsElse("/", "\")
#EOL$ = WindowsElse(#CRLF$, #LF$)
#CTRL$ = MacElse("Cmd", "Ctrl")
#CTRLp$ = #CTRL$ + "+"
#tCTRLp$ = #TAB$ + #CTRLp$
;
#NUL = $00
#SP = ' '
#SP$ = " "
#SQ = $27
#SQ$ = "'"
#DQ = $22
#DQ$ = #DQUOTE$
#LFLF$ = #LF$ + #LF$
;
CompilerIf (#PB_Compiler_Unicode)
#EL = $2026
CompilerElseIf (#Mac)
#EL = $C9
CompilerElse
#EL = $85
CompilerEndIf
CompilerIf (#Mac And (Not #PB_Compiler_Unicode))
#EL$ = "..."
CompilerElse
#EL$ = Chr(#EL)
CompilerEndIf
;
#Debugger = #PB_Compiler_Debugger
;
CompilerIf (#PB_Compiler_Version >= 550)
#OS_Icon_Information = #PB_MessageRequester_Info
#OS_Icon_Warning = #PB_MessageRequester_Warning
#OS_Icon_Error = #PB_MessageRequester_Error
#OS_Icon_Question = WindowsElse(#MB_ICONQUESTION, #Null)
CompilerElse
#OS_Icon_Information = WindowsElse(#MB_ICONINFORMATION, #Null)
#OS_Icon_Warning = WindowsElse(#MB_ICONWARNING, #Null)
#OS_Icon_Error = WindowsElse(#MB_ICONERROR, #Null)
#OS_Icon_Question = WindowsElse(#MB_ICONQUESTION, #Null)
CompilerEndIf
;
#OS_Yes = #PB_MessageRequester_Yes
#OS_No = #PB_MessageRequester_No
#OS_Cancel = #PB_MessageRequester_Cancel
#OS_YesNo = #PB_MessageRequester_YesNo
#OS_YesNoCancel = #PB_MessageRequester_YesNoCancel
;
CompilerIf (#Windows)
#OS_Shortcut_TabNext = 64001
#OS_Shortcut_TabPrevious = 64002
CompilerElse
;
CompilerEndIf
;
#YES = #True
#NO = #False
;-
;- Color Constants
#Black = $000000
#White = $FFFFFF
#Red = $0000FF
#Green = $00FF00
#Blue = $FF0000
#Cyan = $FFFF00
#Magenta = $FF00FF
#Yellow = $00FFFF
#OpaqueBlack = #Black | $FF000000
#OpaqueWhite = #White | $FF000000
#OpaqueRed = #Red | $FF000000
#OpaqueGreen = #Green | $FF000000
#OpaqueBlue = #Blue | $FF000000
#OpaqueCyan = #Cyan | $FF000000
#OpaqueMagenta = #Magenta | $FF000000
#OpaqueYellow = #Yellow | $FF000000
CompilerIf (#Windows)
Enumeration
#Console_Black
#Console_DarkBlue
#Console_DarkGreen
#Console_DarkCyan
#Console_DarkRed
#Console_DarkMagenta
#Console_DarkYellow
#Console_Gray
#Console_DarkGray
#Console_Blue
#Console_Green
#Console_Cyan
#Console_Red
#Console_Magenta
#Console_Yellow
#Console_White
EndEnumeration
#Console_DefaultForeground = #Console_Gray
#Console_DefaultBackground = #Console_Black
CompilerEndIf
;-
;- Character Constants
CompilerIf (#PB_Compiler_Unicode)
#Unicode = #True
#Ascii = #False
#CharSize = 2
;
#PB_Compiler_ASCII = #False
;
#StringMode = #PB_Unicode
#StringModeName = "Unicode"
#StringFileMode = #PB_UTF8
;
Macro ToChars(Bytes)
((Bytes)/2)
EndMacro
Macro ToBytes(Chars)
((Chars)*2)
EndMacro
CompilerElse
#Ascii = #True
#Unicode = #False
#CharSize = 1
;
#PB_Compiler_ASCII = #True
;
#StringMode = #PB_Ascii
#StringModeName = "ASCII"
#StringFileMode = #PB_Ascii
;
Macro ToChars(Bytes)
(Bytes)
EndMacro
Macro ToBytes(Chars)
(Chars)
EndMacro
CompilerEndIf
;-
;- Backend Macros
CompilerIf (#PB_Compiler_Version < 600)
#PB_Backend_Asm = 0
#PB_Backend_C = 1
#PB_Compiler_Backend = #PB_Backend_Asm
CompilerEndIf
CompilerIf (#PB_Compiler_Backend = #PB_Backend_C)
#IsCBackend = #True
#IsAsmBackend = #False
Macro OnCBackend(_Statement)
_Statement
EndMacro
Macro OnAsmBackend(_Statement)
;
EndMacro
CompilerElse
#IsCBackend = #False
#IsAsmBackend = #True
Macro OnCBackend(_Statement)
;
EndMacro
Macro OnAsmBackend(_Statement)
_Statement
EndMacro
CompilerEndIf
;-
;- CPU Macros
CompilerIf (SizeOf(INTEGER) = 8)
#IntSize = 8
#Is64Bit = #True
#Is32Bit = #False
CompilerElse
#IntSize = 4
#Is64Bit = #False
#Is32Bit = #True
CompilerEndIf
;-
;- File Macros
CompilerIf (#Windows)
Macro SameFile(File1, File2)
Bool(LCase(File1) = LCase(File2))
EndMacro
CompilerElse
Macro SameFile(File1, File2)
Bool(File1 = File2)
EndMacro
CompilerEndIf
CompilerEndIf
;-