-
Notifications
You must be signed in to change notification settings - Fork 3
/
GuiEditBox.cls
10460 lines (9426 loc) · 277 KB
/
GuiEditBox.cls
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 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "GuiEditBox"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
' M2000 ver 1.
Option Explicit
Implements IControlIndex
' chr(34) is """" maybe somewhere in a module as public
'Const mway As Long = DT_NOPREFIX Or DT_NOCLIP
Const mway As Long = DT_NOPREFIX Or DT_NOCLIP Or DT_EXPANDTABS Or DT_TABSTOP
Public textinform As String
Private Col() As Long, lastdata As String, thispara As Long
Private mark1 As Long, mark2 As Long
Private TextPixelOffset As Long, LastSearchType As Long
Private Brackets As Boolean
Private nochange As Boolean, sp As String, sp1 As String, sp2 As String
Private TabControl As Long
Private mNoCenterLineEdit As Boolean, LineCommandSep As String
Public PreserveRightSpaces As Boolean
Public HighLightParagraph As Boolean, HighLightColor As Long
Public UseHtmlColors As Boolean
Dim profundo As New clsProfiler
Public SeekNextLine As Boolean
Public ShadowMarks As Boolean
Public StartSymbols As String
Public OtherSymbols As String
Private mSplitExpr As String
Public LineComment1 As String
Public LineComment2 As String
Public AssignSym As String
Public StringSep As String
Public stringsep2 As String
Public ExtraFront As String
Public OpenTag As String, CloseTag As String, DropSym As String
Public CommentSymbols As String
Public ComSymbolsWidth As Long, CommentLineLight As Boolean
Public MultiLineComment1 As String
Private mMultiLineComment2 As String
Public Form1mn1Enabled As Boolean
Public Form1mn2Enabled As Boolean
Public Form1mn3Enabled As Boolean
Public Form1sdnEnabled As Boolean
Public Form1supEnabled As Boolean
Public Form1mscatEnabled As Boolean
Public Form1rthisEnabled As Boolean
Private mColorCollection1 As String
Private mUseCase As Boolean
Public ColorCollection2 As String
Public ColorCollection3 As String
Public ColorCollection4 As String
Private M2000code As Boolean
Public AllowInsertBrackets As Boolean
Public EnablePairs As Boolean
Public EditTextWord As Boolean
Public ColorSet As Long
Public NumberOnly As Boolean
Public NumberIntOnly As Boolean
Public WithEvents glistN As gList
Attribute glistN.VB_VarHelpID = -1
Private blockKeyboard As Boolean
Private LastDocTitle$, para1 As Long, PosPara1 As Long, Para2 As Long, PosPara2 As Long, Para3 As Long, PosPara3 As Long
Public fState As Long
Public WithEvents mDoc As Document ' document
Attribute mDoc.VB_VarHelpID = -1
Dim WithEvents mDoc1 As Document ' header
Attribute mDoc1.VB_VarHelpID = -1
Dim UndoDoc As New Document ' one level of undo no events ' no break lines
Dim undopara As Long, undopos As Long, undotext As String, undomode As Long, undotexthtml As String
Dim Redopara As Long, Redopos As Long, Redotext As String, Redomode As Long
Dim undoprev As Boolean, Redoprev As Boolean
Dim undostate As Boolean
Dim Redostate As Boolean
Dim NoHeadwrap As Boolean
Public SkipProcAtExitFocus As Boolean
Private Type UndoChain
undopara As Long
undopos As Long
undomode As Long
undotext As String
undoprev As Boolean
End Type
Dim NeoUndo As Long, UndoMax As Long
Dim NeoRedo As Long, RedoMax As Long
Dim MultiUndo() As UndoChain
Dim MultiRedo() As UndoChain
Dim GetUndoNext As Boolean
Dim myfilename As String
Dim all As Long, onelineheight As Long
''Event inform(tLine As Long, tPos As Long)
Public LastSelStart As Long
Public NoMark As Boolean
Public NoTitle As Boolean, TitleStay As Boolean
Private mNoColor As Boolean, mNoColor1 As Boolean
Public Title As String
Public UsedAsTextBox As Boolean '' only in m2000. Enter exit - use maxchar - No wrap
Private mEditDoc As Boolean
Public AutoNumber As Boolean
Public Charpos As Long, expandCharPos As Long
Public showparagraph As Boolean
Private showparagraphWork As Boolean
Public SelectionColor As Long
Public SelectionTextColor As Long
Private showparagraphonce As Boolean
Private mNoWrap As Boolean
Private BlockStartPara As Long, BlockStartPos As Long, BlockStartLine As Long, BlockTopline As Long
Private BlockStartCursor As Long, BlockEndCursor As Long
Private BlockEndPara As Long, BlockEndPos As Long, BlockEndline As Long, BlockBottomline As Long
Private Declare Function CopyFromLParamToRect Lib "user32" Alias "CopyRect" (lpDestRect As RECT, ByVal lpSourceRect As Long) As Long
Private Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long
Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function GlobalReAlloc Lib "kernel32" (ByVal hMem As Long, ByVal dwBytes As Long, ByVal wFlags As Long) As Long
Private Declare Function GlobalSize Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
Private Const GMEM_DDESHARE = &H2000
Private Const GMEM_DISCARDABLE = &H100
Private Const GMEM_DISCARDED = &H4000
Private Const GMEM_FIXED = &H0
Private Const GMEM_INVALID_HANDLE = &H8000
Private Const GMEM_LOCKCOUNT = &HFF
Private Const GMEM_MODIFY = &H80
Private Const GMEM_MOVEABLE = &H2
Private Const GMEM_NOCOMPACT = &H10
Private Const GMEM_NODISCARD = &H20
Private Const GMEM_NOT_BANKED = &H1000
Private Const GMEM_NOTIFY = &H4000
Private Const GMEM_SHARE = &H2000
Private Const GMEM_VALID_FLAGS = &H7F72
Private Const GMEM_ZEROINIT = &H40
Private Const GPTR = (GMEM_FIXED Or GMEM_ZEROINIT)
Private Const GMEM_LOWER = GMEM_NOT_BANKED
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)
Private Declare Function GetClipboardData Lib "user32" _
(ByVal wFormat As Long) As Long
Private Declare Function SetClipboardData Lib "user32" _
(ByVal wFormat As Long, ByVal hMem As Long) As Long
Private Declare Function OpenClipboard Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function CloseClipboard Lib "user32" _
() As Long
Private Declare Function IsClipboardFormatAvailable Lib "user32" _
(ByVal wFormat As Long) As Long
Private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoW" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As Long, ByVal cchData As Long) As Long
Private Declare Function GetKeyboardLayout& Lib "user32" (ByVal dwLayout&) ' not NT?
Private Const DWL_ANYTHREAD& = 0
Const LOCALE_ILANGUAGE = 1
' for Gui purposes
Private s$
Public ctrlName As String
Private mesCtrlName As String
Dim mIndex As Long, mStayOpen As Boolean
Dim Callback As GuiM2000
Dim oldEditDoc As Boolean
Dim white As Long, black As Long, dimm1 As Long, dimm2 As Long, capchroma As Long
Dim Quit
Private OldPar As Long, dragCharpos As Long
' new
Private Declare Sub GetMem2 Lib "msvbvm60" (ByVal Addr As Long, RetVal As Integer)
Private Type DRAWTEXTPARAMS
cbSize As Long
iTabLength As Long
iLeftMargin As Long
iRightMargin As Long
uiLengthDrawn As Long
End Type
Dim tParam As DRAWTEXTPARAMS
Private Declare Sub PutMem2 Lib "msvbvm60" (ByVal Addr As Long, ByVal NewVal As Integer)
Private Declare Function CreateRectRgnIndirect Lib "gdi32" (ByRef lpRect As RECT) As Long
Private Declare Function SelectClipRgn Lib "gdi32" (ByVal hDC As Long, ByVal hRgn As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function DrawTextEx Lib "user32" Alias "DrawTextExW" (ByVal hDC As Long, ByVal lpsz As Long, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long, ByVal lpDrawTextParams As Long) As Long
Private Declare Function GetStringTypeExW Lib "kernel32.dll" (ByVal Locale As Long, ByVal dwInfoType As Long, ByVal lpSrcStr As Long, ByVal cchSrc As Long, ByRef lpCharType As Integer) As Long
Private tmpshow As Boolean
Private WordOnly As Boolean
Private ColArr(0 To 15) As Long
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private LastListIndex As Long
Friend Property Get GetCallBack() As GuiM2000
Set GetCallBack = Callback
End Property
Friend Sub Construct(there As GuiM2000, Name$)
mIndex = -1
Set Callback = there
On Error Resume Next
ctrlName = GetTag$
Set glistN = there.Controls.Add("m2000.glist", ctrlName)
there.AddGuiControl Me
glistN.Dynamic
there.Controls(ctrlName).TabStop = True
mesCtrlName = Name$
End Sub
Friend Sub ConstructArray(there As GuiM2000, Name$, i As Long)
Set Callback = there
On Error Resume Next
ctrlName = GetTag$
Set glistN = there.Controls.Add("m2000.glist", ctrlName)
mIndex = i
there.AddGuiControl Me
glistN.Dynamic
there.Controls(ctrlName).TabStop = True
mesCtrlName = Name$
End Sub
Public Sub SetUp()
TabControl = 4
EditTextWord = True
black = 0
dimm1 = rgb(100, 200, 160)
dimm2 = rgb(200, 120, 60)
' for vb6 coloring &HFFFFFF - no checking for number of digits
ColorCollection4 = "|&H|&O|"
AssignSym = "="
ExtraFront = "&"
OtherSymbols = ",;"
LineComment1 = "\"
LineComment2 = "'"
StringSep = Chr$(34)
stringsep2 = Chr$(0)
CommentSymbols = "[\][\]"
ComSymbolsWidth = 2
CommentLineLight = False
MultiLineComment1 = "/*"
MultiLineComment2 = "*/"
Dim ff As New StdFont
With Callback
white = .Controls(1).ForeColor
ff.Name = .CtrlFontName
ff.charset = Form1.DIS.Font.charset
ff.Size = .CtrlFontSize
ff.bold = .CtrlFontBold
End With
mStayOpen = True
With glistN
WordCharLeft = " ,[]"
WordCharRight = " ,[]"
.NoEscapeKey = True
.bypassfirstClick = True
.Vertical = True
.DropEnabled = True
.DragEnabled = True
.PreserveNpixelsHeaderRightTwips = 8
NoMark = False
mNoColor = True
mNoColor1 = True
FileName = vbNullString
glistN.DragEnabled = False
.BackColor = rgb(200, 120, 60)
Set .Font = ff
.ForeColor = white
.dcolor = Callback.Controls(1).dcolor
.LeftMarginPixels = 8
End With
'glistN.addpixels = 0
TextPixelOffset = Int(glistN.TextHeightOffset)
capchroma = glistN.CapColor
EditDoc = True
nowrap = False
enabled = True
SetME
ShowAlways = True
mDoc.ForEditBox = True
End Sub
Sub Show()
If glistN Is Nothing Then Exit Sub
TextPixelOffset = Int(glistN.TextHeightOffset)
If tmpshow Then tmpshow = False: Exit Sub
glistN.PrepareToShow 5
End Sub
Public Sub PasteDoc(thisdoc As String)
Const CF_UNICODETEXT = 13
ClearRedo
If thisdoc = vbNullString Then
thisdoc = GetTextData(CF_UNICODETEXT)
Else
PushUndo
End If
undotext = thisdoc
undopara = mDoc.MarkParagraphID
If mDoc.TextParagraphLen(mDoc.MarkParagraphID) = 0 And glistN.SelStart > 0 Then
undopos = 1 + CharPosStart - glistN.SelStart
Else
undopos = CharPosStart
End If
undomode = 0
mDoc.InsertDoc mDoc.MarkParagraphID, Charpos, (thisdoc)
'ReColorBlock
Render
End Sub
Private Function Myleft$(A As String, Pos As Long)
If Pos < 1 Then Myleft$ = vbNullString Else Myleft$ = Mid$(A, 1, Pos)
End Function
Private Function GetTextData(ByVal lFormatId As Long) As String
Dim bData() As Byte, sr As String, sr1 As String
sr1 = Clipboard.GetText(1)
If (OpenClipboard(0) <> 0) Then
If (GetBinaryData(lFormatId, bData())) Then
sr = bData
If IsWine Then
sr1 = Myleft$(sr, Len(sr1))
GetTextData = Myleft$(sr1, Len(sr1))
Else
GetTextData = Myleft$(sr, Len(sr1))
End If
End If
End If
CloseClipboard
End Function
Private Function GetClipboardMemoryHandle( _
ByVal lFormatId As Long _
) As Long
If (IsClipboardFormatAvailable(lFormatId) <> 0) Then
GetClipboardMemoryHandle = GetClipboardData(lFormatId)
End If
End Function
Private Function GetBinaryData( _
ByVal lFormatId As Long, _
ByRef bData() As Byte _
) As Boolean
Dim hMem As Long, lSize As Long, lPtr As Long
Erase bData
hMem = GetClipboardMemoryHandle(lFormatId)
If (hMem <> 0) Then
lSize = GlobalSize(hMem)
lPtr = GlobalLock(hMem)
If (lSize > 0) Then
ReDim bData(0 To lSize - 2) As Byte
CopyMemory bData(0), ByVal lPtr, lSize - 1
End If
GlobalUnlock hMem
GetBinaryData = (lSize > 0)
End If
End Function
Public Sub HorSrcoll(widthtwips As Long)
glistN.PanPos = widthtwips
End Sub
Public Property Get FileName() As String
FileName = myfilename
End Property
Sub NewTitle(RHS As String, addpixelstoo As Long, Optional factor As Single = 1)
Title = RHS
Set mDoc1 = New Document
mDoc.NoIgnoreCase = Not mUseCase
If Title = vbNullString Then
Else
NoHeadwrap = False
mDoc1.textDoc = Title
glistN.VerticalCenterText = True
If mDoc1.DocLines >= glistN.lines + 1 Then
mDoc1.EmptyDoc
NoHeadwrap = True
mDoc1.textDoc = Title
End If
glistN.HeadLine = vbNullString ' reset
glistN.HeadLine = " " ' give a fake headline
onelineheight = glistN.HeadlineHeight + addpixelstoo
glistN.addpixels = 4 * factor ' 'line spacing
End If
all = mDoc.DocLines
glistN.MultiLineEditBox = True
glistN.ShowBar = True
glistN.ShowBar = False ' now is in autohide mode
glistN.StickBar = True
mDoc.WrapAgain
mDoc1.WrapAgain
glistN.PrepareToShow 10
all = mDoc.DocLines
glistN.CalcAndShowBar
End Sub
Public Property Let FileName(ByVal RHS As String)
myfilename = RHS
onelineheight = 0
Dim thisdoc As New Document, Header As New Document
Set mDoc = thisdoc
mDoc.NoIgnoreCase = Not mUseCase
mDoc.ColorEvent = True
Set mDoc1 = Header
para1 = 0
PosPara1 = 0
Para2 = 0
PosPara2 = 0
Para3 = 0
PosPara3 = 0
BlockStartPara = 0
BlockStartPos = 1
BlockStartLine = 0
BlockTopline = 0
BlockStartCursor = 0
BlockEndCursor = 0
BlockEndPara = 0
BlockEndPos = 1
BlockEndline = 0
BlockBottomline = 0
Dim i As Long
glistN.NoCaretShow = True
ClearRedo
ClearUndo
If RHS = vbNullString Then
mDoc.textDoc = vbNullString
Else
mDoc.textDoc = ReadUnicodeOrANSI(RHS)
End If
Dim what$, ThatPara As Long, pastchars
pastchars = mDoc.TextParagraphLine(1, what$, ThatPara)
mDoc.MarkParagraphID = ThatPara
NoTitle = Title = vbNullString
nowrap = True
If Not NoTitle Then
mDoc1.textDoc = Title
glistN.HeadLine = vbNullString ' reset
glistN.HeadLine = " " ' give a fake headline
onelineheight = glistN.HeadlineHeight
End If
all = mDoc.DocLines
glistN.MultiLineEditBox = True
glistN.ShowBar = True
glistN.ShowBar = False ' now is in autohide mode
glistN.ShowMe
glistN.StickBar = True
mDoc.WrapAgain
mDoc1.WrapAgain
glistN.PrepareToShow 10
all = mDoc.DocLines
glistN.CalcAndShowBar
End Property
Public Sub ResetSelColors()
SelectionTextColor = &HFFFFFF
SelectionColor = &H666666
End Sub
Private Sub Class_Initialize()
' new
Dim i As Long
sp1 = ",+-*/=<>^!.&[]{}()^;""" + "'!"
sp = " " + ChrW(9) + ChrW(160)
sp2 = sp1 + sp
tParam.cbSize = LenB(tParam)
tParam.iTabLength = 4
ColorSet = 1
M2000code = True
For i = 0 To 15: ColArr(CLng(i)) = M2000(i): Next i
M2000code = False
Set mDoc = New Document
mDoc.NoIgnoreCase = Not mUseCase
mDoc.ColorEvent = True
Set mDoc1 = New Document
ResetSelColors
mDoc.LCID = Clid
mDoc1.LCID = Clid
BlockStartPara = BlockEndPara
BlockStartPos = BlockEndPos
undopara = -1
Redopara = -1
mIndex = -1
mUseCase = True
LineCommandSep = ":"
mSplitExpr = ","
HighLightColor = rgb(225, 255, 255)
End Sub
Private Sub Class_Terminate()
Quit = True
Set glistN = Nothing
End Sub
Property Let TabWidth(RHS As Long)
If RHS = 0 Then
tParam.iTabLength = 4
glistN.TabWidthChar = 4
Else
tParam.iTabLength = Abs(RHS)
glistN.TabWidthChar = Abs(RHS)
End If
TabControl = 0
End Property
Property Let SpaceIndent(RHS As Long)
TabControl = Abs(RHS)
End Property
Private Sub glistN_addone(that As String) '
ClearRedo
If that = vbCrLf Then
PushUndo
undopara = mDoc.MarkParagraphID
undotext = that
undopos = SelStart
undomode = 2
ElseIf that = vbCr Then
PushUndo
undopara = mDoc.MarkParagraphID
undotext = vbCrLf
undopos = SelStart
undomode = 1
ElseIf undomode = 1 And undotext <> "" Then
If undopos = SelStart Then
' we add after
undotext = undotext + that
ElseIf undopos = SelStart + 1 Then
undotext = that + undotext
undopos = SelStart
Else
GoTo there
End If
Else
there:
PushUndo
undopara = mDoc.MarkParagraphID
undotext = that
undopos = SelStart ' always the left side of char - so 0 is inside
undomode = 1
End If
End Sub
Public Sub AddUndo(that As String)
If Not enabled Then Exit Sub
ClearRedo
If that = vbCrLf Then
PushUndo
undopara = mDoc.MarkParagraphID
undotext = that
undopos = SelStart
undomode = 2
Else
PushUndo
undopara = mDoc.MarkParagraphID
undotext = that
undopos = SelStart ' always the left side of char - so 0 is inside
undomode = 1
End If
End Sub
Public Sub RemoveUndo(that As String)
ClearRedo
If that = vbCrLf Then
PushUndo
undopara = mDoc.MarkParagraphID
undotext = that
undopos = SelStart
undomode = 3
ElseIf that = vbCr Then
PushUndo
undopara = mDoc.MarkParagraphID
undotext = that
undopos = SelStart
undomode = 3
Else
PushUndo
undopara = mDoc.MarkParagraphID
undotext = that
If mDoc.TextParagraphLen(mDoc.MarkParagraphID) = 0 And glistN.SelStart > 0 Then
undopos = 1 + SelStart - glistN.SelStart
Else
undopos = SelStart
End If
undomode = 0
End If
End Sub
Public Sub ManualInform()
If Not glistN.enabled Then Exit Sub
If glistN.SelStart = 0 Then
If mIndex >= 0 Then
Callback.Callback mesCtrlName + ".Inform(" + str(mIndex) + "," + str(glistN.ListIndex + 1) + ", 1)"
Else
Callback.Callback mesCtrlName + ".Inform(" + str(glistN.ListIndex + 1) + ", 1)"
End If
Else
If mIndex >= 0 Then
Callback.Callback mesCtrlName + ".Inform(" + str(mIndex) + "," + str(glistN.ListIndex + 1) + ", " + str(glistN.SelStart) + ")"
Else
Callback.Callback mesCtrlName + ".Inform(" + str(glistN.ListIndex + 1) + ", " + str(glistN.SelStart) + ")"
End If
End If
End Sub
Private Sub glistN_GroupUndo()
If undopara <> -1 Then
undoprev = True
End If
End Sub
Private Sub glistN_SubSelStart(val As Long, shift As Integer)
expandCharPos = 0
Dim W As Long, A$, l As Long, b$
If HaveMarkedText And Not (shift And 1) = 1 Then
BlockStartPara = BlockEndPara
BlockStartPos = BlockEndPos
glistN.MarkNext = 0
val = 0
Exit Sub
End If
If Charpos < 2 Or NumberOnly Or NumberIntOnly Then Exit Sub
A$ = Mid$(mDoc.TextParagraph(mDoc.MarkParagraphID), Charpos - 1)
If Len(A$) > 0 Then
W = AscW(A$)
If (shift And 2) = 2 And Charpos > 1 Then
A$ = Mid$(mDoc.TextParagraph(mDoc.MarkParagraphID), 1, Charpos - 1)
l = Len(A$)
val = l
If val = 1 Then Exit Sub
b$ = Mid$(A$, l, 1)
If InStr(sp1, b$) = 0 Then
Do While l > 1 And InStr(sp, b$) > 0
l = l - 1
b$ = Mid$(A$, l, 1)
Loop
If InStr(sp1, b$) = 0 Then
If l = val Then
Do While l > 1 And InStr(sp2, b$) = 0
l = l - 1
b$ = Mid$(A$, l, 1)
Loop
If l = 1 And Not InStr(sp2, b$) > 0 Then l = l - 1
Else
If InStr(sp2, b$) > 0 Then l = l - 1
End If
End If
Else
l = l - 1
End If
val = val - l
ElseIf W > -9217 And W < -8192 Then
val = 2
End If
ElseIf Charpos > 0 Then
W = Len(mDoc.TextParagraph(mDoc.MarkParagraphID))
If W < Charpos Then val = Charpos - W
End If
End Sub
Private Sub glistN_AddSelStart(val As Long, shift As Integer)
expandCharPos = 0
If NumberOnly Or NumberIntOnly Then Exit Sub
Dim W As Long, A$, l As Long, b$
If HaveMarkedText And Not (shift And 1) = 1 Then
BlockStartPara = BlockEndPara
BlockStartPos = BlockEndPos
glistN.MarkNext = 0
val = 0
Exit Sub
End If
If Charpos > 0 Then
A$ = Mid$(mDoc.TextParagraph(mDoc.MarkParagraphID), Charpos, 1)
If Len(A$) > 0 Then
W = AscW(A$)
If (shift And 2) = 2 Then
A$ = Mid$(mDoc.TextParagraph(mDoc.MarkParagraphID), Charpos)
l = Len(A$)
val = 1
If l < 2 Then Exit Sub
b$ = Mid$(A$, val, 1)
If InStr(sp1, b$) = 0 Then
Do While val < l And InStr(sp, b$) > 0
val = val + 1
b$ = Mid$(A$, val, 1)
Loop
If InStr(sp1, b$) = 0 Then
If val = 1 Then
Do While val < l And InStr(sp2, b$) = 0
val = val + 1
b$ = Mid$(A$, val, 1)
Loop
If InStr(sp2, b$) > 0 Then val = val - 1
Else
If val < l Then val = val - 1
End If
Else
val = val - 1
End If
End If
ElseIf W > -10241 And W < -9216 Then
val = 2
End If
End If
End If
End Sub
Private Sub glistN_CheckGotFocus()
Callback.RealHover = ctrlName
If Not locked Then
glistN.HideCaretOnexit = False
If glistN.ListIndex < 0 And glistN.listcount > 0 Then glistN.ListindexPrivateUse = 0
If enabled Then
glistN.NoCaretShow = NoMark
mNoColor = mNoColor1
glistN.ForeColor = black
glistN.BackColor = white
Else
mNoColor = True
glistN.NoCaretShow = NoMark
glistN.ForeColor = white
glistN.BackColor = dimm1
End If
If Not NoCenterLineEdit Then
glistN.ShowMe
End If
Else
mNoColor = True
End If
End Sub
Private Sub glistN_CheckLostFocus()
If Not locked Then
If mStayOpen And Not SkipProcAtExitFocus Then
glistN.NoCaretShow = NoMark
glistN.HideCaretOnexit = True
If glistN.Visible Then
If NumberOnly Or UsedAsTextBox Then
SelStartSilent = 0
BlockStartPara = BlockEndPara
BlockStartPos = BlockEndPos
glistN.MarkNext = 0
End If
If Not NoCenterLineEdit Then
glistN.ShowPan
End If
End If
Exit Sub
End If
If Not SkipProcAtExitFocus Then
mNoColor = True
glistN.NoCaretShow = NoMark
glistN.HideCaretOnexit = True
glistN.ForeColor = white
If glistN.BackStyle <> 1 Then
glistN.BackColor = dimm2
End If
glistN.PanPos = 0: glistN.PrepareToShow
Else
'
End If
Else
End If
'RaiseEvent LostFocus
End Sub
Private Sub glistN_CorrectCursorAfterDrag()
If Not mDoc.InvalidPara(OldPar) Then
SelLengthSilent = 0
mDoc.MarkParagraphID = OldPar
glistN.enabled = False
ParaSelStart = dragCharpos
glistN.enabled = True
ManualInform
OldPar = 0
End If
End Sub
Private Sub glistN_DragOverCursor(ok As Boolean)
ok = True
End Sub
Private Sub glistN_getpair(A As String, b As String)
If EnablePairs Then
Select Case A
Case StringSep
b = StringSep
Case Myleft$(stringsep2, 1)
b = Right$(stringsep2, 1)
Case "("
b = ")"
Case "{"
b = "}"
Case "["
b = "]"
Case Else
If Len(OpenTag) > 0 Then
If A = OpenTag Then b = ">"
End If
End Select
End If
End Sub
Private Sub glistN_HaveMark(Yes As Boolean)
Yes = HaveMarkedText
End Sub
Private Sub glistN_MarkCut(ThatData As String)
expandCharPos = 0
ThatData = undotext
End Sub
Private Sub glistN_DragOverDone(A As Boolean)
If Not mDoc.InvalidPara(OldPar) Then
A = True
SelLengthSilent = 0
mDoc.MarkParagraphID = OldPar
glistN.enabled = False
ParaSelStart = dragCharpos
glistN.enabled = True
ManualInform
OldPar = 0
End If
End Sub
Private Sub glistN_DragOverNow(A As Boolean)
If OldPar = 0 Then
A = True
SelLengthSilent = 0
OldPar = mDoc.MarkParagraphID
dragCharpos = Charpos
End If
End Sub
Private Sub glistN_Maybelanguage()
If Not glistN.enabled Then Exit Sub
If glistN.SelStart = 0 Then
If mIndex >= 0 Then
Callback.Callback mesCtrlName + ".Inform(" + str(mIndex) + "," + str(glistN.ListIndex + 1) + ", 1)"
Else
Callback.Callback mesCtrlName + ".Inform(" + str(glistN.ListIndex + 1) + ", 1)"
End If
Else
If mIndex >= 0 Then
Callback.Callback mesCtrlName + ".Inform(" + str(mIndex) + "," + str(glistN.ListIndex + 1) + ", " + str(glistN.SelStart) + ")"
Else
Callback.Callback mesCtrlName + ".Inform(" + str(glistN.ListIndex + 1) + ", " + str(glistN.SelStart) + ")"
End If
End If
Render
End Sub
Private Sub glistN_OutPopUp(X As Single, y As Single, myButton As Integer)
'
If mIndex >= 0 Then
Callback.Callback mesCtrlName + ".PopUp(" + str(mIndex) + "," + str(X + Callback.Controls(ctrlName).Left) + "," + str(y + Callback.Controls(ctrlName).top) + "," + str(myButton) + "," + str(glistN.ListIndex + 1) + ")"
Else
Callback.Callback mesCtrlName + ".PopUp(" + str(X + Callback.Controls(ctrlName).Left) + "," + str(y + Callback.Controls(ctrlName).top) + "," + str(myButton) + "," + str(glistN.ListIndex + 1) + ")"
End If
End Sub
Private Sub glistN_PureListOff()
showparagraphWork = True
End Sub
Private Sub glistN_PureListOn()
showparagraphWork = False
End Sub
Private Sub glistN_PushMark2Undo(that As String)
ClearRedo
undopara = BlockEndPara
undotext = that
undomode = 1
undopos = SelStart
End Sub
Private Sub glistN_PushUndoIfMarked()
If HaveMarkedText Then PushUndo
End Sub
Private Sub glistN_RealCurReplace(A As String)
If showparagraph Then
A = Replace(A, vbTab, ChrW(&H21E5))
End If
End Sub
Private Sub glistN_RemoveOne(that As String)
' push undo removeone
If Not enabled Then Exit Sub
ClearRedo
If that = vbCrLf Then
PushUndo
undopara = mDoc.MarkParagraphID
undotext = that
undopos = SelStart
undomode = 3
ElseIf undomode = 0 And undotext <> "" Then
If undopos + Len(undotext) = SelStart Then
' we add after
undotext = undotext + that
Else
PushUndo
undopara = mDoc.MarkParagraphID
undotext = that
If mDoc.TextParagraphLen(mDoc.MarkParagraphID) = 0 And glistN.SelStart > 0 Then
undopos = 1 + SelStart - glistN.SelStart
Else
If glistN.ListIndex = all Then
undopos = SelStart - 1
Else
undopos = SelStart
End If
End If
' always the left side of char - so 0 is inside
undomode = 0
End If
Else
PushUndo
undopara = mDoc.MarkParagraphID
undotext = that
If mDoc.TextParagraphLen(mDoc.MarkParagraphID) = 0 And glistN.SelStart > 0 Then
undopos = 1 + SelStart - glistN.SelStart
Else
undopos = SelStart
End If
undomode = 0
End If
End Sub
Private Sub glistN_MayRefresh(ok As Boolean)
ok = Not HaveMarkedText
End Sub
Public Property Get MaxCharLength() As Long
MaxCharLength = glistN.maxchar
End Property
Public Property Let MaxCharLength(ByVal RHS As Long)
glistN.maxchar = RHS
End Property
Private Sub glistN_ChangeListItem(item As Long, content As String)
Dim selstart2 As Long, checklistindex As Long, old$
'' only for M2000, use NumberOnly
If NumberOnly Or NumberIntOnly Then
content = MyTrim(content)
NumberOnly = True
If Len(content) > glistN.maxchar Then
Charpos = glistN.maxchar
glistN.SelStartEventAlways = glistN.SelStart - 1
Exit Sub
End If
If content = vbNullString Then
ElseIf Not ValidNum(content, False, NumberIntOnly) Then
undotext = vbNullString
content = mDoc.TextLine(item + 1)
Exit Sub
End If
End If
If UsedAsTextBox Then
If Len(content) > glistN.maxchar Then
IsRTLrun
Charpos = glistN.maxchar
glistN.SelStartEventAlways = glistN.SelStart - 1