From 97df225ad22b2877c901e1271fae79d95b03899b Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Sat, 2 Jan 2016 21:03:09 +0000 Subject: [PATCH] IRCc 0.25: Use big fonts, improved UTF-8 support. git-svn-id: svn://kolibrios.org@6026 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/network/ircc/gui.inc | 22 +++-- programs/network/ircc/ircc.asm | 36 ++++----- programs/network/ircc/serverparser.inc | 6 +- programs/network/ircc/socket.inc | 23 +++--- programs/network/ircc/textbox.inc | 107 ++++++++++++++++++++----- programs/network/ircc/userparser.inc | 1 + programs/network/ircc/window.inc | 4 +- 7 files changed, 131 insertions(+), 68 deletions(-) diff --git a/programs/network/ircc/gui.inc b/programs/network/ircc/gui.inc index 34737269cf..5e0755b5db 100644 --- a/programs/network/ircc/gui.inc +++ b/programs/network/ircc/gui.inc @@ -113,7 +113,7 @@ draw_window: ; Completely redraw the window, recalculate all coordinates and jne .not_channel mov [scroll1.all_redraw], 1 - call draw_channel_list + call draw_user_list ; draw a vertical separator line when there is no scrollbar cmp [scroll2.all_redraw], 1 @@ -138,11 +138,10 @@ draw_window: ; Completely redraw the window, recalculate all coordinates and mov eax, [xsize] mov [edit1.width], eax - push dword edit1 - call [edit_box_draw] + invoke edit_box_draw, edit1 ; draw tabs - call draw_windowtabs + call draw_window_tabs .exit: popa @@ -150,7 +149,7 @@ draw_window: ; Completely redraw the window, recalculate all coordinates and -draw_channel_list: +draw_user_list: pusha @@ -167,8 +166,7 @@ draw_channel_list: mov [scroll1.position], eax @@: ; OK, draw the scrollbar - push dword scroll1 - call [scrollbar_draw] + invoke scrollbar_draw, scroll1 ; dont redraw scrollbar completely next time, ; unless draw_window asks us to by setting [scroll1.all_redraw] back to 1 @@ -211,7 +209,7 @@ draw_channel_list: pop ebx mov bx, TEXT_Y mov ecx, [colors.work_text] - or ecx, 0x80000000 ; ASCIIZ string + or ecx, 0x90000000 ; 8x16 font, zero terminated string mov eax, 4 ; draw text mov edi, [textbox_height] ; how many names will fit on screen @@ -226,16 +224,16 @@ draw_channel_list: mov cx, bx mov bx, USERLIST_WIDTH shl ecx, 16 - mov cx, 10 - 1 + mov cx, FONT_HEIGHT mov edx, 0x00000055 ; blue! mcall 13 popa - mov ecx, 0x8000ffff ; cyan! + mov ecx, 0x9000ffff ; cyan! mcall mov ecx, [colors.work_text] - or ecx, 0x80000000 ; ASCIIZ string + or ecx, 0x90000000 ; 8x16 font, zero terminated string jmp .next .nothighlight: @@ -253,7 +251,7 @@ draw_channel_list: ret -draw_windowtabs: +draw_window_tabs: ; Draw horizontal line diff --git a/programs/network/ircc/ircc.asm b/programs/network/ircc/ircc.asm index 639f5bf704..1d4dbb5d8e 100644 --- a/programs/network/ircc/ircc.asm +++ b/programs/network/ircc/ircc.asm @@ -13,7 +13,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -version equ '0.24' +version equ '0.25' ; connection status STATUS_DISCONNECTED = 0 @@ -43,9 +43,9 @@ UTF8 = 2 USERCMD_MAX_SIZE = 400 WIN_MIN_X = 600 -WIN_MIN_Y = 170 +WIN_MIN_Y = 183 -TEXT_X = 5 +TEXT_X = 2 TEXT_Y = TOP_Y + 2 TOP_SPACE = 2 @@ -77,10 +77,10 @@ WINDOW_BTN_CLOSE = 2 WINDOW_BTN_LIST = 3 SCROLLBAR_WIDTH = 14 -USERLIST_WIDTH = 100 +USERLIST_WIDTH = 160 -FONT_HEIGHT = 9 -FONT_WIDTH = 6 +FONT_WIDTH = 8 +FONT_HEIGHT = 16 format binary as "" @@ -245,7 +245,7 @@ mainloop: mov edi, [window_active] cmp [edi + window.type], WINDOWTYPE_CHANNEL jne .no_update - call draw_channel_list + call draw_user_list .no_update: call highlight_updated_tabs @@ -280,7 +280,7 @@ button: mov ebx, [window_active] mov [ebx + window.selected], eax - call draw_channel_list + call draw_user_list pop eax test eax, 1 shl 25 ; Right mouse button pressed? @@ -378,8 +378,7 @@ main_window_key: mov [edit1.size], 0 mov [edit1.pos], 0 - push dword edit1 - call [edit_box_draw] + invoke edit_box_draw, edit1 call draw_channel_text @@ -389,8 +388,7 @@ main_window_key: jmp mainloop mouse: - push dword edit1 - call [edit_box_mouse] + invoke edit_box_mouse, edit1 ; mcall 37, 7 ; movsx eax, ax @@ -401,12 +399,11 @@ mouse: cmp [edi + window.type], WINDOWTYPE_CHANNEL jne @f push [scroll1.position] - push dword scroll1 - call [scrollbar_mouse] + invoke scrollbar_mouse, scroll1 pop eax cmp eax, [scroll1.position] ; did the scrollbar move? je @f - call draw_channel_list + call draw_user_list @@: ; TODO: check if scrollbar is active? @@ -414,8 +411,7 @@ mouse: mov eax, [edi + window.text_lines] cmp eax, [textbox_height] jbe @f - push dword scroll2 - call [scrollbar_mouse] + invoke scrollbar_mouse, scroll2 mov edi, [window_active] and [edi+window.flags], not FLAG_SCROLL_LOW mov edx, [scroll2.position] @@ -506,10 +502,8 @@ str_welcome db 3, '3 ___', 3, '7__________', 3, '6_________ ', 3, ' db 3, '3| |', 3, '7| | \', 3, '6 \____', 3, '4 \ \___| |_| \ ___/| | \ |', 10 db 3, '3|___|', 3, '7|____|_ /', 3, '6\______ /', 3, '4 \___ >____/__|\___ >___| /__|', 10 db 3, '3 ', 3, '7 \/ ', 3, '6 \/ ', 3, '4 \/ \/ \/', 10 - db 10 db 'Welcome to KolibriOS IRC client ', version, 10 - db 10 - db 'Type /help for help', 10, 10, 0 + db 'Type /help for help', 10, 0 str_version db 'VERSION KolibriOS ' str_programname db 'IRC client ', version, 0 @@ -577,7 +571,7 @@ import boxlib,\ scrollbar_mouse,'scrollbar_v_mouse' ; width, left, top -edit1 edit_box 0, 0, 0, 0xffffff, 0x6f9480, 0, 0, 0, USERCMD_MAX_SIZE, usercommand, mouse_dd, ed_always_focus, 25, 25 +edit1 edit_box 0, 0, 0, 0xffffff, 0x6f9480, 0, 0, 0x000000, USERCMD_MAX_SIZE, usercommand, mouse_dd, ed_always_focus, 25, 25 ; xsize, xpos, ysize, ypos, btn_height, max, cur, pos, bgcol, frcol, linecol scroll1 scrollbar SCROLLBAR_WIDTH, 0, 0, TOP_Y, SCROLLBAR_WIDTH, 0, 0, 0, 0, 0, 0, 1 scroll2 scrollbar SCROLLBAR_WIDTH, 0, 0, TOP_Y, SCROLLBAR_WIDTH, 0, 0, 0, 0, 0, 0, 1 diff --git a/programs/network/ircc/serverparser.inc b/programs/network/ircc/serverparser.inc index 31e57c09df..f46b18e264 100644 --- a/programs/network/ircc/serverparser.inc +++ b/programs/network/ircc/serverparser.inc @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; Written by hidnplayr@kolibrios.org ;; @@ -961,7 +961,7 @@ cmd_353: ; channel usernames reply jmp .add .done: - call draw_channel_list + call draw_user_list .fail: ret @@ -1059,7 +1059,7 @@ cmd_322: ; LIST jz .fail mov [window_active], ebx - call draw_windowtabs + call draw_window_tabs pop esi call print_asciiz mov al, 10 diff --git a/programs/network/ircc/socket.inc b/programs/network/ircc/socket.inc index 1260e5f0f7..811bb91889 100644 --- a/programs/network/ircc/socket.inc +++ b/programs/network/ircc/socket.inc @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; Written by hidnplayr@kolibrios.org ;; @@ -210,7 +210,7 @@ socket_receive: pusha -; TODO: read more data if we receive one full packet +; FIXME: make this a proper stream! .nextpacket: mcall recv, [socketnum], packetbuf, 1024, MSG_DONTWAIT ; read a packet @@ -219,30 +219,33 @@ socket_receive: dec eax jz .disconnected -; ok we have data, now feed it to the recoder +; ok we have data, now feed it to the command splicer - lea edx, [packetbuf + eax] ; edx = end pointer + mov ecx, eax mov esi, packetbuf ; esi = start pointer .nextcommand: mov edi, servercommand .byteloop: - call get_next_byte ; reads byte from [esi] to al - jnc .nextpacket ; if CF is set, we need more data (TODO: dont throw away old data!!!) + lodsb cmp al, 10 je .got_command cmp al, 13 je .got_command stosb - jmp .byteloop + dec ecx + jnz .byteloop + ;;; FIXME + jmp .nextpacket ; we have a command, call the serverparser .got_command: mov byte[edi], 0 ; mark the end of the command - push esi edx + push esi ecx call server_parser - pop edx esi - jmp .nextcommand + pop ecx esi + test ecx, ecx + jnz .nextcommand .done: popa diff --git a/programs/network/ircc/textbox.inc b/programs/network/ircc/textbox.inc index 7d0fa3a3df..d25a3c252e 100644 --- a/programs/network/ircc/textbox.inc +++ b/programs/network/ircc/textbox.inc @@ -11,7 +11,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -text_insert_newlines: ; esi = ASCIIZ string +text_insert_newlines: ; esi = ASCIIZ string xor edx, edx ; number of lines of text cmp byte[esi], 0 @@ -24,6 +24,8 @@ text_insert_newlines: ; esi = ASCIIZ string dec ecx jz .end_of_line lodsb ; get one character of the string + test al, 0x80 + jnz .multiball! test al, al ; end of string? jz .almost_done cmp al, ' ' ; it's a space! remember its position @@ -52,6 +54,20 @@ text_insert_newlines: ; esi = ASCIIZ string ret + .multiball!: + add esi, 4 + and al, 11111000b + cmp al, 11110000b + je .more + dec esi + and al, 11110000b + cmp al, 11100000b + je .more + dec esi + jmp .more + + + ;---------------------------------- ; scan untill next line is reached ; @@ -180,8 +196,8 @@ draw_channel_text: ; Is scrollbar at lowest position? test [edi + window.flags], FLAG_SCROLL_LOW - jnz .yesscroll ;Yes - cmp [scroll2.all_redraw], 1 ;No + jnz .yesscroll ; Yes + cmp [scroll2.all_redraw], 1 ; No jnz .noscroll mov edx, [textbox_height] add edx, [edi + window.text_line_print] @@ -245,11 +261,45 @@ draw_channel_text: .no_offset: xor ebx, ebx .draw_text: + ; Prepare to actually draw some text - mov eax, [textbox_height] ; max number of lines to draw - add ebx, TEXT_X shl 16 + TEXT_Y - mov ecx, [colors.work_text] ; default text color - mov edx, [edi + window.text_print] + add ebx, TEXT_X shl 16 + TEXT_Y ; text coordinates + mov ecx, [colors.work_text] ; default text color + or ecx, 0x30000000 + mov edx, [edi + window.text_print] ; start of text to print + +; Scan backwards on line for color escape codes + mov esi, edx + push edx + std + @@: + lodsb + cmp al, 0 ; end of text + je @f + cmp al, 10 ; hard newline + je @f + cmp al, 3 ; mIRC escape code + jne @b + + cld + lea edx, [esi+2] + call dec_to_esi + jz @f + mov ecx, [irc_colors + 4*esi] + or ecx, 0x30000000 ; UTF-8 text + + cmp byte[edx], ',' ; background color? + jne @f + inc edx + call dec_to_esi + jz @f + mov edi, [irc_colors + 4*esi] + or ecx, 0x40000000 ; enable background color + @@: + cld + + pop edx + mov eax, [textbox_height] ; max number of lines to draw .drawloop: cmp byte[edx], 0 je .end_of_text @@ -263,30 +313,29 @@ draw_channel_text: mov bx, word[textbox_width] imul bx, FONT_WIDTH mov edx, [colors.work] - mcall 13 ; draw rectangle + mcall 13 ; draw rectangle popa - mov esi, edx - add esi, [textbox_width] + push eax + mov esi, [textbox_width] .line: cmp byte[edx], 0 je .end_of_text - cmp byte[edx], 13 je .newline_soft - cmp byte[edx], 10 je .newline_hard - push esi eax - cmp byte[edx], 3 ; escape code for mIRC colors + push esi + cmp byte[edx], 3 ; escape code for mIRC colors jne .no_colors inc edx call dec_to_esi jz .no_colors mov ecx, [irc_colors + 4*esi] + or ecx, 0x30000000 - cmp byte[edx], ',' ; background color? + cmp byte[edx], ',' ; background color? jne .no_colors inc edx call dec_to_esi @@ -296,21 +345,39 @@ draw_channel_text: .no_colors: mov esi, 1 - mcall 4 ; draw text + mcall 4 ; draw text + + mov esi, 1 + mov al, byte[edx] + test al, 10000000b + jz @f + mov esi, 4 + and al, 11111000b + cmp al, 11110000b + je @f + dec esi + and al, 11110000b + cmp al, 11100000b + je @f + dec esi + @@: + add ebx, FONT_WIDTH shl 16 - inc edx - pop eax esi - cmp edx, esi - jb .line + add edx, esi + pop esi + dec esi + jnz .line jmp .line_full .newline_hard: mov ecx, [colors.work_text] + or ecx, 0x30000000 .newline_soft: inc edx .line_full: and ebx, 0x0000ffff add ebx, TEXT_X shl 16 + FONT_HEIGHT + pop eax dec eax jnz .drawloop .end_of_text: diff --git a/programs/network/ircc/userparser.inc b/programs/network/ircc/userparser.inc index c59642918d..60f37882d9 100644 --- a/programs/network/ircc/userparser.inc +++ b/programs/network/ircc/userparser.inc @@ -440,6 +440,7 @@ cmd_usr_part: cmd_usr_close_window: mov esi, [window_active] + mov [window_print], esi cmp [esi + window.type], WINDOWTYPE_SERVER je .not_channel diff --git a/programs/network/ircc/window.inc b/programs/network/ircc/window.inc index 094fd79a8b..c56c07dff5 100644 --- a/programs/network/ircc/window.inc +++ b/programs/network/ircc/window.inc @@ -76,7 +76,7 @@ window_set_name: stosb push esi ebx - call draw_windowtabs + call draw_window_tabs pop ebx esi ret @@ -107,7 +107,7 @@ window_close: ; closes the 'print' window jne @f sub edi, sizeof.window mov [window_active], edi - mov [window_print], edi ;;;;;;;; + mov [window_print], edi @@: ; At last, redraw everything