13,7 → 13,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
version equ '0.1' |
version equ '0.15' |
|
; connection status |
STATUS_DISCONNECTED = 0 |
23,15 → 23,15 |
|
; window flags |
FLAG_UPDATED = 1 shl 0 |
FLAG_CLOSE = 1 shl 1 |
FLAG_RECEIVING_NAMES = 1 shl 2 |
FLAG_RECEIVING_NAMES = 1 shl 1 |
|
; window types |
WINDOWTYPE_SERVER = 0 |
WINDOWTYPE_CHANNEL = 1 |
WINDOWTYPE_CHAT = 2 |
WINDOWTYPE_LIST = 3 |
WINDOWTYPE_DCC = 4 |
WINDOWTYPE_NONE = 0 |
WINDOWTYPE_SERVER = 1 |
WINDOWTYPE_CHANNEL = 2 |
WINDOWTYPE_CHAT = 3 |
WINDOWTYPE_LIST = 4 |
WINDOWTYPE_DCC = 5 |
|
; supported encodings |
CP866 = 0 |
42,15 → 42,17 |
USERCMD_MAX_SIZE = 400 |
|
WIN_MIN_X = 600 |
WIN_MIN_Y = 165 |
WIN_MIN_Y = 170 |
|
TEXT_X = 5 |
TEXT_Y = 30 |
TEXT_Y = TOP_Y + 2 |
|
TOP_Y = 25 |
TOP_Y = 24 |
BOTTOM_Y = 15 |
|
MAX_WINDOWS = 20 |
MAX_USERS = 4096 |
TEXT_BUFFERSIZE = 4096;*1024 |
|
MAX_NICK_LEN = 32 |
MAX_REAL_LEN = 32 ; realname |
69,12 → 71,12 |
WINDOW_BTN_CLOSE = 2 |
WINDOW_BTN_LIST = 3 |
|
SCROLLBAR_WIDTH = 12 |
SCROLLBAR_WIDTH = 14 |
USERLIST_WIDTH = 100 |
|
USERLIST_X = 98 |
FONT_HEIGHT = 9 |
FONT_WIDTH = 6 |
|
TEXTBOX_LINES = 12 |
|
format binary as "" |
|
use32 |
98,7 → 100,7 |
include '../../develop/libraries/box_lib/trunk/box_lib.mac' |
|
struct window |
data_ptr dd ? ; zero if not used |
data_ptr dd ? |
flags db ? |
type db ? |
name rb MAX_WINDOWNAME_LEN |
105,18 → 107,24 |
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,..) |
|
ends |
|
struct window_data |
text rb 120*60 |
title rb 256 |
text rb TEXT_BUFFERSIZE |
names rb MAX_NICK_LEN * MAX_USERS |
usertext rb 256 |
usertextlen dd ? |
ends |
|
include "encodings.inc" |
include "window.inc" ; also contains text print routines |
include "window.inc" |
include "serverparser.inc" |
include "userparser.inc" |
include "socket.inc" |
160,14 → 168,12 |
rep stosd |
|
; allocate window data block |
mov ebx, windows |
call window_create |
mov ebx, windows |
mov [ebx + window.data_ptr], eax |
mov [ebx + window.flags], 0 |
test eax, eax |
jz error |
mov [ebx + window.type], WINDOWTYPE_SERVER |
|
call window_refresh |
|
; get system colors |
mcall 48, 3, colors, 40 |
|
174,13 → 180,19 |
; set edit box and scrollbar colors |
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_text] |
mov [scroll1.line_color], eax |
mov [scroll2.line_color], eax |
|
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 |
190,13 → 202,12 |
mov esi, str_welcome |
call print_text2 |
|
call draw_window ;;; FIXME (gui is not correctly drawn first time because of window sizes) |
call draw_window ; Draw window a first time, so we can figure out skin size |
|
redraw: |
call draw_window |
|
still: |
|
; wait here for event |
mcall 10 |
|
214,15 → 225,15 |
|
call process_network_event |
|
mov edx, [window_active] |
test [edx + window.flags], FLAG_UPDATED |
mov edi, [window_active] |
test [edi + window.flags], FLAG_UPDATED |
jz .no_update |
and [edx + window.flags], not FLAG_UPDATED |
mov edx, [edx + window.data_ptr] |
add edx, window_data.text |
call draw_channel_text |
mov edi, [window_active] |
cmp [edi + window.type], WINDOWTYPE_CHANNEL |
jne .no_update |
call draw_channel_list |
.no_update: |
call print_channel_list |
|
jmp still |
|
236,8 → 247,7 |
|
cmp ax, WINDOW_BTN_CLOSE |
jne @f |
|
call window_close |
call cmd_usr_close_window |
jmp still |
|
@@: |
248,7 → 258,7 |
|
mcall 37, 1 ; Get mouse position |
sub ax, TEXT_Y |
mov bl, 10 |
mov bl, FONT_HEIGHT |
div bl |
and eax, 0x000000ff |
inc eax |
256,7 → 266,7 |
mov ebx, [window_active] |
mov [ebx + window.selected], eax |
|
call print_channel_list |
call draw_channel_list |
|
pop eax |
test eax, 1 shl 25 ; Right mouse button pressed? |
283,15 → 293,17 |
cmp ax, MAX_WINDOWS |
ja exit |
|
; 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.data_ptr], 0 |
cmp [edx + window.type], WINDOWTYPE_NONE |
je exit |
mov [window_active], edx |
call window_refresh |
|
mov [scroll2.position], 1 ;;; FIXME |
call draw_window |
|
jmp still |
304,6 → 316,8 |
call cmd_usr_quit_server |
@@: |
|
error: |
|
mcall -1 |
|
|
315,11 → 329,26 |
push dword edit1 |
call [edit_box_key] |
|
; cmp ah, 178 |
; jne .no_up |
; |
; jmp still |
; |
; |
; .no_up: |
; cmp ah, 177 |
; jne .no_down |
; |
; jmp still |
; |
; .no_down: |
cmp ah, 13 ; enter |
jne no_send2 |
|
call user_parser |
|
mov eax, [edit1.size] |
|
mov [edit1.size], 0 |
mov [edit1.pos], 0 |
|
326,9 → 355,6 |
push dword edit1 |
call [edit_box_draw] |
|
mov edx, [window_active] |
mov edx, [edx + window.data_ptr] |
add edx, window_data.text |
call draw_channel_text |
|
jmp still |
340,16 → 366,33 |
push dword edit1 |
call [edit_box_mouse] |
|
; TODO: check if scrollbar is active |
; 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_v_mouse] |
call [scrollbar_mouse] |
pop eax |
cmp eax, [scroll1.position] ; did the scrollbar move? |
je @f |
call print_channel_list |
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] |
mov edx, [scroll2.position] |
sub edx, [edi + window.text_line_print] |
je @f |
call draw_channel_text.scroll_to_pos |
@@: |
|
jmp still |
|
|
361,9 → 404,16 |
db 'UTF-8 ' |
encoding_text_len = 6 |
|
action_header db '*** ', 0 |
action_header_short db '* ', 0 |
ctcp_header db '-> [',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 |
376,6 → 426,7 |
str_talking db 'Now talking in ',0 |
str_topic db 'Topic is ',0 |
str_setby db 'Set by ',0 |
str_reconnect db 'Connection reset by user.',10,0 |
|
str_version db 'VERSION ' |
str_programname db 'KolibriOS IRC client ', version, 0 |
390,23 → 441,22 |
default_real db 'Kolibri User', 0 |
default_quit db 'KolibriOS forever', 0 |
|
str_welcome db 10 |
db ' ______________________ __ __ __',10 |
db '| \______ \_ ___ \ ____ | | |__| ____ _____/ |_',10 |
db '| || _/ \ \/ _/ ___\| | | |/ __ \ / \ __\',10 |
db '| || | \ \____ \ \___| |_| \ ___/| | \ |',10 |
db '|___||____|_ /\______ / \___ >____/__|\___ >___| /__|',10 |
db ' \/ \/ \/ \/ \/',10 |
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 IRC client ',version,' for KolibriOS',10 |
db 'Welcome to the KolibriOS IRC client v',version,10 |
db 10 |
db 'Type /help for help',10,0 |
db 'Type /help for help',10,10,0 |
|
str_nickchange db 'Nickname is now ',0 |
str_realchange db 'Real name is now ',0 |
str_dotnewline db '.',10, 0 |
str_newline db 10, 0 |
str_connecting db 10,'* Connecting to ',0 |
str_connecting db 3,'3* Connecting to ',0 |
str_help db 10,'following commands are available:',10 |
db 10 |
db '/nick <nick> : change nickname to <nick>',10 |
414,7 → 464,7 |
db '/server <address> : connect to server <address>',10 |
db '/code <code> : change codepage to cp866, cp1251, or utf8',10,0 |
|
str_1 db ' -',0 |
str_1 db 3,'13 -',0 |
str_2 db '- ',0 |
|
str_sockerr db 'Socket Error',10,0 |
421,6 → 471,23 |
str_dnserr db 'Unable to resolve hostname.',10,0 |
str_refused db 'Connection refused',10,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) |
|
sockaddr1: |
dw AF_INET4 |
.port dw 0x0b1a ; 6667 |
430,10 → 497,10 |
|
status dd STATUS_DISCONNECTED |
|
text_start dd ? ; pointer to current textbox data |
textbox_width dd 80 ; in characters, not pixels ;) |
text_pos dd ? ; text writing cursor |
|
textbox_height dd 12 ; in characters |
textbox_width dd 78 ; in characters, not pixels ;) |
|
window_active dd windows |
window_print dd windows |
|
457,21 → 524,20 |
edit_box_draw ,'edit_box' ,\ |
edit_box_key ,'edit_box_key' ,\ |
edit_box_mouse ,'edit_box_mouse' ,\ |
scrollbar_v_draw ,'scrollbar_v_draw' ,\ |
scrollbar_v_mouse,'scrollbar_v_mouse' |
scrollbar_draw, 'scrollbar_v_draw',\ |
scrollbar_mouse,'scrollbar_v_mouse' |
|
I_END: |
|
; width, left, top |
edit1 edit_box 0, 0, 0, 0xffffff, 0x6f9480, 0, 0, 0, USERCMD_MAX_SIZE, usercommand, mouse_dd, ed_focus, 25, 25 |
; xsize, xpos, ysize, ypos, max, cur, pos, bgcol, frcol, linecol |
scroll1 scrollbar SCROLLBAR_WIDTH, 300, 150, TOP_Y, 10, 100, 0, 0, 0, 0, 0, 1 |
scroll2 scrollbar SCROLLBAR_WIDTH, 300, 150, TOP_Y, 10, 100, 0, 0, 0, 0, 0, 1 |
; 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 |
|
main_PID dd ? ; identifier of main thread |
utf8_bytes_rest dd ? ; bytes rest in current UTF8 sequence |
utf8_char dd ? ; first bits of current UTF8 character |
gai_reqdata rb 32 ; buffer for getaddrinfo_start/process |