WIP: apps/ircc: fix text formatting issues (#376) #392
No files matched your search
@@ -158,12 +158,8 @@ skip_parameter:
|
||||
cmp al, ':'
|
||||
jne .part1
|
||||
|
||||
; Skip all trailing spaces
|
||||
; esi already points to first char after ':', preserve leading spaces
|
||||
.part3:
|
||||
lodsb
|
||||
cmp al, ' '
|
||||
je .part3
|
||||
dec esi
|
||||
ret
|
||||
|
||||
; Now, skip all trailing spaces and first semicolon
|
||||
|
||||
@@ -33,10 +33,43 @@ text_insert_newlines: ; esi = ASCIIZ string
|
||||
je .soft_nl
|
||||
cmp al, 10 ; it's a newline, continue onto the next line
|
||||
je .newline
|
||||
cmp al, 3 ; mIRC color escape - skip args without counting width
|
||||
je .skip_color
|
||||
cmp al, 0x20 ; other control char (bold, italic, reset, etc.) - skip without counting
|
||||
jb .next_byte
|
||||
and al, 0xc0 ; Is it a multi byte UTF8 char?
|
||||
cmp al, 0x80
|
||||
je .next_byte
|
||||
jmp .more
|
||||
.skip_color:
|
||||
lodsb ; optional fg color digit(s)
|
||||
cmp al, '0'
|
||||
jb .skip_color_done
|
||||
cmp al, '9'
|
||||
ja .skip_color_done
|
||||
lodsb ; optional 2nd fg digit
|
||||
cmp al, '0'
|
||||
jb .skip_color_comma
|
||||
cmp al, '9'
|
||||
ja .skip_color_comma
|
||||
lodsb ; char after 2 fg digits
|
||||
.skip_color_comma:
|
||||
cmp al, ',' ; optional background color?
|
||||
jne .skip_color_done
|
||||
lodsb ; optional bg color digit(s)
|
||||
cmp al, '0'
|
||||
jb .skip_color_done
|
||||
cmp al, '9'
|
||||
ja .skip_color_done
|
||||
lodsb ; optional 2nd bg digit
|
||||
cmp al, '0'
|
||||
jb .skip_color_done
|
||||
cmp al, '9'
|
||||
ja .skip_color_done
|
||||
jmp .next_byte
|
||||
.skip_color_done:
|
||||
dec esi
|
||||
jmp .next_byte
|
||||
.newline:
|
||||
inc edx
|
||||
jmp .next_line
|
||||
@@ -77,6 +110,10 @@ text_nextline:
|
||||
je .done
|
||||
cmp al, 13
|
||||
je .done
|
||||
cmp al, 3 ; mIRC color escape - skip args without counting width
|
||||
je .skip_color
|
||||
cmp al, 0x20 ; other control char - skip without counting
|
||||
jb .loop
|
||||
and al, 0xc0
|
||||
cmp al, 0x80
|
||||
je .loop ; This byte is the second, third or fourth byte of a multi-byte UTF8 char
|
||||
@@ -84,6 +121,35 @@ text_nextline:
|
||||
jnz .loop
|
||||
.done:
|
||||
ret
|
||||
.skip_color:
|
||||
lodsb
|
||||
cmp al, '0'
|
||||
jb .skip_color_done
|
||||
cmp al, '9'
|
||||
ja .skip_color_done
|
||||
lodsb
|
||||
cmp al, '0'
|
||||
jb .skip_color_comma
|
||||
cmp al, '9'
|
||||
ja .skip_color_comma
|
||||
lodsb
|
||||
.skip_color_comma:
|
||||
cmp al, ','
|
||||
jne .skip_color_done
|
||||
lodsb
|
||||
cmp al, '0'
|
||||
jb .skip_color_done
|
||||
cmp al, '9'
|
||||
ja .skip_color_done
|
||||
lodsb
|
||||
cmp al, '0'
|
||||
jb .skip_color_done
|
||||
cmp al, '9'
|
||||
ja .skip_color_done
|
||||
jmp .loop
|
||||
.skip_color_done:
|
||||
dec esi
|
||||
jmp .loop
|
||||
|
||||
;----------------------------------
|
||||
; print string
|
||||
@@ -279,11 +345,18 @@ draw_channel_text:
|
||||
je @f
|
||||
cmp al, 10 ; hard newline
|
||||
je @f
|
||||
cmp al, 15 ; 0x0F reset char: default color applies from here forward
|
||||
je @f
|
||||
cmp al, 3 ; mIRC escape code
|
||||
jne @b
|
||||
|
||||
cld
|
||||
lea edx, [esi+2]
|
||||
; bare \x03 (no digit) = color reset, use default
|
||||
movzx eax, byte[edx]
|
||||
sub al, '0'
|
||||
cmp al, 9
|
||||
ja @f
|
||||
call dec_to_esi
|
||||
jz @f
|
||||
mov ecx, [irc_colors + 4*esi]
|
||||
@@ -328,9 +401,21 @@ draw_channel_text:
|
||||
cmp byte[edx], 10
|
||||
je .newline_hard
|
||||
|
||||
cmp byte[edx], 15 ; 0x0F: reset all formatting to default
|
||||
jne .check_colors
|
||||
inc edx
|
||||
mov ecx, [colors.work_text]
|
||||
or ecx, 0x30000000
|
||||
jmp .line
|
||||
.check_colors:
|
||||
cmp byte[edx], 3 ; escape code for mIRC colors
|
||||
jne .no_colors
|
||||
inc edx
|
||||
; bare \x03 with no digit = reset color to default
|
||||
movzx eax, byte[edx]
|
||||
sub al, '0'
|
||||
cmp al, 9
|
||||
ja .color_reset
|
||||
call dec_to_esi
|
||||
jz .line
|
||||
mov ecx, [irc_colors + 4*esi]
|
||||
@@ -343,6 +428,11 @@ draw_channel_text:
|
||||
jz .line
|
||||
mov edi, [irc_colors + 4*esi]
|
||||
or ecx, 0x40000000
|
||||
jmp .line
|
||||
.color_reset:
|
||||
mov ecx, [colors.work_text]
|
||||
or ecx, 0x30000000
|
||||
jmp .line
|
||||
.no_colors:
|
||||
|
||||
; Some non-printable, just skip it
|
||||
|
||||
@@ -226,11 +226,11 @@ window_open:
|
||||
.got_it:
|
||||
lodsb
|
||||
cmp al, ' '
|
||||
je .got_it
|
||||
je .got_it ; skip spaces before the colon
|
||||
cmp al, ':'
|
||||
je .got_it
|
||||
dec esi
|
||||
|
||||
je .set_window ; found colon, stop here - preserve leading spaces of message
|
||||
dec esi ; not space or colon, put it back
|
||||
.set_window:
|
||||
mov [window_print], ebx
|
||||
ret
|
||||
|
||||
|
||||
Reference in new issue
Block a user