-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWindow1.rbfrm
353 lines (331 loc) · 10.6 KB
/
Window1.rbfrm
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
#tag Window
Begin Window Window1
BackColor = 16777215
Backdrop = ""
CloseButton = True
Composite = False
Frame = 0
FullScreen = False
HasBackColor = False
Height = 259
ImplicitInstance= True
LiveResize = True
MacProcID = 0
MaxHeight = 32000
MaximizeButton = False
MaxWidth = 32000
MenuBar = ""
MenuBarVisible = True
MinHeight = 64
MinimizeButton = True
MinWidth = 64
Placement = 2
Resizeable = True
Title = "URI Parser Test"
Visible = True
Width = 613
Begin TextField TextField1
AcceptTabs = ""
Alignment = 0
AutoDeactivate = True
AutomaticallyCheckSpelling= False
BackColor = 16777215
Bold = ""
Border = True
CueText = ""
DataField = ""
DataSource = ""
Enabled = True
Format = ""
Height = 22
HelpTag = ""
Index = -2147483648
Italic = ""
Left = 0
LimitText = 0
LockBottom = ""
LockedInPosition= False
LockLeft = True
LockRight = True
LockTop = True
Mask = ""
Password = ""
ReadOnly = ""
Scope = 0
TabIndex = 0
TabPanelIndex = 0
TabStop = True
Text = "PROTOCOL://USER:PASS@SUB.DOMAIN.TLD:65535/DIR/SERVER FILE.EXT?arg1=1&arg2=2#Fragment"
TextColor = 0
TextFont = "System"
TextSize = 0
TextUnit = 0
Top = 0
Underline = ""
UseFocusRing = True
Visible = True
Width = 613
End
Begin Listbox Listbox1
AutoDeactivate = True
AutoHideScrollbars= True
Bold = ""
Border = True
ColumnCount = 2
ColumnsResizable= True
ColumnWidths = "20%,*"
DataField = ""
DataSource = ""
DefaultRowHeight= -1
Enabled = True
EnableDrag = ""
EnableDragReorder= ""
GridLinesHorizontal= 1
GridLinesVertical= 0
HasHeading = True
HeadingIndex = -1
Height = 213
HelpTag = ""
Hierarchical = True
Index = -2147483648
InitialParent = ""
InitialValue = "URI Part Value"
Italic = ""
Left = 0
LockBottom = True
LockedInPosition= False
LockLeft = True
LockRight = True
LockTop = True
RequiresSelection= ""
Scope = 0
ScrollbarHorizontal= ""
ScrollBarVertical= True
SelectionType = 0
TabIndex = 2
TabPanelIndex = 0
TabStop = True
TextFont = "System"
TextSize = 0
TextUnit = 0
Top = 26
Underline = ""
UseFocusRing = True
Visible = True
Width = 613
_ScrollWidth = -1
End
Begin Label Status
AutoDeactivate = True
Bold = ""
DataField = ""
DataSource = ""
Enabled = True
Height = 20
HelpTag = ""
Index = -2147483648
InitialParent = ""
Italic = ""
Left = 0
LockBottom = True
LockedInPosition= False
LockLeft = True
LockRight = True
LockTop = False
Multiline = ""
Scope = 0
Selectable = False
TabIndex = 3
TabPanelIndex = 0
Text = "Awaiting input"
TextAlign = 0
TextColor = &h000000
TextFont = "System"
TextSize = 0
TextUnit = 0
Top = 239
Transparent = False
Underline = ""
Visible = True
Width = 613
End
End
#tag EndWindow
#tag WindowCode
#tag Method, Flags = &h1
Protected Sub Parse(URL As String)
Listbox1.DeleteAllRows
If URL.Trim = "" Then
mResult = Nil
Return
End If
mResult = URL
If mResult.Scheme <> "" Then
Listbox1.AddRow("Scheme", mResult.Scheme)
Listbox1.CellType(Listbox1.LastIndex, 1) = Listbox.TypeEditable
End If
If mResult.Username <> "" Then
Listbox1.AddRow("Username", mResult.Username)
Listbox1.CellType(Listbox1.LastIndex, 1) = Listbox.TypeEditable
End If
If mResult.Password <> "" Then
Listbox1.AddRow("Password", mResult.Password)
Listbox1.CellType(Listbox1.LastIndex, 1) = Listbox.TypeEditable
End If
If mResult.Host <> Nil Then
If mResult.Host.IsLiteral Then
Listbox1.AddRow("IP", mResult.Host.ToString)
Else
Listbox1.AddRow("Host", mResult.Host.ToString)
End If
Listbox1.CellType(Listbox1.LastIndex, 1) = Listbox.TypeEditable
End If
If mResult.Port > 0 Then
Listbox1.AddRow("Port", Format(mResult.Port, "######"))
ElseIf mResult.Scheme <> "" And URIHelpers.SchemeToPort(mResult.Scheme) > 0 Then
Listbox1.AddRow("Port", Format(URIHelpers.SchemeToPort(mResult.Scheme), "######"))
Else
Listbox1.AddRow("Port", "")
End If
Listbox1.CellType(Listbox1.LastIndex, 1) = Listbox.TypeEditable
If mResult.Path <> Nil Then
Listbox1.AddRow("Path", mResult.Path.ToString(False))
Listbox1.CellType(Listbox1.LastIndex, 1) = Listbox.TypeEditable
End If
If mResult.Arguments <> Nil Then
Listbox1.AddFolder("Arguments")
Listbox1.Cell(Listbox1.LastIndex, 1) = mResult.Arguments.ToString
Listbox1.CellType(Listbox1.LastIndex, 1) = Listbox.TypeEditable
Listbox1.RowTag(Listbox1.LastIndex) = mResult.Arguments
End If
If mResult.Fragment <> "" Then
Listbox1.AddRow("Fragment", mResult.Fragment)
Listbox1.CellType(Listbox1.LastIndex, 1) = Listbox.TypeEditable
End If
Listbox1.AddRow("Link value", mResult)
Select Case URIHelpers.ValidateURL(URL)
Case 0
Status.Text = "This URI is legally formatted."
Case URIHelpers.PARSE_ERR_MISSING_SCHEME
Status.Text = "This URI does not have a scheme"
Case URIHelpers.PARSE_ERR_MISSING_DOMAIN
Status.Text = "This URI does not have a domain or IP address"
Case URIHelpers.PARSE_ERR_MISSING_PATH
Status.Text = "This URI does not have a path"
Case URIHelpers.PARSE_ERR_INVALID_PORT
Status.Text = "This URI does not have port"
Case URIHelpers.PARSE_ERR_INVALID_SCHEME
Status.Text = "This URI has an invalid scheme"
Case URIHelpers.PARSE_ERR_INVALID_DOMAIN
Status.Text = "This URI has an invalid domain or IP address"
Case URIHelpers.PARSE_ERR_INVALID_USERNAME
Status.Text = "This URI has an invalid username"
Case URIHelpers.PARSE_ERR_INVALID_PASSWORD
Status.Text = "This URI has an invalid password"
Else
Status.Text = "This URI illegally formatted"
End Select
End Sub
#tag EndMethod
#tag Property, Flags = &h1
Protected mResult As URIHelpers.URI
#tag EndProperty
#tag EndWindowCode
#tag Events TextField1
#tag Event
Sub TextChange()
Parse(Me.Text)
End Sub
#tag EndEvent
#tag Event
Sub Open()
Parse(Me.Text)
End Sub
#tag EndEvent
#tag EndEvents
#tag Events Listbox1
#tag Event
Function CellTextPaint(g As Graphics, row As Integer, column As Integer, x as Integer, y as Integer) As Boolean
If column = 1 And row = Me.ListCount - 1 Then
g.ForeColor = &c0000FF
g.Underline = True
g.DrawString(Me.Cell(row, column), x, y)
Return True
End If
End Function
#tag EndEvent
#tag Event
Function CellClick(row as Integer, column as Integer, x as Integer, y as Integer) As Boolean
#pragma Unused x
#pragma Unused y
If column = 1 And row = Me.ListCount - 1 Then
ShowURL(Me.Cell(row, column))
Return True
End If
End Function
#tag EndEvent
#tag Event
Sub MouseMove(X As Integer, Y As Integer)
Dim row, column As Integer
row = Me.RowFromXY(X, Y)
column = Me.ColumnFromXY(X, Y)
If column = 1 And row = Me.ListCount - 1 Then
Me.MouseCursor = System.Cursors.FingerPointer
Else
Me.MouseCursor = System.Cursors.StandardPointer
End If
End Sub
#tag EndEvent
#tag Event
Sub CellAction(row As Integer, column As Integer)
If mResult = Nil Then Return
If column = 1 Then
Dim u As URI = mResult
Select Case Me.Cell(row, 0)
Case "Scheme"
u.Scheme = Me.Cell(row, column)
Case "Username"
u.Username = Me.Cell(row, column)
Case "Password"
u.Password = Me.Cell(row, column)
Case "IP", "Host"
u.Host = Me.Cell(row, column)
Case "Port"
If Me.Cell(row, column).Trim = "" Then
u.Port = -1
Else
u.Port = Val(Me.Cell(row, column))
End If
Case "Path"
u.Path = Me.Cell(row, column)
Case "Arguments"
Dim args As String = Me.Cell(row, column)
If Left(args, 1) = "?" Then args = Replace(args, "?", "")
u.Arguments = args
Case "Fragment"
u.Fragment = Me.Cell(row, column)
End Select
TextField1.Text = u
End If
End Sub
#tag EndEvent
#tag Event
Sub ExpandRow(row As Integer)
Select Case Me.Cell(row, 0)
Case "Arguments"
Dim a As URIHelpers.Arguments = Me.RowTag(row)
If a = Nil Then Return
Dim c As Integer = a.Count - 1
For i As Integer = c DownTo 0
Dim n, v As String
n = a.Name(i)
v = a.Value(i)
Me.InsertRow(row + 1, n, 1)
Me.CellType(Me.LastIndex, 0) = Listbox.TypeEditable
If v.Trim <> "" Then Me.Cell(Me.LastIndex, 1) = v
Me.CellType(Me.LastIndex, 1) = Listbox.TypeEditable
Next
End Select
End Sub
#tag EndEvent
#tag EndEvents