From e48064d090292659c30c9ce3c286af867d3784bd Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Fri, 1 Jan 2016 21:01:59 +0000 Subject: [PATCH] IRCc 0.24: Make better use of available space on screen. git-svn-id: svn://kolibrios.org@6023 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/network/ircc/build.bat | 6 - programs/network/ircc/gui.inc | 58 +- programs/network/ircc/ircc.asm | 772 ++++++++++++++------------- programs/network/ircc/textbox.inc | 474 ++++++++-------- programs/network/ircc/userparser.inc | 2 +- programs/network/ircc/users.inc | 2 +- programs/network/ircc/window.inc | 224 ++++---- 7 files changed, 765 insertions(+), 773 deletions(-) delete mode 100644 programs/network/ircc/build.bat diff --git a/programs/network/ircc/build.bat b/programs/network/ircc/build.bat deleted file mode 100644 index e004609da8..0000000000 --- a/programs/network/ircc/build.bat +++ /dev/null @@ -1,6 +0,0 @@ -@erase lang.inc -@echo lang fix en >lang.inc -@fasm -m 16384 ircc.asm ircc -@kpack ircc -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network/ircc/gui.inc b/programs/network/ircc/gui.inc index a8d587af83..34737269cf 100644 --- a/programs/network/ircc/gui.inc +++ b/programs/network/ircc/gui.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 ;; @@ -11,7 +11,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - draw_window: ; Completely redraw the window, recalculate all coordinates and sizes pusha @@ -53,25 +52,14 @@ draw_window: ; Completely redraw the window, recalculate all coordinates and add edx, 0x33000000 mov edi, str_programname mcall - mcall 12, 2 - - test [thread_info.wnd_state], 100b ; skip if window rolled up - jne .exit - - mov ebx, [xsize] - mov ecx, [ysize] - sub cx, BOTTOM_Y ;;;; - push cx - shl ecx, 16 - pop cx - mov edx, [colors.work_graph] - mcall 38 ; draw bottom line - mov ecx, TOP_Y SHL 16 + TOP_Y - mcall ; draw top line + mcall 12, 2 + + test [thread_info.wnd_state], 100b ; skip if window is rolled up + jne .exit ; calculate available space for textbox and coordinates for scrollbars mov eax, [ysize] - sub eax, TOP_Y + BOTTOM_Y - 1 ;;;; + sub eax, TOP_Y + INPUTBOX_HEIGHT - 1 ;;;; mov [scroll2.y_size], ax mov [scroll1.y_size], ax sub eax, 4 ;;;; @@ -137,14 +125,14 @@ draw_window: ; Completely redraw the window, recalculate all coordinates and shl ebx, 16 pop bx mov ecx, [ysize] - add ecx, TOP_Y shl 16 - (BOTTOM_Y) + add ecx, TOP_Y shl 16 - (INPUTBOX_HEIGHT) mov edx, [colors.work_graph] mcall 38 .not_channel: ; draw editbox mov eax, [ysize] - sub eax, 13 ;;;;;; + sub eax, INPUTBOX_HEIGHT mov [edit1.top], eax mov eax, [xsize] @@ -267,11 +255,18 @@ draw_channel_list: draw_windowtabs: +; Draw horizontal line + + mov ebx, [xsize] + mov edx, [colors.work_graph] + mov ecx, TOP_Y SHL 16 + TOP_Y + mcall 38 + ; Create the buttons mov eax, 8 - mov ebx, 5 shl 16 + 120 - mov ecx, 12 shl 16 + 12 + mov ebx, TAB_WIDTH + mov ecx, TOP_SPACE shl 16 + TAB_HEIGHT mov edx, WINDOW_BTN_START mov edi, windows .more_btn: @@ -283,23 +278,22 @@ draw_windowtabs: @@: mcall inc edx - add ebx, 125 shl 16 + add ebx, (TAB_WIDTH + TAB_SPACE) shl 16 add edi, sizeof.window cmp [edi + window.data_ptr], 0 jne .more_btn ; Draw the close window button - mov edi, [window_active] cmp [edi + window.type], WINDOWTYPE_SERVER ; dont let the user close server window je @f ; mov eax, 8 mov ebx, [xsize] - sub ebx, 12 + sub ebx, SCROLLBAR_WIDTH shl ebx, 16 - mov bx, 12 - mov ecx, 6 shl 16 + 12 + mov bx, SCROLLBAR_WIDTH + mov ecx, TOP_SPACE shl 16 + TAB_HEIGHT - 1 mov edx, WINDOW_BTN_CLOSE mov esi, 0x00aa0000 ; red ! mcall @@ -308,14 +302,14 @@ draw_windowtabs: ; Draw the windownames onto the buttons mov eax, 4 - mov ebx, 10 shl 16 + 15 + mov ebx, 5 shl 16 + TOP_SPACE + 4 ;;;; mov esi, MAX_WINDOWS mov edi, windows .more: mov ecx, [colors.work_button_text] test [edi + window.flags], FLAG_UPDATED jz @f - mov ecx, 0x00aa0000 ; RED! + mov ecx, 0x00aa0000 ; RED! @@: or ecx, 0x80000000 ; ASCIIZ string lea edx, [edi + window.name] @@ -323,7 +317,7 @@ draw_windowtabs: add edi, sizeof.window ; get ptr to next window cmp [edi + window.data_ptr], 0 je .enough - add ebx, 125 shl 16 + add ebx, (TAB_WIDTH + TAB_SPACE) shl 16 dec esi jnz .more .enough: @@ -334,7 +328,7 @@ draw_windowtabs: highlight_updated_tabs: mov eax, 4 - mov ebx, 10 shl 16 + 15 + mov ebx, 5 shl 16 + TOP_SPACE + 4 ;;;; mov ecx, 0x80aa0000 mov esi, MAX_WINDOWS mov edi, windows @@ -347,7 +341,7 @@ highlight_updated_tabs: add edi, sizeof.window ; get ptr to next window cmp [edi + window.data_ptr], 0 je .enough_ - add ebx, 125 shl 16 + add ebx, (TAB_WIDTH + TAB_SPACE) shl 16 dec esi jnz .more_ .enough_: diff --git a/programs/network/ircc/ircc.asm b/programs/network/ircc/ircc.asm index 7d1957638a..639f5bf704 100644 --- a/programs/network/ircc/ircc.asm +++ b/programs/network/ircc/ircc.asm @@ -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 ;; ;; ;; ;; IRC client for KolibriOS ;; @@ -13,85 +13,89 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -version equ '0.23' +version equ '0.24' ; connection status -STATUS_DISCONNECTED = 0 -STATUS_RESOLVING = 1 -STATUS_CONNECTING = 2 -STATUS_CONNECTED = 3 +STATUS_DISCONNECTED = 0 +STATUS_RESOLVING = 1 +STATUS_CONNECTING = 2 +STATUS_CONNECTED = 3 ; window flags -FLAG_UPDATED = 1 shl 0 -FLAG_RECEIVING_NAMES = 1 shl 1 -FLAG_SCROLL_LOW = 1 shl 2 +FLAG_UPDATED = 1 shl 0 +FLAG_RECEIVING_NAMES = 1 shl 1 +FLAG_SCROLL_LOW = 1 shl 2 ; window types -WINDOWTYPE_NONE = 0 -WINDOWTYPE_SERVER = 1 -WINDOWTYPE_CHANNEL = 2 -WINDOWTYPE_CHAT = 3 -WINDOWTYPE_LIST = 4 -WINDOWTYPE_DCC = 5 +WINDOWTYPE_NONE = 0 +WINDOWTYPE_SERVER = 1 +WINDOWTYPE_CHANNEL = 2 +WINDOWTYPE_CHAT = 3 +WINDOWTYPE_LIST = 4 +WINDOWTYPE_DCC = 5 ; supported encodings -CP866 = 0 -CP1251 = 1 -UTF8 = 2 +CP866 = 0 +CP1251 = 1 +UTF8 = 2 ; settings -USERCMD_MAX_SIZE = 400 +USERCMD_MAX_SIZE = 400 -WIN_MIN_X = 600 -WIN_MIN_Y = 170 +WIN_MIN_X = 600 +WIN_MIN_Y = 170 -TEXT_X = 5 -TEXT_Y = TOP_Y + 2 +TEXT_X = 5 +TEXT_Y = TOP_Y + 2 -TOP_Y = 24 -BOTTOM_Y = 15 +TOP_SPACE = 2 +TAB_HEIGHT = 14 +TAB_WIDTH = 120 +TAB_SPACE = 5 +TOP_Y = TOP_SPACE+ TAB_HEIGHT +INPUTBOX_HEIGHT = 13 -MAX_WINDOWS = 20 -MAX_USERS = 4096 -TEXT_BUFFERSIZE = 1024*1024 +MAX_WINDOWS = 20 +MAX_USERS = 4096 +TEXT_BUFFERSIZE = 1024*1024 -MAX_NICK_LEN = 32 -MAX_REAL_LEN = 32 ; realname -MAX_SERVER_NAME = 256 +MAX_NICK_LEN = 32 +MAX_REAL_LEN = 32 ; realname +MAX_SERVER_NAME = 256 -MAX_CHANNEL_LEN = 40 -MAX_CHANNELS = 37 +MAX_CHANNEL_LEN = 40 +MAX_CHANNELS = 37 -MAX_COMMAND_LEN = 512 +MAX_COMMAND_LEN = 512 -TIMESTAMP = 3 ; 3 = hh:mm:ss, 2 = hh:mm, 0 = no timestamp +TIMESTAMP = 3 ; 3 = hh:mm:ss, 2 = hh:mm, 0 = no timestamp -MAX_WINDOWNAME_LEN = 256 +MAX_WINDOWNAME_LEN = 256 -WINDOW_BTN_START = 100 -WINDOW_BTN_CLOSE = 2 -WINDOW_BTN_LIST = 3 +WINDOW_BTN_START = 100 +WINDOW_BTN_CLOSE = 2 +WINDOW_BTN_LIST = 3 -SCROLLBAR_WIDTH = 14 -USERLIST_WIDTH = 100 +SCROLLBAR_WIDTH = 14 +USERLIST_WIDTH = 100 -FONT_HEIGHT = 9 -FONT_WIDTH = 6 +FONT_HEIGHT = 9 +FONT_WIDTH = 6 format binary as "" use32 - org 0x0 + org 0x0 - db 'MENUET01' ; 8 byte id - dd 1 ; header version - dd START ; program start - dd I_END ; program image size - dd IM_END+2048 ; required amount of memory - dd IM_END+2048 - dd param - dd path + db 'MENUET01' ; 8 byte id + dd 1 ; header version + dd START ; program start + dd I_END ; program image size + dd IM_END+2048 ; required amount of memory + dd IM_END+2048 + dd param + dd path include "../../macros.inc" include "../../proc32.inc" @@ -100,28 +104,28 @@ include "../../network.inc" include "../../struct.inc" include "../../develop/libraries/box_lib/trunk/box_lib.mac" -struct window - data_ptr dd ? - flags db ? - type db ? - name rb MAX_WINDOWNAME_LEN - users dd ? - users_scroll dd ? - selected dd ? ; selected user, 0 if none selected +struct window + data_ptr dd ? + flags db ? + type db ? + name rb MAX_WINDOWNAME_LEN + users dd ? + users_scroll dd ? + selected dd ? ; selected user, 0 if none selected - text_start dd ? ; pointer to current textbox data - text_end dd ? - text_print dd ? ; pointer to first character to print on screen - text_line_print dd ? ; line number of that character - text_write dd ? ; write pointer - text_lines dd ? ; total number of lines - text_scanned dd ? ; pointer to beginning of unscanned data (we still need to count number of lines, insert newline characters,..) + text_start dd ? ; pointer to current textbox data + text_end dd ? + text_print dd ? ; pointer to first character to print on screen + text_line_print dd ? ; line number of that character + text_write dd ? ; write pointer + text_lines dd ? ; total number of lines + text_scanned dd ? ; pointer to beginning of unscanned data (we still need to count number of lines, insert newline characters,..) ends -struct window_data - text rb TEXT_BUFFERSIZE - names rb MAX_NICK_LEN * MAX_USERS +struct window_data + text rb TEXT_BUFFERSIZE + names rb MAX_NICK_LEN * MAX_USERS ends include "encodings.inc" @@ -136,220 +140,220 @@ include "textbox.inc" START: - mcall 68, 11 ; init heap so we can allocate memory dynamically + mcall 68, 11 ; init heap so we can allocate memory dynamically ; wanted events - mcall 40, EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_STACK+EVM_MOUSE+EVM_MOUSE_FILTER + mcall 40, EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_STACK+EVM_MOUSE+EVM_MOUSE_FILTER ; load libraries - stdcall dll.Load, @IMPORT - test eax, eax - jnz exit + stdcall dll.Load, @IMPORT + test eax, eax + jnz exit ; find path to main settings file (ircc.ini) - mov edi, path ; Calculate the length of zero-terminated string - xor al, al - mov ecx, 1024 - repne scasb - dec edi - mov eax, '.ini' - stosd - xor al, al - stosb + mov edi, path ; Calculate the length of zero-terminated string + xor al, al + mov ecx, 1024 + repne scasb + dec edi + mov eax, '.ini' + stosd + xor al, al + stosb ; Fill the window buffer with zeros - mov edi, windows - mov ecx, (sizeof.window*MAX_WINDOWS+3)/4 - xor eax, eax - rep stosd + mov edi, windows + mov ecx, (sizeof.window*MAX_WINDOWS+3)/4 + xor eax, eax + rep stosd ; clear command area too - mov edi, servercommand - mov ecx, 600/4 - rep stosd + mov edi, servercommand + mov ecx, 600/4 + rep stosd ; allocate window data block - mov ebx, windows - call window_create_textbox - test eax, eax - jz error - mov [ebx + window.type], WINDOWTYPE_SERVER + mov ebx, windows + call window_create_textbox + test eax, eax + jz error + mov [ebx + window.type], WINDOWTYPE_SERVER ; get system colors - mcall 48, 3, colors, 40 + mcall 48, 3, colors, 40 ; set edit box and scrollbar colors - mov eax, [colors.work] - mov [scroll1.bg_color], eax - mov [scroll2.bg_color], eax + mov eax, [colors.work] + mov [scroll1.bg_color], eax + mov [scroll2.bg_color], eax - mov eax, [colors.work_button] - mov [scroll1.front_color], eax - mov [scroll2.front_color], eax + mov eax, [colors.work_button] + mov [scroll1.front_color], eax + mov [scroll2.front_color], eax - mov eax, [colors.work_text] - mov [scroll1.line_color], eax - mov [scroll2.line_color], eax + mov eax, [colors.work_text] + mov [scroll1.line_color], eax + mov [scroll2.line_color], eax - mov [scroll1.type], 1 ; 0 = simple, 1 = skinned - mov [scroll2.type], 1 + mov [scroll1.type], 1 ; 0 = simple, 1 = skinned + mov [scroll2.type], 1 ; get settings from ini - invoke ini.get_str, path, str_user, str_nick, user_nick, MAX_NICK_LEN, default_nick - invoke ini.get_str, path, str_user, str_real, user_real_name, MAX_REAL_LEN, default_real - invoke ini.get_str, path, str_user, str_quitmsg, quit_msg, 250, default_quit + invoke ini.get_str, path, str_user, str_nick, user_nick, MAX_NICK_LEN, default_nick + invoke ini.get_str, path, str_user, str_real, user_real_name, MAX_REAL_LEN, default_real + invoke ini.get_str, path, str_user, str_quitmsg, quit_msg, 250, default_quit ; Welcome user - mov esi, str_welcome - call print_asciiz + mov esi, str_welcome + call print_asciiz ; Check if parameter contains an URL - cmp byte[param], 0 - je @f - mov esi, param - mov ecx, 1024 - call cmd_usr_server.now + cmp byte[param], 0 + je @f + mov esi, param + mov ecx, 1024 + call cmd_usr_server.now @@: ; Draw window a first time, so we can figure out skin size - call draw_window + call draw_window redraw: - call draw_window + call draw_window mainloop: - mcall 10 ; wait for event + mcall 10 ; wait for event - dec eax - jz redraw + dec eax + jz redraw - dec eax - jz main_window_key + dec eax + jz main_window_key - dec eax - jz button + dec eax + jz button - cmp al, 3 - je mouse + cmp al, 3 + je mouse - call process_network_event + call process_network_event - mov edi, [window_active] - test [edi + window.flags], FLAG_UPDATED - jz .no_update - call draw_channel_text - mov edi, [window_active] - cmp [edi + window.type], WINDOWTYPE_CHANNEL - jne .no_update - call draw_channel_list + mov edi, [window_active] + test [edi + window.flags], FLAG_UPDATED + jz .no_update + call draw_channel_text + mov edi, [window_active] + cmp [edi + window.type], WINDOWTYPE_CHANNEL + jne .no_update + call draw_channel_list .no_update: - call highlight_updated_tabs + call highlight_updated_tabs - jmp mainloop + jmp mainloop button: - mcall 17 ; get id - ror eax, 8 + mcall 17 ; get id + ror eax, 8 - cmp ax, 1 ; close program - je exit + cmp ax, 1 ; close program + je exit - cmp ax, WINDOW_BTN_CLOSE - jne @f - call cmd_usr_close_window - jmp mainloop + cmp ax, WINDOW_BTN_CLOSE + jne @f + call cmd_usr_close_window + jmp mainloop @@: - cmp ax, WINDOW_BTN_LIST - jne @f + cmp ax, WINDOW_BTN_LIST + jne @f - push eax + push eax - mcall 37, 1 ; Get mouse position - sub ax, TEXT_Y - mov bl, FONT_HEIGHT - div bl - and eax, 0x000000ff - inc eax - add eax, [scroll1.position] - mov ebx, [window_active] - mov [ebx + window.selected], eax + mcall 37, 1 ; Get mouse position + sub ax, TEXT_Y + mov bl, FONT_HEIGHT + div bl + and eax, 0x000000ff + inc eax + add eax, [scroll1.position] + mov ebx, [window_active] + mov [ebx + window.selected], eax - call draw_channel_list + call draw_channel_list - pop eax - test eax, 1 shl 25 ; Right mouse button pressed? - jz mainloop + pop eax + test eax, 1 shl 25 ; Right mouse button pressed? + jz mainloop ; TODO: check if selected nick is my nick! ; Right mouse BTN was pressed, open chat window - mov ebx, [window_active] - mov eax, [ebx + window.selected] - dec eax - imul eax, MAX_NICK_LEN - mov ebx, [ebx + window.data_ptr] - lea esi, [ebx + window_data.names + eax] - call window_open - test ebx, ebx - jz mainloop - mov [window_active], ebx - call redraw + mov ebx, [window_active] + mov eax, [ebx + window.selected] + dec eax + imul eax, MAX_NICK_LEN + mov ebx, [ebx + window.data_ptr] + lea esi, [ebx + window_data.names + eax] + call window_open + test ebx, ebx + jz mainloop + mov [window_active], ebx + call redraw - jmp mainloop + jmp mainloop @@: - sub ax, WINDOW_BTN_START - jb exit + sub ax, WINDOW_BTN_START + jb exit - cmp ax, MAX_WINDOWS - ja exit + cmp ax, MAX_WINDOWS + ja exit ; Save users scrollbar position - push [scroll1.position] - mov edx, [window_active] - pop [edx + window.users_scroll] + push [scroll1.position] + mov edx, [window_active] + pop [edx + window.users_scroll] ; OK, time to switch to another window. - mov dx, sizeof.window - mul dx - shl edx, 16 - mov dx, ax - add edx, windows - cmp [edx + window.type], WINDOWTYPE_NONE - je exit - mov [window_active], edx + mov dx, sizeof.window + mul dx + shl edx, 16 + mov dx, ax + add edx, windows + cmp [edx + window.type], WINDOWTYPE_NONE + je exit + mov [window_active], edx - push [edx + window.text_line_print] - pop [scroll2.position] + push [edx + window.text_line_print] + pop [scroll2.position] - push [edx + window.users_scroll] - pop [scroll1.position] + push [edx + window.users_scroll] + pop [scroll1.position] - call draw_window - jmp mainloop + call draw_window + jmp mainloop exit: - cmp [socketnum], 0 - je @f - mov esi, quit_msg - call quit_server + cmp [socketnum], 0 + je @f + mov esi, quit_msg + call quit_server @@: error: - mcall -1 + mcall -1 main_window_key: - mcall 2 + mcall 2 - push dword edit1 - call [edit_box_key] + push dword edit1 + call [edit_box_key] ; cmp ah, 178 ; jne .no_up @@ -364,251 +368,251 @@ main_window_key: ; jmp mainloop ; ; .no_down: - cmp ah, 13 ; enter - jne no_send2 + cmp ah, 13 ; enter + jne no_send2 - call user_parser + call user_parser - mov eax, [edit1.size] + mov eax, [edit1.size] - mov [edit1.size], 0 - mov [edit1.pos], 0 + mov [edit1.size], 0 + mov [edit1.pos], 0 - push dword edit1 - call [edit_box_draw] + push dword edit1 + call [edit_box_draw] - call draw_channel_text + call draw_channel_text - jmp mainloop + jmp mainloop no_send2: - jmp mainloop + jmp mainloop mouse: - push dword edit1 - call [edit_box_mouse] + push dword edit1 + call [edit_box_mouse] ; mcall 37, 7 ; movsx eax, ax ; add [scroll2.position], eax ; TODO: check if scrollbar is active? - mov edi, [window_active] - cmp [edi + window.type], WINDOWTYPE_CHANNEL - jne @f - push [scroll1.position] - push dword scroll1 - call [scrollbar_mouse] - pop eax - cmp eax, [scroll1.position] ; did the scrollbar move? - je @f - call draw_channel_list + mov edi, [window_active] + cmp [edi + window.type], WINDOWTYPE_CHANNEL + jne @f + push [scroll1.position] + push dword scroll1 + call [scrollbar_mouse] + pop eax + cmp eax, [scroll1.position] ; did the scrollbar move? + je @f + call draw_channel_list @@: ; TODO: check if scrollbar is active? - mov edi, [window_active] - mov eax, [edi + window.text_lines] - cmp eax, [textbox_height] - jbe @f - push dword scroll2 - call [scrollbar_mouse] - mov edi, [window_active] - and [edi+window.flags], not FLAG_SCROLL_LOW - mov edx, [scroll2.position] - add edx, [scroll2.cur_area] - sub edx, [scroll2.max_area] - jne .not_low - or [edi+window.flags], FLAG_SCROLL_LOW + mov edi, [window_active] + mov eax, [edi + window.text_lines] + cmp eax, [textbox_height] + jbe @f + push dword scroll2 + call [scrollbar_mouse] + mov edi, [window_active] + and [edi+window.flags], not FLAG_SCROLL_LOW + mov edx, [scroll2.position] + add edx, [scroll2.cur_area] + sub edx, [scroll2.max_area] + jne .not_low + or [edi+window.flags], FLAG_SCROLL_LOW .not_low: - mov edx, [scroll2.position] - sub edx, [edi + window.text_line_print] - je @f - call draw_channel_text.scroll_to_pos + mov edx, [scroll2.position] + sub edx, [edi + window.text_line_print] + je @f + call draw_channel_text.scroll_to_pos @@: - jmp mainloop + jmp mainloop ; DATA AREA encoding_text: -db 'CP866 ' -db 'CP1251' -db 'UTF-8 ' +db 'CP866 ' +db 'CP1251' +db 'UTF-8 ' encoding_text_len = 6 -join_header db 3, '3* ', 0 -quit_header db 3, '5* ', 0 -nick_header db 3, '2* ', 0 -kick_header db 3, '5* ', 0 -mode_header db 3, '2* ', 0 -part_header db 3, '5* ', 0 -topic_header db 3, '3* ', 0 -action_header db 3, '6* ', 0 -ctcp_header db 3, '13-> [', 0 -msg_header db 3, '7-> *', 0 -ctcp_version db '] VERSION', 10, 0 -ctcp_ping db '] PING', 10, 0 -ctcp_time db '] TIME', 10, 0 +join_header db 3, '3* ', 0 +quit_header db 3, '5* ', 0 +nick_header db 3, '2* ', 0 +kick_header db 3, '5* ', 0 +mode_header db 3, '2* ', 0 +part_header db 3, '5* ', 0 +topic_header db 3, '3* ', 0 +action_header db 3, '6* ', 0 +ctcp_header db 3, '13-> [', 0 +msg_header db 3, '7-> *', 0 +ctcp_version db '] VERSION', 10, 0 +ctcp_ping db '] PING', 10, 0 +ctcp_time db '] TIME', 10, 0 -has_left_channel db ' has left ', 0 -joins_channel db ' has joined ', 0 -is_now_known_as db ' is now known as ', 0 -has_quit_irc db ' has quit IRC', 10, 0 +has_left_channel db ' has left ', 0 +joins_channel db ' has joined ', 0 +is_now_known_as db ' is now known as ', 0 +has_quit_irc db ' has quit IRC', 10, 0 -sets_mode db ' sets mode ', 0 -str_kicked db ' is kicked from ', 0 -str_by db ' by ', 0 -str_nickchange db 'Nickname is now ', 0 -str_realchange db 'Real name is now ', 0 -str_talking db 'Now talking in ', 0 -str_topic db 'Topic is "', 0 -str_topic_end db '"', 10, 0 -str_setby db 'Set by ', 0 +sets_mode db ' sets mode ', 0 +str_kicked db ' is kicked from ', 0 +str_by db ' by ', 0 +str_nickchange db 'Nickname is now ', 0 +str_realchange db 'Real name is now ', 0 +str_talking db 'Now talking in ', 0 +str_topic db 'Topic is "', 0 +str_topic_end db '"', 10, 0 +str_setby db 'Set by ', 0 -str_connecting db 3, '3* Connecting to ', 0 -str_sockerr db 3, '5* Socket error', 10, 0 -str_dnserr db 3, '5* Unable to resolve hostname', 10, 0 -str_refused db 3, '5* Connection refused', 10, 0 -str_srv_disconnected db 3, '5* Server disconnected', 10, 0 -str_disconnected db 3, '5* Disconnected', 10, 0 -str_reconnect db 3, '5* Connection reset by user', 10, 0 -str_notconnected db 3, '5* Not connected to server', 10, 0 -str_notchannel db 3, '5* You are not on a channel', 10, 0 +str_connecting db 3, '3* Connecting to ', 0 +str_sockerr db 3, '5* Socket error', 10, 0 +str_dnserr db 3, '5* Unable to resolve hostname', 10, 0 +str_refused db 3, '5* Connection refused', 10, 0 +str_srv_disconnected db 3, '5* Server disconnected', 10, 0 +str_disconnected db 3, '5* Disconnected', 10, 0 +str_reconnect db 3, '5* Connection reset by user', 10, 0 +str_notconnected db 3, '5* Not connected to server', 10, 0 +str_notchannel db 3, '5* You are not on a channel', 10, 0 -str_1 db 3, '13 -', 0 -str_2 db '- ', 0 +str_1 db 3, '13 -', 0 +str_2 db '- ', 0 -str_list db 'list', 0 +str_list db 'list', 0 -str_help db 'The following commands are available:', 10 - db 10 - db '/nick : change nickname', 10 - db '/real : change real name', 10 - db '/server
: connect to server', 10 - db '/code : change codepage (cp866, cp1251, or utf8)', 10 - db '/join : join a channel', 10 - db '/part : part from a channel', 10 - db '/quit : quit server', 10 - db '/msg : send a private message', 10 - db '/ctcp : send a message using client to client protocol', 10 - db 10 - db 'Other commands are send straight to server.', 10 - db 10, 0 +str_help db 'The following commands are available:', 10 + db 10 + db '/nick : change nickname', 10 + db '/real : change real name', 10 + db '/server
: connect to server', 10 + db '/code : change codepage (cp866, cp1251, or utf8)', 10 + db '/join : join a channel', 10 + db '/part : part from a channel', 10 + db '/quit : quit server', 10 + db '/msg : send a private message', 10 + db '/ctcp : send a message using client to client protocol', 10 + db 10 + db 'Other commands are send straight to server.', 10 + db 10, 0 -str_welcome 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 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 the KolibriOS IRC client v', version, 10 - db 10 - db 'Type /help for help', 10, 10, 0 +str_welcome 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 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 -str_version db 'VERSION ' -str_programname db 'KolibriOS IRC client v', version, 0 +str_version db 'VERSION KolibriOS ' +str_programname db 'IRC client ', version, 0 -str_user db 'user', 0 -str_nick db 'nick', 0 -str_real db 'realname', 0 -str_email db 'email', 0 -str_quitmsg db 'quitmsg', 0 +str_user db 'user', 0 +str_nick db 'nick', 0 +str_real db 'realname', 0 +str_email db 'email', 0 +str_quitmsg db 'quitmsg', 0 -default_nick db 'kolibri_user', 0 -default_real db 'Kolibri User', 0 -default_quit db 'KolibriOS forever', 0 +default_nick db 'kolibri_user', 0 +default_real db 'Kolibri User', 0 +default_quit db 'KolibriOS forever', 0 -irc_colors dd 0xffffff ; 0 white - dd 0x000000 ; 1 black - dd 0x00007f ; 2 blue (navy) - dd 0x009300 ; 3 green - dd 0xff0000 ; 4 red - dd 0x7f0000 ; 5 brown (maroon) - dd 0x9c009c ; 6 purple - dd 0xfc7f00 ; 7 olive - dd 0xffff00 ; 8 yellow - dd 0x00fc00 ; 9 light green - dd 0x009393 ; 10 teal - dd 0x00ffff ; 11 cyan - dd 0x0000fc ; 12 royal blue - dd 0xff00ff ; 13 pink - dd 0x7f7f7f ; 14 grey - dd 0xd4d0c4 ; 15 light grey (silver) +irc_colors dd 0xffffff ; 0 white + dd 0x000000 ; 1 black + dd 0x00007f ; 2 blue (navy) + dd 0x009300 ; 3 green + dd 0xff0000 ; 4 red + dd 0x7f0000 ; 5 brown (maroon) + dd 0x9c009c ; 6 purple + dd 0xfc7f00 ; 7 olive + dd 0xffff00 ; 8 yellow + dd 0x00fc00 ; 9 light green + dd 0x009393 ; 10 teal + dd 0x00ffff ; 11 cyan + dd 0x0000fc ; 12 royal blue + dd 0xff00ff ; 13 pink + dd 0x7f7f7f ; 14 grey + dd 0xd4d0c4 ; 15 light grey (silver) sockaddr1: - dw AF_INET4 -.port dw 0x0b1a ; 6667 FIXMEEEEEE -.ip dd 0 - rb 10 + dw AF_INET4 +.port dw 0x0b1a ; 6667 FIXMEEEEEE +.ip dd 0 + rb 10 -status dd STATUS_DISCONNECTED +status dd STATUS_DISCONNECTED -window_active dd windows -window_print dd windows +window_active dd windows +window_print dd windows align 4 @IMPORT: -library network, 'network.obj',\ - libini, 'libini.obj',\ - boxlib, 'box_lib.obj' +library network, 'network.obj',\ + libini, 'libini.obj',\ + boxlib, 'box_lib.obj' -import network,\ - getaddrinfo, 'getaddrinfo',\ - freeaddrinfo, 'freeaddrinfo',\ - inet_ntoa, 'inet_ntoa' +import network,\ + getaddrinfo, 'getaddrinfo',\ + freeaddrinfo, 'freeaddrinfo',\ + inet_ntoa, 'inet_ntoa' -import libini,\ - ini.get_str, 'ini_get_str',\ - ini.get_int, 'ini_get_int' +import libini,\ + ini.get_str, 'ini_get_str',\ + ini.get_int, 'ini_get_int' -import boxlib,\ - edit_box_draw, 'edit_box',\ - edit_box_key, 'edit_box_key',\ - edit_box_mouse, 'edit_box_mouse',\ - scrollbar_draw, 'scrollbar_v_draw',\ - scrollbar_mouse,'scrollbar_v_mouse' +import boxlib,\ + edit_box_draw, 'edit_box',\ + edit_box_key, 'edit_box_key',\ + edit_box_mouse, 'edit_box_mouse',\ + scrollbar_draw, 'scrollbar_v_draw',\ + 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 - ; xsize, xpos, ysize, ypos, btn_height, max, cur, pos, bgcol, frcol, linecol + ; 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 + ; 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 -usercommand db '/server chat.freenode.net', 0 - rb MAX_COMMAND_LEN +usercommand db '/server chat.freenode.net', 0 + rb MAX_COMMAND_LEN I_END: -utf8_bytes_rest dd ? ; bytes rest in current UTF8 sequence -utf8_char dd ? ; first bits of current UTF8 character +utf8_bytes_rest dd ? ; bytes rest in current UTF8 sequence +utf8_char dd ? ; first bits of current UTF8 character -packetbuf rb 1024 ; buffer for packets to server -path rb 1024 -param rb 1024 +packetbuf rb 1024 ; buffer for packets to server +path rb 1024 +param rb 1024 -servercommand rb 600 +servercommand rb 600 -thread_info process_information -xsize dd ? -ysize dd ? -mouse_dd dd ? +thread_info process_information +xsize dd ? +ysize dd ? +mouse_dd dd ? -textbox_height dd ? ; in characters -textbox_width dd ? ; in characters, not pixels ;) +textbox_height dd ? ; in characters +textbox_width dd ? ; in characters, not pixels ;) -colors system_colors +colors system_colors -irc_server_name rb MAX_SERVER_NAME ; TODO: move this server URL into window struct -socketnum dd ? ; TODO: same for socket +irc_server_name rb MAX_SERVER_NAME ; TODO: move this server URL into window struct +socketnum dd ? ; TODO: same for socket -user_nick rb MAX_NICK_LEN -user_real_name rb MAX_REAL_LEN -quit_msg rb 250 +user_nick rb MAX_NICK_LEN +user_real_name rb MAX_REAL_LEN +quit_msg rb 250 -windows rb MAX_WINDOWS*sizeof.window +windows rb MAX_WINDOWS*sizeof.window IM_END: \ No newline at end of file diff --git a/programs/network/ircc/textbox.inc b/programs/network/ircc/textbox.inc index 7397d571fa..7d0fa3a3df 100644 --- a/programs/network/ircc/textbox.inc +++ b/programs/network/ircc/textbox.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 ;; @@ -13,44 +13,44 @@ text_insert_newlines: ; esi = ASCIIZ string - xor edx, edx ; number of lines of text - cmp byte[esi], 0 - je .done + xor edx, edx ; number of lines of text + cmp byte[esi], 0 + je .done .next_line: - xor ebx, ebx - mov ecx, [textbox_width] - inc ecx + xor ebx, ebx + mov ecx, [textbox_width] + inc ecx .more: - dec ecx - jz .end_of_line - lodsb ; get one character of the string - test al, al ; end of string? - jz .almost_done - cmp al, ' ' ; it's a space! remember its position - je .space - cmp al, 13 ; we already inserted a newline once, make it a space again - je .soft_nl - cmp al, 10 ; it's a newline, continue onto the next line - jne .more - inc edx - jmp .next_line + dec ecx + jz .end_of_line + lodsb ; get one character of the string + test al, al ; end of string? + jz .almost_done + cmp al, ' ' ; it's a space! remember its position + je .space + cmp al, 13 ; we already inserted a newline once, make it a space again + je .soft_nl + cmp al, 10 ; it's a newline, continue onto the next line + jne .more + inc edx + jmp .next_line .soft_nl: - mov byte[esi-1], ' ' + mov byte[esi-1], ' ' .space: - mov ebx, esi ; last detected space - jmp .more + mov ebx, esi ; last detected space + jmp .more .end_of_line: - inc edx - test ebx, ebx ; did we detect any spaces on this line? - jz .next_line ; no: just continue onto the next line - mov byte[ebx-1], 13 ; yes: replace last space on line with a soft newline - mov esi, ebx ; and continue parsing just after last space - jmp .next_line ; + inc edx + test ebx, ebx ; did we detect any spaces on this line? + jz .next_line ; no: just continue onto the next line + mov byte[ebx-1], 13 ; yes: replace last space on line with a soft newline + mov esi, ebx ; and continue parsing just after last space + jmp .next_line ; .almost_done: - dec esi + dec esi .done: - ret + ret ;---------------------------------- ; scan untill next line is reached @@ -61,20 +61,20 @@ text_insert_newlines: ; esi = ASCIIZ string ;---------------------------------- text_nextline: - mov ecx, [textbox_width] + mov ecx, [textbox_width] .loop: - lodsb - test al, al - jz .done - cmp al, 10 - je .done - cmp al, 13 - je .done - dec ecx - jnz .loop + lodsb + test al, al + jz .done + cmp al, 10 + je .done + cmp al, 13 + je .done + dec ecx + jnz .loop .done: - ret + ret ;---------------------------------- @@ -86,21 +86,21 @@ text_nextline: ;---------------------------------- print_string: - push eax + push eax .loop: - lodsb - cmp al, bl - je .done - cmp al, 13 - je .loop - test al, al - jz .done - call print_char - jmp .loop + lodsb + cmp al, bl + je .done + cmp al, 13 + je .loop + test al, al + jz .done + call print_char + jmp .loop .done: - pop eax + pop eax - ret + ret ;---------------------------------- @@ -111,17 +111,17 @@ print_string: ;---------------------------------- print_asciiz: - push eax + push eax .loop: - lodsb - test al, al - jz .done - call print_char - jmp .loop + lodsb + test al, al + jz .done + call print_char + jmp .loop .done: - pop eax + pop eax - ret + ret ;---------------------------------- @@ -132,252 +132,252 @@ print_asciiz: ;---------------------------------- print_char: - push esi edi - mov esi, [window_print] - mov edi, [esi + window.text_write] - stosb - cmp edi, [esi + window.text_end] - jae .uh_ow - mov [esi + window.text_write], edi + push esi edi + mov esi, [window_print] + mov edi, [esi + window.text_write] + stosb + cmp edi, [esi + window.text_end] + jae .uh_ow + mov [esi + window.text_write], edi .continue: - or [esi + window.flags], FLAG_UPDATED - pop edi esi + or [esi + window.flags], FLAG_UPDATED + pop edi esi - ret + ret .uh_ow: - pusha - mov edi, [esi + window.text_start] - mov [esi + window.text_print], edi - lea esi, [edi + TEXT_BUFFERSIZE/2] - call text_nextline - mov ecx, TEXT_BUFFERSIZE/8 - rep movsd - mov esi, edi - call text_insert_newlines + pusha + mov edi, [esi + window.text_start] + mov [esi + window.text_print], edi + lea esi, [edi + TEXT_BUFFERSIZE/2] + call text_nextline + mov ecx, TEXT_BUFFERSIZE/8 + rep movsd + mov esi, edi + call text_insert_newlines - mov ebx, [window_print] - mov [ebx + window.text_lines], edx - mov [ebx + window.text_scanned], esi - mov [ebx + window.text_write], esi - mov [ebx + window.text_line_print], 0 - popa + mov ebx, [window_print] + mov [ebx + window.text_lines], edx + mov [ebx + window.text_scanned], esi + mov [ebx + window.text_write], esi + mov [ebx + window.text_line_print], 0 + popa - jmp .continue + jmp .continue draw_channel_text: - mov edi, [window_active] - and [edi + window.flags], not FLAG_UPDATED ; clear the 'window is updated' flag + mov edi, [window_active] + and [edi + window.flags], not FLAG_UPDATED ; clear the 'window is updated' flag ; Scan new text for newlines - mov esi, [edi + window.text_scanned] - call text_insert_newlines - add [edi + window.text_lines], edx - mov [edi + window.text_scanned], esi + mov esi, [edi + window.text_scanned] + call text_insert_newlines + add [edi + window.text_lines], edx + mov [edi + window.text_scanned], esi ; Is scrollbar at lowest position? - test [edi + window.flags], FLAG_SCROLL_LOW - jnz .yesscroll ;Yes - cmp [scroll2.all_redraw], 1 ;No - jnz .noscroll - mov edx, [textbox_height] - add edx, [edi + window.text_line_print] + test [edi + window.flags], FLAG_SCROLL_LOW + jnz .yesscroll ;Yes + cmp [scroll2.all_redraw], 1 ;No + jnz .noscroll + mov edx, [textbox_height] + add edx, [edi + window.text_line_print] cmp edx, [edi + window.text_lines] - jl .noscroll + jl .noscroll .yesscroll: ; Scrollbar was at lowest position, scroll down automatically when new text arrived. - mov edx, [edi + window.text_lines] - sub edx, [textbox_height] - jle .noscroll ; There are less lines of text than fit into the window, dont scroll.. - sub edx, [edi + window.text_line_print] - je .noscroll ; We are already at the bottom pos, dont scroll.. - .scroll_to_pos: ; edx = number of lines to go up/down (flags must indicate direction) - pushf - add [edi + window.text_line_print], edx - mov esi, [edi + window.text_print] - popf - ja .loop_forward - std ; set direction flag so we can scan backwards - dec esi - dec esi ; move our cursor just in front of newline, for scanning backwards + mov edx, [edi + window.text_lines] + sub edx, [textbox_height] + jle .noscroll ; There are less lines of text than fit into the window, dont scroll.. + sub edx, [edi + window.text_line_print] + je .noscroll ; We are already at the bottom pos, dont scroll.. + .scroll_to_pos: ; edx = number of lines to go up/down (flags must indicate direction) + pushf + add [edi + window.text_line_print], edx + mov esi, [edi + window.text_print] + popf + ja .loop_forward + std ; set direction flag so we can scan backwards + dec esi + dec esi ; move our cursor just in front of newline, for scanning backwards .loop_backward: - call text_nextline - inc edx - jnz .loop_backward - inc esi - inc esi ; move the cursor just after last newline - cld - jmp .ok + call text_nextline + inc edx + jnz .loop_backward + inc esi + inc esi ; move the cursor just after last newline + cld + jmp .ok .loop_forward: - call text_nextline - dec edx - jnz .loop_forward + call text_nextline + dec edx + jnz .loop_forward .ok: - mov [edi + window.text_print], esi + mov [edi + window.text_print], esi .noscroll: ; Update and draw scrollbar when nescessary - mov edx, [edi + window.text_lines] - cmp edx, [textbox_height] - jbe .scroll_done + mov edx, [edi + window.text_lines] + cmp edx, [textbox_height] + jbe .scroll_done - mov [scroll2.max_area], edx - mov eax, [edi + window.text_line_print] - mov [scroll2.position], eax + mov [scroll2.max_area], edx + mov eax, [edi + window.text_line_print] + mov [scroll2.position], eax - push dword scroll2 ; redraw scrollbar - call [scrollbar_draw] - mov [scroll2.all_redraw], 0 ; next time, dont redraw it completely + push dword scroll2 ; redraw scrollbar + call [scrollbar_draw] + mov [scroll2.all_redraw], 0 ; next time, dont redraw it completely .scroll_done: ; Calculate start offset coordinates (align text to bottom) - mov ebx, [textbox_height] - sub ebx, [edi + window.text_lines] - jb .no_offset - imul ebx, FONT_HEIGHT - push [edi + window.text_start] - pop [edi + window.text_print] - jmp .draw_text + mov ebx, [textbox_height] + sub ebx, [edi + window.text_lines] + jb .no_offset + imul ebx, FONT_HEIGHT + push [edi + window.text_start] + pop [edi + window.text_print] + jmp .draw_text .no_offset: - xor ebx, ebx + 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] + 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] .drawloop: - cmp byte[edx], 0 - je .end_of_text + cmp byte[edx], 0 + je .end_of_text ; Clear one row of characters - pusha - mov cx, bx - shl ecx, 16 - mov cx, FONT_HEIGHT - mov ebx, TEXT_X shl 16 - mov bx, word[textbox_width] - imul bx, FONT_WIDTH - mov edx, [colors.work] - mcall 13 ; draw rectangle - popa + pusha + mov cx, bx + shl ecx, 16 + mov cx, FONT_HEIGHT + mov ebx, TEXT_X shl 16 + mov bx, word[textbox_width] + imul bx, FONT_WIDTH + mov edx, [colors.work] + mcall 13 ; draw rectangle + popa - mov esi, edx - add esi, [textbox_width] + mov esi, edx + add esi, [textbox_width] .line: - cmp byte[edx], 0 - je .end_of_text + cmp byte[edx], 0 + je .end_of_text - cmp byte[edx], 13 - je .newline_soft + cmp byte[edx], 13 + je .newline_soft - cmp byte[edx], 10 - je .newline_hard + cmp byte[edx], 10 + je .newline_hard - push esi eax - 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] + push esi eax + 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] - cmp byte[edx], ',' ; background color? - jne .no_colors - inc edx - call dec_to_esi - jz .no_colors - mov edi, [irc_colors + 4*esi] - or ecx, 0x40000000 + cmp byte[edx], ',' ; background color? + jne .no_colors + inc edx + call dec_to_esi + jz .no_colors + mov edi, [irc_colors + 4*esi] + or ecx, 0x40000000 .no_colors: - mov esi, 1 - mcall 4 ; draw text - add ebx, FONT_WIDTH shl 16 - inc edx - pop eax esi - cmp edx, esi - jb .line - jmp .line_full + mov esi, 1 + mcall 4 ; draw text + add ebx, FONT_WIDTH shl 16 + inc edx + pop eax esi + cmp edx, esi + jb .line + jmp .line_full .newline_hard: - mov ecx, [colors.work_text] + mov ecx, [colors.work_text] .newline_soft: - inc edx + inc edx .line_full: - and ebx, 0x0000ffff - add ebx, TEXT_X shl 16 + FONT_HEIGHT - dec eax - jnz .drawloop + and ebx, 0x0000ffff + add ebx, TEXT_X shl 16 + FONT_HEIGHT + dec eax + jnz .drawloop .end_of_text: - ret + ret dec_to_esi: - xor esi, esi + xor esi, esi .loop: - movzx eax, byte[edx] - sub al, '0' - jb .done - cmp al, 9 - ja .done - inc edx - lea esi, [esi*4 + esi] ; esi * 5 - lea esi, [esi*2 + eax] ; esi * 2 + eax - jmp .loop + movzx eax, byte[edx] + sub al, '0' + jb .done + cmp al, 9 + ja .done + inc edx + lea esi, [esi*4 + esi] ; esi * 5 + lea esi, [esi*2 + eax] ; esi * 2 + eax + jmp .loop .done: - cmp esi, 16 - jae .fail - ret + cmp esi, 16 + jae .fail + ret .fail: - xor esi, esi - ret + xor esi, esi + ret if TIMESTAMP print_timestamp: - pusha - mcall 3 ; get system time - mov ebx, eax + pusha + mcall 3 ; get system time + mov ebx, eax - mov al, '[' - call print_char - mov ecx, TIMESTAMP + mov al, '[' + call print_char + mov ecx, TIMESTAMP .loop: - mov al, bl - shr al, 4 - add al, '0' - call print_char + mov al, bl + shr al, 4 + add al, '0' + call print_char - mov al, bl - and al, 0x0f - add al, '0' - call print_char + mov al, bl + and al, 0x0f + add al, '0' + call print_char - dec ecx - jz .done + dec ecx + jz .done - mov al, ':' - call print_char - shr ebx, 8 - jmp .loop + mov al, ':' + call print_char + shr ebx, 8 + jmp .loop .done: - mov al, ']' - call print_char - mov al, ' ' - call print_char + mov al, ']' + call print_char + mov al, ' ' + call print_char - popa - ret + popa + ret end if \ No newline at end of file diff --git a/programs/network/ircc/userparser.inc b/programs/network/ircc/userparser.inc index e619fe3a0a..c59642918d 100644 --- a/programs/network/ircc/userparser.inc +++ b/programs/network/ircc/userparser.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 ;; diff --git a/programs/network/ircc/users.inc b/programs/network/ircc/users.inc index e92dfb1b06..9806cedf71 100644 --- a/programs/network/ircc/users.inc +++ b/programs/network/ircc/users.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 ;; diff --git a/programs/network/ircc/window.inc b/programs/network/ircc/window.inc index deda67e108..094fd79a8b 100644 --- a/programs/network/ircc/window.inc +++ b/programs/network/ircc/window.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 ;; @@ -19,36 +19,36 @@ window_create_textbox: - push ebx + push ebx ; allocate the window data block - mcall 68, 12, sizeof.window_data - test eax, eax - pop ebx - jz .fail + mcall 68, 12, sizeof.window_data + test eax, eax + pop ebx + jz .fail ; fill it with all zeros - push eax - mov edi, eax - mov ecx, (sizeof.window_data+3)/4 - xor eax, eax - rep stosd - pop eax + push eax + mov edi, eax + mov ecx, (sizeof.window_data+3)/4 + xor eax, eax + rep stosd + pop eax - mov [ebx + window.data_ptr], eax - mov [ebx + window.flags], FLAG_SCROLL_LOW + mov [ebx + window.data_ptr], eax + mov [ebx + window.flags], FLAG_SCROLL_LOW - add eax, window_data.text+2 ; let text begin at offset 2, this way the text will be prepended with two null bytes - mov [ebx + window.text_start], eax - mov [ebx + window.text_print], eax - mov [ebx + window.text_write], eax - mov [ebx + window.text_scanned], eax - mov [ebx + window.text_lines], 0 - mov [ebx + window.text_line_print], 0 - add eax, TEXT_BUFFERSIZE-1 - mov [ebx + window.text_end], eax + add eax, window_data.text+2 ; let text begin at offset 2, this way the text will be prepended with two null bytes + mov [ebx + window.text_start], eax + mov [ebx + window.text_print], eax + mov [ebx + window.text_write], eax + mov [ebx + window.text_scanned], eax + mov [ebx + window.text_lines], 0 + mov [ebx + window.text_line_print], 0 + add eax, TEXT_BUFFERSIZE-1 + mov [ebx + window.text_end], eax .fail: - ret + ret ; window_set_name @@ -62,58 +62,58 @@ window_create_textbox: window_set_name: - lea edi, [ebx + window.name] - mov ecx, MAX_WINDOWNAME_LEN + lea edi, [ebx + window.name] + mov ecx, MAX_WINDOWNAME_LEN .loop: - lodsb - cmp al, 0x21 ; name ends with 0, space or ! - jbe .addzero - stosb - dec ecx - jnz .loop + lodsb + cmp al, 0x21 ; name ends with 0, space or ! + jbe .addzero + stosb + dec ecx + jnz .loop .addzero: - xor al, al - stosb + xor al, al + stosb - push esi ebx - call draw_windowtabs - pop ebx esi + push esi ebx + call draw_windowtabs + pop ebx esi - ret + ret -window_close: ; closes the 'print' window +window_close: ; closes the 'print' window ; Remove the window (overwrite current structure with trailing ones) - mov edi, [window_print] - push [edi + window.data_ptr] ; remember data ptr so we can free it later - lea esi, [edi + sizeof.window] - mov ecx, windows + MAX_WINDOWS*sizeof.window - sub ecx, esi - rep movsb + mov edi, [window_print] + push [edi + window.data_ptr] ; remember data ptr so we can free it later + lea esi, [edi + sizeof.window] + mov ecx, windows + MAX_WINDOWS*sizeof.window + sub ecx, esi + rep movsb ; Completely zero the trailing window block (there will always be one!) - mov ecx, sizeof.window - xor al, al - rep stosb + mov ecx, sizeof.window + xor al, al + rep stosb ; free the window data block - pop ecx - mcall 68, 13 + pop ecx + mcall 68, 13 ; We closed this window so we need to show another - mov edi, [window_active] - cmp [edi + window.data_ptr], 0 - jne @f - sub edi, sizeof.window - mov [window_active], edi - mov [window_print], edi ;;;;;;;; + mov edi, [window_active] + cmp [edi + window.data_ptr], 0 + jne @f + sub edi, sizeof.window + mov [window_active], edi + mov [window_print], edi ;;;;;;;; @@: ; At last, redraw everything - call draw_window + call draw_window - ret + ret ; window_find: @@ -125,33 +125,33 @@ window_close: ; closes the 'print' window window_find: - mov ebx, windows - mov eax, MAX_WINDOWS + mov ebx, windows + mov eax, MAX_WINDOWS .scanloop: - push esi - cmp [ebx + window.type], WINDOWTYPE_NONE - je .try_next - lea edi, [ebx + window.name] - mov ecx, MAX_WINDOWNAME_LEN - repe cmpsb - cmp byte[edi-1], 0 ; last equall character was null? yes, the strings match! - je .got_it - cmp byte[edi], 0 ; we're at the end of string1.. ? - jne .try_next - cmp byte[esi], 0x21 ; and the end of string2? yes! - jbe .got_it + push esi + cmp [ebx + window.type], WINDOWTYPE_NONE + je .try_next + lea edi, [ebx + window.name] + mov ecx, MAX_WINDOWNAME_LEN + repe cmpsb + cmp byte[edi-1], 0 ; last equall character was null? yes, the strings match! + je .got_it + cmp byte[edi], 0 ; we're at the end of string1.. ? + jne .try_next + cmp byte[esi], 0x21 ; and the end of string2? yes! + jbe .got_it .try_next: - pop esi - add ebx, sizeof.window - dec eax - jnz .scanloop + pop esi + add ebx, sizeof.window + dec eax + jnz .scanloop - xor ebx, ebx - ret + xor ebx, ebx + ret .got_it: - add esp, 4 - ret + add esp, 4 + ret @@ -166,48 +166,48 @@ window_find: window_open: ; Skip heading spaces - lodsb - cmp al, ' ' - je window_open - cmp al, ':' - je window_open - dec esi + lodsb + cmp al, ' ' + je window_open + cmp al, ':' + je window_open + dec esi - call window_find - test ebx, ebx - jnz .got_it + call window_find + test ebx, ebx + jnz .got_it ; create channel window - search for empty slot .create_it: - mov ebx, windows - mov ecx, MAX_WINDOWS + mov ebx, windows + mov ecx, MAX_WINDOWS .scanloop2: - cmp [ebx + window.type], WINDOWTYPE_NONE - je .free_found - add ebx, sizeof.window - dec ecx - jnz .scanloop2 - jmp .error + cmp [ebx + window.type], WINDOWTYPE_NONE + je .free_found + add ebx, sizeof.window + dec ecx + jnz .scanloop2 + jmp .error .free_found: - call window_create_textbox - test eax, eax - jz .error - mov [ebx + window.type], WINDOWTYPE_CHAT ; FIXME: let caller handle this ? + call window_create_textbox + test eax, eax + jz .error + mov [ebx + window.type], WINDOWTYPE_CHAT ; FIXME: let caller handle this ? - call window_set_name + call window_set_name .got_it: - lodsb - cmp al, ' ' - je .got_it - cmp al, ':' - je .got_it - dec esi + lodsb + cmp al, ' ' + je .got_it + cmp al, ':' + je .got_it + dec esi - mov [window_print], ebx - ret + mov [window_print], ebx + ret .error: - xor ebx, ebx - ret \ No newline at end of file + xor ebx, ebx + ret \ No newline at end of file