WikiPad

Check-in [d9bc02361d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Some missing files added.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:d9bc02361d60f12420437b5558b697cc9e04828c
User & Date: JohnFound 2011-04-08 08:48:26
Context
2011-04-08
13:50
Uses AsmEdit for the text editing. Opens the file specified in the command line. On exit save the current configuration of the shortcuts. Can insert multiline texts. New icon to be used for .wiki document association. check-in: 93562586dc user: lhmnai0 tags: trunk
08:48
Some missing files added. check-in: d9bc02361d user: JohnFound tags: trunk
08:41
Implemented AsmEdit as an edit control. Some highlighing added. Work in progress. check-in: 9cbee56b0a user: JohnFound tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added Arguments.asm.





































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
proc ParseCommandLine
.num dd ?
begin
        stdcall StrNew
        mov     ebx, eax

        invoke  GetCommandLine
        stdcall StrCopy, ebx, eax
        stdcall StrLen, ebx
        mov     ecx, eax

        stdcall StrPtr, ebx
        mov     edi, eax

        mov     [.num], 0
.foundspc:
        call    .skipspc
        call    .findquoted
        jc      .found

        call    .findnotquoted
        jnc     .finish

.found:
        inc     [.num]
        cmp     [.num], 1
        je      .foundspc
        pushad

        stdcall _openFileCallback, esi, 0

        popad
        jmp     .foundspc

.finish:
        stdcall StrDel, ebx
        return

.findquoted:
        jecxz   .false
        mov     al, '"'
        cmp     [edi], al
        jne     .false

        inc     edi
        dec     ecx
        jecxz   .false

        mov     esi, edi
        repnz scasb
        jnz     .false

        mov     byte [edi-1], 0
        stc
        ret

.false:
        clc
        ret

.findnotquoted:
        jecxz   .false
        mov     al, ' '

        mov     esi, edi
        repnz scasb
        jnz     .ok

        mov     byte [edi-1], 0
.ok:
        stc
        ret

.skipspc:
        cmp     byte [edi], ' '
        jne     .endskip

        inc     edi
        loop    .skipspc
.endskip:
        ret
endp

Added asmedit/asmedit.asm.













































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
;-------------------------------------------
; Assembly Editor for Win32
; Copyright (c) 2001-2002, Tomasz Grysztar.
; All rights reserved.
;-------------------------------------------

iglobal
  cAsmEditClassName   text  'ASMEDIT'
  wheel_scroll_lines      dd  3             ; this is the number of lines to scroll with mouse wheel.
endg


uglobal
  case_table   rb 100h
endg

;-------------------------------------------
; Registers AsmEdit control class.
; Call only once in application.
;-------------------------------------------
initialize RegisterAsmEditClass

.ae WNDCLASS

begin
        mov     [.ae.style], CS_GLOBALCLASS + CS_DBLCLKS
        mov     [.ae.lpfnWndProc], AsmEdit
        mov     eax,[hInstance]
        mov     [.ae.hInstance],eax
        mov     [.ae.hbrBackground],0
        xor     eax,eax
        mov     [.ae.cbClsExtra],eax
        mov     [.ae.cbWndExtra], $10
        mov     [.ae.lpszMenuName],eax
        mov     [.ae.lpszClassName], cAsmEditClassName
        mov     [.ae.hIcon], eax
        mov     [.ae.hCursor],0         ; If Window procedure handles WM_SETCURSOR, this should be NULL
        lea     eax, [.ae]
        invoke  RegisterClass,eax
        or      eax,eax
        jz      .failed

        push    ebx esi edi

        mov     edi,case_table
        xor     ebx,ebx
        mov     esi,100h

    .make_case_table:
        invoke  CharLower,ebx
        stosb
        inc     bl
        dec     esi
        jnz     .make_case_table

        pop     edi esi ebx

        xor     eax,eax
        jmp     .finish

.failed:
        mov     eax,1
.finish:
        return
endp


;----------------------------------------------
; AsmEdit window proc
;----------------------------------------------
proc AsmEdit, .hwnd, .wmsg, .wparam, .lparam

  .editor_memory dd ?
  .editor_style dd ?

  .editor_data:

  .first_line dd ?
  .lines_count dd ?
  .caret_line dd ?
  .caret_position dd ?
  .caret_line_number dd ?
  .window_line dd ?
  .window_position dd ?
  .window_line_number dd ?
  .sel_line dd ?
  .sel_position dd ?
  .sel_line_number dd ?
  .editor_mode dd ?
  .line_to_draw dd ?
  .Modified  dd ?

  .editor_status_size = $ - .editor_data

  .editor_font dd ?
  .font_width dd ?
  .font_height dd ?
  .page_size dd ?
  .editor_screen dd ?
  .screen_width dd ?
  .screen_height dd ?
  .background_color dd ?
  .text_color dd ?
  .selection_background dd ?
  .selection_text dd ?
  .margin_background dd ?
  .margin_border dd ?
  .margin_width dd ?
  .margin_gap dd ?
  .focus_fg dd ?
  .focus_bg dd ?
  .syntax_proc dd ?
  .syntax_colors dd ?
  .unallocated_lines dd ?
  .unallocated_lines_end dd ?
  .memory_search_block dd ?
  .memory_search_line dd ?
  .undo_data dd ?
  .search_text dd ?
  .caret_x dd ?
  .caret_y dd ?
  .PopupMenu dd ?
  .read_only dd ?
  .focus_line dd ?

  .bookmark_count = 10
  .bookmarks rd .bookmark_count
  .bookmark_icon dd ?

  .current_operation db ?
  .last_operation db ?
  .mouse_select db ?
  .focus db ?

  .editor_data_size = $ - .editor_data

  .current_line dd ?
  .return_value dd ?
  .background_brush dd ?
  .selection_brush dd ?
  .margin_brush dd ?
  .marginb_brush dd ?
  .bookmark_brush dd ?
  .was_selection db ?
  .line_selection db ?
  .redraw_now db ?
  .notification db ?

; moved from global to local - 12.08.2003 johnfound
  .sc   SCROLLINFO
  .ps   PAINTSTRUCT
  .tm   TEXTMETRIC
  .rect RECT
  .rc   RECT
  .pt   POINT

  .char         rb 4
  .kbstate      rb 100h

  .line_colors  rb 100h
  .line_buffer  rb 100h
  .text_buffer  rb 100h
  .param_buffer rd 10h


begin
        push    ebx esi edi

        invoke  GetWindowLong, [.hwnd], GWL_STYLE
        mov     [.editor_style],eax
        cmp     [.wmsg], WM_CREATE
        je      .wmcreate
        cmp     [.wmsg], WM_GETDLGCODE
        je      .wmgetdlgcode
        invoke  GetWindowLong, [.hwnd], ofsAsmEditMemory
        or      eax,eax
        jz      .defwndproc
        mov     [.editor_memory],eax
        lea     esi,[eax+8]
        lea     edi,[.editor_data]
        mov     ecx,.editor_data_size shr 2
        rep     movsd
        mov     [.return_value],0
        mov     [.notification],0
        mov     [.redraw_now],0
        cmp     [.wmsg],WM_DESTROY
        je      .wmdestroy
        cmp     [.wmsg],WM_PAINT
        je      .wmpaint
        invoke  HideCaret,[.hwnd]
        cmp     [.wmsg],WM_HSCROLL
        je      .wmhscroll
        cmp     [.wmsg],WM_VSCROLL
        je      .wmvscroll
        cmp     [.wmsg],WM_SIZE
        je      .wmsize
        cmp     [.sel_line],0
        setnz   al
        mov     [.was_selection],al
        xor     al,al
        xchg    [.current_operation],al
        mov     [.last_operation],al
        mov     eax,[.wmsg]
        cmp     eax,WM_SETFOCUS
        je      .wmsetfocus
        cmp     eax,WM_KILLFOCUS
        je      .wmkillfocus
        cmp     eax,WM_LBUTTONDOWN
        je      .wmlbuttondown
        cmp     eax,WM_LBUTTONUP
        je      .wmlbuttonup
        cmp     eax,WM_RBUTTONDOWN
        je      .wmrbuttondown
        cmp     eax,WM_RBUTTONUP
        je      .wmrbuttonup
        cmp     eax,WM_MOUSEMOVE
        je      .wmmousemove
        cmp     eax,WM_LBUTTONDBLCLK
        je      .wmlbuttondblclk
        cmp     eax,WM_MOUSEWHEEL
        je      .wmmousewheel
        cmp     eax,WM_COPY
        je      .wmcopy

        cmp     eax,WM_SYSKEYDOWN
        je      .wmsyskeydown
        cmp     eax,WM_KEYDOWN
        je      .wmkeydown
        cmp     [.read_only],0
        jne     .dont_process               ; Added Tommy Lillehagen 31.01.2004
        cmp     eax,WM_CHAR
        je      .wmchar
        cmp     eax,WM_CUT
        je      .wmcut
        cmp     eax,WM_PASTE
        je      .wmpaste
        cmp     eax,WM_CLEAR
        je      .wmclear
        cmp     eax,WM_SETTEXT
        je      .wmsettext
        cmp     eax,WM_UNDO
        je      .wmundo
        cmp     eax,EM_UNDO
        je      .wmundo
        cmp     eax,EM_REPLACESEL
        je      .emreplacesel
        cmp     eax,AEM_COMMENT
        je      .aemcomment
        cmp     eax,AEM_INDENT
        je      .aemindent
    .dont_process:

        cmp     eax,WM_GETTEXTLENGTH
        je      .wmgettextlength
        cmp     eax,WM_GETTEXT
        je      .wmgettext
        cmp     eax,WM_SETFONT
        je      .wmsetfont
        cmp     eax,WM_GETFONT
        je      .wmgetfont
        cmp     eax,WM_CONTEXTMENU
        je      .wmrbuttonup
        cmp     eax,EM_CANUNDO
        je      .emcanundo
        cmp     eax,EM_EMPTYUNDOBUFFER
        je      .ememptyundobuffer
        cmp     eax,AEM_SETMODE
        je      .aemsetmode
        cmp     eax,AEM_GETMODE
        je      .aemgetmode
        cmp     eax, AEM_GETMODIFIED            ; John Found 25.11.2003
        je      .aemgetmodified
        cmp     eax, AEM_SETMODIFIED
        je      .aemsetmodified
        cmp     eax,AEM_SETSYNTAXHIGHLIGHT
        je      .aemsetsyntaxhighlight
        cmp     eax, AEM_GETLINEPTR
        je      .aemgetlineptr
        cmp     eax,AEM_GETLINEDATA
        je      .aemgetlinedata
        cmp     eax, AEM_SETLINEDATA
        je      .aemsetlinedata
        cmp     eax,AEM_SETPOS
        je      .aemsetpos
        cmp     eax,AEM_GETPOS
        je      .aemgetpos
        cmp     eax, AEM_GETCARETXY     ; Added john found 06.01.2004
        je      .amgetcaretxy
        cmp     eax,AEM_FINDFIRST
        je      .aemfindfirst
        cmp     eax,AEM_FINDNEXT
        je      .aemfindnext
        cmp     eax,AEM_CANFINDNEXT
        je      .aemcanfindnext
        cmp     eax,AEM_GETWORDATCARET
        je      .aemgetwordatcaret
        cmp     eax,AEM_SETTEXTCOLOR
        je      .aemsettextcolor
        cmp     eax,AEM_SETSELCOLOR
        je      .aemsetselcolor
        cmp     eax,AEM_SETPOPUPMENU
        je      .aemsetpopupmenu
        cmp     eax,AEM_SETMARGINCOLOR
        je      .aemsetmargincolor
        cmp     eax,AEM_SETMARGINWIDTH
        je      .aemsetmarginwidth
        cmp     eax,AEM_SETTHEME
        je      .aemsettheme
        cmp     eax,AEM_TOGGLEBOOKMARK
        je      .aemtogglebookmark
        cmp     eax,AEM_GOTOBOOKMARK
        je      .aemgotobookmark
        cmp     eax,AEM_CLEARBOOKMARKS
        je      .aemclearbookmarks
        cmp     eax,AEM_SETBOOKMARKICON
        je      .aemsetbookmarkicon
        cmp     eax,AEM_READONLY                ; Added Tommy Lillehagen 30.01.2004
        je      .aemreadonly
        cmp     eax,AEM_SETFOCUSLINE            ; Added Tommy Lillehagen 30.01.2004
        je      .aemsetfocusline

        invoke  ShowCaret,[.hwnd]

.defwndproc:
        invoke  DefWindowProc,[.hwnd],[.wmsg],[.wparam],[.lparam]
        jmp     .finish

.wmcreate:
        call    .init_editor_memory
        jc      .create_failed
        call    .init_editor_data
        invoke  SetWindowLong, [.hwnd], ofsAsmEditMemory, [.editor_memory]
        invoke  GetSysColor,COLOR_WINDOW
        mov     [.background_color],eax
        mov     [.margin_background],eax
        mov     [.margin_border],eax
        invoke  GetSysColor,COLOR_WINDOWTEXT
        mov     [.text_color],eax
        invoke  GetSysColor,COLOR_HIGHLIGHT
        mov     [.selection_background],eax
        mov     [.focus_bg],eax
        invoke  GetSysColor,COLOR_HIGHLIGHTTEXT
        mov     [.selection_text],eax
        mov     [.focus_fg],eax

        invoke  GetStockObject, SYSTEM_FIXED_FONT
        mov     [.editor_font], eax

        invoke  GetDC,[.hwnd]
        mov     ebx,eax
        invoke  SelectObject,ebx,[.editor_font]

        lea     eax, [.tm]
        invoke  GetTextMetrics,ebx,eax

        mov     eax,[.tm.tmHeight]
        test    eax, eax
        jnz     @f
        inc     eax
@@:
        mov     [.font_height],eax
        mov     eax,[.tm.tmAveCharWidth]
        test    eax, eax
        jnz     @f
        inc     eax
@@:
        mov     [.font_width],eax
        invoke  ReleaseDC,[.hwnd],ebx
        call    .update_positions
        call    .update_screen

        mov     [.PopupMenu], NULL
        mov     [.Modified], FALSE
        mov     [.bookmark_icon], NULL

        call    .clear_marks

        mov     [.margin_width],1
        mov     [.margin_gap],0
        mov     [.return_value],0
        mov     [.read_only],0
        mov     [.focus_line],0
        jmp     .done

    .create_failed:
        or      eax,-1
        jmp     .finish


;----------- WM_DESTROY --------------------

.wmdestroy:
        invoke  GlobalFree,[.editor_screen]
        call    .release_editor_memory
        invoke  SetWindowLong,[.hwnd], ofsAsmEditMemory, 0
        xor     eax,eax
        jmp     .finish

.wmgetdlgcode:
        mov     eax, DLGC_WANTCHARS or DLGC_WANTARROWS or DLGC_WANTTAB
        mov     ecx, [.lparam]
        test    ecx, ecx
        jz      .finish

        cmp     [ecx+MSG.message], WM_KEYDOWN
        jne     .finish

        cmp     [ecx+MSG.wParam], VK_RETURN
        jne     .finish

        or      eax, DLGC_WANTMESSAGE
        jmp     .finish

.wmpaint:
        lea     eax,[.rect]
        invoke  GetUpdateRect,[.hwnd],eax,FALSE
        or      eax,eax
        jz      .finish
        cmp     [.editor_screen],0
        je      .finish
        lea     eax, [.ps]
        invoke  BeginPaint,[.hwnd],eax
        mov     ebx,eax
        invoke  CreateSolidBrush,[.background_color]
        mov     [.background_brush],eax
        invoke  CreateSolidBrush,[.selection_background]
        mov     [.selection_brush],eax
        call    .paint_marks
        invoke  SelectObject,ebx,[.editor_font]
        mov     esi,[.editor_screen]
        mov     eax,[.screen_width]
        mul     [.screen_height]
        lea     edi,[esi+eax]
        mov     [.rect.top],0
        mov     eax,[.font_height]
        mov     [.rect.bottom],eax
        mov     ecx,[.screen_height]
        mov     eax,[.window_line_number]
        dec     eax
        mov     [.line_to_draw],eax
    .paint_screen:
        push    ecx
        inc     [.line_to_draw]
        mov     eax,[.margin_width]
        mov     [.rect.left],eax
        mov     ecx,[.screen_width]
    .paint_line:
        cmp     byte [esi],0
        je      .paint_empty_block
        mov     edx,1
        mov     al,[edi]
    .get_characters_block:
        cmp     edx,ecx
        je      .get_color
        cmp     al,[edi+edx]
        jne     .get_color
        cmp     byte [esi+edx],0
        je      .get_color
        inc     edx
        jmp     .get_characters_block
    .paint_empty_block:
        mov     edx,1
        test    byte [edi],80h
        jnz     .get_empty_selection
    .get_empty_block:
        cmp     edx,ecx
        je      .fill_empty_block
        cmp     byte [esi+edx],0
        jne     .fill_empty_block
        test    byte [edi+edx],80h
        jnz     .fill_empty_block
        inc     edx
        jmp     .get_empty_block
    .fill_empty_block:
        push    ecx edx
        mov     eax,[.font_width]
        mul     edx
        add     eax,[.rect.left]
        mov     [.rect.right],eax
        lea     eax, [.rect]
        invoke  FillRect,ebx,eax,[.background_brush]
        jmp     .paint_next_block
    .get_empty_selection:
        cmp     edx,ecx
        je      .fill_empty_selection
        cmp     byte [esi+edx],0
        jne     .fill_empty_selection
        test    byte [edi+edx],80h
        jz      .fill_empty_selection
        inc     edx
        jmp     .get_empty_selection
    .fill_empty_selection:
        push    ecx edx
        mov     eax,[.font_width]
        mul     edx
        add     eax,[.rect.left]
        mov     [.rect.right],eax
        lea     eax, [.rect]
        invoke  FillRect,ebx,eax,[.selection_brush]
        jmp     .paint_next_block
    .get_color:
        push    ecx edx
        mov     eax,[.focus_line]
        cmp     [.line_to_draw],eax
        je      .focusline_color
        test    byte [edi],80h
        jnz     .highlight_color
        invoke  SetBkColor,ebx,[.background_color]
        mov     al,[edi]
        or      al,al
        jnz     .syntax_color
    .default_color:
        invoke  SetTextColor,ebx,[.text_color]
        jmp     .color_ok
    .syntax_color:
        movzx   eax,al
        mov     edx,[.syntax_colors]
        or      edx,edx
        jz      .default_color
        mov     eax,[edx+(eax-1)*4]
        invoke  SetTextColor,ebx,eax
        jmp     .color_ok
    .highlight_color:
        invoke  SetBkColor,ebx,[.selection_background]
        invoke  SetTextColor,ebx,[.selection_text]
        jmp     .color_ok
    .focusline_color:
        invoke  SetBkColor,ebx,[.focus_bg]
        invoke  SetTextColor,ebx,[.focus_fg]
    .color_ok:
        mov     ecx,[esp]
        mov     eax,[.font_width]
        mul     ecx
        add     eax,[.rect.left]
        mov     [.rect.right],eax
        lea     eax, [.rect]
        invoke  DrawText,ebx,esi,ecx,eax,DT_LEFT+DT_NOPREFIX+DT_SINGLELINE
    .paint_next_block:
        pop     edx ecx
        sub     ecx,edx
        add     esi,edx
        add     edi,edx
        mov     eax,[.rect.right]
        mov     [.rect.left],eax
        or      ecx,ecx
        jnz     .paint_line
        mov     eax,[.font_height]
        add     [.rect.top],eax
        add     [.rect.bottom],eax
        pop     ecx
        dec     ecx
        jnz     .paint_screen
        invoke  DeleteObject,[.background_brush]
        invoke  DeleteObject,[.selection_brush]
        lea     eax, [.ps]
        invoke  EndPaint,[.hwnd],eax
        xor     eax,eax
        jmp     .finish

    .paint_bookmarks:
        pushad
        invoke  GetDC,[.hwnd]
        mov     ebx,eax
        invoke  CreateSolidBrush,[.background_color]
        mov     [.background_brush],eax
        lea     eax,[.rect]
        invoke  GetClientRect,[.hwnd],eax
        call    .paint_marks
        invoke  DeleteObject,[.background_brush]
        invoke  ReleaseDC,[.hwnd],ebx
        popad
        ret
    .paint_marks:
        push    [.rect.left] [.rect.right]
        cmp     [.margin_gap],0
        je      .fill_margin
        mov     eax,[.margin_width]
        sub     eax,[.margin_gap]
        mov     [.rect.right],eax
        invoke  CreateSolidBrush,[.margin_background]
        mov     [.margin_brush],eax
        lea     eax,[.rect]
        invoke  FillRect,ebx,eax,[.margin_brush]
        mov     eax,[.rect.right]
        mov     [.rect.left],eax
        invoke  DeleteObject,[.margin_brush]
        add     [.rect.right],1
        invoke  CreateSolidBrush,[.margin_border]
        mov     [.marginb_brush],eax
        lea     eax,[.rect]
        invoke  FillRect,ebx,eax,[.marginb_brush]
        mov     eax,[.rect.right]
        mov     [.rect.left],eax
        invoke  DeleteObject,[.marginb_brush]
        mov     eax,[.margin_gap]
        dec     eax
        add     [.rect.right],eax
      .fill_margin:
        lea     eax,[.rect]
        invoke  FillRect,ebx,eax,[.background_brush]
        pop     [.rect.right] [.rect.left]
        xor     eax,eax
        mov     [.rc.left],eax
        mov     eax,[.margin_width]
        sub     eax,[.margin_gap]
        mov     [.rc.right],eax
        cmp     [.margin_width],1
        jle     .no_marks
        mov     ecx,.bookmark_count
      .paint_next_mark:
        push    ecx
        mov     eax,4
        mul     ecx
        lea     edx,[.bookmarks-4]
        add     eax,edx
        cmp     dword [eax],0
        je      .paint_next_item
        mov     edx,dword [eax]
        mov     eax,edx
        sub     eax,[.window_line_number]
        inc     eax
        call    .mark_line
      .paint_next_item:
        pop     ecx
        loop    .paint_next_mark
      .no_marks:
        ret
      .mark_line:
        mov     ecx,[.font_height]
        mul     ecx
        sub     eax,[.font_height]
        mov     [.rc.top],eax
        mov     [.rc.left],1
        cmp     [.bookmark_icon],0
        je      .no_marks
        invoke  DrawIconEx,ebx,[.rc.left],[.rc.top],[.bookmark_icon],14,14,0,0,DI_NORMAL
        ret
.wmsetfocus:
        or      [.focus],-1
        call    .create_caret
        mov     [.notification],AEN_SETFOCUS
        cmp     [.was_selection],0
        je      .done
        jmp     .moved_window
.wmkillfocus:
        mov     [.focus],0
        invoke  DestroyCaret
        mov     [.notification],AEN_KILLFOCUS
        cmp     [.was_selection],0
        je      .done
        jmp     .moved_window
.wmhscroll:
        mov     [.sc.cbSize],sizeof.SCROLLINFO
        mov     [.sc.fMask],SIF_PAGE
        lea     eax, [.sc]
        invoke  GetScrollInfo,[.hwnd],SB_HORZ,eax
        movzx   eax,word [.wparam]
        cmp     eax,SB_LINEUP
        je      .hscroll_left
        cmp     eax,SB_LINEDOWN
        je      .hscroll_right
        cmp     eax,SB_THUMBTRACK
        je      .hscroll_pos
        cmp     eax,SB_PAGEUP
        je      .hscroll_wleft
        cmp     eax,SB_PAGEDOWN
        je      .hscroll_wright
    .hscroll_ignore:
        jmp     .done
    .hscroll_left:
        cmp     [.window_position],0
        je      .hscroll_ignore
        dec     [.window_position]
        jmp     .moved_window
    .hscroll_right:
        mov     eax,100h
        sub     eax,[.sc.nPage]
        cmp     [.window_position],eax
        jge     .hscroll_ignore
        inc     [.window_position]
        jmp     .moved_window
    .hscroll_pos:
        movzx   eax,word [.wparam+2]
        mov     [.window_position],eax
        jmp     .moved_window
    .hscroll_wleft:
        mov     eax,[.sc.nPage]
        sub     [.window_position],eax
        jnc     .moved_window
        mov     [.window_position],0
        jmp     .moved_window
    .hscroll_wright:
        mov     eax,[.sc.nPage]
        mov     ecx,100h
        sub     ecx,eax
        add     [.window_position],eax
        cmp     [.window_position],ecx
        jbe     .moved_window
        mov     [.window_position],ecx
        jmp     .moved_window
.wmvscroll:
        mov     [.sc.cbSize],sizeof.SCROLLINFO
        mov     [.sc.fMask],SIF_ALL
        lea     eax, [.sc]
        invoke  GetScrollInfo,[.hwnd],SB_VERT,eax
        movzx   eax,word [.wparam]
        cmp     eax,SB_LINEUP
        je      .vscroll_up
        cmp     eax,SB_LINEDOWN
        je      .vscroll_down
        cmp     eax,SB_THUMBTRACK
        je      .vscroll_pos
        cmp     eax,SB_PAGEUP
        je      .vscroll_pageup
        cmp     eax,SB_PAGEDOWN
        je      .vscroll_pagedown
    .vscroll_ignore:
        jmp     .done
    .vscroll_up:
        mov     esi,[.window_line]
        mov     esi,[esi+4]
        or      esi,esi
        jz      .vscroll_ignore
        dec     [.window_line_number]
        mov     [.window_line],esi
        jmp     .moved_window
    .vscroll_down:
        mov     eax,[.sc.nPos]
        add     eax,[.sc.nPage]
        cmp     eax,[.sc.nMax]
        ja      .vscroll_ignore
        mov     esi,[.window_line]
        mov     esi,[esi]
        or      esi,esi
        jz      .vscroll_ignore
        inc     [.window_line_number]
        mov     [.window_line],esi
        jmp     .moved_window
    .vscroll_pos:
        mov     eax,[.sc.nTrackPos]
        call    .find_line
        or      esi,esi
        jz      .vscroll_ignore
        mov     [.window_line],esi
        mov     [.window_line_number],ecx
        jmp     .moved_window
    .vscroll_pageup:
        mov     esi,[.window_line]
        mov     ecx,[.sc.nPage]
    .scroll_up:
        mov     eax,[esi+4]
        or      eax,eax
        jz      .scroll_ok
        dec     [.window_line_number]
        mov     esi,eax
        loop    .scroll_up
        jmp     .scroll_ok
    .vscroll_pagedown:
        mov     esi,[.window_line]
        mov     eax,[.sc.nPos]
        add     eax,[.sc.nPage]
        mov     ecx,[.sc.nMax]
        sub     ecx,eax
        inc     ecx
        cmp     ecx,[.sc.nPage]
        jbe     .scroll_down
        mov     ecx,[.sc.nPage]
    .scroll_down:
        mov     eax,[esi]
        or      eax,eax
        jz      .scroll_ok
        inc     [.window_line_number]
        mov     esi,eax
        loop    .scroll_down
    .scroll_ok:
        mov     [.window_line],esi
        jmp     .moved_window

.wmmousewheel:
        mov     esi,[.window_line]
        mov     eax,[.wparam]
        sar     eax,16
        cdq
        mov     ecx,120
        idiv    ecx
        imul    eax,[wheel_scroll_lines]
        mov     ecx,eax
        cmp     ecx,0
        jg      .scroll_up
        neg     ecx
        jnz     .scroll_down
        jmp     .done


;---------- WM_SIZE -------------------------------

.wmsize:
        cmp     [.editor_screen], 0
        je      @f
        invoke  GlobalFree,[.editor_screen]     ; sometimes [.editor_screen] is NULL here.
@@:
        call    .update_positions
        call    .update_screen
        lea     esi, [.rect]
        invoke  GetClientRect,[.hwnd],esi
        invoke  InvalidateRect,[.hwnd],esi,FALSE
        jmp     .done

;----------- WM_KEYDOWN ---------------------------

.wmkeydown:
        lea     eax, [.kbstate]
        invoke  GetKeyboardState, eax
        cmp     [.was_selection],0
        jne     .process_key
        mov     eax,[.caret_line]
        mov     [.sel_line],eax
        mov     eax,[.caret_position]
        mov     [.sel_position],eax
        mov     eax,[.caret_line_number]
        mov     [.sel_line_number],eax

    .process_key:
        mov     eax,[.wparam]
        cmp     eax,VK_LEFT
        je      .left
        cmp     eax,VK_RIGHT
        je      .right
        cmp     eax,VK_UP
        je      .up
        cmp     eax,VK_DOWN
        je      .down
        cmp     eax,VK_HOME
        je      .line_home
        cmp     eax,VK_END
        je      .line_end
        cmp     eax,VK_PGUP
        je      .pgup
        cmp     eax,VK_PGDN
        je      .pgdn

        cmp     [.read_only],0       ; read only => only navigation keys
        jne     .ignore

        cmp     eax,VK_BACK
        je      .back
        cmp     eax,VK_DELETE
        je      .del
        cmp     eax,VK_INSERT
        je      .insert
        cmp     eax,VK_F6
        je      .duplicate_line
        test    [.kbstate+VK_CONTROL],80h
        jz      .convert_to_ascii
        cmp     eax,'Y'
        je      .remove_line


    .convert_to_ascii:
        mov     ax,word [.lparam+2]
        and     eax,7Fh

        lea     ecx, [.kbstate]
        lea     edx, [.char]
        invoke  ToAscii, [.wparam], eax, ecx, edx, FALSE

        or      eax,eax
        jz      .ignore
        mov     al,[.char]
        cmp     al,20h
        jae     .put_char
        cmp     al,0Dh
        je      .put_char
        cmp     al,9
        je      .put_char
        jmp     .ignore
  .left:
        test    [.kbstate+VK_CONTROL],80h
        jnz     .word_left
        cmp     [.caret_position],0
        je      .ignore
        dec     [.caret_position]
        jmp     .moved_caret
  .right:
        test    [.kbstate+VK_CONTROL],80h
        jnz     .word_right
        cmp     [.caret_position],100h
        je      .ignore
        inc     [.caret_position]
        jmp     .moved_caret
  .up:
        mov     esi,[.caret_line]
        mov     eax,[esi+4]
        or      eax,eax
        jz      .ignore
        mov     [.caret_line],eax
        dec     [.caret_line_number]
        jmp     .moved_caret
  .down:
        mov     esi,[.caret_line]
        mov     eax,[esi]
        or      eax,eax
        jz      .ignore
        mov     [.caret_line],eax
        inc     [.caret_line_number]
        jmp     .moved_caret
  .line_home:
        test    [.kbstate+VK_CONTROL],80h
        jnz     .screen_home
        mov     [.caret_position],0
        jmp     .moved_caret
  .line_end:
        test    [.kbstate+VK_CONTROL],80h
        jnz     .screen_end
    .find_line_end:
        mov     edi,[.caret_line]
        add     edi,108h-1
        mov     al,20h
        mov     ecx,100h
        std
        repe    scasb
        setne   al
        movzx   eax,al
        add     ecx,eax
        cld
        mov     [.caret_position],ecx
        jmp     .moved_caret
  .screen_home:
        mov     eax,[.window_line]
        mov     [.caret_line],eax
        mov     eax,[.window_line_number]
        mov     [.caret_line_number],eax
        jmp     .moved_caret
  .screen_end:
        mov     eax,[.window_line_number]
        add     eax,[.page_size]
        dec     eax
        call    .find_line
        mov     [.caret_line],esi
        mov     [.caret_line_number],ecx
        jmp     .moved_caret
  .pgup:
        test    [.kbstate+VK_CONTROL],80h
        jnz     .text_home
        mov     eax,[.caret_line_number]
        mov     eax,[.caret_line_number]
        sub     eax,[.page_size]
        ja      .pgup_caret_ok
        mov     eax,1
    .pgup_caret_ok:
        call    .find_line
        mov     [.caret_line],esi
        mov     [.caret_line_number],ecx
        mov     eax,[.window_line_number]
        sub     eax,[.page_size]
        ja      .pgup_window_ok
        mov     eax,1
        cmp     [.window_line_number],eax
        je      .moved_caret
    .pgup_window_ok:
        call    .find_line
        mov     [.window_line],esi
        mov     [.window_line_number],ecx
        jmp     .moved_caret
  .pgdn:
        test    [.kbstate+VK_CONTROL],80h
        jnz     .text_end
        mov     eax,[.caret_line_number]
        mov     eax,[.caret_line_number]
        add     eax,[.page_size]
        call    .find_line
        mov     [.caret_line],esi
        mov     [.caret_line_number],ecx
        mov     eax,[.window_line_number]
        mov     ecx,[.page_size]
        add     eax,ecx
        mov     ebx,[.lines_count]
        sub     ebx,ecx
        jbe     .moved_caret
        inc     ebx
        cmp     eax,ebx
        jb      .pgdn_window_ok
        mov     eax,ebx
        cmp     [.window_line_number],eax
        je      .moved_caret
    .pgdn_window_ok:
        call    .find_line
        mov     [.window_line],esi
        mov     [.window_line_number],ecx
        jmp     .moved_caret
  .text_home:
        mov     eax,[.first_line]
        mov     [.caret_line],eax
        mov     [.caret_line_number],1
        jmp     .moved_caret
  .text_end:
        or      eax,-1
        call    .find_line
        mov     [.caret_line],esi
        mov     [.caret_line_number],ecx
        jmp     .moved_caret
  .word_left:
        mov     ecx,[.caret_position]
        mov     esi,[.caret_line]
        add     esi,8
    .find_left_word:
        sub     ecx,1
        jc      .word_line_up
        mov     al,[esi+ecx]
        call    .recognize_character
        jnc     .find_word_start
        jmp     .find_left_word
    .word_line_up:
        sub     esi,8
        mov     eax,[esi+4]
        or      eax,eax
        jz      .word_left_ok
        mov     [.caret_line],eax
        dec     [.caret_line_number]
        lea     esi,[eax+8]
        mov     ecx,100h
        jmp     .find_left_word
    .find_word_start:
        sub     ecx,1
        jc      .word_left_ok
        mov     al,[esi+ecx]
        call    .recognize_character
        jc      .word_left_ok
        jmp     .find_word_start
    .word_left_ok:
        inc     ecx
        mov     [.caret_position],ecx
        jmp     .moved_caret
  .word_right:
        mov     ecx,[.caret_position]
        mov     esi,[.caret_line]
        add     esi,8
        cmp     ecx,100h
        je      .word_line_down
    .find_word_end:
        add     ecx,1
        jc      .word_line_down
        mov     al,[esi+ecx]
        call    .recognize_character
        jc      .find_right_word
        jmp     .find_word_end
    .find_right_word:
        add     cl,1
        jc      .word_line_down
    .check_right_word:
        mov     al,[esi+ecx]
        call    .recognize_character
        jnc     .word_right_ok
        jmp     .find_right_word
    .word_line_down:
        mov     eax,[esi-8]
        or      eax,eax
        jz      .find_line_end
        mov     [.caret_line],eax
        inc     [.caret_line_number]
        lea     esi,[eax+8]
        xor     ecx,ecx
        jmp     .check_right_word
    .word_right_ok:
        mov     [.caret_position],ecx
        jmp     .moved_caret
  .insert:
        test    [.kbstate+VK_MENU],80h
        jnz     .switch_blocks
        test    [.kbstate+VK_CONTROL],80h
        jnz     .wmcopy
        test    [.kbstate+VK_SHIFT],80h
        jnz     .wmpaste
        xor     [.editor_mode],AEMODE_OVERWRITE
        mov     [.notification],AEN_MODECHANGE
        call    .create_caret
        cmp     [.was_selection],1
        je      .done
        mov     [.sel_line],0
        jmp     .done
  .del:
        test    [.kbstate+VK_CONTROL],80h
        jnz     .wmclear
        test    [.kbstate+VK_SHIFT],80h
        jnz     .wmcut
        cmp     [.was_selection],0
        je      .no_selection
        test    [.editor_style],AES_SECURESEL
        jz      .wmclear
    .no_selection:
        mov     edi,[.caret_line]
        mov     [.current_line],edi
        test    [.editor_mode],AEMODE_OVERWRITE
        jnz     .delete_char
        add     edi,108h-1
        mov     al,20h
        mov     ecx,100h
        std
        repe    scasb
        setne   al
        movzx   eax,al
        add     ecx,eax
        cld
        mov     edx,[.caret_position]
        cmp     edx,ecx
        jb      .delete_char
        mov     ecx,100h
        sub     ecx,edx
        mov     edi,[.caret_line]
        mov     esi,[edi]
        or      esi,esi
        jz      .ignore
        call    .store_status_for_undo
        call    .store_line_for_undo
        mov     [.current_line],esi
        call    .store_line_for_undo
        mov     ebx,[esi]
        mov     [edi],ebx
        or      ebx,ebx
        jz      .append_line
        mov     [.current_line],ebx
        call    .store_line_for_undo
        mov     [ebx+4],edi
    .append_line:
        or      dword [esi],-1
        dec     [.lines_count]
        lea     edi,[edi+8+edx]
        add     esi,8
        rep     movsb
        mov     [.sel_line],0
        jmp     .text_modified
    .delete_char:
        mov     [.current_operation],VK_DELETE
        cmp     [.last_operation],VK_DELETE
        je      .undo_delete_ok
        call    .store_status_for_undo
        call    .store_line_for_undo
    .undo_delete_ok:
        call    .delete_character
        mov     [.sel_line],0
        jmp     .text_modified
  .back:
        cmp     [.was_selection],0
        je      .no_selection_to_clear
        test    [.editor_style],AES_SECURESEL
        jz      .wmclear
    .no_selection_to_clear:
        mov     eax,[.caret_line]
        mov     [.current_line],eax
        cmp     [.caret_position],0
        je      .line_back
        test    [.kbstate+VK_CONTROL],80h
        jnz     .word_back
        mov     [.current_operation],VK_BACK
        cmp     [.last_operation],VK_BACK
        je      .undo_back_ok
        call    .store_status_for_undo
        call    .store_line_for_undo
    .undo_back_ok:
        dec     [.caret_position]
        call    .delete_character
        mov     [.sel_line],0
        jmp     .text_modified
    .word_back:
        call    .store_status_for_undo
        call    .store_line_for_undo
        mov     ecx,[.caret_position]
        mov     esi,[.caret_line]
        add     esi,8
    .skip_spaces:
        sub     ecx,1
        jc      .delete_word
        mov     al,[esi+ecx]
        cmp     al,20h
        je      .skip_spaces
        call    .recognize_character
        jnc     .find_word_to_delete_start
    .find_word_to_delete_end:
        sub     ecx,1
        jc      .delete_word
        mov     al,[esi+ecx]
        call    .recognize_character
        jnc     .delete_word
        jmp     .find_word_to_delete_end
    .find_word_to_delete_start:
        sub     ecx,1
        jc      .delete_word
        mov     al,[esi+ecx]
        call    .recognize_character
        jc      .delete_word
        jmp     .find_word_to_delete_start
    .delete_word:
        inc     ecx
        mov     eax,ecx
        lea     edi,[esi+eax]
        xchg    eax,[.caret_position]
        lea     esi,[esi+eax]
        mov     ecx,100h
        sub     ecx,eax
        rep     movsb
        mov     ecx,[.caret_line]
        add     ecx,108h
        sub     ecx,edi
        mov     al,20h
        rep     stosb
        jmp     .text_modified
    .line_back:
        test    [.editor_mode],AEMODE_OVERWRITE
        jnz     .ignore
        mov     esi,[.caret_line]
        mov     edi,[esi+4]
        or      edi,edi
        jz      .ignore
        call    .store_status_for_undo
        call    .store_line_for_undo
        mov     [.caret_line],edi
        dec     [.caret_line_number]
        mov     [.current_line],edi
        call    .store_line_for_undo
        mov     eax,[esi]
        mov     [edi],eax
        or      dword [esi],-1
        dec     [.lines_count]
        or      eax,eax
        jz      .line_removed
        mov     [.current_line],eax
        call    .store_line_for_undo
        mov     [eax+4],edi
    .line_removed:
        add     edi,108h-1
        mov     al,20h
        mov     ecx,100h
        std
        repe    scasb
        setne   al
        movzx   eax,al
        add     ecx,eax
        add     edi,eax
        cld
        inc     edi
        mov     [.caret_position],ecx
        sub     ecx,100h
        neg     ecx
        add     esi,8
        rep     movsb
        mov     [.sel_line],0
        jmp     .text_modified
  .put_char:
        mov     ebx,[.caret_line]
        mov     [.current_line],ebx
        cmp     al,0Dh
        je      .new_line
        cmp     al,9
        je      .tab
        cmp     [.was_selection],0
        je      .no_selection_to_replace
        call    .store_status_for_undo
        test    [.editor_style],AES_SECURESEL
        jnz     .put_new_char
        push    eax
        call    .delete_block
        pop     eax
        call    .insert_character
        jmp     .text_modified
    .no_selection_to_replace:
        mov     [.current_operation],VK_SPACE
        cmp     [.last_operation],VK_SPACE
        je      .undo_put_ok
        call    .store_status_for_undo
    .put_new_char:
        call    .store_line_for_undo
    .undo_put_ok:
        call    .insert_character
        mov     [.sel_line],0
        jmp     .text_modified
  .tab:
        call    .store_status_for_undo
        cmp     [.was_selection],0
        je      .tab_securesel
        test    [.editor_style],AES_SECURESEL
        jnz     .tab_securesel
        test    [.editor_style],AES_INDENTSEL
        jnz     .indent_text
        call    .delete_block
        call    .make_tab
        jmp     .text_modified
    .tab_securesel:
        call    .store_line_for_undo
        call    .make_tab
        mov     [.sel_line],0
        jmp     .text_modified
    .make_tab:
        test    [.editor_style],AES_SMARTTABS
        jz      .standard_tab
        mov     esi,[.current_line]
        mov     esi,[esi+4]
        or      esi,esi
        jz      .standard_tab
        mov     edx,[.caret_position]
        lea     edi,[esi+8+edx]
        mov     ecx,100h
        sub     ecx,edx
        jecxz   .standard_tab
        mov     al,20h
        repne   scasb
        jne     .standard_tab
        repe    scasb
        je      .standard_tab
        add     ecx,edx
        sub     ecx,100h-1
        neg     ecx
        jmp     .tab_spaces
    .standard_tab:
        mov     ecx,[.caret_position]
        and     ecx,not 111b
        sub     ecx,[.caret_position]
        add     ecx,8
    .tab_spaces:
        push    ecx
        mov     al,20h
        call    .insert_character
        pop     ecx
        loop    .tab_spaces
        ret
    .indent_text:
        pushad
        mov     [.caret_position],0
        mov     [.sel_position],100h
        mov     ecx,[.sel_line_number]
        sub     ecx,[.caret_line_number]
        cmp     ecx,0
        je      .text_modified
        cmp     ecx,0
        jg      .count_lines_ok
        neg     ecx
        push    ecx
      .goto_first_line:
        mov     esi,[.caret_line]
        test    esi, esi
        jz      @f
        mov     edi,[esi+4]
        mov     [.caret_line],edi
        loop    .goto_first_line
@@:
        mov     ebx,[.caret_line_number]
        mov     eax,[.sel_line_number]
        mov     [.sel_line_number],ebx
        mov     [.caret_line_number],eax
        pop     ecx
      .count_lines_ok:
        inc     ecx
        push    [.caret_line_number] [.caret_line] [.caret_position]
      .indent_loop:
        push    ecx
        xor     eax,eax
        mov     [.caret_position],0
        test    [.kbstate+VK_SHIFT],80h
        jz      .do_indent
        mov     esi,[.caret_line]
        add     esi,8
        cmp     byte [esi],20h
        jne     .ok_next
        inc     esi
        cmp     byte [esi],20h
        jne     .ok_next
        call    .delete_character
        call    .delete_character
        jmp     .ok_next
      .do_indent:
        mov     al,' '
        call    .insert_character
        mov     al,' '
        call    .insert_character
      .ok_next:
        inc     [.caret_line_number]
        mov     esi,[.caret_line]
        mov     edi,[esi]
        mov     [.caret_line],edi
        pop     ecx
        loop    .indent_loop
        pop     [.caret_position] [.caret_line] [.caret_line_number]
        popad
        jmp     .text_modified
  .new_line:
        call    .store_status_for_undo
        cmp     [.was_selection],0
        je      .new_line_securesel
        test    [.editor_style],AES_SECURESEL
        jnz     .new_line_securesel
        call    .delete_block
    .new_line_securesel:
        test    [.editor_mode],AEMODE_OVERWRITE
        jnz     .next_line
        call    .store_line_for_undo
        call    .allocate_line
        jc      .out_of_memory
        mov     edi,eax
        mov     [.current_line],eax
        call    .store_line_for_undo
        mov     esi,[.caret_line]
        mov     ebx,[esi]
        mov     [.current_line],ebx
        call    .store_line_for_undo
        mov     [edi],ebx
        mov     [edi+4],esi
        mov     [esi],edi
        or      ebx,ebx
        jz      .line_prepared
        mov     [ebx+4],edi
    .line_prepared:
        mov     [.caret_line],edi
        inc     [.caret_line_number]
        add     edi,8
        add     esi,8
        mov     edx,[.caret_position]
        mov     [.caret_position],0
        test    [.editor_style],AES_AUTOINDENT
        jz      .indent_ok
        push    edi
        mov     al,20h
        lea     edi,[esi+edx]
        mov     ecx,100h
        sub     ecx,edx
        repe    scasb
        je      .line_ok
        mov     edx,100h-1
        sub     edx,ecx
    .line_ok:
        mov     edi,esi
        mov     ecx,100h
        repe    scasb
        setne   al
        neg     ecx
        add     ecx,100h-1
        movzx   eax,al
        imul    ecx,eax
        pop     edi
        cmp     ecx,edx
        ja      .indent_ok
        mov     [.caret_position],ecx
    .indent_ok:
        mov     eax,20202020h
        mov     ecx,100h shr 2
        rep     stosd
        inc     [.lines_count]
        cmp     edx,100h
        je      .new_line_ok
        sub     edi,100h
        add     edi,[.caret_position]
        add     esi,edx
        cmp     edx,[.caret_position]
        jae     .position_ok
        mov     edx,[.caret_position]
    .position_ok:
        mov     ecx,100h
        sub     ecx,edx
    .move_data:
        movsb
        mov     byte [esi-1],20h
        loop    .move_data
        jmp     .new_line_ok
    .next_line:
        mov     esi,[.caret_line]
        mov     ebx,[esi]
        or      ebx,ebx
        jnz     .next_line_ok
        call    .store_line_for_undo
        call    .allocate_line
        jc      .out_of_memory
        mov     esi,[.caret_line]
        mov     ebx,eax
        mov     [.current_line],eax
        call    .store_line_for_undo
        mov     [esi],ebx
        mov     [ebx],dword 0
        mov     [ebx+4],esi
        lea     edi,[ebx+8]
        mov     eax,20202020h
        mov     ecx,100h shr 2
        rep     stosd
        inc     [.lines_count]
    .next_line_ok:
        mov     [.caret_line],ebx
        inc     [.caret_line_number]
        mov     [.caret_position],0
    .new_line_ok:
        mov     eax,[.caret_line]
        mov     [.current_line],eax
        call    .store_line_for_undo
        mov     [.sel_line],0
        jmp     .text_modified
  .remove_line:
        mov     esi,[.caret_line]
        mov     [.current_line],esi
        mov     ebx,[esi]
        or      ebx,ebx
        jz      .clear_line
        mov     [.caret_position],0
        call    .store_status_for_undo
        call    .store_line_for_undo
        cmp     esi,[.window_line]
        jne     .window_ok
        mov     [.window_line],ebx
    .window_ok:
        mov     edi,[esi+4]
        mov     [.caret_line],ebx
        mov     [.current_line],ebx
        call    .store_line_for_undo
        mov     [ebx+4],edi
        or      dword [esi],-1
        dec     [.lines_count]
        or      edi,edi
        jz      .removed_first
        mov     [.current_line],edi
        call    .store_line_for_undo
        mov     [edi],ebx
        mov     [.sel_line],0
        jmp     .text_modified
    .removed_first:
        mov     [.first_line],ebx
        mov     [.sel_line],0
        jmp     .text_modified
    .clear_line:
        lea     edi,[esi+8]
        mov     ecx,100h
        mov     al,20h
        repe    scasb
        je      .ignore
        mov     [.caret_position],0
        call    .store_status_for_undo
        call    .store_line_for_undo
        lea     edi,[esi+8]
        mov     eax,20202020h
        mov     ecx,100h shr 2
        rep     stosd
        mov     [.sel_line],0
        jmp     .text_modified
  .duplicate_line:
        mov     esi,[.caret_line]
        mov     [.current_line],esi
        call    .store_status_for_undo
        call    .store_line_for_undo
        call    .allocate_line
        jc      .out_of_memory
        mov     edi,eax
        mov     [.current_line],eax
        call    .store_line_for_undo
        mov     esi,[.caret_line]
        mov     ebx,[esi]
        mov     [.current_line],ebx
        call    .store_line_for_undo
        mov     [edi],ebx
        mov     [edi+4],esi
        mov     [esi],edi
        or      ebx,ebx
        jz      .line_ready
        mov     [ebx+4],edi
    .line_ready:
        add     esi,8
        add     edi,8
        mov     ecx,100h shr 2
        rep     movsd
        inc     [.lines_count]
        jmp     .text_modified
.wmsyskeydown:
        mov     eax,[.wparam]
        cmp     eax,VK_INSERT
        je      .switch_blocks
        cmp     [.read_only],0
        jne     .ignore
        cmp     eax,VK_BACK
        je      .wmundo
        mov     al,[.last_operation]
        mov     [.current_operation],al
        invoke  ShowCaret,[.hwnd]
        jmp     .defwndproc
  .switch_blocks:
        xor     [.editor_mode],AEMODE_VERTICALSEL
        mov     [.notification],AEN_MODECHANGE
        cmp     [.was_selection],0
        je      .ignore
        jmp     .moved_window

.wmchar:
        test    [.lparam],1 shl 31
        jz      .ignore

        mov     eax,[.wparam]
        jmp     .put_char


;-------- WM_LBUTTONDOWN -------------------

.wmlbuttondown:
        call    .update_mouse_cursor
        cmp     [.focus],0
        jne     .focus_ok
        invoke  SetFocus,[.hwnd]
        mov     esi,[.editor_memory]
        add     esi,8
        lea     edi,[.editor_data]
        mov     ecx,.editor_data_size shr 2
        rep     movsd
    .focus_ok:
        lea     eax,[.kbstate]
        invoke  GetKeyboardState,eax
        cmp     [.was_selection],0
        jne     .sel_ok
        mov     eax,[.caret_line]
        mov     [.sel_line],eax
        mov     eax,[.caret_position]
        mov     [.sel_position],eax
        mov     eax,[.caret_line_number]
        mov     [.sel_line_number],eax
    .sel_ok:
        call    .get_mouse_position
        invoke  SetCapture,[.hwnd]
        or      [.mouse_select],-1
        jmp     .moved_caret
    .get_mouse_position:
        mov     ax,word [.lparam]
        cwde
        sub     eax,[.margin_width]
        cdq
        idiv    [.font_width]
        add     eax,[.window_position]
        cmp     eax,0
        jl      .lowest_position
        cmp     eax,100h
        jg      .highest_position
        jmp     .click_position_ok
    .lowest_position:
        xor     eax,eax
        jmp     .click_position_ok
    .highest_position:
        mov     eax,100h
    .click_position_ok:
        mov     [.caret_position],eax
        mov     ax,word [.lparam+2]
        cwde
        cdq
        idiv    [.font_height]
        add     eax,[.window_line_number]
        cmp     eax,0
        jg      .click_line_ok
        mov     eax,1
    .click_line_ok:
        call    .find_line
        mov     [.caret_line],esi
        mov     [.caret_line_number],ecx
        ret
.wmlbuttonup:
        mov     [.mouse_select],0
        invoke  ReleaseCapture
        test    [.kbstate+VK_CONTROL],80h
        jz      .done
        mov     eax,[.lparam]
        and     eax,0FFFFh
        cmp     eax,[.margin_width]
        jge     .done
        mov     [.sel_position],100h
        mov     [.caret_position],0
        mov     eax,[.caret_line]
        mov     ebx,[.caret_line_number]
        mov     [.sel_line],eax
        mov     [.sel_line_number],ebx
        jmp     .moved_selection

.wmrbuttondown:
        cmp     [.was_selection],0
        jne     .ignore

        call    .get_mouse_position
        jmp    .moved_selection

.wmrbuttonup:
        cmp     [.PopupMenu],0
        je      .wmlbuttonup
        lea     eax,[.pt]
        invoke  GetCursorPos,eax
        invoke  GetParent,[.hwnd]
        invoke  TrackPopupMenu,[.PopupMenu],TPM_LEFTALIGN or TPM_RIGHTBUTTON ,[.pt.x],[.pt.y],0,eax,0
        jmp     .wmlbuttonup

.wmmousemove:
        call    .update_mouse_cursor
        cmp     [.mouse_select],0
        je      .ignore
        cmp     [.was_selection],0
        jne     .select
        mov     eax,[.caret_line]
        mov     ebx,[.caret_line_number]
        mov     [.sel_line],eax
        mov     [.sel_line_number],ebx
        mov     eax,[.caret_position]
        mov     [.sel_position],eax
    .select:
        call    .get_mouse_position
        jmp     .moved_selection

.update_mouse_cursor:
        mov     eax,[.lparam]
        and     eax,0FFFFh
        cmp     eax,[.margin_width]
        jge     .cursor_normal
        invoke  LoadCursor,0,IDC_ARROW
        invoke  SetCursor,eax
        jmp     .cursor_ok
      .cursor_normal:
        invoke  LoadCursor,0,IDC_IBEAM
        invoke  SetCursor,eax
      .cursor_ok:
        ret

.wmlbuttondblclk:
        mov     [.mouse_select],0
        call    .get_mouse_position
        call    .get_word_edges
        mov     [.sel_position],edx
        mov     [.caret_position],ecx
        mov     eax,[.caret_line]
        mov     ebx,[.caret_line_number]
        mov     [.sel_line],eax
        mov     [.sel_line_number],ebx
        jmp     .moved_selection
.wmcopy:
        cmp     [.was_selection],0
        je      .ignore
        call    .copy_to_clipboard
        jmp     .ignore
    .copy_to_clipboard:
        call    .get_block_size
        invoke  GlobalAlloc,GMEM_MOVEABLE+GMEM_DDESHARE,ecx
        mov     ebx,eax
        invoke  GlobalLock,ebx
        mov     edi,eax
        push    ebx
        call    .copy_block
        pop     ebx
        invoke  GlobalUnlock,ebx
        invoke  OpenClipboard,[.hwnd]
        invoke  EmptyClipboard
        invoke  SetClipboardData,CF_TEXT,ebx
        or      eax,eax
        jz      .copy_failed
        invoke  CloseClipboard
        ret
    .copy_failed:
        invoke  GlobalFree,ebx
        ret
.wmcut:
        cmp     [.was_selection],0
        je      .ignore
        call    .copy_to_clipboard
.wmclear:
        cmp     [.was_selection],0
        je      .ignore
        call    .store_status_for_undo
        call    .delete_block
        mov     [.sel_line],0
        jmp     .text_modified

;------- WM_PASTE -------------------------

.wmpaste:
        invoke  OpenClipboard,NULL
        invoke  GetClipboardData,CF_TEXT
        or      eax,eax
        jz      .close_clipboard
        mov     ebx,eax
        invoke  GlobalLock,ebx
        mov     esi,eax
        push    ebx
        call    .store_status_for_undo
        call    .get_selection_start_position
        cmp     [.was_selection],0
        je      .do_paste
        test    [.editor_style],AES_SECURESEL
        jnz     .do_paste
        push    esi
        call    .delete_block
        pop     esi
    .do_paste:
        call    .insert_block
        pop     ebx
        jc      .close_clipboard
        invoke  GlobalUnlock,ebx
        invoke  CloseClipboard
        test    [.editor_style],AES_SECURESEL
        jnz     .text_modified
        mov     eax,[.sel_line]
        mov     ebx,[.sel_position]
        mov     ecx,[.sel_line_number]
        mov     [.caret_line],eax
        mov     [.caret_position],ebx
        mov     [.caret_line_number],ecx
        mov     [.sel_line],0
        jmp     .text_modified
    .close_clipboard:
        invoke  CloseClipboard
        jmp     .ignore
    .get_selection_start_position:
        mov     eax,[.sel_line_number]
        mov     ebx,[.sel_position]
        cmp     [.was_selection],0
        je      .new_position_ok
        cmp     eax,[.caret_line_number]
        ja      .new_position_ok
        jb      .update_position
        cmp     ebx,[.caret_position]
        ja      .new_position_ok
    .update_position:
        xchg    eax,[.caret_line_number]
        xchg    ebx,[.caret_position]
        push    eax ebx
        call    .update_positions
        pop     [.caret_position] [.caret_line_number]
    .new_position_ok:
        ret

;------- WM_SETTEXT -----------------------

.wmsettext:
        call    .reset_editor_memory
        call    .allocate_line
        mov     [.first_line],eax
        mov     [.lines_count],1
        mov     [.caret_line],eax
        mov     [.caret_line_number],1
        mov     [.window_line],eax
        mov     [.window_line_number],1
        mov     edi,eax
        xor     eax,eax
        stosd
        stosd
        mov     eax,20202020h
        mov     ecx,100h shr 2
        rep     stosd
        mov     [.caret_position],0
        mov     [.window_position],0
        mov     [.sel_line],0
        mov     esi,[.lparam]
        or      esi,esi
        jz      .text_modified
        mov     ebx,[.first_line]
        lea     edi,[ebx+8]
        mov     ecx,100h
    .copy_line:
        lodsb
        or      al,al
        jz      .text_modified
        cmp     al,0Ah
        je      .copy_lf
        cmp     al,0Dh
        je      .copy_cr
        cmp     al,9
        je      .copy_tab
        stosb
        loop    .copy_line
    .skip_overlap:
        lodsb
        or      al,al
        jz      .text_modified
        cmp     al,0Ah
        je      .copy_lf
        cmp     al,0Dh
        je      .copy_cr
        jmp     .skip_overlap
    .copy_tab:
        mov     edx,ecx
        and     ecx,111b
        setz    al
        shl     al,3
        or      cl,al
        sub     edx,ecx
        jc      .skip_overlap
        mov     al,20h
        rep     stosb
        mov     ecx,edx
        jmp     .copy_line
    .copy_lf:
        cmp     byte [esi],0Dh
        jne     .copy_new_line
        inc     esi
        jmp     .copy_new_line
    .copy_cr:
        cmp     byte [esi],0Ah
        jne     .copy_new_line
        inc     esi
    .copy_new_line:
        push    ebx esi
        call    .allocate_line
        jc      .out_of_memory
        pop     esi ebx
        mov     edi,eax
        mov     edx,[ebx]
        mov     [edi],edx
        mov     [edi+4],ebx
        mov     [ebx],edi
        mov     ebx,edi
        add     edi,8
        mov     eax,20202020h
        mov     ecx,100h shr 2
        rep     stosd
        inc     [.lines_count]
        or      edx,edx
        jz      .do_copy
        mov     [edx+4],ebx
    .do_copy:
        mov     ecx,100h
        lea     edi,[ebx+8]
        jmp     .copy_line


.wmgettextlength:
        mov     esi,[.first_line]
        xor     edx,edx
    .get_line_length:
        lea     edi,[esi+8+100h-1]
        mov     ecx,100h
        mov     al,20h
        std
        repe    scasb
        cld
        setne   al
        movzx   eax,al
        add     edx,ecx
        add     edx,eax
        add     edx,2
        mov     esi,[esi]
        or      esi,esi
        jnz     .get_line_length
        sub     edx,2
        mov     [.return_value],edx
        jmp     .ignore


;---------- WM_GETTEXT ------------------------

.wmgettext:
        mov     edi,[.lparam]
        mov     ebx,[.first_line]
        mov     edx,[.wparam]
        sub     edx,1
        jc      .ignore
    .get_line:
        push    edi
        lea     edi,[ebx+8+100h-1]
        mov     ecx,100h
        mov     al,20h
        std
        repe    scasb
        cld
        setne   al
        movzx   eax,al
        add     ecx,eax
        pop     edi
        lea     esi,[ebx+8]
        test    [.editor_style],AES_OPTIMALFILL
        jz      .copy_data

        push    ecx edx edi
        lea     edi,[.line_colors]
        mov     ecx,100h shr 2
        xor     eax,eax
        rep     stosd
        lea     edi, [.line_colors]
        invoke  .syntax_proc, esi, edi
        pop     edi edx ecx

    .optimal_fill:
        cmp     ecx,8
        jbe     .copy_data
        push    ecx edi
        lea     edi,[esi+7]
        lea     eax,[.line_colors+edi-8]
        sub     eax,ebx
        mov     ecx,8

    .count_spaces:
        cmp     byte [edi],20h
        jne     .spaces_counted
        cmp     byte [eax],0
        jne     .spaces_counted
        dec     edi
        dec     eax
        loop    .count_spaces
    .spaces_counted:
        pop     edi eax
        cmp     ecx,7
        jb      .put_tab
        mov     ecx,8
        sub     edx,ecx
        jc      .cut_overlap
        rep     movsb
        mov     ecx,eax
        sub     ecx,8
        jmp     .optimal_fill
    .put_tab:
        sub     edx,ecx
        jc      .cut_overlap
        push    esi
        rep     movsb
        pop     esi
        add     esi,8
        or      edx,edx
        jz      .end_text
        dec     edx
        mov     ecx,eax
        sub     ecx,8
        mov     al,9
        stosb
        jmp     .optimal_fill
    .copy_data:
        sub     edx,ecx
        jc      .cut_overlap
        rep     movsb
        mov     ebx,[ebx]
        or      ebx,ebx
        jz      .end_text
        sub     edx,2
        jc      .end_text
        mov     ax,0A0Dh
        stosw
        jmp     .get_line
    .cut_overlap:
        neg     edx
        sub     ecx,edx
        rep     movsb
    .end_text:
        xor     al,al
        stosb
        mov     eax,edi
        dec     eax
        sub     eax,[.lparam]
        mov     [.return_value],eax
        jmp     .ignore

;--------- WM_SETFONT ---------------------

.wmsetfont:
        mov     esi,[.wparam]
        or      esi,esi
        jnz     .get_metrics

        invoke  GetStockObject, SYSTEM_FIXED_FONT
        mov     esi, eax

    .get_metrics:
        invoke  GetDC,[.hwnd]
        mov     ebx,eax
        invoke  SelectObject,ebx,esi

        lea     eax, [.tm]
        invoke  GetTextMetrics,ebx,eax

        invoke  ReleaseDC,[.hwnd],ebx

        test    [.tm.tmPitchAndFamily],TMPF_FIXED_PITCH
        jnz     .ignore

        mov     [.return_value],esi
        mov     [.editor_font],esi
        mov     eax,[.tm.tmHeight]
        test    eax, eax
        jnz     @f
        inc     eax
@@:
        mov     [.font_height],eax

        mov     eax,[.tm.tmAveCharWidth]
        test    eax, eax
        jnz     @f
        inc     eax
@@:
        mov     [.font_width],eax
        call    .create_caret
        mov     eax,[.lparam]
        mov     [.redraw_now],al
        jmp     .wmsize


;----------- WM_GETFONT ----------------------

.wmgetfont:
        mov     eax,[.editor_font]
        mov     [.return_value],eax
        jmp     .ignore


;------------ WM_UNDO ------------------------
.wmundo:
        cmp     [.undo_data],0
        je      .ignore
        call    .undo
        mov     [.last_operation],0
        call    .create_caret
        jmp     .text_modified

.emcanundo:
        mov     eax,[.undo_data]
        or      eax,eax
        jz      .ignore
        mov     [.return_value],TRUE
        jmp     .ignore

.ememptyundobuffer:
        call    .clear_undo_data
        jmp     .ignore

.emreplacesel:
        test    [.editor_mode],AEMODE_VERTICALSEL
        jnz     .ignore
        push    [.editor_mode]
        and     [.editor_mode],not AEMODE_OVERWRITE
        push    [.caret_line] [.caret_position]
        cmp     [.wparam],0
        je      .status_ok
        call    .store_status_for_undo

    .status_ok:
        call    .get_selection_start_position
        cmp     [.was_selection],0
        je      .ready_for_replace
        call    .delete_block
        mov     [.sel_line],0

    .ready_for_replace:
        mov     esi,[.lparam]
        call    .insert_block
        mov     [.notification],AEN_TEXTCHANGE
        pop     eax esi
        pop     [.editor_mode]
        sub     esi,[.caret_line]
        sub     eax,[.caret_position]
        or      eax,esi
        jz      .text_modified
        mov     eax,[.sel_line]
        xchg    eax,[.caret_line]
        mov     [.sel_line],eax
        mov     eax,[.sel_line_number]
        xchg    eax,[.caret_line_number]
        mov     [.sel_line_number],eax
        mov     eax,[.sel_position]
        xchg    eax,[.caret_position]
        mov     [.sel_position],eax
        jmp     .text_modified

.aemsetmode:
        mov     eax,[.wparam]
        xchg    [.editor_mode],eax
        cmp     eax,[.editor_mode]
        je      .ignore
        mov     [.notification],AEN_MODECHANGE
        call    .create_caret
        cmp     [.was_selection],0
        jne     .moved_window
        jmp     .done

.aemgetmode:
        mov     eax,[.editor_mode]
        mov     [.return_value],eax
        jmp     .ignore

; John Found - 25.11.2003
.aemgetmodified:
        mov     eax, [.Modified]
        mov     [.return_value], eax
        jmp     .ignore

.aemsetmodified:
        mov     eax, [.wparam]
        xchg    eax, [.Modified]
        mov     [.return_value], eax
        mov     [.notification],AEN_TEXTCHANGE
        jmp     .ignore

.aemsetsyntaxhighlight:
        mov     eax,[.wparam]
        mov     ebx,[.lparam]
        cmp     eax,0
        je      .no_new_colors
        mov     [.syntax_colors],eax
      .no_new_colors:
        mov     [.syntax_proc],ebx
      .syntax_proc_ok:
        or      ebx,ebx
        jnz     .wmsize
        mov     [.syntax_proc],SyntaxProc
        jmp     .wmsize


.aemsettextcolor:
        mov     eax,[.wparam]
        mov     ebx,[.lparam]
        mov     [.text_color],eax
        mov     [.background_color],ebx
        jmp     .wmsize


.aemsetselcolor:
        mov     eax,[.wparam]
        mov     ebx,[.lparam]
        mov     [.selection_text],eax
        mov     [.selection_background],ebx
        jmp     .wmsize


.aemsetmargincolor:
        mov     eax,[.wparam]
        mov     ebx,[.lparam]
        mov     [.margin_background],eax
        mov     [.margin_border],ebx
        jmp     .wmsize


.aemsetmarginwidth:
        mov     eax,[.wparam]
        mov     ebx,[.lparam]
        mov     [.margin_gap],eax
        mov     [.margin_width],ebx
        jmp     .wmsize


.aemsetpopupmenu:
        mov     eax, [.lparam]
        mov     [.PopupMenu],eax
        jmp     .ignore


.aemsettheme:
        mov     ebx,[.lparam]
        mov     eax,[ebx]
        mov     [.text_color],eax
        add     ebx,4
        mov     eax,[ebx]
        mov     [.background_color],eax
        add     ebx,4
        mov     eax,[ebx]
        mov     [.selection_text],eax
        add     ebx,4
        mov     eax,[ebx]
        mov     [.selection_background],eax
        add     ebx,4
        mov     eax,[ebx]
        mov     [.margin_background],eax
        add     ebx,4
        mov     eax,[ebx]
        mov     [.margin_border],eax
        add     ebx,4
        mov     eax,[ebx]
        mov     [.margin_width],eax
        add     ebx,4
        mov     eax,[ebx]
        mov     [.margin_gap],eax
        add     ebx,4
        mov     eax,[ebx]
        mov     [.focus_fg],eax
        add     ebx,4
        mov     eax,[ebx]
        mov     [.focus_bg],eax
        add     ebx,4
        mov     eax,[ebx]
        mov     [.syntax_proc],eax
        or      eax,eax
        jnz     .syn_colors
        mov     [.syntax_proc],SyntaxProc
      .syn_colors:
        add     ebx,4
        mov     [.syntax_colors],ebx
        jmp     .wmsize


;----------------------------------------------------

.aemtogglebookmark:
       mov     ecx, .bookmark_count
       mov     edx,[.caret_line_number]
       xor     eax,eax

  .loop_exists:
       cmp     [.bookmarks + 4*ecx - 4],edx
       je      .done_toggle
       loop    .loop_exists

       mov     ecx,.bookmark_count
       xchg    edx,eax

  .check_next_mark:
        cmp     dword [.bookmarks + 4*ecx - 4], edx
        je      .done_toggle
        loop    .check_next_mark

        jmp     .wmsize

  .done_toggle:
        mov     dword [.bookmarks + 4*ecx - 4], eax
        mov     [.return_value],ecx
        jmp     .wmsize


;--------------------------------------------------

.aemgotobookmark:
        mov     eax,[.lparam]
        cmp     eax,AEBM_NEXT
        je      .aemnextbookmark
        cmp     eax,AEBM_PREV
        je      .aemprevbookmark
        mov     eax,[.wparam]
        mov     ecx,4
        mul     ecx
        lea     edx,[.bookmarks-4]
        add     eax,edx
        mov     ecx,dword [eax]
        mov     [.return_value],ecx
        jmp     .ignore
.aemnextbookmark:
        mov     ecx,.bookmark_count
      .loop_next:
        push    ecx
        mov     eax,4
        mul     ecx
        lea     edx,[.bookmarks-4]
        add     eax,edx
        mov     ecx,[.caret_line_number]
        cmp     dword [eax],ecx
        jle     .loop_check_next
        mov     ecx,[.return_value]
        cmp     ecx,0
        je      .set_next_value
        cmp     ecx,dword [eax]
        jl      .loop_check_next
      .set_next_value:
        mov     ecx,dword [eax]
        mov     [.return_value],ecx
      .loop_check_next:
        pop     ecx
        loop    .loop_next
        jmp     .ignore
.aemprevbookmark:
        mov     ecx,.bookmark_count
      .loop_prev:
        push    ecx
        mov     eax,4
        mul     ecx
        lea     edx,[.bookmarks-4]
        add     eax,edx
        mov     ecx,[.caret_line_number]
        cmp     dword [eax],ecx
        jge     .loop_check_prev
        mov     ecx,[.return_value]
        cmp     ecx,0
        je      .set_prev_value
        cmp     ecx,dword [eax]
        jg      .loop_check_prev
      .set_prev_value:
        mov     ecx,dword [eax]
        mov     [.return_value],ecx
      .loop_check_prev:
        pop     ecx
        loop    .loop_prev
        jmp     .ignore
.aemclearbookmarks:
        call    .clear_marks
        jmp     .wmsize
      .clear_marks:
        mov     ecx,.bookmark_count
      .clear_next_mark:
        push    ecx
        mov     eax,4
        mul     ecx
        lea     edx, [.bookmarks-4]
        add     eax, edx
        mov     dword [eax],0
        pop     ecx
        loop    .clear_next_mark
        ret
.aemsetbookmarkicon:
        mov     eax,[.wparam]
        mov     [.bookmark_icon],eax
        jmp     .wmsize
.aemcomment:
        mov     [.caret_position],0
        mov     [.sel_position],100h
        mov     ecx,[.sel_line_number]
        sub     ecx,[.caret_line_number]
        cmp     ecx,0
        je      .text_modified
        cmp     ecx,0
        jg      .count_lines
        neg     ecx
        push    ecx
      .goto_first:
        mov     esi,[.caret_line]
        mov     edi,[esi+4]
        mov     [.caret_line],edi
        loop    .goto_first
        mov     ebx,[.caret_line_number]
        mov     eax,[.sel_line_number]
        mov     [.sel_line_number],ebx
        mov     [.caret_line_number],eax
        pop     ecx
      .count_lines:
        inc     ecx
        push    [.caret_line_number] [.caret_line] [.caret_position]
      .comment_loop:
        push    ecx
        xor     eax,eax
        mov     [.caret_position],0
        cmp     [.lparam],1
        je      .do_comment
        mov     esi,[.caret_line]
        add     esi,8
      .check_for_blank:
        cmp     byte [esi],' '
        je      .inc_pos
        cmp     byte [esi],';'
        jne     .next_line_comment
        call    .delete_character
        jmp     .next_line_comment
      .inc_pos:
        inc     esi
        inc     [.caret_position]
        jmp     .check_for_blank
      .do_comment:
        mov     al,';'
        call    .insert_character
      .next_line_comment:
        inc     [.caret_line_number]
        mov     esi,[.caret_line]
        mov     edi,[esi]
        mov     [.caret_line],edi
        pop     ecx
        loop    .comment_loop
        pop     [.caret_position] [.caret_line] [.caret_line_number]
        jmp     .text_modified

.aemindent:
        cmp     [.lparam],1
        je      .not_outdent
        mov     [.kbstate+VK_SHIFT],80h
        jmp     .do_aemindent
      .not_outdent:
        mov     [.kbstate+VK_SHIFT],0
      .do_aemindent:
        jmp     .indent_text

.aemreadonly: ; Added Tommy Lillehagen 30.01.2004
        mov     eax,[.wparam]
        mov     [.read_only],eax
        mov     [.return_value],eax
        jmp     .ignore

.aemsetfocusline: ; Added Tommy Lillehagen 30.01.2004
        mov     eax,[.wparam]
        mov     [.focus_line],eax
        test    eax,eax
        jz      .wmsize
        sub     eax,[.window_line_number]
        inc     eax
        jz      .setfocusline_updatepos
        js      .setfocusline_updatepos
        cmp     eax,[.screen_height]
        jl      .refresh

    .setfocusline_updatepos:
        mov     eax,[.wparam]
        mov     ecx,[.screen_height]
        shr     ecx,1
        sub     eax,ecx
        jz      .setfocusline_notok
        jns     .setfocusline_ok

    .setfocusline_notok:
        xor     eax,eax
        inc     eax

    .setfocusline_ok:
        call    .find_line
        mov     [.window_line],esi
        mov     [.window_line_number],ecx
        jmp     .moved_window

.aemgetlineptr:
        mov     esi,[.caret_line]
        mov     eax,[.wparam]
        or      eax,eax
        jz      .line_ptr_ok
        call    .find_line
        cmp     ecx,[.wparam]
        jne     .ignore
    .line_ptr_ok:
        mov     [.return_value],esi
        jmp     .ignore


.aemgetlinedata:
        mov     esi,[.caret_line]
        mov     eax,[.wparam]
        or      eax,eax
        jz      .line_data_ok
        call    .find_line
        cmp     ecx,[.wparam]
        jne     .ignore
    .line_data_ok:
        add     esi,8
        mov     edi,[.lparam]
        mov     ecx,100h shr 2
        rep     movsd
        mov     [.return_value],100h
        jmp     .ignore

.aemsetlinedata:        ; Sets only the text of the line, not the pointers.
        mov     esi,[.caret_line]
        mov     eax,[.wparam]
        or      eax,eax
        jz      .setline_data_ok
        call    .find_line
        cmp     ecx,[.wparam]
        jne     .ignore
    .setline_data_ok:
        add     esi,8
        mov     edi,[.lparam]
        xchg    esi, edi
        mov     ecx,100h shr 2
        rep     movsd
        mov     [.return_value],100h
        jmp     .ignore

.aemsetpos:
        mov     edi,[.wparam]
        virtual at edi
        .aepos  AEPOS
        end     virtual
        cmp     [.sel_line],0
        jne     .sel_start_ok
        mov     eax,[.caret_line]
        mov     [.sel_line],eax
        mov     eax,[.caret_line_number]
        mov     [.sel_line_number],eax
        mov     eax,[.caret_position]
        mov     [.sel_position],eax
    .sel_start_ok:
        mov     eax,[.aepos.selectionLine]
        or      eax,eax
        jz      .sel_line_ok
        call    .find_line
        mov     [.sel_line],esi
        mov     [.sel_line_number],ecx
    .sel_line_ok:
        mov     eax,[.aepos.selectionPosition]
        or      eax,eax
        jz      .sel_position_ok
        dec     eax
        mov     [.sel_position],eax
        cmp     eax,100h
        jbe     .sel_position_ok
        mov     [.sel_position],100h
    .sel_position_ok:
        mov     eax,[.aepos.caretLine]
        or      eax,eax
        jz      .caret_line_ok
        call    .find_line
        mov     [.caret_line],esi
        mov     [.caret_line_number],ecx
    .caret_line_ok:
        mov     eax,[.aepos.caretPosition]
        or      eax,eax
        jz      .caret_position_ok
        dec     eax
        cmp     eax,100h
        jbe     .caret_position_ok
        mov     eax,100h
    .caret_position_ok:
        mov     [.caret_position],eax
        cmp     esi,[.sel_line]
        jne     .moved_selection
        cmp     eax,[.sel_position]
        jne     .moved_selection
        mov     [.sel_line],0
        jmp     .moved_selection

.aemgetpos:
        mov     edi,[.wparam]
        mov     eax,[.caret_line_number]
        mov     [.aepos.selectionLine],eax
        mov     [.aepos.caretLine],eax
        mov     eax,[.caret_position]
        inc     eax
        mov     [.aepos.selectionPosition],eax
        mov     [.aepos.caretPosition],eax
        cmp     [.sel_line],0
        je      .ignore
        mov     eax,[.sel_line_number]
        mov     [.aepos.selectionLine],eax
        mov     eax,[.sel_position]
        inc     eax
        mov     [.aepos.selectionPosition],eax
        jmp     .ignore

.amgetcaretxy:
        mov     ecx, [.wparam]

        mov     eax,[.caret_y]
        mov     ebx,[.caret_x]
        add     ebx,[.margin_width]

        mov     [ecx+AECARETXY.x0], ebx
        mov     [ecx+AECARETXY.x1], ebx
        mov     [ecx+AECARETXY.y0], eax

        add     eax, [.font_height]
        mov     [ecx+AECARETXY.y1], eax
        jmp     .ignore

.aemfindfirst:
        mov     eax,[.search_text]
        or      eax,eax
        jnz     .buffer_ok
        call    .allocate_line
        jc      .out_of_memory
    .buffer_ok:
        mov     esi,[.lparam]
        mov     edi,eax
        mov     eax,[.wparam]
        push    edi
        stosd
        stosd
        mov     edx,eax
        mov     ebx,case_table
        mov     ecx,100h
        lodsb
    .copy_text:
        test    edx,AEFIND_CASESENSITIVE
        jnz     .text_case_ok
        xlatb
    .text_case_ok:
        stosb
        lodsb
        or      al,al
        loopnz  .copy_text
        pop     edi
        jnz     .ignore
        neg     ecx
        add     ecx,100h
        mov     [edi+4],ecx
        mov     [.search_text],edi
.aemfindnext:
        mov     esi,[.search_text]
        or      esi,esi
        jz      .ignore
        cmp     dword [esi+4],0
        je      .ignore
        mov     edi,[.caret_line]
        mov     ecx,[.caret_line_number]
        mov     edx,[.caret_position]
        test    byte [esi],AEFIND_BACKWARD
        jnz     .search_backward
    .do_search:
        push    ecx
        call    .find_text
        pop     ecx
        jnc     .text_found
        inc     ecx
        xor     edx,edx
        mov     edi,[edi]
        or      edi,edi
        jnz     .do_search
        jmp     .search_done
    .text_found:
        mov     [.caret_line],edi
        mov     [.sel_line],edi
        mov     [.caret_line_number],ecx
        mov     [.sel_line_number],ecx
        mov     [.caret_position],eax
        mov     esi,[.search_text]
        add     eax,[esi+4]
        mov     [.sel_position],eax
        call    .update_positions
        call    .let_caret_appear
        mov     eax,[.caret_position]
        xchg    eax,[.sel_position]
        mov     [.caret_position],eax
        mov     [.return_value],TRUE
        jmp     .moved_selection
    .backward_found:
        mov     [.caret_line],edi
        mov     [.sel_line],edi
        mov     [.caret_line_number],ecx
        mov     [.sel_line_number],ecx
        mov     [.sel_position],eax
        mov     esi,[.search_text]
        add     eax,[esi+4]
        mov     [.caret_position],eax
        call    .update_positions
        call    .let_caret_appear
        mov     eax,[.caret_position]
        xchg    eax,[.sel_position]
        mov     [.caret_position],eax
        mov     [.return_value],TRUE
        jmp     .moved_selection
    .search_backward:
        push    ecx
        call    .find_text
        pop     ecx
        jnc     .backward_found
        dec     ecx
        mov     edx,100h
        mov     edi,[edi+4]
        or      edi,edi
        jnz     .search_backward
    .search_done:
        xor     eax,eax
        mov     esi,[.search_text]
        mov     [esi],eax
        mov     [.search_text],eax
        jmp     .done
.aemcanfindnext:
        cmp     [.search_text],0
        je      .ignore
        mov     [.return_value],TRUE
        jmp     .ignore
.aemgetwordatcaret:
        call    .get_word_edges

        mov     word [.return_value], dx
        mov     word [.return_value+2], cx

        mov     edi,[.lparam]
        lea     esi,[esi+8+edx]
        sub     ecx,edx
        inc     ecx
        cmp     cx, word [.wparam]
        jbe     .size_ok
        movzx   ecx, word [.wparam]
    .size_ok:
        dec     ecx
        rep     movsb
        xor     al,al
        stosb

        jmp     .ignore

    .get_word_edges:
        mov     esi,[.caret_line]
        mov     edx,[.caret_position]
    .find_left_edge:
        or      edx,edx
        jz      .left_edge_ok
        mov     al,[esi+8+edx-1]
        cmp     byte [.wparam+2], 0
        jne     .pointok

        cmp     al, '.'
        je      .inword

.pointok:
        call    .recognize_character
        jc      .left_edge_ok

.inword:
        dec     edx
        jmp     .find_left_edge
    .left_edge_ok:
        mov     ecx,[.caret_position]
    .find_right_edge:
        cmp     ecx,100h
        je      .right_edge_ok
        mov     al,[esi+8+ecx]
        call    .recognize_character
        jc      .right_edge_ok
        inc     ecx
        jmp     .find_right_edge
    .right_edge_ok:
        ret
.moved_caret:
        test    [.kbstate+VK_SHIFT],80h
        jnz     .moved_selection
        mov     [.sel_line],0
.moved_selection:
        mov     [.notification],AEN_POSCHANGE
        jmp     .update
.moved_window:
        call    .update_positions
        jmp     .refresh
.text_modified:
        mov     [.notification],AEN_TEXTCHANGE
    .update:
        call    .update_positions
        call    .let_caret_appear
    .refresh:
        call    .paint_bookmarks
        cmp     [.focus_line],0
        jne     .wmsize
        mov     eax,[.editor_screen]
        or      eax,eax
        jz      .wmsize
        push    eax
        call    .update_screen
        mov     esi,[esp]
        mov     edi,[.editor_screen]
        or      edi,edi
        jz      .refresh_failed
        mov     [.rect.top],0
        mov     edx,[.font_height]
        mov     [.rect.bottom],edx
        mov     ecx,[.screen_height]
    .refresh_screen:
        push    ecx
        mov     ecx,[.screen_width]
        mov     ebx,[.screen_height]
        imul    ebx,ecx
        mov     edx,[.font_width]
        xor     eax,eax
        mov     [.rect.left],eax
        mov     [.rect.right],eax
    .refresh_line:
        mov     al,[esi]
        mov     ah,[esi+ebx]
        cmp     al,[edi]
        jne     .refresh_changed
        cmp     ah,[edi+ebx]
        jne     .refresh_changed
        inc     esi
        inc     edi
        add     [.rect.left],edx
        add     [.rect.right],edx
        loop    .refresh_line
        jmp     .refresh_next_line
    .refresh_changed:
        mov     al,[esi]
        mov     ah,[esi+ebx]
        inc     esi
        add     [.rect.right],edx
        cmp     al,[edi]
        jne     .changed_more
        cmp     ah,[edi+ebx]
        jne     .changed_more
        inc     edi
        jmp     .invalidate
    .changed_more:
        inc     edi
        loop    .refresh_changed
    .invalidate:
        push    ecx edx
        mov     eax,[.margin_width]
        add     [.rect.left],eax
        add     [.rect.right],eax
        lea     eax, [.rect]
        invoke  InvalidateRect,[.hwnd],eax,FALSE
        pop     edx ecx
        mov     eax,[.margin_width]
        sub     [.rect.right],eax
        mov     eax,[.rect.right]
        mov     [.rect.left],eax
        jecxz   .refresh_next_line
        dec     ecx
        jnz     .refresh_line
    .refresh_next_line:
        mov     eax,[.font_height]
        add     [.rect.top],eax
        add     [.rect.bottom],eax
        pop      ecx
        dec     ecx
        jnz     .refresh_screen
        invoke      GlobalFree
        jmp     .done
    .refresh_failed:
        pop     [.editor_screen]
        jmp     .wmsize


.ignore:
        mov     dl,[.last_operation]
        mov     [.current_operation],dl
        cmp     [.was_selection],0
        jne     .done
        mov     [.sel_line],0
.done:
        cmp     [.focus],0
        je      .caret_ok
        call    .update_caret_position
        invoke  ShowCaret,[.hwnd]

    .caret_ok:

        lea     esi,[.editor_data]
        mov     edi,[.editor_memory]
        add     edi,8
        mov     ecx,.editor_data_size shr 2
        rep     movsd                           ; updates editor memory.

        cmp     [.notification],0
        je      .notification_ok
        invoke  GetWindowLong, [.hwnd], GWL_HWNDPARENT
        mov     edi,eax
        invoke  GetWindowLong, [.hwnd], GWL_ID
        movzx   ebx,[.notification]
        shl     ebx,16
        or      eax,ebx
        invoke  SendMessage, edi, WM_COMMAND, eax, [.hwnd]

    .notification_ok:
        cmp     [.redraw_now],0
        je      .redraw_ok
        invoke  UpdateWindow,[.hwnd]

    .redraw_ok:
        mov     eax,[.return_value]

.finish:
        pop     edi esi ebx
        return

.out_of_memory:
        call    .undo

.not_enough_memory:
        lea     esp,[.editor_memory-10h]
        mov     [.notification],AEN_OUTOFMEMORY
        or      [.return_value],-1
        jmp     .ignore

.update_positions:
        lea     eax, [.rect]
        invoke  GetClientRect,[.hwnd],eax
        mov     eax,[.rect.left]
        add     eax,[.margin_width]
        mov     [.rect.left],eax
        cmp     eax,[.rect.right]
        jbe     .margin_ok
        mov     [.rect.right],eax
    .margin_ok:
        mov     eax,[.rect.right]
        sub     eax,[.rect.left]
        cdq
        div     [.font_width]
        add     edx,-1
        adc     eax,0
        mov     [.screen_width],eax
        mov     eax,[.rect.bottom]
        sub     eax,[.rect.top]
        cdq
        div     [.font_height]
        add     edx,-1
        adc     eax,0
        mov     [.screen_height],eax

    .setup_vscroll:
        mov     ecx,[.lines_count]
        mov     [.sc.cbSize],sizeof.SCROLLINFO
        mov     [.sc.fMask],SIF_DISABLENOSCROLL+SIF_RANGE+SIF_PAGE+SIF_POS
        mov     [.sc.nMin],1
        mov     [.sc.nMax],ecx
        mov     eax,[.rect.bottom]
        sub     eax,[.rect.top]
        xor     edx,edx
        div     [.font_height]
        mov     [.page_size],eax
        mov     [.sc.nPage],eax
        mov     edx,[.window_line_number]
        mov     [.sc.nPos],edx
        cmp     edx,1
        je      .vscroll_ok
        add     edx,eax
        dec     edx
        cmp     edx,ecx
        jle     .vscroll_ok
        sub     edx,ecx

    .vscroll_correction:
        mov     esi,[.window_line]
        mov     esi,[esi+4]
        or      esi,esi
        jz      .setup_vscroll
        mov     [.window_line],esi
        dec     [.window_line_number]
        dec     edx
        jnz     .vscroll_correction
        jmp     .setup_vscroll

    .vscroll_ok:
        test    [.editor_style],WS_VSCROLL
        jz      .setup_hscroll
        lea     eax, [.sc]
        invoke  SetScrollInfo,[.hwnd],SB_VERT,eax,TRUE

    .setup_hscroll:
        mov     [.sc.nMin],0
        mov     [.sc.nMax],100h
        mov     eax,[.rect.right]
        sub     eax,[.rect.left]
        xor     edx,edx
        div     [.font_width]
        mov     [.sc.nPage],eax
        mov     edx,[.window_position]
        mov     [.sc.nPos],edx
        or      edx,edx
        jz      .hscroll_ok
        add     edx,eax
        cmp     edx,101h
        jbe     .hscroll_ok
        sub     edx,101h
        sub     [.window_position],edx
        jnc     .setup_hscroll
        mov     [.window_position],0
        jmp     .setup_hscroll

    .hscroll_ok:
        test    [.editor_style],WS_HSCROLL
        jz      .setup_caret
        lea     eax, [.sc]
        invoke  SetScrollInfo,[.hwnd],SB_HORZ,eax,TRUE

    .setup_caret:
        mov     eax,[.font_width]
        mov     edx,[.caret_position]
        sub     edx,[.window_position]
        imul    eax,edx
        mov     [.caret_x],eax
        mov     eax,[.font_height]
        mov     edx,[.caret_line_number]
        sub     edx,[.window_line_number]
        imul    eax,edx
        mov     [.caret_y],eax
        ret

.let_caret_appear:
        mov     eax,[.caret_position]
        cmp     eax,[.window_position]
        jl      .horizontal_correction
        mov     eax,[.rect.right]
        sub     eax,[.rect.left]
        xor     edx,edx
        div     [.font_width]
        or      eax,eax
        jz      .horizontal_check
        dec     eax

    .horizontal_check:
        neg     eax
        add     eax,[.caret_position]
        cmp     [.window_position],eax
        jge     .horizontal_ok

    .horizontal_correction:
        mov     [.window_position],eax
        call    .update_positions

    .horizontal_ok:
        mov     esi,[.caret_line]
        mov     ecx,[.caret_line_number]
        cmp     ecx,[.window_line_number]
        jl      .vertical_correction
        mov     eax,[.rect.bottom]
        sub     eax,[.rect.top]
        xor     edx,edx
        div     [.font_height]
        or      eax,eax
        jz      .vertical_check
        dec     eax

    .vertical_check:
        neg     eax
        add     eax,[.caret_line_number]
        cmp     [.window_line_number],eax
        jge     .vertical_ok
        mov     esi,[.window_line]
        mov     ecx,[.window_line_number]

    .vertical_find:
        mov     esi,[esi]
        inc     ecx
        cmp     ecx,eax
        jl      .vertical_find

    .vertical_correction:
        mov     [.window_line],esi
        mov     [.window_line_number],ecx
        call    .update_positions

    .vertical_ok:
        ret


.create_caret:
        xor     eax,eax
        test    [.editor_mode],AEMODE_OVERWRITE
        jnz     .block_caret
        test    [.editor_style],AES_CONSOLECARET
        jnz     .console_caret
        invoke  CreateCaret,[.hwnd],NULL,0,[.font_height]
        jmp     .update_caret_position

    .block_caret:
        invoke  CreateCaret,[.hwnd],NULL,[.font_width],[.font_height]
        jmp     .update_caret_position

    .console_caret:
        invoke  CreateCaret,[.hwnd],NULL,[.font_width],2

.update_caret_position:
        mov     eax,[.caret_y]
        mov     ebx,[.caret_x]
        add     ebx,[.margin_width]
        test    [.editor_mode],AEMODE_OVERWRITE
        jnz     .set_position
        test    [.editor_style],AES_CONSOLECARET
        jz      .set_position
        add     eax,[.font_height]
        sub     eax,2

      .set_position:
        cmp     ebx,[.margin_width]
        jge     @F
        xor     ebx,ebx
        sub     ebx,[.font_width]
        @@:
        invoke  SetCaretPos,ebx,eax
        ret




.update_screen:
        mov     eax,[.screen_width]
        mul     [.screen_height]
        mov     ebx,eax
        shl     eax,1
        or      eax,eax
        jz      .screen_allocated
        invoke  GlobalAlloc,GMEM_FIXED,eax
    .screen_allocated:
        mov     [.editor_screen],eax
        or      eax,eax
        jz      .screen_prepared
        mov     edi,eax
        add     ebx,edi
        push    ebx
        mov     ecx,[.screen_height]
        mov     esi,[.window_line]

    .prepare_screen:
        push    ecx
        push    edi

        lea     edi,[.line_colors]
        mov     ecx,100h shr 2
        xor     eax,eax
        rep     stosd
        lea     eax,[esi+8]

        lea     edi, [.line_colors]
        invoke  .syntax_proc, eax, edi

        pop     edi
        push    esi

        mov     edx,[.window_position]
        lea     esi,[esi+8+edx]
        mov     eax,100h
        sub     eax,edx
        cmp     eax,[.screen_width]
        jbe     .prepare_line
        mov     eax,[.screen_width]
    .prepare_line:
        mov     ecx,eax
        rep     movsb
        lea     esi,[.line_colors+edx]
        mov     ecx,eax
        xchg    edi,ebx
        rep     movsb
        xchg    edi,ebx
        pop     esi
        cmp     eax,[.screen_width]
        je      .prepare_next_line
        mov     ecx,[.screen_width]
        sub     ecx,eax
        xor     al,al
        mov     edx,ecx
        rep     stosb
        xchg    edi,ebx
        mov     ecx,edx
        rep     stosb
        xchg    edi,ebx
    .prepare_next_line:
        pop     ecx
        mov     esi,[esi]
        dec     ecx
        jz      .prepare_selection
        or      esi,esi
        jnz     .prepare_screen
    .prepare_empty_lines:
        imul    ecx,[.screen_width]
        xor     al,al
        mov     edx,ecx
        rep     stosb
        xchg    edi,ebx
        mov     ecx,edx
        rep     stosb
    .prepare_selection:
        pop     ebx
        test    [.editor_style],ES_NOHIDESEL
        jnz     .hidesel_ok
        cmp     [.focus],0
        je      .screen_prepared
    .hidesel_ok:
        cmp     [.sel_line],0
        je      .screen_prepared
        mov     eax,[.window_line_number]
        mov     esi,[.sel_line_number]
        mov     edi,[.caret_line_number]
        sub     esi,eax
        sub     edi,eax
        mov     ecx,[.window_position]
        mov     eax,[.sel_position]
        mov     edx,[.caret_position]
        sub     eax,ecx
        sub     edx,ecx
        cmp     esi,edi
        jle     .sel_boundaries_ok
        xchg    esi,edi
        xchg    eax,edx
    .sel_boundaries_ok:
        mov     ecx,[.screen_height]
        cmp     edi,0
        jl      .screen_prepared
        cmp     esi,ecx
        jge     .screen_prepared
        cmp     esi,edi
        je      .prepare_vsel
        test    [.editor_mode],AEMODE_VERTICALSEL
        jz      .prepare_hsel
    .prepare_vsel:
        cmp     eax,edx
        jle     .vsel_boundaries_ok
        xchg    eax,edx
    .vsel_boundaries_ok:
        cmp     esi,0
        jge     .vsel_start_ok
        xor     esi,esi
    .vsel_start_ok:
        inc     edi
        cmp     edi,ecx
        jle     .vsel_end_ok
        mov     edi,ecx
    .vsel_end_ok:
        mov     ecx,[.screen_width]
        cmp     edx,0
        jl      .screen_prepared
        cmp     eax,ecx
        jge     .screen_prepared
        cmp     eax,0
        jge     .vsel_line_start_ok
        xor     eax,eax
    .vsel_line_start_ok:
        cmp     edx,ecx
        jle     .vsel_line_end_ok
        mov     edx,ecx
    .vsel_line_end_ok:
        mov     ecx,edi
        sub     ecx,esi
        imul    esi,[.screen_width]
        add     ebx,esi
    .prepare_vsel_line:
        push    eax ecx
        mov     edi,ebx
        mov     ecx,edx
        sub     ecx,eax
        lea     edi,[ebx+eax]
        mov     al,80h
        rep     stosb
        add     ebx,[.screen_width]
        pop     ecx eax
        loop    .prepare_vsel_line
        jmp     .screen_prepared
    .prepare_hsel:
        cmp     esi,0
        jge     .hsel_start_ok
        xor     esi,esi
        xor     eax,eax
    .hsel_start_ok:
        cmp     edi,ecx
        jl      .hsel_end_ok
        mov     edi,ecx
        xor     edx,edx
    .hsel_end_ok:
        inc     esi
        mov     ecx,edi
        sub     ecx,esi
        imul    ecx,[.screen_width]
        imul    esi,[.screen_width]
        lea     edi,[ebx+esi]
        neg     eax
        add     eax,[.screen_width]
        cmp     eax,0
        jle     .hsel_start_line_ok
        sub     edi,eax
        add     ecx,eax
        sub     eax,[.screen_width]
        jle     .hsel_start_line_ok
        add     edi,eax
        sub     ecx,eax
    .hsel_start_line_ok:
        cmp     edx,0
        jle     .hsel_end_line_ok
        add     ecx,edx
        sub     edx,[.screen_width]
        jle     .hsel_end_line_ok
        sub     ecx,edx
    .hsel_end_line_ok:
        mov     al,80h
        rep     stosb
    .screen_prepared:
        ret




.init_editor_memory:

        invoke  VirtualAlloc,0,10800h,MEM_COMMIT,PAGE_READWRITE
        or      eax,eax
        jz      .memory_error
        mov     [.editor_memory],eax
        mov     dword [eax],0
        mov     dword [eax+4],0
        lea     ebx,[eax+108h]
        mov     [.unallocated_lines],ebx
        mov     [.memory_search_line],ebx
        add     eax,10800h
        mov     [.unallocated_lines_end],eax
        mov     [.memory_search_block],eax
        clc
        ret
    .memory_error:
        stc
        ret

.reset_editor_memory:
        mov     esi,[.editor_memory]
        lea     eax,[esi+108h]
        mov     [.unallocated_lines],eax
        mov     [.memory_search_line],eax
        lea     eax,[esi+10800h]
        mov     [.unallocated_lines_end],eax
        mov     [.memory_search_block],eax
        pushd   [esi]
    .decommit:
        pop     ebx
        test    ebx, ebx
        jz      .decommit_done
        pushd   [ebx]
        invoke  VirtualFree, ebx, 0, MEM_RELEASE
        jmp     .decommit

    .decommit_done:
        mov     eax,[.editor_memory]
        mov     [eax],dword 0
        mov     [.undo_data],0
        mov     [.search_text],0
        mov     [.current_operation],0
        ret

.release_editor_memory:
        mov     esi,[.editor_memory]
    .release:
        mov     ebx,[esi]
        invoke  VirtualFree,esi,0,MEM_RELEASE
        mov     esi,ebx
        or      esi,esi
        jnz     .release
        mov     [.editor_memory],0
        ret
.allocate_line:
        mov     eax,[.unallocated_lines]
        mov     ebx,[.memory_search_block]
        mov     esi,[.memory_search_line]
        cmp     eax,[.unallocated_lines_end]
        je      .find_free_line
        add     [.unallocated_lines],108h
        clc
        ret
    .find_free_line:
        cmp     esi,ebx
        je      .find_in_next_block
        cmp     dword [esi],-1
        je      .reuse_line
        add     esi,108h
        cmp     esi,[.memory_search_line]
        jne     .find_free_line
        sub     ebx,10800h
    .find_last_memory_block:
        cmp     dword [ebx],0
        je      .allocate_more_memory
        mov     ebx,[ebx]
        jmp     .find_last_memory_block
    .allocate_more_memory:
        invoke  VirtualAlloc,0,10800h,MEM_COMMIT,PAGE_READWRITE
        or      eax,eax
        jz      .failed
        mov     [ebx],eax
        mov     [eax],dword 0
        mov     [eax+4],ebx
        lea     ebx,[eax+10800h]
        mov     [.unallocated_lines_end],ebx
        add     eax,108h
        lea     ebx,[eax+108h]
        mov     [.unallocated_lines],ebx
        clc
        ret
    .failed:
        stc
        ret
    .reuse_line:
        mov     eax,esi
        mov     [.memory_search_block],ebx
        add     esi,108h
        mov     [.memory_search_line],esi
        clc
        ret
    .find_in_next_block:
        sub     ebx,10800h
        mov     esi,[ebx]
        lea     ebx,[esi+10800h]
        or      esi,esi
        jnz     .find_free_line
        mov     ebx,[.editor_memory]
        mov     esi,ebx
        add     ebx,10800h
        jmp     .find_free_line
.init_editor_data:
        call    .allocate_line
        mov     [.first_line],eax
        mov     [.lines_count],1
        mov     [.caret_line],eax
        mov     [.caret_line_number],1
        mov     [.window_line],eax
        mov     [.window_line_number],1
        mov     edi,eax
        xor     eax,eax
        stosd
        stosd
        mov     eax,20202020h
        mov     ecx,100h shr 2
        rep     stosd
        mov     [.caret_position],0
        mov     [.sel_position], 0
        mov     [.window_position],0
        mov     [.sel_line],0
        mov     [.sel_line_number], 1   ; 11.12.2003 John Found Added, bug fix for
                                        ; some functions immediately after creation
                                        ; of AsmEdit.
        mov     [.undo_data],0
        mov     [.search_text],0
        mov     [.current_operation],0
        mov     [.editor_mode],0
        mov     [.syntax_proc], SyntaxProc
        mov     [.syntax_colors],0
        mov     [.focus],0
        mov     [.mouse_select],0
        ret
.insert_character:
        mov     edx,[.caret_position]
        cmp     edx,100h
        je      .insert_done
        mov     esi,[.caret_line]
        lea     esi,[esi+8+edx]
        test    [.editor_mode],AEMODE_OVERWRITE
        jnz     .overwrite
        mov     ecx,100h
        sub     ecx,edx
        inc     edx
        mov     [.caret_position],edx
        mov     ah,al
        mov     ebx,esi
        mov     edx,ecx
    .shift_data_right:
        xchg    al,[esi]
        inc     esi
        loop    .shift_data_right
        test    [.editor_style],AES_AUTOBRACKETS
        jz      .insert_done
        cmp     ah,'('
        je      .round
        cmp     ah,'['
        je      .square
        cmp     ah,'{'
        je      .brace
    .insert_done:
        ret
    .round:
        mov     al,')'
        jmp     .auto_bracket
    .square:
        mov     al,']'
        jmp     .auto_bracket
    .brace:
        mov     al,'}'
    .auto_bracket:
        xor     ah,ah
        mov     ecx,edx
        dec     ecx
        jz      .insert_done
        lea     esi,[ebx+1]
        xchg    al,[esi]
        call    .recognize_character
        jnc     .cancel_bracket
        inc     esi
        dec     ecx
        jnz     .shift_data_right
        ret
    .cancel_bracket:
        mov     [esi],al
        ret
    .overwrite:
        mov     [esi],al
        inc     [.caret_position]
        ret
.delete_character:
        mov     edx,[.caret_position]
        cmp     edx,100h
        je      .delete_done
        mov     esi,[.caret_line]
        mov     al,20h
        test    [.editor_mode],AEMODE_OVERWRITE
        jnz     .delete
        add     esi,108h
        mov     ecx,100h
        sub     ecx,[.caret_position]
    .shift_data_left:
        dec     esi
        xchg    al,[esi]
        loop    .shift_data_left
    .delete_done:
        ret
    .delete:
        mov     [esi+8+edx],al
        ret

.recognize_character:
        cmp     al,20h
        jb      .neutral_character
        cmp     al,30h
        jb      .separator_character
        cmp     al,3Ah
        jb      .neutral_character
        cmp     al,40h
        jb      .separator_character
        cmp     al,5Bh
        jb      .neutral_character
        cmp     al,5Fh
        jb      .separator_character
        cmp     al,7Bh
        jb      .neutral_character
        cmp     al,7Fh
        jb      .separator_character
    .neutral_character:
        clc
        ret
    .separator_character:
        stc
        ret
.find_line:
        mov     esi,[.first_line]
        mov     ecx,1
        mov     edx,[.window_line_number]
        cmp     eax,edx
        jae     .forward_from_window
        sub     edx,eax
        cmp     edx,eax
        jb      .backward_from_window
        jmp     .find_forward
    .forward_from_window:
        mov     esi,[.window_line]
        mov     ecx,edx
    .find_forward:
        cmp     ecx,eax
        je      .line_found
        cmp     [esi],dword 0
        je      .line_found
        inc     ecx
        mov     esi,[esi]
        jmp     .find_forward
    .backward_from_window:
        mov     esi,[.window_line]
        mov     ecx,[.window_line_number]
    .find_backward:
        cmp     ecx,eax
        je      .line_found
        cmp     [esi+4],dword 0
        je      .line_found
        dec     ecx
        mov     esi,[esi+4]
        jmp     .find_backward
    .line_found:
        ret

.insert_block:
        test    [.editor_mode],AEMODE_VERTICALSEL
        jz      .do_insert_block
        push    esi
        or      edx,-1
        xor     ecx,ecx
    .count:
        lodsb
        cmp     al,9
        je      .cannot_insert
        cmp     al,0Dh
        je      .count_next_line
        or      al,al
        jz      .check_count
        inc     ecx
        jmp     .count
    .count_next_line:
        lodsb
    .check_count:
        cmp     edx,0
        jl      .line_to_insert_ok
        je      .cannot_insert
        cmp     edx,ecx
        je      .line_to_insert_ok
        jmp     .cannot_insert
    .line_to_insert_ok:
        mov     edx,ecx
        xor     ecx,ecx
        or      al,al
        jz      .cannot_insert
        cmp     byte [esi],0
        jne     .count
        pop     esi
    .do_insert_block:
        mov     eax,[.caret_line]
        mov     [.current_line],eax
        call    .store_line_for_undo
        mov     edx,[eax]
        mov     [.current_line],edx
        call    .store_line_for_undo
        mov     ebx,eax
        mov     [.sel_line],ebx
        mov     edx,[.caret_position]
        mov     eax,[.caret_line_number]
        mov     [.sel_line_number],eax
        lea     edi,[ebx+8+edx]
        test    [.editor_mode],AEMODE_OVERWRITE
        jnz     .begin_insert
        test    [.editor_mode],AEMODE_VERTICALSEL
        jnz     .begin_insert

        push    esi edi
        mov     esi,edi

        lea     edi,[.line_buffer]
        mov     ecx,100h
        sub     ecx,[.caret_position]
        rep     movsb

        mov     ecx,[.caret_position]
        mov     al,20h
        rep     stosb
        mov     edi,[esp]
        mov     ecx,100h
        sub     ecx,[.caret_position]
        mov     al,20h
        rep     stosb
        pop     edi esi
    .begin_insert:
        mov     edx,esi
        xor     ecx,ecx
    .count_characters:
        lodsb
        cmp     al,0Dh
        je      .put_string
        cmp     al,9
        je      .convert_string
        or      al,al
        jz      .put_string
        inc     ecx
        jmp     .count_characters

    .convert_string:
        mov     esi,edx
        push    edi
        lea     edi,[.text_buffer]
        xor     ecx,ecx

    .convert_tabs:
        lodsb
        cmp     al,0Dh
        je      .convert_done
        cmp     al,9
        je      .insert_tab
        or      al,al
        jz      .convert_done
        cmp     ecx,100h
        jae     .convert_tabs
        inc     ecx
        stosb
        jmp     .convert_tabs
    .insert_tab:
        mov     edx,ecx
        and     ecx,not 111b
        sub     ecx,edx
        add     ecx,8
        add     edx,ecx
        mov     al,20h
        rep     stosb
        mov     ecx,edx
        jmp     .convert_tabs

    .convert_done:
        lea     edx,[.text_buffer]
        pop     edi

    .put_string:
        xchg    esi,edx
        lea     eax,[ebx+108h]
        sub     eax,edi
        cmp     eax,ecx
        jbe     .larger_string
        test    [.editor_mode],AEMODE_VERTICALSEL
        jz      .simple_put
        test    [.editor_mode],AEMODE_OVERWRITE
        jnz     .simple_put
        sub     eax,ecx
        xchg    eax,ecx
        push    esi edi
        lea     esi,[edi+ecx-1]
        lea     edi,[ebx+108h-1]
        std
        rep     movsb
        cld
        pop     edi esi
        xchg    eax,ecx
    .simple_put:
        rep     movsb
        jmp     .put_ok
    .larger_string:
        xchg    ecx,eax
        sub     eax,ecx
        rep     movsb
    .put_ok:
        mov     esi,edx
        cmp     byte [esi-1],0
        je      .last_line
        lodsb
        or      al,al
        jz      .last_line
        cmp     byte [esi],0
        je      .last_line
        test    [.editor_mode],AEMODE_VERTICALSEL
        jnz     .insert_next_line
        test    [.editor_mode],AEMODE_OVERWRITE
        jnz     .overwrite_line
    .insert_new_line:
        push    ebx esi
        call    .allocate_line
        jc      .out_of_memory
        pop     esi ebx
        mov     [.sel_line],eax
        inc     [.sel_line_number]
        mov     [.current_line],eax
        call    .store_line_for_undo
        mov     edi,eax
        mov     edx,[ebx]
        mov     [edi],edx
        mov     [edi+4],ebx
        mov     [ebx],edi
        mov     ebx,edi
        add     edi,8
        mov     eax,20202020h
        mov     ecx,100h shr 2
        rep     stosd
        inc     [.lines_count]
        or      edx,edx
        jz      .insert_into_line
        mov     [edx+4],ebx
        jmp     .insert_into_line
    .overwrite_line:
        lea     ecx,[ebx+8+100h]
        sub     ecx,edi
        mov     al,20h
        rep     stosb
    .insert_next_line:
        mov     eax,[ebx]
        or      eax,eax
        jz      .insert_new_line
        mov     ebx,eax
        mov     [.sel_line],ebx
        inc     [.sel_line_number]
        mov     [.current_line],eax
        call    .store_line_for_undo
    .insert_into_line:
        mov     edx,esi
        xor     ecx,ecx
        lea     edi,[ebx+8]
        test    [.editor_mode],AEMODE_VERTICALSEL
        jz      .count_characters
        add     edi,[.caret_position]
        jmp     .count_characters
    .last_line:
        test    [.editor_mode],AEMODE_OVERWRITE
        jnz     .block_inserted
        test    [.editor_mode],AEMODE_VERTICALSEL
        jnz     .block_inserted
        lea     eax,[ebx+108h]
        cmp     edi,eax
        jae     .block_inserted
        push    edi
        mov     ecx,eax
        sub     ecx,edi
        lea     esi,[.line_buffer]
        rep     movsb
        pop     edi
    .block_inserted:
        lea     ebx,[ebx+8]
        mov     eax,edi
        sub     eax,ebx
        mov     [.sel_position],eax
        clc
        ret
    .cannot_insert:
        pop     esi
        stc
        ret
.delete_block:
        mov     eax,[.sel_line]
        mov     ebx,[.sel_position]
        mov     ecx,[.caret_line]
        mov     edx,[.caret_position]
        mov     esi,[.sel_line_number]
        test    [.editor_mode],AEMODE_VERTICALSEL
        jnz     .delete_vertical
        cmp     esi,[.caret_line_number]
        jb      .boundaries_for_delete_ok
        ja      .exchange_boundaries_for_delete
        cmp     ebx,edx
        jb      .boundaries_for_delete_ok
    .exchange_boundaries_for_delete:
        xchg    eax,ecx
        xchg    ebx,edx
        mov     esi,[.caret_line_number]
    .boundaries_for_delete_ok:
        mov     [.caret_line],eax
        mov     [.caret_line_number],esi
        mov     esi,eax
        mov     [.sel_line],0
        test    [.editor_mode],AEMODE_OVERWRITE
        jnz     .overwrite_delete
        mov     [.caret_position],ebx
        mov     [.current_line],eax
        call    .store_line_for_undo
        mov     edi,eax
        cmp     eax,ecx
        je      .delete_from_line
        mov     eax,[eax]
    .delete_line:
        mov     [.current_line],eax
        call    .store_line_for_undo
        mov     esi,eax
        cmp     eax,[.window_line]
        jne     .release_line
        mov     eax,[.caret_line]
        mov     [.window_line],eax
        mov     eax,[.caret_line_number]
        mov     [.window_line_number],eax
    .release_line:
        cmp     esi,ecx
        je      .lines_deleted
        or      eax,-1
        xchg    [esi],eax
        dec     [.lines_count]
        jmp     .delete_line
    .lines_deleted:
        mov     eax,[esi]
        mov     [edi],eax
        or      eax,eax
        jz      .delete_last_line
        mov     [.current_line],eax
        call    .store_line_for_undo
        mov     eax,[.current_line]
        mov     [eax+4],edi
    .delete_last_line:
        or      dword [esi],-1
    .delete_from_line:
        lea     edi,[edi+8+ebx]
        lea     esi,[esi+8+edx]
        mov     ecx,100h
        sub     ecx,ebx
        xor     eax,eax
        cmp     ebx,edx
        jae     .move_remaining_data
        mov     ecx,100h
        sub     ecx,edx
        mov     eax,edx
        sub     eax,ebx
    .move_remaining_data:
        rep     movsb
        mov     ecx,eax
        mov     al,20h
        rep     stosb
    .block_deleted:
        ret
    .overwrite_delete:
        push    ecx
        mov     ecx,100h
        sub     ecx,ebx
        lea     edi,[esi+ebx+8]
        pop     ebx
    .fill_with_spaces:
        cmp     esi,ebx
        jne     .end_fill_ok
        sub     ecx,100h
        add     ecx,edx
    .end_fill_ok:
        mov     al,20h
        rep     stosb
        cmp     esi,ebx
        je      .block_deleted
        mov     esi,[esi]
        mov     [.current_line],esi
        call    .store_line_for_undo
        mov     ecx,100h
        lea     edi,[esi+8]
        jmp     .fill_with_spaces
    .delete_vertical:
        cmp     esi,[.caret_line_number]
        jbe     .vboundaries_for_delete_ok
        xchg    eax,ecx
    .vboundaries_for_delete_ok:
        cmp     ebx,edx
        jbe     .hboundaries_for_delete_ok
        xchg    ebx,edx
    .hboundaries_for_delete_ok:
        mov     [.sel_line],0
        mov     esi,eax
        mov     edi,ecx
        mov     [.current_line],esi
        call    .store_line_for_undo
        test    [.editor_mode],AEMODE_OVERWRITE
        jnz     .vertical_fill
        mov     [.caret_position],ebx
    .cut_from_line:
        push    esi edi
        lea     edi,[esi+8+ebx]
        lea     esi,[esi+8+edx]
        mov     ecx,100h
        sub     ecx,edx
        rep     movsb
        mov     ecx,edx
        sub     ecx,ebx
        mov     al,20h
        rep     stosb
        pop     edi esi
        cmp     esi,edi
        je      .block_deleted
        mov     esi,[esi]
        mov     [.current_line],esi
        call    .store_line_for_undo
        jmp     .cut_from_line
    .vertical_fill:
        push    edi
        lea     edi,[esi+8+ebx]
        mov     ecx,edx
        sub     ecx,ebx
        mov     al,20h
        rep     stosb
        pop     edi
        cmp     esi,edi
        je      .block_deleted
        mov     esi,[esi]
        mov     [.current_line],esi
        call    .store_line_for_undo
        jmp     .vertical_fill
.copy_block:
        mov     esi,[.sel_line]
        mov     eax,[.caret_line]
        mov     ebx,[.sel_position]
        mov     edx,[.caret_position]
        mov     ecx,[.sel_line_number]
        test    [.editor_mode],AEMODE_VERTICALSEL
        jnz     .copy_vertical_block
        cmp     ecx,[.caret_line_number]
        jb      .boundaries_for_copy_ok
        ja      .exchange_boundaries_for_copy
        cmp     ebx,edx
        jb      .boundaries_for_copy_ok
    .exchange_boundaries_for_copy:
        xchg    esi,eax
        xchg    ebx,edx
    .boundaries_for_copy_ok:
        cmp     esi,eax
        je      .hboundaries_for_copy_ok
        push    esi edi
        lea     edi,[esi+108h-1]
        lea     esi,[esi+8+ebx]
        mov     ecx,100h
        sub     ecx,ebx
        mov     ebx,eax
        jmp     .get_line_size
    .copy_whole_line:
        mov     esi,[esi]
        cmp     esi,ebx
        je      .copy_last_line
        push    esi edi
        add     esi,8
        lea     edi,[esi+100h-1]
        mov     ecx,100h
    .get_line_size:
        mov     al,20h
        std
        repe    scasb
        setne   al
        movzx   eax,al
        add     ecx,eax
        cld
        pop     edi
        rep     movsb
        mov     word [edi],0A0Dh
        add     edi,2
        pop     esi
        jmp     .copy_whole_line
    .copy_last_line:
        add     esi,8
        mov     ecx,edx
        rep     movsb
        mov     ax,0A0Dh
        stosw
        xor     al,al
        stosb
        ret
    .copy_vertical_block:
        cmp     ecx,[.caret_line_number]
        jb      .vboundaries_for_copy_ok
        xchg    esi,eax
    .vboundaries_for_copy_ok:
        cmp     ebx,edx
        jb      .hboundaries_for_copy_ok
        xchg    ebx,edx
    .hboundaries_for_copy_ok:
        push    esi
        lea     esi,[esi+8+ebx]
        mov     ecx,edx
        sub     ecx,ebx
        rep     movsb
        mov     word [edi],0A0Dh
        add     edi,2
        pop     esi
        cmp     esi,eax
        je      .block_copied
        mov     esi,[esi]
        jmp     .hboundaries_for_copy_ok
    .block_copied:
        xor     al,al
        stosb
        ret
.get_block_size:
        xor     ecx,ecx
        mov     esi,[.sel_line]
        mov     eax,[.caret_line]
        mov     ebx,[.sel_position]
        mov     edx,[.caret_position]
        mov     edi,[.sel_line_number]
        test    [.editor_mode],AEMODE_VERTICALSEL
        jnz     .vertical_block
        cmp     edi,[.caret_line_number]
        jb      .boundaries_ok
        ja      .exchange_boundaries
        cmp     ebx,edx
        jb      .boundaries_ok
    .exchange_boundaries:
        xchg    esi,eax
        xchg    ebx,edx
    .boundaries_ok:
        xor     ecx,ecx
        cmp     esi,eax
        je      .hboundaries_ok
        add     edx,ecx
        mov     ecx,100h
        sub     ecx,ebx
        mov     ebx,eax
        lea     edi,[esi+8+100h-1]
        jmp     .count_line_bytes
    .whole_line:
        mov     esi,[esi]
        cmp     esi,ebx
        je      .block_size_ok
        lea     edi,[esi+8+100h-1]
        mov     ecx,100h
    .count_line_bytes:
        mov     al,20h
        std
        repe    scasb
        setne   al
        movzx   eax,al
        add     ecx,eax
        cld
        add     edx,ecx
        add     edx,2
        jmp     .whole_line
    .block_size_ok:
        mov     ecx,edx
        add     ecx,3
        ret
    .vertical_block:
        cmp     edi,[.caret_line_number]
        jb      .vboundaries_ok
        xchg    esi,eax
    .vboundaries_ok:
        cmp     ebx,edx
        jb      .hboundaries_ok
        xchg    ebx,edx
    .hboundaries_ok:
        add     ecx,edx
        sub     ecx,ebx
        add     ecx,2
        cmp     esi,eax
        je      .vertical_block_size_ok
        mov     esi,[esi]
        jmp     .hboundaries_ok
    .vertical_block_size_ok:
        inc     ecx
        ret
.find_text:
        push    edi edx
        add     edi,8
        mov     esi,[.search_text]
        test    byte [esi],AEFIND_BACKWARD
        jnz     .backward
        mov     ecx,100h
        sub     ecx,edx
        jz      .not_found
        add     edi,edx
        test    byte [esi],AEFIND_CASESENSITIVE
        jnz     .case_ok
        mov     esi,edi
        lea     edi,[.text_buffer]
        push    ecx
        mov     ebx,case_table
    .convert_case:
        lodsb
        xlatb
        stosb
        loop    .convert_case
        pop     ecx
        lea     edi,[.text_buffer]
        mov     esi,[.search_text]
    .case_ok:
        mov     edx,ecx
        cmp     ecx,[esi+4]
        jb      .not_found
    .search:
        mov     al,[esi+8]
        repne   scasb
        jne     .not_found
        mov     eax,[esi+4]
        dec     eax
        jz      .found
        cmp     ecx,eax
        jb      .not_found
        push    ecx esi edi
        mov     ecx,eax
        lea     esi,[esi+8+1]
        repe    cmpsb
        pop     edi esi ecx
        jne     .search
    .found:
        mov     eax,edx
        sub     eax,ecx
        dec     eax
        add     eax,[esp]
        test    byte [esi],AEFIND_WHOLEWORDS
        jz      .found_ok
        or      eax,eax
        jz      .left_bound_ok
        mov     ebx,[esp+4]
        push    eax
        mov     al,[ebx+8+eax-1]
        call    .recognize_character
        pop     eax
        jnc     .search
    .left_bound_ok:
        mov     ebx,[esi+4]
        add     ebx,eax
        cmp     ebx,100h
        je      .found_ok
        add     ebx,[esp+4]
        push    eax
        mov     al,[ebx+8]
        call    .recognize_character
        pop     eax
        jnc     .search
    .found_ok:
        pop     edx edi
        cld
        clc
        ret
    .backward:
        std
        or      edx,edx
        jz      .not_found
        mov     ecx,edx
        lea     edi,[edi+edx-1]
        mov     esi,[.search_text]
        test    byte [esi],AEFIND_CASESENSITIVE
        jnz     .backward_case_ok
        mov     esi,edi
        lea     edi,[.text_buffer+ecx-1]
        push    ecx
        mov     ebx,case_table
    .convert_case_backward:
        lodsb
        xlatb
        stosb
        loop    .convert_case_backward
        pop     ecx
        lea     edi,[.text_buffer+ecx-1]
        mov     esi,[.search_text]
    .backward_case_ok:
        cmp     ecx,[esi+4]
        jb      .not_found
    .backward_search:
        mov     eax,[esi+4]
        mov     al,[esi+8+eax-1]
        repne   scasb
        jne     .not_found
        mov     eax,[esi+4]
        dec     eax
        jz      .found_in_backward
        cmp     ecx,eax
        jb      .not_found
        push    ecx esi edi
        mov     ecx,eax
        lea     esi,[esi+8+eax-1]
        repe    cmpsb
        pop     edi esi ecx
        jne     .backward_search
    .found_in_backward:
        mov     eax,ecx
        inc     eax
        mov     ebx,eax
        sub     eax,[esi+4]
        test    byte [esi],AEFIND_WHOLEWORDS
        jz      .found_ok
        cmp     ebx,100h
        je      .right_bound_ok
        add     ebx,[esp+4]
        push    eax
        mov     al,[ebx+8]
        call    .recognize_character
        pop     eax
        jnc     .backward_search
    .right_bound_ok:
        or      eax,eax
        jz      .found_ok
        mov     ebx,[esp+4]
        push    eax
        mov     al,[ebx+8+eax-1]
        call    .recognize_character
        pop     eax
        jnc     .backward_search
        jmp     .found_ok
    .not_found:
        pop     edx edi
        cld
        stc
        ret

.store_status_for_undo:
        pusha
        cmp     [.was_selection],0
        jne     .selection_ok
        mov     [.sel_line],0

    .selection_ok:
        call    .allocate_line
        jc      .not_enough_memory
        mov     [eax],dword 0
        mov     edi,eax
        xchg    eax,[.undo_data]
        push    eax
        call    .allocate_line
        jnc     .store_editor_status
        or      eax,-1
        stosd
        jmp     .not_enough_memory

    .store_editor_status:
        mov     [eax],dword 0
        mov     [eax+4],dword 0
        stosd
        pop     eax
        stosd
        lea     esi,[.editor_data]
        mov     ecx,.editor_status_size shr 2
        rep     movsd
        popa
        clc
        ret

.store_line_for_undo:
        pusha
        cmp     [.current_line],0
        je      .line_for_undo_ok

        mov     [.Modified], TRUE       ; John Found 25.11.2003

        mov     esi,[.undo_data]
        or      esi,esi
        jz      .line_for_undo_ok
        mov     esi,[esi]
        mov     ecx,[esi+4]
        lea     edi,[esi+8+ecx*8]
        inc     ecx
        cmp     ecx,20h
        jbe     .slot_ok
        push    esi
        call    .allocate_line
        jc      .out_of_memory
        mov     esi,eax
        mov     ebx,[.undo_data]
        mov     [ebx],esi
        pop     dword [esi]
        mov     ecx,1
        lea     edi,[esi+8]
    .slot_ok:
        mov     [esi+4],ecx
        mov     esi,[.current_line]
        mov     eax,[esi]
        cmp     eax,-1
        jne     .store_line
        stosd
        mov     eax,esi
        stosd
        jmp     .line_for_undo_ok
    .store_line:
        call    .allocate_line
        jc      .out_of_memory
        mov     ebx,eax
        stosd
        mov     eax,[.current_line]
        stosd
        mov     esi,eax
        mov     edi,ebx
        mov     ecx,108h shr 2
        rep     movsd
    .line_for_undo_ok:
        popa
        ret


.undo:
        mov     esi,[.undo_data]
        or      esi,esi
        jz      .undo_ok
        or      ebx,-1
        xchg    ebx,[esi]
        add     esi,4
        lodsd
        mov     [.undo_data],eax
        lea     edi,[.editor_data]
        mov     ecx,.editor_status_size shr 2
        rep     movsd
    .lines_block:
        or      ebx,ebx
        jz      .undo_ok
        mov     esi,ebx
        or      ebx,-1
        xchg    ebx,[esi]
        add     esi,4
        lodsd
        mov     ecx,eax
        jecxz   .undo_ok
        lea     esi,[esi+ecx*8]
    .restore_lines:
        sub     esi,8
        push    esi ecx
        mov     edi,[esi+4]
        mov     esi,[esi]
        or      esi,esi
        jz      .restore_next
        cmp     esi,-1
        jne     .restore_data
        mov     eax,esi
        stosd
        jmp     .restore_next
    .restore_data:
        mov     ecx,108h shr 2
        rep     movsd
        or      dword [esi-108h],-1
    .restore_next:
        pop     ecx esi
        loop    .restore_lines
        jmp     .lines_block
    .undo_ok:
        ret


.clear_undo_data:
        mov     esi,[.undo_data]
        or      esi,esi
        jz      .undo_data_ok
        or      ebx,-1
        xchg    ebx,[esi]
        add     esi,4
        lodsd
        mov     [.undo_data],eax
    .release_lines_block:
        or      ebx,ebx
        jz      .clear_undo_data
        mov     esi,ebx
        or      ebx,-1
        xchg    ebx,[esi]
        add     esi,4
        lodsd
        mov     ecx,eax
        jecxz   .clear_undo_data
        lea     esi,[esi+ecx*8]
    .release_lines:
        sub     esi,8
        mov     eax,[esi]
        cmp     eax,-1
        je      .release_next
        or      dword [eax],-1
    .release_next:
        loop    .release_lines
        jmp     .release_lines_block
    .undo_data_ok:
        mov     [.last_operation],0
        ret

endp

proc SyntaxProc, .lpLine, .lpColors
begin
        return
endp

Added asmedit/asmedit.inc.

























































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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

; AsmEdit styles

AES_AUTOINDENT   = 0001h
AES_SMARTTABS    = 0002h
AES_OPTIMALFILL  = 0004h
AES_SECURESEL    = 0008h
AES_AUTOBRACKETS = 0010h
AES_CONSOLECARET = 0020h
AES_INDENTSEL    = 0040h  ; indent/outdent selection by pressing tab/shift+tab

; AsmEdit messages

AEM_SETMODE            = WM_USER + 0   ; (modevalue, null)
AEM_GETMODE            = WM_USER + 1   ; (null, null): modevalue
AEM_SETSYNTAXHIGHLIGHT = WM_USER + 2   ; (syntaxcolors or 0, syntaxproc)
AEM_GETLINEDATA        = WM_USER + 3   ; (linenum, *buffer)
AEM_SETPOS             = WM_USER + 4   ; (*aepos, null)
AEM_GETPOS             = WM_USER + 5   ; (*aepos, null)
AEM_FINDFIRST          = WM_USER + 6   ; (flags, *string): found?
AEM_FINDNEXT           = WM_USER + 7   ; (null, null): found?
AEM_CANFINDNEXT        = WM_USER + 8   ; (null, null): found?
AEM_GETWORDATCARET     = WM_USER + 9   ; (sizeof, *buffer)
AEM_SETTEXTCOLOR       = WM_USER + 10  ; (fg, bg)
AEM_SETSELCOLOR        = WM_USER + 11  ; (fg, bg)
AEM_SETPOPUPMENU       = WM_USER + 12  ; (null, handle)
AEM_SETMARGINCOLOR     = WM_USER + 13  ; (bg, border)
AEM_SETMARGINWIDTH     = WM_USER + 14  ; (gap, width)
AEM_SETTHEME           = WM_USER + 15  ; (null, *aetheme)
AEM_TOGGLEBOOKMARK     = WM_USER + 16  ; (null, null): id
AEM_GOTOBOOKMARK       = WM_USER + 17  ; (id/null, aebm_?): linenum
AEM_CLEARBOOKMARKS     = WM_USER + 18  ; (null, null)
AEM_COMMENT            = WM_USER + 19  ; (null, true/false)
AEM_INDENT             = WM_USER + 20  ; (null, true/false)
AEM_SETLINEDATA        = WM_USER + 21  ; (linenum, *buffer)
AEM_GETLINEPTR         = WM_USER + 22  ; (linenum, 0):lineptr
AEM_GETMODIFIED        = WM_USER + 23  ; (null, null):modified
AEM_SETMODIFIED        = WM_USER + 24  ; (modified, null): old_modified
AEM_SETBOOKMARKICON    = WM_USER + 25  ; (handle, null)
AEM_GETCARETXY         = WM_USER + 26  ; (ptr AECARETXY, 0)
AEM_READONLY           = WM_USER + 27  ; (true/false, null): true/false
AEM_SETFOCUSLINE       = WM_USER + 28  ; (line, null)

; AsmEdit mode flags

AEMODE_OVERWRITE   = 1
AEMODE_VERTICALSEL = 2

; AsmEdit search flags

AEFIND_CASESENSITIVE = 1
AEFIND_WHOLEWORDS    = 2
AEFIND_BACKWARD      = 4

; AsmEdit bookmark constants

AEBM_NUM  = 0
AEBM_NEXT = 1
AEBM_PREV = 2

; AsmEdit notifications

AEN_SETFOCUS     = 01h
AEN_KILLFOCUS    = 02h
AEN_TEXTCHANGE   = 03h
AEN_POSCHANGE    = 04h
AEN_MODECHANGE   = 05h
AEN_OUTOFMEMORY  = 0Fh

; AsmEdit position structure

struct AEPOS
   .selectionPosition dd ?
   .selectionLine     dd ?
   .caretPosition     dd ?
   .caretLine         dd ?
ends

struct AECARETXY
  .x0 dd ?
  .y0 dd ?
  .x1 dd ?
  .y1 dd ?
ends

; AsmEdit theme structure
struc AETHEME tfg,tbg,sfg,sbg,mbg,mfg,mw,gw,focusfg,focusbg,synproc,[syn]
{
   common
     .text_color        dd tfg
     .text_background   dd tbg
     .sel_text          dd sfg
     .sel_background    dd sbg
     .margin_background dd mbg
     .margin_border     dd mfg
     .margin_width      dd mw
     .margin_gap        dd gw
     .focus_color       dd focusfg
     .focus_background  dd focusbg
     .syntax_proc       dd synproc
     .syntax_colors:
   forward
     if ~ syn eq
       dd syn
     end if
   common
     .syntax_colors_count = ($ - .syntax_colors) / 4
 }


macro Theme fontName, fontSize, fontCharset, asmeditStyle,      \
            tfg,tbg,sfg,sbg,mbg,mfg,mw,gw,focusfg,focusbg,[syn]
{
  common
    local ..fontN, ..theme, ..beg, ..size
  ..beg:
    dd ..fontN
    dd fontSize
    dd fontCharset
    dd asmeditStyle
    dd ..theme
    dd ..size
  common
    ..fontN db fontName, 0
            rb 256 - ($-..fontN)
    ..theme AETHEME tfg, tbg, sfg, sbg, mbg, mfg, mw, gw, focusfg, focusbg, 0, syn
  ..size = $ - ..beg
}



struct AELINE
  .next dd ?
  .prev dd ?
  .text rb 256
ends

; AsmEdit offsets in window extra memory.
ofsAsmEditMemory     = 0
ofsOpenFileStruct    = $c

Added asmedit/syntax.asm.





































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
ttText = 0
ttStr = 1
ttRem = 2
ttNum = 3
ttChar = 4

clDefaultText   = 0
clSymbol        = 1
clNumber        = 2
clString        = 3
clComment       = 4
clRegister      = 5
clInstruction   = 6
clDirective     = 7
clPreprocessor  = 8

SyntaxColorCount = 8

macro dps [txt] {
    forward
      if txt eq 0
        db 0
      else
        db txt
        db 0
        dw 0
      end if
  }


  struc synList minLen, maxLen, ptrlist {
    .MinLen  dd minLen
    .MaxLen  dd maxLen
    .ptrList dd ptrlist
  }

  virtual at 0
    synList synList 0, 0, 0
  end virtual


proc fasm_syntax, .ptrLine, .ptrColors
.status      dd ?
.wlen        dd ?
.w           rb 256
.lastword    dd ?
.Quo         db ?

; Sometimes, AsmEdit calls this procedure with wrong ptrLine.
; In these cases GPF appear.

begin
        pushad
        mov     [.status],ttText
        xor     ah,ah
        mov     [.wlen], 0
        mov     esi, [.ptrLine]
        mov     edi, [.ptrColors]
        mov     [.lastword], edi
        mov     ecx,256

.loop:
        lodsb
        cmp     [.status], ttRem
        je      .endif
        cmp     [.status], ttStr
        jne     .ifnotstr
        cmp     al,[.Quo]
        jne     .endif
        mov     [.status], ttText
        jmp     .endif

.ifnotstr:
        cmp     al, ';'
        jne     .notrem
        mov     [.status], ttRem
        mov     ah, clComment
        jmp     .endif

.notrem:
        cmp     al, '"'
        je      .str
        cmp     al, "'"
        jne     .notstr

.str:
        mov     [.status], ttStr
        mov     [.Quo], al
        mov     ah, clString
        jmp     .endif

.notstr:
        call    .CharInSymbols
        jnc     .notsym
        mov     [.status], ttChar
        mov     ah, clSymbol
        call    .MakeWord
        jmp     .endif

.notsym:
        lea     edx,[esi-1]
        cmp     edx, [.ptrLine]
        je      .maybenum

        cmp     [.status], ttChar
        jne     .notnumbeg

.maybenum:
        call    .CharInNum
        jnc     .notnum
        mov      [.status], ttNum
        mov      ah, clNumber
        jmp      .endif

.notnum:
        mov     [.status], ttText
        xor     ah,ah
        mov     [.wlen], 1
        mov     [.w], al
        mov     [.lastword], edi
        jmp     .endif

.notnumbeg:
        cmp     [.status], ttText
        jne     .endif
        xor     ah,ah
        lea     ebx, [.w]
        add     ebx, [.wlen]
        mov     [ebx], al
        inc     [.wlen]

.endif:
        mov     [edi], ah
        inc     edi
        dec     ecx
        jnz     .loop

.endwhile:
        popad
        return
endp



.MakeWord:
        push    edi esi eax ecx
        cmp     [.wlen],0
        je      .end
        lea     esi, [.w]
        push    esi edi
        lea     edi, [.w]
 .new_char:
        lodsb
        cmp     al,0
        je      .ok
        cmp     al,"A"
        jl      @F
        cmp     al,"Z"
        jg      @F
        add     al,20h
@@:
        stosb
        jmp     .new_char
.ok:
        pop     edi esi

        mov     ah, clRegister
        stdcall FindInstr, sSymbols, esi, [.wlen], 2, 0
        jnc     .maybeinstr

        cmp     dl, 10h
        je      .found

        mov     ah, clDirective
        jmp     .found

.maybeinstr:
        mov     ah, clInstruction
        stdcall FindInstr, sInstructions, esi, [.wlen], 3, 1
        jnc     .maybeoperator

        cmp     edx, fasm_instructions - instruction_handler
        jae     .found

        mov     ah, clDirective
        jmp     .found

.maybeoperator:
        mov     ah, clDirective
        stdcall SearchSimple, directive_operators, esi, [.wlen], 1
        jc      .found

        mov     ah, clPreprocessor
        stdcall SearchSimple, preprocessor_directives, esi, [.wlen], 2
        jc      .found
        stdcall SearchSimple, macro_directives, esi, [.wlen], 2
        jnc     .notfound

.found:
        mov     ebx, [.wlen]
        mov     edi, [.lastword]

.chgcolor:
        mov     [edi], ah
        inc     edi
        dec     ebx
        jnz     .chgcolor

.notfound:
        and     [.wlen], 0

.end:
        pop     ecx eax esi edi
        retn


.CharInSymbols:
        push    edi ecx

        mov     edi, symbol_characters+1
        movzx   ecx, byte [edi-1]

        repne scasb
        jne   @f
        stc
        pop     ecx edi
        ret
@@:
        clc
        pop     ecx edi
        retn


.CharInNum:
        cmp     al, '$'
        jne     @f
        stc
        retn

@@:
        cmp     al, '0'
        jb      @f
        cmp     al, '9'
        ja      @f
        stc
        retn
@@:
        clc
        retn




proc FindInstr, .ptrArray, .ptrWord, .len, .addbytes, .return
.count dd ?
begin

        push    eax ebx ecx esi edi

        mov     ecx, [.ptrArray]
        mov     edi, [.ptrWord]
        mov     edx, [.len]

        cmp     edx, [ecx+synList.MinLen]
        jb      .notfound

        cmp     edx, [ecx+synList.MaxLen]
        ja      .notfound

        mov     esi, [ecx+synList.ptrList]

        sub     edx, [ecx+synList.MinLen]
        movzx   eax, word [esi+4*edx+2]       ; items count
        mov     [.count], eax
        movzx   ebx, word [esi+4*edx]         ; offset to esi
        add     esi, ebx
        mov     edx,[.len]
        add     edx, [.addbytes]

.loopmain:
        dec     [.count]
        js      .notfound

        xor     ebx, ebx

.loopword:
        mov     al,[esi+ebx]
        cmp     [edi+ebx], al
        ja      .next
        jb      .notfound
        inc     ebx
        cmp     ebx, [.len]
        jne     .loopword

        cmp     [.return], 0
        jl      .found

        lea     eax, [esi+ebx]
        add     eax, [.return]

        movsx   edx, word [eax]

.found:
        stc
        jmp     .end

.next:
        add     esi, edx
        jmp     .loopmain

.notfound:
        clc

.end:
        pop     edi esi ecx ebx eax
        return
endp



proc SearchSimple, .ptrList, .ptrWord, .len, .addbytes
.count dd ?
begin
        push    eax ecx edx esi edi

        mov     esi, [.ptrList]
        mov     edx, [.len]

.loopmain:
        lodsb
        test    al, al
        jz      .notfound

        cmp     al, dl
        jne     .next

        mov     edi, [.ptrWord]
        movzx   ecx, al
        repe    cmpsb
        je      .found

        add     esi, ecx
        add     esi, [.addbytes]
        jmp     .loopmain

.next:
        movzx   eax, al
        lea     esi, [esi+eax]
        add     esi, [.addbytes]
        jmp     .loopmain

.found:
        stc
        jmp     .end

.notfound:
        clc
.end:
        pop     edi esi edx ecx eax
        return
endp





iglobal
  sInstructions synList 2, 16, instructions
  sSymbols      synList 2, 11, symbols
endg

Added doc/WikiPad.wiki.





















>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
<b>WikiPad</b> is small text editor with only one function - fast inserting of text markup tags in the text.

The idea is to allow the user to define tags he wants to use and to associate every tag with shortcut key
that to insert the tag in the text.

The set of tags can be saved in configuration file. This way one can use different tag sets for different
formats - wiki pages, BBCode, HTML or any other tag based markup language.

Besides tags, one can use the same approach to define snipets of text that to be insert with shortcut or
one mouse click - for example, signatures, ASCII art, smiles, etc.

Added resources/Logo.gif.

cannot compute difference between binary files