-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmMain.frm
2244 lines (1967 loc) · 63.3 KB
/
frmMain.frm
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 = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "richtx32.ocx"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.1#0"; "MSCOMCTL.OCX"
Begin VB.Form frmMain
AutoRedraw = -1 'True
Caption = "WebPad"
ClientHeight = 5775
ClientLeft = 165
ClientTop = 450
ClientWidth = 8385
Icon = "frmMain.frx":0000
KeyPreview = -1 'True
LinkTopic = "Form1"
ScaleHeight = 5775
ScaleWidth = 8385
Visible = 0 'False
Begin RichTextLib.RichTextBox rtf2
Height = 975
Left = 2640
TabIndex = 3
Top = 0
Visible = 0 'False
Width = 1335
_ExtentX = 2355
_ExtentY = 1720
_Version = 393217
Enabled = -1 'True
ScrollBars = 3
TextRTF = $"frmMain.frx":08CA
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Lucida Console"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.PictureBox PicLeft
Align = 3 'Align Left
BorderStyle = 0 'None
Height = 5475
Left = 0
ScaleHeight = 5475
ScaleWidth = 1215
TabIndex = 2
Top = 0
Width = 1215
Begin RichTextLib.RichTextBox RTF
Height = 615
Left = 0
TabIndex = 0
Top = 0
Visible = 0 'False
Width = 1095
_ExtentX = 1931
_ExtentY = 1085
_Version = 393217
ScrollBars = 3
OLEDragMode = 0
OLEDropMode = 1
TextRTF = $"frmMain.frx":094D
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Lucida Console"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
End
Begin VB.Timer Timer1
Left = 7560
Top = 240
End
Begin VB.Timer PasteTimer
Interval = 100
Left = 7560
Top = 720
End
Begin MSComctlLib.StatusBar SB
Align = 2 'Align Bottom
Height = 300
Left = 0
TabIndex = 1
Top = 5475
Width = 8385
_ExtentX = 14790
_ExtentY = 529
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 5
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
AutoSize = 1
Object.Width = 8123
Text = "File not saved"
TextSave = "File not saved"
Object.ToolTipText = "File path"
EndProperty
BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628}
Alignment = 1
AutoSize = 2
Object.Width = 873
MinWidth = 882
Text = "0"
TextSave = "0"
Object.ToolTipText = "Cursor position"
EndProperty
BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628}
Alignment = 1
AutoSize = 2
Object.Width = 873
MinWidth = 882
Text = "0"
TextSave = "0"
Object.ToolTipText = "Selection length"
EndProperty
BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628}
Alignment = 1
Object.Width = 1764
MinWidth = 1764
Text = "2 bytes"
TextSave = "2 bytes"
Object.ToolTipText = "File size"
EndProperty
BeginProperty Panel5 {8E3867AB-8586-11D1-B16A-00C0F0283628}
EndProperty
EndProperty
End
Begin VB.Menu mnuFile
Caption = "&File"
Begin VB.Menu mnuFileNew
Caption = "&New"
End
Begin VB.Menu mnuFileOpen
Caption = "&Open"
End
Begin VB.Menu mnuFileSave
Caption = "&Save"
End
Begin VB.Menu mnuFileSaveAs
Caption = "Save &As"
End
Begin VB.Menu mnuFileSP1
Caption = "-"
End
Begin VB.Menu mnuFilePrint
Caption = "&Print"
End
Begin VB.Menu mnuFileProperties
Caption = "Properties"
End
Begin VB.Menu mnuFilePageSetup
Caption = "Page Setup"
Visible = 0 'False
End
Begin VB.Menu mnuFileSP3
Caption = "-"
End
Begin VB.Menu mnuFileExit
Caption = "E&xit"
End
Begin VB.Menu mnuFiles
Caption = "-"
Index = 0
Visible = 0 'False
End
End
Begin VB.Menu mnuEditBase
Caption = "Edit"
Begin VB.Menu mnuCut
Caption = "Cut"
End
Begin VB.Menu mnuCopy
Caption = "Copy"
End
Begin VB.Menu mnuPaste
Caption = "Paste"
End
Begin VB.Menu mnuCopyrightpane
Caption = "Copy right pane"
End
Begin VB.Menu mnuFind
Caption = "Find"
Shortcut = ^F
End
Begin VB.Menu next_menu
Caption = "Find Next"
End
End
Begin VB.Menu mnuFormat
Caption = "&Options"
Begin VB.Menu mnu_shortcut
Caption = "Customize shortcut keys"
End
Begin VB.Menu mnuSplit
Caption = "&Split Pane (Alt-S)"
End
Begin VB.Menu ontop
Caption = "Always On Top"
End
Begin VB.Menu mnuFormatWordwrap
Caption = "Wordwrap"
End
Begin VB.Menu mnuFormatSP1
Caption = "-"
End
Begin VB.Menu mnuFormatFont
Caption = "Font"
End
Begin VB.Menu mnuResetFont
Caption = "Reset Font"
End
Begin VB.Menu mnuFormatBackcolor
Caption = "Backcolor"
End
Begin VB.Menu mnuFormatSP2
Caption = "-"
End
Begin VB.Menu mnuRememberPos
Caption = "Remember last position"
Checked = -1 'True
End
Begin VB.Menu mnuchangeicon
Caption = "Change Icon"
End
Begin VB.Menu mnu_setdefaults
Caption = "Set defaults for this file"
End
Begin VB.Menu mnuFormatStats
Caption = "Document Statistics"
End
Begin VB.Menu mnuFilterRTF
Caption = "Filter RTF"
Checked = -1 'True
End
Begin VB.Menu mnu_changelog
Caption = "Show change log"
End
Begin VB.Menu mnuMenubar
Caption = "Menubar (Alt-M)"
Checked = -1 'True
End
Begin VB.Menu mnuScrollbars
Caption = "Horiz Scrollbar (Alt-L)"
Checked = -1 'True
End
Begin VB.Menu mnuViewTitlebar
Caption = "Compact mode (Alt-C)"
End
Begin VB.Menu mnuViewStatusbar
Caption = "Statusbar (Alt-T)"
Checked = -1 'True
End
End
Begin VB.Menu mnuhelp
Caption = "Help"
Begin VB.Menu mnu_help
Caption = "Help"
End
Begin VB.Menu mnuFileAbout
Caption = "About"
End
End
Begin VB.Menu mnuRightClick
Caption = "right click menu"
Visible = 0 'False
Begin VB.Menu mnuAngelfire
Caption = "Open Web Site"
End
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private junktmp As Integer
Private b_left As Integer
Private b_top As Integer
Private b_width As Integer
Private b_height As Integer
Private L As Long
Private DOSfiletype As Boolean
Private reminded As Boolean
Private compact_mode As Boolean
Private lStyle As Long
Public changelog As String
Private selecting_down As Boolean, selecting_up As Boolean
Private dont_save_settings As Boolean ' dont save when loading file that has defaults in ini file
Private settings_string As String
Private col As Long
Private newstart As Long
Private orig_start As Long
Public macro_function As Integer
Public current_file As String
Public remap_key As Integer
Public searching As Boolean
Public separator As String
Private Const CURSORWIDTH = 6
Private Const CURSORHEIGHT = 11
Private Const SW_SHOW = 5
Private Const SW_SHOWNORMAL = 1
Private Const EM_SCROLL& = &HB5
Private Const SB_LINEDOWN& = 1
Private Const SB_LINEUP& = 0
Private Const EM_LINESCROLL& = &HB6
Private Const EM_SCROLLCARET& = &HB7
Private Const SB_PAGEDOWN& = 3
Private Const SB_PAGEUP& = 2
Private Const EM_GETFIRSTVISIBLELINE& = &HCE
Private Declare Function SendMessageBynum& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
Private Const VK_CONTROL = &H11
Private Const EM_LINEFROMCHAR = &HC9
Private Const MAX_SAVSTRINGS = 5
Private Const WM_COPY = &H301
Private Const WM_CUT = &H300
Private Const WM_PASTE = &H302
Private Const WM_VSCROLL = &H115
'Private Const SB_LINEDOWN = 1
'Private Const SB_LINEUP = 0
'Call SendMessage(Text1.hwnd, WM_VSCROLL, SB_LINEDOWN, 0)
Dim savstring(MAX_SAVSTRINGS) As String
Private num_savstrings As Integer
'Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As _
String, ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function FindExecutable Lib "shell32.dll" Alias _
"FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As _
String, ByVal lpResult As String) As Long
Private Declare Function CreateCaret Lib "user32" (ByVal hwnd As Long, _
ByVal hBitmap As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function ShowCaret Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function ShowScrollBar Lib "user32" (ByVal hwnd As Long, _
ByVal wBar As Long, ByVal bShow As Long) As Long
Private Const SB_HORZ = 0
Private Const SB_VERT = 1
Private Const SB_BOTH = 3
Private Const GWL_STYLE = -16&
Private Const WS_CAPTION = &HC00000
Private Const WS_BORDER = &H800000
Private Const WS_SIZEBOX = &H40000
Public WithEvents Undo As clsUndo 'heavily modified version of a class by Sebastian Thomschke
Attribute Undo.VB_VarHelpID = -1
Public onlyLoading As Boolean 'indicates form load complete
Dim mTStop() As Boolean 'allows the use of 'tab' within the richtextbox
'rather than moving focus to the next control
Dim myCommand As String
Sub adjust_cursor()
Exit Sub ' until I figure out best place to put this routine
Call CreateCaret(RTF.hwnd, 0, CURSORWIDTH, CURSORHEIGHT)
Call ShowCaret(RTF.hwnd)
End Sub
Private Sub mnu_changelog_Click()
MsgBox changelog
End Sub
Private Sub mnu_setdefaults_Click()
dont_save_settings = True
For i = 0 To num_savstrings - 1
param = Split5(savstring(i), "=")
param = Split5(param(1), "|")
If param(0) = current_file Then
savstring(i) = "default=" & current_file & "|" & _
param(1) & "|" & CStr(Me.Left) & "|" & CStr(Me.Top) & "|" & _
CStr(Me.Width) & "|" & CStr(Me.Height) & "|" & param(6)
Exit For
End If
Next
End Sub
Private Sub mnu_shortcut_Click()
frmCustomize.Show
End Sub
Private Sub mnuchangeicon_Click()
With cmndlg
.filefilter = "Icons (*.ico)"
OpenFile
If Len(.filename) <> 0 Then Set Me.Icon = LoadPicture(.filename)
End With
End Sub
Private Sub mnuCopy_Click()
SendMessage RTF.hwnd, WM_COPY, 0, 0
End Sub
Private Sub mnuCopyrightpane_Click()
SendMessage rtf2.hwnd, WM_COPY, 0, 0
End Sub
Private Sub mnuCut_Click()
SendMessage RTF.hwnd, WM_CUT, 0, 0
'RTF.Text = ""
End Sub
Private Sub mnuFiles_Click(Index As Integer)
load_new_file (mnuFiles(Index).Caption) ' menu to load preset file
End Sub
Private Sub mnuFilterRTF_Click()
mnuFilterRTF.Checked = Not mnuFilterRTF.Checked
End Sub
Private Sub mnuMenubar_Click()
menuvisible = Not menuvisible
mnuMenubar.Checked = menuvisible
mnuFile.Visible = menuvisible
mnuEditBase.Visible = menuvisible
mnuFormat.Visible = menuvisible
mnuhelp.Visible = menuvisible
End Sub
Private Sub mnuPaste_Click()
SendMessage RTF.hwnd, WM_PASTE, 0, 0
End Sub
Private Sub mnuRememberPos_Click()
mnuRememberPos.Checked = Not mnuRememberPos.Checked
End Sub
Private Sub mnuResetFont_Click()
st = RTF.SelStart
RTF.SelStart = 0
RTF.SelLength = Len(RTF.Text)
RTF.SelFontName = "Lucida Console"
RTF.SelFontSize = 10
RTF.SelStart = st
RTF.SelLength = 0
End Sub
Private Sub mnuScrollbars_Click()
mnuScrollbars.Checked = Not mnuScrollbars.Checked
' scrollbars = Not scrollbars
ShowScrollBar RTF.hwnd, SB_HORZ, mnuScrollbars.Checked
End Sub
Private Sub resize_rtf2()
Debug.Print "kwrr 1 rtf1 width: " + Str(RTF.Width) + " rtf2: " + Str(RTF.Width)
midpoint = RTF.Width / 2
RTF.Width = midpoint
rtf2.Left = midpoint + 1
rtf2.Width = RTF.Width
rtf2.Height = RTF.Height
Debug.Print "kwrr 2 rtf1 width: " + Str(RTF.Width) + " rtf2: " + Str(RTF.Width)
End Sub
Private Sub mnuSplit_Click()
rtf2.Visible = Not rtf2.Visible
If rtf2.Visible Then
resize_rtf2
Else
RTF.Width = PicLeft.Width - 120
End If
End Sub
Private Sub mnuViewTitlebar_Click()
compact_mode = Not compact_mode
' SB.Visible = Not compact_mode
' mnuFile.Visible = Not compact_mode
' mnuEditBase.Visible = Not compact_mode
' mnuFormat.Visible = Not compact_mode
' mnuhelp.Visible = Not compact_mode
If compact_mode Then
' turn off menu first
menuvisible = True
mnuMenubar_Click
' turn off statusbar
mnuViewStatusbar.Checked = True
mnuViewStatusbar_Click
oriStyle = GetWindowLong(Me.hwnd, GWL_STYLE)
lStyle = oriStyle And (Not WS_CAPTION)
SetWindowLong Me.hwnd, GWL_STYLE, lStyle
Else
menuvisible = False
mnuMenubar_Click
mnuViewStatusbar_Click
Me.Hide
lStyle = oriStyle Or WS_CAPTION Or WS_SIZEBOX
SetWindowLong Me.hwnd, GWL_STYLE, lStyle
Me.Show
End If
End Sub
Private Sub ontop_Click()
ontop.Checked = Not ontop.Checked
If ontop.Checked Then
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
SB.Panels(1) = "Always on top"
Set frmFind.Icon = Me.Icon ' save old icon to restore
Set Me.Icon = frmCustomize.Icon
Else
SetWindowPos Me.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
SB.Panels(1) = "No longer always on top"
Set Me.Icon = frmFind.Icon
End If
End Sub
Private Sub PicLeft_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SendMessage hwnd, &H112, &HF012&, 0&
End Sub
Private Sub RTF_Click()
force_control_up
End Sub
Private Sub RTF_DblClick()
Call test_url
End Sub
Function test_url() ' see if url is at cursor
Dim lOrigin As Long, lFinal As Long, filelength
On Error GoTo error:
filelength = Len(RTF.Text)
test_url = False
SB.Panels(1) = "checking url..."
' get positions of beginning & end of word (space delimited)
lOrigin = RTF.SelStart
lFinal = lOrigin + 1
Do While (lOrigin > 1 And Mid(RTF.Text, lOrigin, 1) <> " " And Asc(Mid(RTF.Text, lOrigin, 1)) <> 10)
lOrigin = lOrigin - 1
Loop
If lOrigin > 1 Then lOrigin = lOrigin + 1
Do While (Mid(RTF.Text, lFinal, 1) <> " " And Asc(Mid(RTF.Text, lFinal, 1)) <> 13 And lFinal < filelength)
lFinal = lFinal + 1
Loop
If lFinal <> filelength Then lFinal = lFinal - 1
SB.Panels(1) = ""
If (lFinal - lOrigin > 3) Then
If Mid(RTF.Text, lOrigin, 4) = "http" Or Mid(RTF.Text, lOrigin, 3) = "www" Or _
Mid(RTF.Text, lOrigin, 5) = "<http" Then
'Mid(RTF.Text, lOrigin, 7) = "telnet:" Then
open_url (Mid(RTF.Text, lOrigin, lFinal - lOrigin + 1))
test_url = True
ElseIf Mid(RTF.Text, lOrigin + 1, 2) = ":\" Then
Shell Mid(RTF.Text, lOrigin, lFinal - lOrigin + 1), vbNormalFocus
'Call ShellExecute(Me.hwnd, "Open", "c:\\junk.txt", 0&, 0&, SW_SHOWMAXIMIZED)
'Call ShellExecute(Me.hwnd, "open", BrowserExec, Mid(RTF.Text, lOrigin, lFinal - lOrigin + 1), Dummy, SW_SHOWNORMAL)
ElseIf InStr(Mid(RTF.Text, lOrigin, lFinal - lOrigin + 1), "@") Then
ShellExecute 0, vbNullString, "mailto:" & Mid(RTF.Text, lOrigin, lFinal - lOrigin + 1), vbNullString, vbNullString, vbNormalFocus
test_url = True
ElseIf Mid(RTF.Text, lOrigin, 7) = "TodayIs" Then
RTF.SelStart = lOrigin - 1
todaystr = Choose(Weekday(Now()), "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
tmp_str = "TodayIs " & todaystr & " " & Date
i = 0
Do While (Asc(Mid(RTF.Text, lOrigin + i, 1)) <> 13)
i = i + 1
Loop
RTF.SelLength = i
RTF.SelText = tmp_str
test_url = True
End If
End If
Return
error:
End Function
Private Sub say(strr As String)
RTF.SelStart = Len(RTF.Text)
RTF.Text = RTF.Text + strr + vbCrLf
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
Call adjust_cursor
SB.Panels(1) = ""
If Len(changelog) < MAX_LOG_CHANGES Then changelog = changelog + Chr(KeyAscii)
End Sub
Public Sub force_alt_up()
' release the alt key state from "pressed"
GetKeyboardState keystate(0)
keystate(VK_LMENU) = keystate(VK_LMENU) And &H7F
SetKeyboardState keystate(0)
alt_forced_up = True
End Sub
Public Sub resume_alt_down()
GetKeyboardState keystate(0)
keystate(VK_LMENU) = keystate(VK_LMENU) Or &H80
SetKeyboardState keystate(0)
alt_forced_up = False
End Sub
Public Sub force_control_up()
' release the control key state from "pressed"
GetKeyboardState keystate(0)
keystate(VK_CONTROL) = keystate(VK_CONTROL) And &H7F
SetKeyboardState keystate(0)
control_forced_up = True
End Sub
Public Sub resume_control_down()
GetKeyboardState keystate(0)
keystate(VK_CONTROL) = keystate(VK_CONTROL) Or &H80
SetKeyboardState keystate(0)
control_forced_up = False
End Sub
Private Sub force_shift_up()
GetKeyboardState keystate(0)
keystate(VK_SHIFT) = keystate(VK_SHIFT) And &H7F
SetKeyboardState keystate(0)
shift_forced_up = True
End Sub
Private Sub resume_shift_down()
GetKeyboardState keystate(0)
keystate(VK_SHIFT) = keystate(VK_SHIFT) Or &H80
SetKeyboardState keystate(0)
shift_forced_up = False
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Call adjust_cursor
If Shift = 4 And KeyCode = 18 Then force_control_up
If KeyCode = vbKeyControl Then
control_down = False
tmp_str = SB.Panels(5)
Mid(tmp_str, 1, 1) = " "
SB.Panels(5) = tmp_str
End If
If KeyCode = vbKeyShift Then
shift_down = False
tmp_str = SB.Panels(5)
Mid(tmp_str, 2, 1) = " "
SB.Panels(5) = tmp_str
End If
End Sub
Private Sub mnu_help_Click()
Dim helptext As String
helptext = "if shift/alt/number will assign numeric key to bookmark (last search string)" & vbCrLf & _
"Alt-number: jump to bookmark" & vbCrLf & _
"Alt-V: Paste under cursor" & vbCrLf & _
"Alt-N to switch to Normal size" & vbCrLf & _
"Alt-S to switch to small size" & vbCrLf & _
"Alt-A toggles 'always on top'" & vbCrLf & _
"Alt-M to toggle statusbar/menubar" & vbCrLf & _
"Alt-W toggles wordwrap" & vbCrLf & _
"Alt-Q: save and exit" & vbCrLf & _
"Alt-X to exit without changes" & vbCrLf
MsgBox helptext
End Sub
Private Sub goto_bol()
For L = RTF.SelStart To 1 Step -1
If Asc(Mid(RTF.Text, L, 1)) = 10 Then Exit For
Next
RTF.SelStart = L
End Sub
Private Sub goto_eol()
For L = RTF.SelStart To Len(RTF.Text)
If (Asc(Mid(RTF.Text, L, 1)) = 13) Then Exit For
Next
RTF.SelStart = L
End Sub
Private Function InStrMult(start As Integer, fullstring As String, _
expr1 As String, expr2 As String)
ret1 = InStr(start, fullstring, expr1, 0)
ret2 = InStr(start, fullstring, expr2, 0)
If ret1 < ret2 Then
InStrMult = ret1
Else
InStrMult = ret2
End If
End Function
Private Function orig_goto_next_word() ' slower since it does NOT use InStr
If Not DOSfiletype Then
goto_next_word = False
Return
End If
text_reached = False
For L = RTF.SelStart + 1 To Len(RTF.Text) - 1
If Asc(Mid(RTF.Text, L, 1)) <> 32 Then text_reached = True
If (Asc(Mid(RTF.Text, L, 1)) = 13) Then
L = L - 1
Exit For ' stop at CR
End If
If text_reached And (Asc(Mid(RTF.Text, L, 1)) = 32) And (Asc(Mid(RTF.Text, L + 1, 1)) <> 32) Then Exit For
Next
If RTF.SelStart = L Then
goto_next_word = False
Else
goto_next_word = True ' indicate that it's advanced
RTF.SelStart = L
End If
End Function
Private Sub RTF_KeyDown(KeyCode As Integer, Shift As Integer)
' ctrl-A to select all
If (Shift = 2) And KeyCode = vbKeyA Then
RTF.SelStart = 0
RTF.SelLength = Len(RTF.Text)
Exit Sub
End If
Call adjust_cursor
If KeyCode = 13 And Len(changelog) < MAX_LOG_CHANGES Then changelog = changelog + vbCrLf
SelFont
SB.Panels(2) = RTF.SelStart
SB.Panels(3) = RTF.SelLength
If (DOSfiletype And (Shift = 1) And ((KeyCode = vbKeyDown) Or (KeyCode = vbKeyUp))) Then
If selecting_down Then
If KeyCode = vbKeyDown Then
Debug.Print "origstart: " + Str(RTF.SelStart) + " sellength: " + Str(RTF.SelLength)
L = InStr(RTF.SelStart + RTF.SelLength + 1, RTF.Text, Chr(13), 0) - 1
If L < 1 Then Exit Sub
RTF.SelLength = L - RTF.SelStart + 2
Debug.Print " L: " + Str(L) + " newstart: " + Str(RTF.SelStart) + " sellength: " + Str(RTF.SelLength)
Else ' up arrow so user is subtracting from bottom of selection
L = InStrRev(RTF.Text, Chr(10), RTF.SelStart + RTF.SelLength - 2, 0)
If L >= RTF.SelStart Then RTF.SelLength = L - RTF.SelStart
End If
ElseIf selecting_up Then
If KeyCode = vbKeyUp Then
L = InStrRev(RTF.Text, Chr(10), RTF.SelStart - 1, 0)
newlength = RTF.SelLength + RTF.SelStart - L
If L >= 0 Then RTF.SelStart = L
If newlength >= 0 Then RTF.SelLength = newlength
Else ' down arrow so user is subtracting from top of selection
L = InStr(RTF.SelStart + 2, RTF.Text, Chr(13), 0)
newlength = RTF.SelLength - (L - RTF.SelStart) - 1
RTF.SelStart = L + 1
If newlength >= 0 Then RTF.SelLength = newlength
End If
Else
goto_bol
L = InStr(RTF.SelStart + 1, RTF.Text, Chr(13), 0)
If L = 0 Then Exit Sub
RTF.SelLength = L - RTF.SelStart + 1
If KeyCode = vbKeyDown Then
selecting_down = True
Else
selecting_up = True
End If
End If
KeyCode = 0
Else
If KeyCode <> 16 Then ' if not shift down
selecting_down = False
selecting_up = False
End If
End If
End Sub
Private Sub daily_reminder()
param = Split5(Date, "/200")
reminded = True
force_control_up
control_down = False
' to be detected, date must have leading & trailing space (like " 9/11 ")
' and be in first 1000 lines of file
Found = frmMain.RTF.Find(" " & param(0) & " ", 0, 1000, mWholeword Or mmatchCase)
If Found > -1 Then
SendKeys "+{END}", True
j = Len(RTF.SelText) \ 2 ' use to center heading
i = MsgBox(Space(j) & "REMINDER:" + vbCrLf + vbCrLf + RTF.SelText + vbCrLf + Space(j) & "Turn off?", vbYesNo)
If i = 6 Then ' 6=yes 7=no
SendKeys "{HOME}{RIGHT}*", True ' insert * so no leading space anymore
FileChanged = True
End If
End If
SendKeys "^", True
'force_control_up
'resume_control_down
End Sub
Private Sub check_byte()
L = L + 1
Debug.Print Mid(RTF.Text, L, 1), Asc(Mid(RTF.Text, L, 1))
End Sub
Private Sub set_filetype()
On Error GoTo WOOPS2
For L = 1 To Len(RTF.Text)
If Asc(Mid(RTF.Text, L, 1)) = 10 Then Exit For
Next
If Asc(Mid(RTF.Text, L - 1, 1)) = 13 Then
DOSfiletype = True
Else
DOSfiletype = False
End If
WOOPS2:
End Sub
Private Function goto_next_word()
Dim cr_loc As Long
'Debug.Print vbCrLf & vbCrLf & "at 1; sel: " & Str(RTF.SelStart) & " is " & Mid(RTF.Text, RTF.SelStart + 1, 1)
If Not DOSfiletype Then
goto_next_word = False
Return
End If
text_reached = False
' advance past spaces
For L = RTF.SelStart + 1 To Len(RTF.Text) - 1
' If Asc(Mid(RTF.Text, L, 1)) <> 32 Then
If Mid(RTF.Text, L, 1) <> " " Then
L = L - 1
Exit For 'text_reached = True
End If
Next
If L > RTF.SelStart Then ' cursor has traveled over spaces before reaching word
RTF.SelStart = L
Exit Function
End If
cr_loc = InStr(L + 1, RTF.Text, Chr(13), 0)
If cr_loc = 0 Then cr_loc = Len(RTF.Text)
L = InStr(L + 1, RTF.Text, " ", 0) ' advance to next space
If L > cr_loc Then L = cr_loc
While Mid(RTF.Text, L + 1, 1) = " " And L < cr_loc
L = L + 1
Wend
If L = cr_loc Then L = cr_loc - 1
If RTF.SelStart = L Then
goto_next_word = False
Else
goto_next_word = True ' indicate that it's advanced
RTF.SelStart = L
End If
End Function
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim url_there As Boolean
On Error Resume Next
If KeyCode > 48 And KeyCode < 59 And Shift = 2 Then
If (KeyCode - 49) < mnuFiles.UBound Then
' now close file and open mnuFiles(KeyCode - 48).Caption
load_new_file (mnuFiles(KeyCode - 48).Caption)
End If
End If
Call adjust_cursor
If KeyCode = 122 Then L = RTF.SelStart ' F11
If KeyCode = 123 Then MsgBox RTF.SelStart ' check_byte ' F12
'shft=1 ctrl=2 alt=4
If KeyCode = vbKeyControl Then
control_down = True
tmp_str = SB.Panels(5)
Mid(tmp_str, 1, 1) = "C"
SB.Panels(5) = tmp_str
End If
If Shift = 6 Then
control_down = False
tmp_str = SB.Panels(5)
Mid(tmp_str, 1, 1) = " "
SB.Panels(5) = tmp_str
End If
' if shift/alt is pressed, assign numeric key to bookmark
If Shift = 5 Then
If KeyCode > 47 And KeyCode < 58 Then
bookmarkstr(KeyCode - 48) = RTF.SelText
SB.Panels(1) = "bookmark " & CStr(KeyCode - 48) & " set"
KeyCode = 0
End If
End If
If KeyCode = vbKeyShift Then
shift_down = True
tmp_str = SB.Panels(5)
Mid(tmp_str, 2, 1) = "S"
SB.Panels(5) = tmp_str
End If
' hardcode ^A to select all
' If (Shift = 2) And KeyCode = vbKeyA Then
' RTF.SelStart = 0
' RTF.SelLength = Len(RTF.Text)
' End If
If Shift = 2 And KeyCode = vbKeyF Then control_down = True
If control_down And shift_down Then
If KeyCode = vbKeyE Then ' top
KeyCode = vbKeyHome
force_shift_up
resume_control_down
ElseIf KeyCode = vbKeyD Then ' bottom
KeyCode = vbKeyEnd
resume_control_down
force_shift_up
ElseIf KeyCode = vbKeyH Then ' word left
'If DOSfiletype Then ' use new word move
' text_reached = False
'L = InStr(Mid(RTF.Text, lOrigin, lFinal - lOrigin + 1), "@") then
'For L = RTF.SelStart To 2 Step -1
' If Asc(Mid(RTF.Text, L, 1)) <> 32 Then text_reached = True
' If (Asc(Mid(RTF.Text, L - 1, 1)) = 13) Then Exit For ' stop at CR
' If text_reached And (Asc(Mid(RTF.Text, L, 1)) = 32) And (Asc(Mid(RTF.Text, L + 1, 1)) <> 32) Then Exit For
'Next
' If L >= 0 Then RTF.SelStart = L
' KeyCode = 0
'Else ' use windows builtin word shift
force_shift_up
resume_control_down
KeyCode = vbKeyLeft
'End If
ElseIf KeyCode = vbKeyL Then ' word right
If DOSfiletype Then
goto_next_word
KeyCode = 0
Else
force_shift_up
resume_control_down
KeyCode = vbKeyRight