-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathForm1.frm
More file actions
1121 lines (958 loc) · 35.9 KB
/
Form1.frm
File metadata and controls
1121 lines (958 loc) · 35.9 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
VERSION 5.00
Object = "{FBE17B58-A1F0-4B91-BDBD-C9AB263AC8B0}#78.0#0"; "scivb_lite.ocx"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmMain
Caption = "Script Basic IDE"
ClientHeight = 9870
ClientLeft = 165
ClientTop = 735
ClientWidth = 13905
BeginProperty Font
Name = "Courier"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
KeyPreview = -1 'True
LinkTopic = "Form1"
ScaleHeight = 9870
ScaleWidth = 13905
StartUpPosition = 3 'Windows Default
Begin MSComctlLib.ListView lvErrors
Height = 1050
Left = 4500
TabIndex = 6
Top = 5850
Width = 1860
_ExtentX = 3281
_ExtentY = 1852
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = -1 'True
FullRowSelect = -1 'True
GridLines = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Courier"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
NumItems = 3
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Text = "Line"
Object.Width = 1411
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Text = "File"
Object.Width = 3881
EndProperty
BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 2
Text = "Error"
Object.Width = 2540
EndProperty
End
Begin VB.Timer tmrHideCallTip
Enabled = 0 'False
Interval = 600
Left = 9720
Top = 135
End
Begin MSComctlLib.ListView lvVars
Height = 1050
Left = 11745
TabIndex = 5
Top = 5895
Width = 1860
_ExtentX = 3281
_ExtentY = 1852
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = -1 'True
FullRowSelect = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Courier"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
NumItems = 4
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Text = "scope"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Text = "name"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 2
Text = "type"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 3
Text = "value"
Object.Width = 2540
EndProperty
End
Begin MSComctlLib.ListView lvCallStack
Height = 1185
Left = 9810
TabIndex = 3
Top = 5850
Width = 1815
_ExtentX = 3201
_ExtentY = 2090
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = -1 'True
FullRowSelect = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Courier"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
NumItems = 2
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Text = "Line"
Object.Width = 1235
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Text = "Function"
Object.Width = 2540
EndProperty
End
Begin VB.TextBox txtOut
Height = 1185
Left = 6525
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 2
Top = 5760
Width = 3165
End
Begin SCIVB_LITE.SciSimple scivb
Height = 5865
Left = 90
TabIndex = 0
Top = 630
Width = 13650
_ExtentX = 24077
_ExtentY = 10345
End
Begin MSComctlLib.ImageList ilToolbar
Left = 10305
Top = 0
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 15
ImageHeight = 15
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 11
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0000
Key = "Run"
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":010C
Key = "Start Debugger"
EndProperty
BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0216
Key = "Break"
EndProperty
BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0320
Key = "Stop"
EndProperty
BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":042A
Key = "Toggle Breakpoint"
EndProperty
BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0534
Key = "Clear All Breakpoints"
EndProperty
BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":063E
Key = "Step In"
EndProperty
BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0748
Key = "Step Over"
EndProperty
BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0852
Key = "Step Out"
EndProperty
BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":095C
Key = "Run to Cursor"
EndProperty
BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0A66
Key = ""
EndProperty
EndProperty
End
Begin MSComctlLib.Toolbar tbarDebug
Height = 330
Left = 180
TabIndex = 1
Top = 225
Width = 3870
_ExtentX = 6826
_ExtentY = 582
ButtonWidth = 609
ButtonHeight = 582
Style = 1
_Version = 393216
BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
NumButtons = 13
BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Run"
Object.ToolTipText = "Run"
EndProperty
BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Start Debugger"
Object.ToolTipText = "Start Debugger"
EndProperty
BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Break"
Object.ToolTipText = "Break"
EndProperty
BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Stop"
Object.ToolTipText = "Stop"
EndProperty
BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Toggle Breakpoint"
Object.ToolTipText = "Toggle Breakpoint"
EndProperty
BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Clear All Breakpoints"
Object.ToolTipText = "Clear All Breakpoiunts"
EndProperty
BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Step In"
Object.ToolTipText = "Step In"
EndProperty
BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Step Over"
Object.ToolTipText = "Step Over"
EndProperty
BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Step Out"
Object.ToolTipText = "Step Out"
EndProperty
BeginProperty Button12 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Run to Cursor"
Object.ToolTipText = "Run to Cursor"
EndProperty
BeginProperty Button13 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
EndProperty
End
Begin MSComctlLib.ImageList ilToolbars_Disabled
Left = 11025
Top = 0
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 15
ImageHeight = 15
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 10
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0B72
Key = "Run"
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0C7E
Key = "Break"
EndProperty
BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0D8A
Key = "Clear All Breakpoints"
EndProperty
BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0E96
Key = "Run to Cursor"
EndProperty
BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0FA2
Key = "Step Over"
EndProperty
BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":10AE
Key = "Step Out"
EndProperty
BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":11BA
Key = "Step In"
EndProperty
BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":12C6
Key = "Stop"
EndProperty
BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":13D2
Key = "Start Debugger"
EndProperty
BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":14DC
Key = "Toggle Breakpoint"
EndProperty
EndProperty
End
Begin MSComctlLib.TabStrip ts
Height = 3120
Left = 180
TabIndex = 4
Top = 6615
Width = 13650
_ExtentX = 24077
_ExtentY = 5503
Placement = 1
_Version = 393216
BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628}
NumTabs = 4
BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628}
Caption = "Output"
ImageVarType = 2
EndProperty
BeginProperty Tab2 {1EFB659A-857C-11D1-B16A-00C0F0283628}
Caption = "Errors"
ImageVarType = 2
EndProperty
BeginProperty Tab3 {1EFB659A-857C-11D1-B16A-00C0F0283628}
Caption = "Variables"
ImageVarType = 2
EndProperty
BeginProperty Tab4 {1EFB659A-857C-11D1-B16A-00C0F0283628}
Caption = "CallStack"
ImageVarType = 2
EndProperty
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Courier"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.Label lblStatus
Caption = "Status: Idle"
Height = 375
Left = 4185
TabIndex = 7
Top = 270
Width = 4560
End
Begin VB.Menu mnuFile
Caption = "File"
Begin VB.Menu mnuNewFile
Caption = "New"
End
Begin VB.Menu mnuOpen
Caption = "Open"
End
Begin VB.Menu mnuSave
Caption = "Save"
End
Begin VB.Menu mnuSpacer
Caption = "-"
End
Begin VB.Menu mnuOptions
Caption = "Options"
End
End
Begin VB.Menu mnuEdit
Caption = "Edit"
Begin VB.Menu mnuFind
Caption = "Find"
End
End
Begin VB.Menu mnuCallStackPopup
Caption = "mnuCallStackPopup"
Begin VB.Menu mnuExecuteTillReturn
Caption = "Execute Until Return"
End
End
Begin VB.Menu mnuVarsPopup
Caption = "mnuVarsPopup"
Begin VB.Menu mnuVarSetValue
Caption = "Modify Value"
End
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim WithEvents sciext As CSciExtender
Attribute sciext.VB_VarHelpID = -1
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Private Declare Function run_script Lib "sb_engine" (ByVal lpLibFileName As String, ByVal use_debugger As Long) As Long
Private Declare Sub GetErrorString Lib "sb_engine" (ByVal iErrorCode As Long, ByVal buf As String, ByVal sz As Long)
Private Declare Sub SetCallBacks Lib "sb_engine" (ByVal msgProc As Long, ByVal dbgCmdProc As Long, ByVal hostResolverProc As Long, ByVal lineInputfunc As Long)
Dim loadedFile As String
Dim hsbLib As Long
Public lastEIP As Long
Public hasImports As Boolean
Const SC_MARK_CIRCLE = 0
Const SC_MARK_ARROW = 2
Const SC_MARK_BACKGROUND = 22
'http://www.scintilla.org/aprilw/SciLexer.bas
Dim selCallStackItem As ListItem
Dim selVariable As ListItem
Private Sub RefreshVariables()
Dim li As ListItem
Dim vars As Collection
Dim v As CVariable
lvVars.ListItems.Clear
Set vars = EnumVariables()
For Each v In vars
Set li = lvVars.ListItems.Add(, , IIf(v.isGlobal, "Global", "Local"))
li.SubItems(1) = v.name
li.SubItems(2) = v.varType
li.SubItems(3) = v.Value
Set li.Tag = v
Next
End Sub
Private Sub RefreshCallStack()
Dim c As Collection
Dim cs As cCallStack
Dim li As ListItem
lvCallStack.ListItems.Clear
Set c = EnumCallStack()
For Each cs In c
Set li = lvCallStack.ListItems.Add(, , cs.lineNo)
li.SubItems(1) = cs.func
Next
End Sub
Private Sub lvCallStack_ItemClick(ByVal Item As MSComctlLib.ListItem)
scivb.GotoLine CLng(Item.Text)
Set selCallStackItem = Item
End Sub
Private Sub lvErrors_ItemClick(ByVal Item As MSComctlLib.ListItem)
On Error Resume Next
Dim lline As Long
lline = CLng(Item.Text) - 1
If lline > 0 Then
scivb.GotoLine lline
scivb.SelLength = Len(scivb.GetLineText(lline)) - 2
End If
End Sub
Private Sub lvVars_DblClick()
If selVariable Is Nothing Then Exit Sub
If selVariable.SubItems(2) <> "array" Then
mnuVarSetValue_Click
Exit Sub
End If
Dim c As Collection
Dim varName As String
Dim v As CVariable
On Error Resume Next
Set v = selVariable.Tag
varName = selVariable.SubItems(1)
Set c = EnumArrayVariables(varName)
If c.count > 0 Then
frmAryDump.DumpArrayValues varName, c, v.pAryElement
End If
End Sub
Private Sub lvVars_ItemClick(ByVal Item As MSComctlLib.ListItem)
Set selVariable = Item
End Sub
Private Sub lvVars_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 2 Then PopupMenu mnuVarsPopup
End Sub
Private Sub mnuExecuteTillReturn_Click()
MsgBox "todo: disable all breakpoints,run to line selCallStackItem.text + 1, reenable breakpoints", vbInformation
End Sub
Private Sub mnuFind_Click()
scivb.ShowFindReplace
End Sub
Private Sub mnuNewFile_Click()
If scivb.isDirty Then
If MsgBox("Editor has changed save contents?", vbInformation + vbYesNo) = vbYes Then
If Len(loadedFile) = 0 Then
loadedFile = dlg.SaveDialog(AllFiles, "default.sb")
If Len(loadedFile) = 0 Then Exit Sub
End If
scivb.SaveFile loadedFile
End If
End If
scivb.Text = Empty
loadedFile = dlg.OpenDialog(AllFiles)
If Len(loadedFile) = 0 Then Exit Sub
scivb.LoadFile loadedFile
End Sub
Private Sub mnuOpen_Click()
Dim f As String
f = dlg.OpenDialog(AllFiles)
If Len(f) = 0 Then Exit Sub
LoadFile f
End Sub
Private Sub mnuOptions_Click()
frmOptions.Show 1, Me
End Sub
Private Sub mnuSave_Click()
scivb.SaveFile loadedFile
End Sub
Private Sub mnuVarSetValue_Click()
If Not running Then Exit Sub
If selVariable Is Nothing Then Exit Sub
Dim Value As String, newVal As String
Dim v As CVariable
On Error Resume Next
Set v = selVariable.Tag
If v Is Nothing Then
MsgBox "Variable tag not set?"
Exit Sub
End If
If v.varType = "array" Then
lvVars_DblClick
Exit Sub 'unless they want to change the var type here? todo?
End If
If v.varType = "ref" Then
MsgBox "Can not edit ref variables edit the parent variable directly..", vbInformation
Exit Sub
End If
Value = selVariable.SubItems(3)
If Left(Value, 1) = """" Then Value = Mid(Value, 2)
If Right(Value, 1) = """" Then Value = Mid(Value, 1, Len(Value) - 1)
newVal = InputBox("Modify variable " & v.name, , Value)
If Len(newVal) > 0 And newVal <> Value Then
SetVariable v, newVal
RefreshVariables
End If
End Sub
Private Sub sciext_MarginClick(lline As Long, Position As Long, margin As Long, modifiers As Long)
'Debug.Print "MarginClick: line,pos,margin,modifiers", lLine, Position, margin, modifiers
ToggleBreakPoint lline
End Sub
Private Sub sciext_MouseDwellEnd(lline As Long, Position As Long)
If running Then tmrHideCallTip.Enabled = True
End Sub
Private Sub sciext_MouseDwellStart(lline As Long, Position As Long)
'Debug.Print "MouseDwell: " & lLine & " CurWord: " & sciext.WordUnderMouse(Position)
Dim li As ListItem
Dim curWord As String
If running Then
curWord = sciext.WordUnderMouse(Position)
For Each li In lvVars.ListItems
If LCase(li.SubItems(1)) = LCase(curWord) Then 'they have moused over a variable..
Set selVariable = li
scivb.SelStart = Position 'so call tip shows right under it..
scivb.SelLength = 0
scivb.ShowCallTip curWord & " = " & li.SubItems(3)
Exit For
End If
Next
End If
End Sub
'Private Sub sciext_NewLine()
' On Error Resume Next
' Dim l As Long, lText As String, tmp() As String
'
' l = scivb.CurrentLine - 1
' lText = scivb.GetLineText(l)
' lText = Trim(Replace(lText, vbTab, Empty))
' If Len(lText) = 0 Then Exit Sub
'
' tmp() = Split(LCase(lText), " ")
' If tmp(0) = "function" Or tmp(0) = "sub" Then
' 'lets scan forward to either next function/sub, or see if a matching end function/sub already exists
' 'if not exists, then we can auto close the function block for them and record the function name for autocomplete..
' 'this means that when opening a new document..we would also have to conduct teh func name scan to build initial autocomplete list
' 'todo
' End If
'
'End Sub
Private Sub scivb_AutoCompleteEvent(className As String)
'Debug.Print className
Dim matches() As String
Dim prevWord As String
Dim orgPos As Long
Dim curpos As Long
'first lets see if this is an import/include statement
prevWord = LCase(sciext.WordUnderMouse(scivb.SelStart - Len(className) - 1, True))
If prevWord = "include" Or prevWord = "import" Then
matches() = GetAutoCompleteStringForIncludes(className)
If Not AryIsEmpty(matches) Then
If UBound(matches) = 0 Then
'only one match so just auto complete it..
'scivb.SelStart = scivb.SelStart - Len(className)
'scivb.SelLength = Len(className)
scivb.SelStart = scivb.DirectSCI.WordStartPosition(scivb.SelStart, True)
scivb.SelLength = scivb.DirectSCI.WordEndPosition(scivb.SelStart, True) - scivb.SelStart
scivb.SelText = matches(0)
Else
'show all matches for partial string
scivb.ShowAutoComplete Join(matches, " ")
End If
Else
'show all include files
scivb.ShowAutoComplete Join(IncludeFiles, " ")
End If
Exit Sub
End If
'now lets see if it scoped to a specific module
curpos = scivb.DirectSCI.GetCurPos()
curpos = curpos - Len(className) - 2
If curpos > 4 Then
'this check wont trigger for nt::Msg[ctrl+space], only nt::
If Mid(scivb.Text, curpos + 1, 2) = "::" Then 'its an module lookup
orgPos = scivb.DirectSCI.GetCurPos()
scivb.SetCurrentPosition curpos
prevWord = scivb.CurrentWord
scivb.SetCurrentPosition orgPos
If ShowAutoCompleteForModule(prevWord, className) Then Exit Sub
End If
End If
'now search the built in api for partial matches to whats already typed..
matches() = GetAutoCompleteString(className)
If Not AryIsEmpty(matches) Then
If UBound(matches) = 0 Then
'only one match so just auto complete it..
'scivb.SelStart = scivb.SelStart - Len(className)
'scivb.SelLength = Len(className)
scivb.SelStart = scivb.DirectSCI.WordStartPosition(scivb.SelStart, True)
scivb.SelLength = scivb.DirectSCI.WordEndPosition(scivb.SelStart, True) - scivb.SelStart
scivb.SelText = matches(0)
Else
'show all matches for partial string
scivb.ShowAutoComplete Join(matches, " ")
End If
Else
'ok no partial matches, lets just show entire api list..
If Not AryIsEmpty(FunctionPrototypes) Then
scivb.ShowAutoComplete Join(FunctionPrototypes, " ")
End If
End If
End Sub
Private Function ShowAutoCompleteForModule(modName As String, fragment As String) As Boolean
On Error Resume Next
Dim methods As String
Dim matches() As String
If Len(modName) = 0 Then Exit Function
If Not isIncludeFile(modName) Then Exit Function
If Not isFileIncluded(modName, scivb.Text) Then Exit Function
methods = modules(modName)
If Err.Number <> 0 Then Exit Function
If Len(fragment) = 0 Then
scivb.ShowAutoComplete methods 'ctrl-space after [module]::
ShowAutoCompleteForModule = True
Else
matches() = GetAutoCompleteStringForModule(methods, fragment) 'example nt::msg[ctrl-space]
If Not AryIsEmpty(matches) Then
If UBound(matches) = 0 Then
'scivb.SelStart = scivb.SelStart - Len(modName) - 1
'scivb.SelLength = Len(modName) + 1
scivb.SelStart = scivb.DirectSCI.WordStartPosition(scivb.SelStart, True)
scivb.SelLength = scivb.DirectSCI.WordEndPosition(scivb.SelStart, True) - scivb.SelStart
scivb.SelText = matches(0)
Else
scivb.ShowAutoComplete ":" & Join(matches, ":")
End If
ShowAutoCompleteForModule = True
End If
End If
End Function
Private Sub scivb_CallTipClick(Position As Long)
If running Then mnuVarSetValue_Click
End Sub
Private Sub scivb_DoubleClick()
Dim word As String
word = scivb.CurrentWord
If Len(word) < 20 Then
Me.Caption = " " & scivb.hilightWord(word, , vbTextCompare) & " instances of '" & word & " ' found"
End If
End Sub
Private Sub scivb_MouseUp(Button As Integer, Shift As Integer, x As Long, y As Long)
If scivb.SelLength > 0 And scivb.SelLength < 20 Then
Dim word As String
word = Trim(scivb.SelText)
word = Replace(word, vbTab, "")
If Len(word) < 20 Then
Me.Caption = " " & scivb.hilightWord(word, , vbTextCompare) & " instances of '" & word & " ' found"
End If
Else
scivb.hilightClear
End If
End Sub
Private Sub scivb_KeyDown(KeyCode As Long, Shift As Long)
'Debug.Print KeyCode & " " & Shift
Select Case KeyCode
Case vbKeyF2: ToggleBreakPoint
Case vbKeyF5: If running Then DebuggerCmd dc_Run Else ExecuteScript True
Case vbKeyF7: DebuggerCmd dc_stepinto
Case vbKeyF8: DebuggerCmd dc_StepOver
Case vbKeyF9: DebuggerCmd dc_StepOut
End Select
End Sub
Private Sub scivb_KeyUp(KeyCode As Long, Shift As Long)
Dim curWord As String
Dim txt As String
Dim curpos As Long
Dim prevChar As String
Dim methods As String
If KeyCode = 186 Then ': character
curpos = scivb.GetCaretInLine()
txt = scivb.GetLineText(scivb.CurrentLine)
If curpos < 3 Then Exit Sub
prevChar = Mid(txt, curpos - 1, 1)
If prevChar <> ":" Then Exit Sub
scivb.GotoCol curpos - 2
curWord = scivb.CurrentWord
scivb.GotoCol curpos
On Error Resume Next
If Len(curWord) > 0 Then
If isIncludeFile(curWord) And isFileIncluded(curWord, scivb.Text) Then
methods = modules(curWord)
If Err.Number = 0 Then scivb.ShowAutoComplete methods
End If
End If
End If
End Sub
Private Sub tbarDebug_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.key
Case "Run": If running Then DebuggerCmd dc_Run Else ExecuteScript
Case "Start Debugger": If running Then DebuggerCmd dc_Run Else ExecuteScript True
Case "Stop": DebuggerCmd dc_Quit
Case "Step In": DebuggerCmd dc_stepinto
Case "Step Over": DebuggerCmd dc_StepOver
Case "Step Out": DebuggerCmd dc_StepOut
Case "Run to Cursor": RunToLine scivb.CurrentLine + 1
Case "Toggle Breakpoint": ToggleBreakPoint
Case "Clear All Breakpoints": RemoveAllBreakpoints
Case "Break": dbg_Break hDebugObject
End Select
End Sub
Private Sub CheckError()
On Error Resume Next
Dim lline As Long
If lvErrors.ListItems.count = 0 Then Exit Sub
ts.Tabs(2).Selected = True
lline = CLng(lvErrors.ListItems(1).Text) - 1
If lline <> 0 Then
scivb.GotoLine lline
scivb.SelLength = Len(scivb.GetLineText(lline)) - 2
End If
End Sub
Private Sub ExecuteScript(Optional withDebugger As Boolean)
Dim rv As Long
Dim buf As String
If Len(Trim(scivb.Text)) = 0 Then Exit Sub
If Len(loadedFile) = 0 Then
loadedFile = dlg.SaveDialog(AllFiles, "default.sb")
If Len(loadedFile) = 0 Then Exit Sub
End If
txtOut.Text = Empty
lvErrors.ListItems.Clear
ts.Tabs(1).Selected = True
sciext.LockEditor
If scivb.isDirty Then scivb.SaveFile loadedFile
running = True
SetToolBarIcons
lblStatus = "Status: " & IIf(withDebugger, "Debugging...", "Running...")
rv = run_script(loadedFile, IIf(withDebugger, 1, 0))
'if user closed form while debugger running..we must exit now or form_load again hidden..
If shuttingDown Then Exit Sub
CheckError
lblStatus = "Status: Idle"
running = False
SetToolBarIcons
ClearUIBreakpoints
sciext.LockEditor False
scivb.DeleteMarker lastEIP, 1
lvVars.ListItems.Clear
lvCallStack.ListItems.Clear
Set selVariable = Nothing
Set selCallStackItem = Nothing
If hasImports Then scivb.LoadFile loadedFile
End Sub
Private Sub SetToolBarIcons()
Dim b As Button
Set tbarDebug.ImageList = Nothing
Set tbarDebug.ImageList = IIf(running, ilToolbar, ilToolbars_Disabled)
For Each b In tbarDebug.Buttons
If Len(b.key) > 0 Then
b.Image = b.key
b.ToolTipText = b.key
If b.key <> "Run" And b.key <> "Start Debugger" Then
b.Enabled = running
End If
End If
Next
End Sub
Private Sub Form_Load()
SetToolBarIcons
FormPos Me, True
lvVars.Visible = False
lvCallStack.Visible = False
lvErrors.Visible = False
mnuCallStackPopup.Visible = False
mnuVarsPopup.Visible = False
hsbLib = LoadLibrary(App.path & "\engine\sb_engine.dll")
If hsbLib = 0 Then
hsbLib = LoadLibrary(App.path & "\sb_engine.dll")
If hsbLib = 0 Then
MsgBox "Failed to load sb_engine.dll by explicit path?", vbInformation
End If
End If
includeDir = GetMySetting("includeDir", App.path & "\include\")
moduleDir = GetMySetting("moduleDir", App.path & "\modules\")
InitIntellisense includeDir
SetDefaultDirs includeDir, moduleDir
SetCallBacks AddressOf vb_stdout, AddressOf GetDebuggerCommand, AddressOf HostResolver, AddressOf VbLineInput
LoadFunctionPrototypes App.path & "\dependancies\calltips.txt"
scivb.LoadHighlighter App.path & "\dependancies\vb.bin"
scivb.DirectSCI.HideSelection False
scivb.DirectSCI.MarkerDefine 2, SC_MARK_CIRCLE
scivb.DirectSCI.MarkerSetFore 2, vbRed 'set breakpoint color
scivb.DirectSCI.MarkerSetBack 2, vbRed
scivb.DirectSCI.MarkerDefine 1, SC_MARK_ARROW
scivb.DirectSCI.MarkerSetFore 1, vbBlack 'current eip
scivb.DirectSCI.MarkerSetBack 1, vbYellow
scivb.DirectSCI.MarkerDefine 3, SC_MARK_BACKGROUND
scivb.DirectSCI.MarkerSetFore 3, vbBlack 'current eip
scivb.DirectSCI.MarkerSetBack 3, vbYellow