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
|
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
|
-
+
-
+
-
-
+
+
|
MAX_CCITEMS = 100
MAX_CCITEMS = 50
uglobal
hCCList dd 0
hCCPrefix dd 0
endg
idCCList = 763
proc CreateCCList, .parent
begin
push ebx
invoke CreateWindowExW, WS_EX_CLIENTEDGE, cFormClassName, 0, WS_POPUP, \
invoke CreateWindowExW, 0, cFormClassName, 0, WS_POPUP, \
0, 0, 300, 120, [.parent], 0, [hInstance], 0
mov [hCCList], eax
invoke SetPropW, eax, [propOwnerAsmEdit], [.parent]
; invoke SetWindowLongA, [hCCList], GWL_HWNDPARENT, [.parent]
stdcall SubclassWindow, [hCCList], CCParentProc
invoke CreateWindowExW, 0, cListboxClassName, 0, \
WS_CHILD or WS_VSCROLL or WS_VISIBLE or LBS_NOINTEGRALHEIGHT or LBS_OWNERDRAWFIXED or LBS_NODATA, \
invoke CreateWindowExW, WS_EX_CLIENTEDGE, cListboxClassName, 0, \
WS_CHILD or WS_BORDER or WS_VSCROLL or WS_VISIBLE or LBS_NOINTEGRALHEIGHT or LBS_OWNERDRAWFIXED or LBS_NODATA, \
0, 0, 300, 120, [hCCList], idCCList, [hInstance], 0
mov ebx, eax
stdcall SubclassWindow, ebx, CCListProc
stdcall GetDefaultFont, gdfMessage
invoke SendMessageW, ebx, WM_SETFONT, eax, TRUE
|
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
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
-
|
invoke GetWindowLongW, [hCCList], GWL_USERDATA
mov ebx, [eax+TArray.count]
lea esi, [eax+TArray.array]
or eax, -1
.matchloop:
inc eax
cmp eax, ebx
je .notfound1
mov ecx, [esi]
lea esi, [esi+4]
mov ecx, [ecx+TLabel.iName]
add ecx, [ptrNames]
stdcall StringMatchCase, ecx, edi
jnc .matchloop
.found:
invoke SendMessageW, [hCCList], LB_SETCURSEL, eax, 0
clc
return
.notfound1:
invoke GetWindowLongW, [hCCList], GWL_USERDATA
mov ebx, [eax+TArray.count]
lea esi, [eax+TArray.array]
or eax, -1
.matchloop2:
inc eax
cmp eax, ebx
je .notfound
mov ecx, [esi]
lea esi, [esi+4]
mov ecx, [ecx+TLabel.iName]
add ecx, [ptrNames]
stdcall StringMatch, ecx, edi, FALSE
stdcall StringMatchNoCase, ecx, edi
jc .found
jnc .matchloop
jmp .matchloop2
invoke SendMessageW, [hCCList], LB_SETCURSEL, eax, 0
clc
return
.notfound:
invoke SendMessageW, [hCCList], LB_SETCURSEL, -1, 0
stc
return
endp
|
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
|
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
|
-
+
-
+
-
+
+
+
-
+
-
-
-
+
-
-
-
-
-
+
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
|
@@:
invoke SetWindowPos, [hCCList], NULL, eax, ecx, 0, 0, SWP_NOSIZE or SWP_NOZORDER or SWP_NOACTIVATE or SWP_NOCOPYBITS
lea ebx, [.word]
invoke SendMessageW, [.aedit], AEM_GETWORDATCARET, $100, ebx
stdcall WideCharToUtf8, ebx
mov ebx, eax
mov [.hWord], eax
cmp word [.word], '.'
jne .localok
cmp [hCCPrefix], 0
jne .prefixok
stdcall SearchForLabelPrefixInEditor, [.aedit], [.aepos.caretLine]
mov [hCCPrefix], eax
.prefixok:
cmp [hCCPrefix], 0
je .localok
stdcall StrInsert, ebx, [hCCPrefix], 0
stdcall StrInsert, [.hWord], [hCCPrefix], 0
; here ebx contains a pointer to the whole name including the parent label.
; here [.hWord] contains a pointer to the whole name including the parent label.
.localok:
stdcall ClearCCList
stdcall SearchTree, ebx, ptrLabels
stdcall SearchTree, [.hWord], ptrLabels
stdcall StrDel, ebx
test eax, eax
jz .destroycc
mov esi, [eax]
test esi, esi
jz .destroycc
mov ebx, [esi+TArray.count]
lea esi, [esi+TArray.array]
test ebx, ebx
jz .destroycc
mov edi, edx ; The last word
mov edi, edx ; The last word. It points somewhere inside [.hWord], so from this moment to the end of the procedure, this string must not be freed or changed!!!
invoke GetWindowLongW, [hCCList], GWL_USERDATA
mov edx, eax
test edx, edx
jz .destroycc
xor ecx, ecx
; benchmark code.
; mov [.count], ecx
; stdcall GetTimestamp
; mov [.time], eax
push esi ebx
xor ecx, ecx
.fill_loop:
.fill_loop1:
; inc [.count] ; benchmark
mov eax, [esi+TLabel.iName]
test eax, eax
jz .next
jz .next1
add eax, [ptrNames]
stdcall StringMatch, eax, edi, TRUE
jnc .next
stdcall StringMatchCase, eax, edi
jnc .next1
stdcall AddArrayItems, edx, 1
mov [eax], esi
inc ecx
cmp ecx, MAX_CCITEMS
jae .end_fill_loop
jae .end_fill_loop1
.next:
.next1:
add esi, sizeof.TLabel
dec ebx
jnz .fill_loop
jnz .fill_loop1
.end_fill_loop:
.end_fill_loop1:
pop ebx esi
; benchmark code...
; pushad
; stdcall GetTimestamp
; sub eax, [.time]
; stdcall Output, 'Fill loop time:'
; stdcall OutputNumber, eax, 10, 8
; stdcall Output, <' ms ', 13, 10>
;
; stdcall Output, 'Total processed:'
; stdcall OutputNumber, [.count], 10, 8
; stdcall Output, <' records ', 13, 10>
;
; popad
.fill_loop2:
mov eax, [esi+TLabel.iName]
test eax, eax
jz .next2
add eax, [ptrNames]
stdcall StringMatchCase, eax, edi
jc .next2
stdcall StringMatch, eax, edi
jnc .next2
stdcall AddArrayItems, edx, 1
mov [eax], esi
inc ecx
cmp ecx, 2*MAX_CCITEMS
jae .end_fill_loop2
.next2:
add esi, sizeof.TLabel
dec ebx
jnz .fill_loop2
.end_fill_loop2:
push ecx
invoke SetWindowLongW, [hCCList], GWL_USERDATA, edx
pop ecx
test ecx, ecx
jz .destroycc
invoke SendMessageW, [hCCList], LB_SETCOUNT, ecx
invoke SendMessageW, [hCCList], LB_SETCOUNT, ecx, 0
stdcall SelectCCList, edi
stdcall StrDel, edi
invoke SetWindowPos, [hCCList], NULL, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOMOVE or SWP_NOZORDER or SWP_SHOWWINDOW or SWP_NOACTIVATE
.finish:
stdcall StrDel, [.hWord]
popad
return
.destroycc:
invoke PostMessageW, [hCCList], WM_CLOSE, 0, 0
jmp .finish
endp
; If str1 begins with str2 then returns CF=1
; else CF=0
;
; Case insensitive! Two EMPTY strings DOES match!
;
; preserves all registers.
proc StringMatch, .str1, .str2
begin
push esi edi eax
mov esi, [.str1]
mov edi, [.str2]
.loop:
mov al, [edi]
lea edi, [edi+1]
test al,al
jz .yesmatch
mov ah, [esi]
lea esi, [esi+1]
test ah,ah
jz .notmatch
or eax, $2020
cmp al,ah
je .loop
.notmatch:
clc
pop eax edi esi
return
.yesmatch:
stc
pop eax edi esi
return
endp
; If str1 begins with str2 then returns CF=1
; else CF=0
;
; Case sensitive! Two EMPTY strings does NOT match!
;
; preserves all registers.
proc StringMatchCase, .str1, .str2
begin
push esi edi eax
mov esi, [.str1]
mov edi, [.str2]
.loop:
mov al, [edi]
lea edi, [edi+1]
test al,al
jz .match
mov ah, [esi]
lea esi, [esi+1]
test ah,ah
jz .notmatch
cmp al,ah
je .loop
.notmatch:
clc
pop eax edi esi
return
.match:
cmp esi, [.str1]
je .notmatch
.yesmatch:
stc
pop eax edi esi
return
endp
; If str1 begins with str2 then returns CF=1
; else CF=0
;
; Case insensitive! Two EMPTY strings does NOT match!
;
; preserves all registers.
proc StringMatch, .str1, .str2, .empty
proc StringMatchNoCase, .str1, .str2
begin
push esi edi eax
mov esi, [.str1]
mov edi, [.str2]
.loop:
|