Subversion Repositories Kolibri OS

Rev

Rev 6097 | Rev 9092 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6097 Rev 6596
Line 21... Line 21...
21
        mov     ecx, [textbox_width]
21
        mov     ecx, [textbox_width]
22
        inc     ecx
22
        inc     ecx
23
  .more:
23
  .more:
24
        dec     ecx
24
        dec     ecx
25
        jz      .end_of_line
25
        jz      .end_of_line
-
 
26
  .next_byte:
26
        lodsb                           ; get one character of the string
27
        lodsb                           ; get one character of the string
27
        test    al, 0x80
-
 
28
        jnz     .multiball!
-
 
29
        test    al, al                  ; end of string?
28
        test    al, al                  ; end of string?
30
        jz      .almost_done
29
        jz      .almost_done
31
        cmp     al, ' '                 ; it's a space! remember its position
30
        cmp     al, ' '                 ; it's a space! remember its position
32
        je      .space
31
        je      .space
33
        cmp     al, 13                  ; we already inserted a newline once, make it a space again
32
        cmp     al, 13                  ; we already inserted a newline once, make it a space again
34
        je      .soft_nl
33
        je      .soft_nl
35
        cmp     al, 10                  ; it's a newline, continue onto the next line
34
        cmp     al, 10                  ; it's a newline, continue onto the next line
-
 
35
        je      .newline
-
 
36
        and     al, 0xc0                ; Is it a multi byte UTF8 char?
-
 
37
        cmp     al, 0x80
-
 
38
        je      .next_byte
36
        jne     .more
39
        jmp     .more
-
 
40
  .newline:
37
        inc     edx
41
        inc     edx
38
        jmp     .next_line
42
        jmp     .next_line
39
  .soft_nl:
43
  .soft_nl:
40
        mov     byte[esi-1], ' '
44
        mov     byte[esi-1], ' '
41
  .space:
45
  .space:
Line 52... Line 56...
52
        dec     esi
56
        dec     esi
53
  .done:
57
  .done:
Line 54... Line 58...
54
 
58
 
Line 55... Line -...
55
        ret
-
 
56
 
-
 
57
  .multiball!:
-
 
58
        add     esi, 4
-
 
59
        and     al, 11111000b
-
 
60
        cmp     al, 11110000b
-
 
61
        je      .more
-
 
62
        dec     esi
-
 
63
        and     al, 11110000b
-
 
64
        cmp     al, 11100000b
-
 
65
        je      .more
-
 
66
        dec     esi
-
 
67
        jmp     .more
-
 
Line 68... Line 59...
68
 
59
        ret
69
 
60
 
70
 
61
 
71
;----------------------------------
62
;----------------------------------
Line 84... Line 75...
84
        jz      .done
75
        jz      .done
85
        cmp     al, 10
76
        cmp     al, 10
86
        je      .done
77
        je      .done
87
        cmp     al, 13
78
        cmp     al, 13
88
        je      .done
79
        je      .done
-
 
80
        and     al, 0xc0
-
 
81
        cmp     al, 0x80
-
 
82
        je      .loop           ; This byte is the second, third or fourth byte of a multi-byte UTF8 char
89
        dec     ecx
83
        dec     ecx
90
        jnz     .loop
84
        jnz     .loop
91
  .done:
85
  .done:
92
 
-
 
93
        ret
86
        ret
Line 94... Line -...
94
 
-
 
95
 
87
 
96
;----------------------------------
88
;----------------------------------
97
; print string
89
; print string
98
;
90
;
99
; IN:   esi = ptr to string
91
; IN:   esi = ptr to string