2013-05-28 19:34:26 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2024-02-23 17:55:00 +01:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2024. All rights reserved. ;;
|
2013-05-28 19:34:26 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;; IRC client for KolibriOS ;;
|
|
|
|
;; ;;
|
|
|
|
;; Written by hidnplayr@kolibrios.org, ;;
|
|
|
|
;; text encoder/decoder by Clevermouse. ;;
|
|
|
|
;; ;;
|
|
|
|
;; GNU GENERAL PUBLIC LICENSE ;;
|
|
|
|
;; Version 2, June 1991 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2024-03-05 10:49:00 +01:00
|
|
|
version equ '0.36'
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
; connection status
|
2016-01-01 22:01:59 +01:00
|
|
|
STATUS_DISCONNECTED = 0
|
|
|
|
STATUS_RESOLVING = 1
|
|
|
|
STATUS_CONNECTING = 2
|
|
|
|
STATUS_CONNECTED = 3
|
2016-01-03 15:50:44 +01:00
|
|
|
STATUS_LOGGED_IN = 4
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
; window flags
|
2016-01-01 22:01:59 +01:00
|
|
|
FLAG_UPDATED = 1 shl 0
|
|
|
|
FLAG_RECEIVING_NAMES = 1 shl 1
|
|
|
|
FLAG_SCROLL_LOW = 1 shl 2
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
; window types
|
2016-01-01 22:01:59 +01:00
|
|
|
WINDOWTYPE_NONE = 0
|
|
|
|
WINDOWTYPE_SERVER = 1
|
|
|
|
WINDOWTYPE_CHANNEL = 2
|
|
|
|
WINDOWTYPE_CHAT = 3
|
|
|
|
WINDOWTYPE_LIST = 4
|
|
|
|
WINDOWTYPE_DCC = 5
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
; supported encodings
|
2016-01-01 22:01:59 +01:00
|
|
|
CP866 = 0
|
|
|
|
CP1251 = 1
|
|
|
|
UTF8 = 2
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
; settings
|
2016-01-01 22:01:59 +01:00
|
|
|
USERCMD_MAX_SIZE = 400
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
WIN_MIN_X = 600
|
2016-01-02 22:03:09 +01:00
|
|
|
WIN_MIN_Y = 183
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-02 22:03:09 +01:00
|
|
|
TEXT_X = 2
|
2016-01-01 22:01:59 +01:00
|
|
|
TEXT_Y = TOP_Y + 2
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
TOP_SPACE = 2
|
|
|
|
TAB_HEIGHT = 14
|
|
|
|
TAB_WIDTH = 120
|
|
|
|
TAB_SPACE = 5
|
|
|
|
TOP_Y = TOP_SPACE+ TAB_HEIGHT
|
|
|
|
INPUTBOX_HEIGHT = 13
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
MAX_WINDOWS = 20
|
|
|
|
MAX_USERS = 4096
|
|
|
|
TEXT_BUFFERSIZE = 1024*1024
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
MAX_NICK_LEN = 32
|
|
|
|
MAX_REAL_LEN = 32 ; realname
|
2018-07-01 16:29:23 +02:00
|
|
|
QUIT_MSG_LEN = 250
|
2016-01-01 22:01:59 +01:00
|
|
|
MAX_SERVER_NAME = 256
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
MAX_CHANNEL_LEN = 40
|
|
|
|
MAX_CHANNELS = 37
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
MAX_COMMAND_LEN = 512
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2018-07-01 16:29:23 +02:00
|
|
|
PACKETBUF_SIZE = 1024
|
|
|
|
PATH_SIZE = 1024
|
|
|
|
PARAM_SIZE = 1024
|
|
|
|
SERVERCOMMAND_SIZE = 600
|
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
TIMESTAMP = 3 ; 3 = hh:mm:ss, 2 = hh:mm, 0 = no timestamp
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
MAX_WINDOWNAME_LEN = 256
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
WINDOW_BTN_START = 100
|
|
|
|
WINDOW_BTN_CLOSE = 2
|
|
|
|
WINDOW_BTN_LIST = 3
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
SCROLLBAR_WIDTH = 14
|
2016-01-02 22:03:09 +01:00
|
|
|
USERLIST_WIDTH = 160
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-02 22:03:09 +01:00
|
|
|
FONT_WIDTH = 8
|
|
|
|
FONT_HEIGHT = 16
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
format binary as ""
|
|
|
|
|
|
|
|
use32
|
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
org 0x0
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
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
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2013-06-07 19:26:03 +02:00
|
|
|
include "../../macros.inc"
|
|
|
|
include "../../proc32.inc"
|
|
|
|
include "../../dll.inc"
|
|
|
|
include "../../network.inc"
|
|
|
|
include "../../struct.inc"
|
2014-01-18 16:51:43 +01:00
|
|
|
include "../../develop/libraries/box_lib/trunk/box_lib.mac"
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
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,..)
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
ends
|
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
struct window_data
|
|
|
|
text rb TEXT_BUFFERSIZE
|
|
|
|
names rb MAX_NICK_LEN * MAX_USERS
|
2013-05-28 19:34:26 +02:00
|
|
|
ends
|
|
|
|
|
|
|
|
include "encodings.inc"
|
2013-11-01 15:02:08 +01:00
|
|
|
include "window.inc"
|
2013-05-28 19:34:26 +02:00
|
|
|
include "serverparser.inc"
|
|
|
|
include "userparser.inc"
|
|
|
|
include "socket.inc"
|
|
|
|
include "gui.inc"
|
|
|
|
include "users.inc"
|
2013-10-20 20:47:47 +02:00
|
|
|
include "textbox.inc"
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
START:
|
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
mcall 68, 11 ; init heap so we can allocate memory dynamically
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
; wanted events
|
2016-01-01 22:01:59 +01:00
|
|
|
mcall 40, EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_STACK+EVM_MOUSE+EVM_MOUSE_FILTER
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
; load libraries
|
2016-01-01 22:01:59 +01:00
|
|
|
stdcall dll.Load, @IMPORT
|
|
|
|
test eax, eax
|
|
|
|
jnz exit
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
; find path to main settings file (ircc.ini)
|
2016-01-01 22:01:59 +01:00
|
|
|
mov edi, path ; Calculate the length of zero-terminated string
|
|
|
|
xor al, al
|
2018-07-01 16:29:23 +02:00
|
|
|
mov ecx, PATH_SIZE
|
2016-01-01 22:01:59 +01:00
|
|
|
repne scasb
|
|
|
|
dec edi
|
|
|
|
mov eax, '.ini'
|
|
|
|
stosd
|
|
|
|
xor al, al
|
|
|
|
stosb
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
; Fill the window buffer with zeros
|
2016-01-01 22:01:59 +01:00
|
|
|
mov edi, windows
|
|
|
|
mov ecx, (sizeof.window*MAX_WINDOWS+3)/4
|
|
|
|
xor eax, eax
|
|
|
|
rep stosd
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
; clear command area too
|
2016-01-01 22:01:59 +01:00
|
|
|
mov edi, servercommand
|
2018-07-01 16:29:23 +02:00
|
|
|
mov ecx, SERVERCOMMAND_SIZE/4
|
2016-01-01 22:01:59 +01:00
|
|
|
rep stosd
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
; allocate window data block
|
2016-01-01 22:01:59 +01:00
|
|
|
mov ebx, windows
|
|
|
|
call window_create_textbox
|
|
|
|
test eax, eax
|
2018-07-01 16:29:23 +02:00
|
|
|
jz exit
|
2016-01-01 22:01:59 +01:00
|
|
|
mov [ebx + window.type], WINDOWTYPE_SERVER
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
; get settings from ini
|
2016-01-01 22:01:59 +01:00
|
|
|
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
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
; Welcome user
|
2016-01-01 22:01:59 +01:00
|
|
|
mov esi, str_welcome
|
|
|
|
call print_asciiz
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2014-01-18 16:51:43 +01:00
|
|
|
; Check if parameter contains an URL
|
2016-01-01 22:01:59 +01:00
|
|
|
cmp byte[param], 0
|
|
|
|
je @f
|
|
|
|
mov esi, param
|
2018-07-01 16:29:23 +02:00
|
|
|
mov ecx, PARAM_SIZE
|
2016-01-01 22:01:59 +01:00
|
|
|
call cmd_usr_server.now
|
2014-01-18 16:51:43 +01:00
|
|
|
@@:
|
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
redraw:
|
2016-01-01 22:01:59 +01:00
|
|
|
call draw_window
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2014-01-18 16:51:43 +01:00
|
|
|
mainloop:
|
2016-01-01 22:01:59 +01:00
|
|
|
mcall 10 ; wait for event
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
dec eax
|
|
|
|
jz redraw
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
dec eax
|
|
|
|
jz main_window_key
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
dec eax
|
|
|
|
jz button
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
cmp al, 3
|
|
|
|
je mouse
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
call process_network_event
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
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
|
2016-01-02 22:03:09 +01:00
|
|
|
call draw_user_list
|
2013-05-28 19:34:26 +02:00
|
|
|
.no_update:
|
2016-01-01 22:01:59 +01:00
|
|
|
call highlight_updated_tabs
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
jmp mainloop
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
button:
|
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
mcall 17 ; get id
|
|
|
|
ror eax, 8
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
cmp ax, 1 ; close program
|
2018-07-01 16:29:23 +02:00
|
|
|
je quit
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
cmp ax, WINDOW_BTN_CLOSE
|
|
|
|
jne @f
|
|
|
|
call cmd_usr_close_window
|
|
|
|
jmp mainloop
|
2013-10-07 16:02:05 +02:00
|
|
|
|
|
|
|
@@:
|
2016-01-01 22:01:59 +01:00
|
|
|
cmp ax, WINDOW_BTN_LIST
|
|
|
|
jne @f
|
2013-10-07 16:02:05 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
push eax
|
2013-10-07 16:02:05 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
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
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-02 22:03:09 +01:00
|
|
|
call draw_user_list
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
pop eax
|
|
|
|
test eax, 1 shl 25 ; Right mouse button pressed?
|
|
|
|
jz mainloop
|
2014-01-18 16:51:43 +01:00
|
|
|
|
|
|
|
; TODO: check if selected nick is my nick!
|
2013-10-07 16:02:05 +02:00
|
|
|
|
|
|
|
; Right mouse BTN was pressed, open chat window
|
2016-01-01 22:01:59 +01:00
|
|
|
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]
|
2017-10-12 22:38:22 +02:00
|
|
|
; Strip user prefixes
|
|
|
|
cmp byte[esi], '~'
|
|
|
|
je .inc
|
|
|
|
cmp byte[esi], '&'
|
|
|
|
je .inc
|
|
|
|
cmp byte[esi], '@'
|
|
|
|
je .inc
|
|
|
|
cmp byte[esi], '%'
|
|
|
|
je .inc
|
|
|
|
cmp byte[esi], '+'
|
|
|
|
je .inc
|
|
|
|
.open:
|
2016-01-01 22:01:59 +01:00
|
|
|
call window_open
|
|
|
|
test ebx, ebx
|
|
|
|
jz mainloop
|
|
|
|
mov [window_active], ebx
|
|
|
|
call redraw
|
|
|
|
|
|
|
|
jmp mainloop
|
2017-10-12 22:38:22 +02:00
|
|
|
.inc:
|
|
|
|
inc esi
|
|
|
|
jmp .open
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
@@:
|
2016-01-01 22:01:59 +01:00
|
|
|
sub ax, WINDOW_BTN_START
|
2018-07-01 16:29:23 +02:00
|
|
|
jb quit
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
cmp ax, MAX_WINDOWS
|
2018-07-01 16:29:23 +02:00
|
|
|
ja quit
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2014-03-09 22:57:21 +01:00
|
|
|
; Save users scrollbar position
|
2016-01-01 22:01:59 +01:00
|
|
|
push [scroll1.position]
|
|
|
|
mov edx, [window_active]
|
|
|
|
pop [edx + window.users_scroll]
|
2014-03-09 22:57:21 +01:00
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
; OK, time to switch to another window.
|
2016-01-01 22:01:59 +01:00
|
|
|
mov dx, sizeof.window
|
|
|
|
mul dx
|
|
|
|
shl edx, 16
|
|
|
|
mov dx, ax
|
|
|
|
add edx, windows
|
|
|
|
cmp [edx + window.type], WINDOWTYPE_NONE
|
2018-07-01 16:29:23 +02:00
|
|
|
je quit
|
2016-01-01 22:01:59 +01:00
|
|
|
mov [window_active], edx
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
push [edx + window.text_line_print]
|
|
|
|
pop [scroll2.position]
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
push [edx + window.users_scroll]
|
|
|
|
pop [scroll1.position]
|
2014-03-09 22:57:21 +01:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
call draw_window
|
|
|
|
jmp mainloop
|
2013-10-07 16:02:05 +02:00
|
|
|
|
2018-07-01 16:29:23 +02:00
|
|
|
quit:
|
2016-01-01 22:01:59 +01:00
|
|
|
cmp [socketnum], 0
|
|
|
|
je @f
|
|
|
|
mov esi, quit_msg
|
|
|
|
call quit_server
|
2013-10-07 16:02:05 +02:00
|
|
|
@@:
|
|
|
|
|
2018-07-01 16:29:23 +02:00
|
|
|
exit:
|
|
|
|
|
|
|
|
; Close all open windows
|
|
|
|
call window_close_all
|
|
|
|
|
|
|
|
; Erase RAM areas which could contain the connection details
|
|
|
|
xor eax, eax
|
|
|
|
mov edi, irc_server_name
|
|
|
|
mov ecx, MAX_SERVER_NAME
|
|
|
|
rep stosb
|
|
|
|
|
|
|
|
mov edi, user_nick
|
|
|
|
mov ecx, MAX_NICK_LEN
|
|
|
|
rep stosb
|
|
|
|
|
|
|
|
mov edi, user_real_name
|
|
|
|
mov ecx, MAX_REAL_LEN
|
|
|
|
rep stosb
|
|
|
|
|
|
|
|
mov edi, sockaddr1
|
|
|
|
mov ecx, SOCKADDR1_SIZE
|
|
|
|
rep stosb
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
mcall -1
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main_window_key:
|
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
mcall 2
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
push dword edit1
|
|
|
|
call [edit_box_key]
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
; cmp ah, 178
|
|
|
|
; jne .no_up
|
|
|
|
;
|
2014-01-18 16:51:43 +01:00
|
|
|
; jmp mainloop
|
2013-11-01 15:02:08 +01:00
|
|
|
;
|
|
|
|
;
|
|
|
|
; .no_up:
|
|
|
|
; cmp ah, 177
|
|
|
|
; jne .no_down
|
|
|
|
;
|
2014-01-18 16:51:43 +01:00
|
|
|
; jmp mainloop
|
2013-11-01 15:02:08 +01:00
|
|
|
;
|
|
|
|
; .no_down:
|
2016-01-01 22:01:59 +01:00
|
|
|
cmp ah, 13 ; enter
|
|
|
|
jne no_send2
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
call user_parser
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
mov eax, [edit1.size]
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
mov [edit1.size], 0
|
|
|
|
mov [edit1.pos], 0
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-02 22:03:09 +01:00
|
|
|
invoke edit_box_draw, edit1
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
call draw_channel_text
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
jmp mainloop
|
2013-05-28 19:34:26 +02:00
|
|
|
no_send2:
|
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
jmp mainloop
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
mouse:
|
2016-01-02 22:03:09 +01:00
|
|
|
invoke edit_box_mouse, edit1
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2014-01-18 16:51:43 +01:00
|
|
|
; mcall 37, 7
|
|
|
|
; movsx eax, ax
|
|
|
|
; add [scroll2.position], eax
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
; TODO: check if scrollbar is active?
|
2016-01-01 22:01:59 +01:00
|
|
|
mov edi, [window_active]
|
|
|
|
cmp [edi + window.type], WINDOWTYPE_CHANNEL
|
|
|
|
jne @f
|
|
|
|
push [scroll1.position]
|
2016-01-02 22:03:09 +01:00
|
|
|
invoke scrollbar_mouse, scroll1
|
2016-01-01 22:01:59 +01:00
|
|
|
pop eax
|
|
|
|
cmp eax, [scroll1.position] ; did the scrollbar move?
|
|
|
|
je @f
|
2016-01-02 22:03:09 +01:00
|
|
|
call draw_user_list
|
2013-11-01 15:02:08 +01:00
|
|
|
@@:
|
|
|
|
|
|
|
|
; TODO: check if scrollbar is active?
|
2016-01-01 22:01:59 +01:00
|
|
|
mov edi, [window_active]
|
|
|
|
mov eax, [edi + window.text_lines]
|
|
|
|
cmp eax, [textbox_height]
|
|
|
|
jbe @f
|
2016-01-02 22:03:09 +01:00
|
|
|
invoke scrollbar_mouse, scroll2
|
2016-01-01 22:01:59 +01:00
|
|
|
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
|
2014-04-13 13:19:26 +02:00
|
|
|
.not_low:
|
2016-01-01 22:01:59 +01:00
|
|
|
mov edx, [scroll2.position]
|
|
|
|
sub edx, [edi + window.text_line_print]
|
|
|
|
je @f
|
|
|
|
call draw_channel_text.scroll_to_pos
|
2013-05-28 19:34:26 +02:00
|
|
|
@@:
|
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
jmp mainloop
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
; DATA AREA
|
|
|
|
|
|
|
|
encoding_text:
|
2016-01-01 22:01:59 +01:00
|
|
|
db 'CP866 '
|
|
|
|
db 'CP1251'
|
|
|
|
db 'UTF-8 '
|
2013-05-28 19:34:26 +02:00
|
|
|
encoding_text_len = 6
|
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
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
|
2018-07-01 16:29:23 +02:00
|
|
|
ctcp_header_recv db 3, '13', 0
|
2016-01-01 22:01:59 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
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
|
2016-01-03 15:50:44 +01:00
|
|
|
str_notconnected db 3, '5* You are not connected', 10, 0
|
2016-01-01 22:01:59 +01:00
|
|
|
str_notchannel db 3, '5* You are not on a channel', 10, 0
|
2016-01-03 15:50:44 +01:00
|
|
|
str_notloggedin db 3, '5* You are not logged in to the server', 10, 0
|
2016-01-01 22:01:59 +01:00
|
|
|
|
|
|
|
str_1 db 3, '13 -', 0
|
|
|
|
str_2 db '- ', 0
|
|
|
|
|
|
|
|
str_list db 'list', 0
|
|
|
|
|
|
|
|
str_help db 'The following commands are available:', 10
|
|
|
|
db 10
|
2018-07-01 16:29:23 +02:00
|
|
|
db '/nick <nick> : change nickname', 10
|
|
|
|
db '/real <real name> : change real name', 10
|
|
|
|
db '/server <address> : connect to server', 10
|
|
|
|
db '/code <code> : change codepage (cp866, cp1251, or utf8)', 10
|
|
|
|
db '/join <channel> : join a channel', 10
|
|
|
|
db '/part <channel> : part from a channel', 10
|
|
|
|
db '/quit : quit server', 10
|
|
|
|
db '/msg <user> : send a private message', 10
|
|
|
|
db '/ctcp <user> : send a message using client-to-client protocol', 10
|
2016-01-01 22:01:59 +01:00
|
|
|
db 10
|
2018-07-01 16:29:23 +02:00
|
|
|
db 'Other commands are sent straight to a server', 10
|
2016-01-01 22:01:59 +01:00
|
|
|
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 'Welcome to KolibriOS IRC client ', version, 10
|
2016-01-02 22:03:09 +01:00
|
|
|
db 'Type /help for help', 10, 0
|
2016-01-01 22:01:59 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
default_nick db 'kolibri_user', 0
|
|
|
|
default_real db 'Kolibri User', 0
|
|
|
|
default_quit db 'KolibriOS forever', 0
|
|
|
|
|
2020-05-07 17:43:50 +02:00
|
|
|
closing_cross db 'x',0
|
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
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)
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
sockaddr1:
|
2016-01-01 22:01:59 +01:00
|
|
|
dw AF_INET4
|
|
|
|
.port dw 0x0b1a ; 6667 FIXMEEEEEE
|
|
|
|
.ip dd 0
|
|
|
|
rb 10
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2018-07-01 16:29:23 +02:00
|
|
|
SOCKADDR1_SIZE = 18
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
status dd STATUS_DISCONNECTED
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
window_active dd windows
|
|
|
|
window_print dd windows
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2024-03-05 10:49:00 +01:00
|
|
|
cmd_remaining dd 0
|
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
align 4
|
|
|
|
@IMPORT:
|
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
library network, 'network.obj',\
|
|
|
|
libini, 'libini.obj',\
|
|
|
|
boxlib, 'box_lib.obj'
|
|
|
|
|
|
|
|
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 boxlib,\
|
2022-01-03 22:03:06 +01:00
|
|
|
edit_box_draw, 'edit_box_draw',\
|
2016-01-01 22:01:59 +01:00
|
|
|
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
|
2016-01-03 15:50:44 +01:00
|
|
|
edit1 edit_box 0, 0, 0, 0xffffff, 0x6f9480, 0, 0, 0x000000, USERCMD_MAX_SIZE, input_text, mouse_dd, ed_always_focus, 25, 25
|
2016-01-01 22:01:59 +01:00
|
|
|
; xsize, xpos, ysize, ypos, btn_height, max, cur, pos, bgcol, frcol, linecol
|
2013-11-01 15:02:08 +01:00
|
|
|
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
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2021-06-20 23:30:24 +02:00
|
|
|
input_text db '/server irc.libera.chat', 0
|
2016-01-01 22:01:59 +01:00
|
|
|
rb MAX_COMMAND_LEN
|
2013-06-07 19:26:03 +02:00
|
|
|
|
2014-01-18 16:51:43 +01:00
|
|
|
I_END:
|
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
user_command rb MAX_COMMAND_LEN*4
|
|
|
|
.size dd ?
|
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
utf8_bytes_rest dd ? ; bytes rest in current UTF8 sequence
|
|
|
|
utf8_char dd ? ; first bits of current UTF8 character
|
2014-01-18 16:51:43 +01:00
|
|
|
|
2018-07-01 16:29:23 +02:00
|
|
|
packetbuf rb PACKETBUF_SIZE ; buffer for packets to server
|
|
|
|
path rb PATH_SIZE
|
|
|
|
param rb PARAM_SIZE
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2018-07-01 16:29:23 +02:00
|
|
|
servercommand rb SERVERCOMMAND_SIZE
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
thread_info process_information
|
|
|
|
xsize dd ?
|
|
|
|
ysize dd ?
|
|
|
|
mouse_dd dd ?
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
textbox_height dd ? ; in characters
|
|
|
|
textbox_width dd ? ; in characters, not pixels ;)
|
2014-03-08 18:31:33 +01:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
colors system_colors
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
irc_server_name rb MAX_SERVER_NAME ; TODO: move this server URL into window struct
|
|
|
|
socketnum dd ? ; TODO: same for socket
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
user_nick rb MAX_NICK_LEN
|
|
|
|
user_real_name rb MAX_REAL_LEN
|
2018-07-01 16:29:23 +02:00
|
|
|
quit_msg rb QUIT_MSG_LEN
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-01 22:01:59 +01:00
|
|
|
windows rb MAX_WINDOWS*sizeof.window
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2014-03-09 22:57:21 +01:00
|
|
|
IM_END:
|