Rev 7090 | Rev 7890 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7090 | Rev 7300 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2017. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2018. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;; IRC client for KolibriOS ;; |
6 | ;; IRC client for KolibriOS ;; |
7 | ;; ;; |
7 | ;; ;; |
8 | ;; Written by hidnplayr@kolibrios.org, ;; |
8 | ;; Written by hidnplayr@kolibrios.org, ;; |
9 | ;; text encoder/decoder by Clevermouse. ;; |
9 | ;; text encoder/decoder by Clevermouse. ;; |
10 | ;; ;; |
10 | ;; ;; |
11 | ;; GNU GENERAL PUBLIC LICENSE ;; |
11 | ;; GNU GENERAL PUBLIC LICENSE ;; |
12 | ;; Version 2, June 1991 ;; |
12 | ;; Version 2, June 1991 ;; |
13 | ;; ;; |
13 | ;; ;; |
14 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
14 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
15 | 15 | ||
16 | version equ '0.30' |
16 | version equ '0.31' |
17 | 17 | ||
18 | ; connection status |
18 | ; connection status |
19 | STATUS_DISCONNECTED = 0 |
19 | STATUS_DISCONNECTED = 0 |
20 | STATUS_RESOLVING = 1 |
20 | STATUS_RESOLVING = 1 |
21 | STATUS_CONNECTING = 2 |
21 | STATUS_CONNECTING = 2 |
22 | STATUS_CONNECTED = 3 |
22 | STATUS_CONNECTED = 3 |
23 | STATUS_LOGGED_IN = 4 |
23 | STATUS_LOGGED_IN = 4 |
24 | 24 | ||
25 | ; window flags |
25 | ; window flags |
26 | FLAG_UPDATED = 1 shl 0 |
26 | FLAG_UPDATED = 1 shl 0 |
27 | FLAG_RECEIVING_NAMES = 1 shl 1 |
27 | FLAG_RECEIVING_NAMES = 1 shl 1 |
28 | FLAG_SCROLL_LOW = 1 shl 2 |
28 | FLAG_SCROLL_LOW = 1 shl 2 |
29 | 29 | ||
30 | ; window types |
30 | ; window types |
31 | WINDOWTYPE_NONE = 0 |
31 | WINDOWTYPE_NONE = 0 |
32 | WINDOWTYPE_SERVER = 1 |
32 | WINDOWTYPE_SERVER = 1 |
33 | WINDOWTYPE_CHANNEL = 2 |
33 | WINDOWTYPE_CHANNEL = 2 |
34 | WINDOWTYPE_CHAT = 3 |
34 | WINDOWTYPE_CHAT = 3 |
35 | WINDOWTYPE_LIST = 4 |
35 | WINDOWTYPE_LIST = 4 |
36 | WINDOWTYPE_DCC = 5 |
36 | WINDOWTYPE_DCC = 5 |
37 | 37 | ||
38 | ; supported encodings |
38 | ; supported encodings |
39 | CP866 = 0 |
39 | CP866 = 0 |
40 | CP1251 = 1 |
40 | CP1251 = 1 |
41 | UTF8 = 2 |
41 | UTF8 = 2 |
42 | 42 | ||
43 | ; settings |
43 | ; settings |
44 | USERCMD_MAX_SIZE = 400 |
44 | USERCMD_MAX_SIZE = 400 |
45 | 45 | ||
46 | WIN_MIN_X = 600 |
46 | WIN_MIN_X = 600 |
47 | WIN_MIN_Y = 183 |
47 | WIN_MIN_Y = 183 |
48 | 48 | ||
49 | TEXT_X = 2 |
49 | TEXT_X = 2 |
50 | TEXT_Y = TOP_Y + 2 |
50 | TEXT_Y = TOP_Y + 2 |
51 | 51 | ||
52 | TOP_SPACE = 2 |
52 | TOP_SPACE = 2 |
53 | TAB_HEIGHT = 14 |
53 | TAB_HEIGHT = 14 |
54 | TAB_WIDTH = 120 |
54 | TAB_WIDTH = 120 |
55 | TAB_SPACE = 5 |
55 | TAB_SPACE = 5 |
56 | TOP_Y = TOP_SPACE+ TAB_HEIGHT |
56 | TOP_Y = TOP_SPACE+ TAB_HEIGHT |
57 | INPUTBOX_HEIGHT = 13 |
57 | INPUTBOX_HEIGHT = 13 |
58 | 58 | ||
59 | MAX_WINDOWS = 20 |
59 | MAX_WINDOWS = 20 |
60 | MAX_USERS = 4096 |
60 | MAX_USERS = 4096 |
61 | TEXT_BUFFERSIZE = 1024*1024 |
61 | TEXT_BUFFERSIZE = 1024*1024 |
62 | 62 | ||
63 | MAX_NICK_LEN = 32 |
63 | MAX_NICK_LEN = 32 |
64 | MAX_REAL_LEN = 32 ; realname |
64 | MAX_REAL_LEN = 32 ; realname |
- | 65 | QUIT_MSG_LEN = 250 |
|
65 | MAX_SERVER_NAME = 256 |
66 | MAX_SERVER_NAME = 256 |
66 | 67 | ||
67 | MAX_CHANNEL_LEN = 40 |
68 | MAX_CHANNEL_LEN = 40 |
68 | MAX_CHANNELS = 37 |
69 | MAX_CHANNELS = 37 |
69 | 70 | ||
70 | MAX_COMMAND_LEN = 512 |
71 | MAX_COMMAND_LEN = 512 |
- | 72 | ||
- | 73 | PACKETBUF_SIZE = 1024 |
|
- | 74 | PATH_SIZE = 1024 |
|
- | 75 | PARAM_SIZE = 1024 |
|
- | 76 | SERVERCOMMAND_SIZE = 600 |
|
71 | 77 | ||
72 | TIMESTAMP = 3 ; 3 = hh:mm:ss, 2 = hh:mm, 0 = no timestamp |
78 | TIMESTAMP = 3 ; 3 = hh:mm:ss, 2 = hh:mm, 0 = no timestamp |
73 | 79 | ||
74 | MAX_WINDOWNAME_LEN = 256 |
80 | MAX_WINDOWNAME_LEN = 256 |
75 | 81 | ||
76 | WINDOW_BTN_START = 100 |
82 | WINDOW_BTN_START = 100 |
77 | WINDOW_BTN_CLOSE = 2 |
83 | WINDOW_BTN_CLOSE = 2 |
78 | WINDOW_BTN_LIST = 3 |
84 | WINDOW_BTN_LIST = 3 |
79 | 85 | ||
80 | SCROLLBAR_WIDTH = 14 |
86 | SCROLLBAR_WIDTH = 14 |
81 | USERLIST_WIDTH = 160 |
87 | USERLIST_WIDTH = 160 |
82 | 88 | ||
83 | FONT_WIDTH = 8 |
89 | FONT_WIDTH = 8 |
84 | FONT_HEIGHT = 16 |
90 | FONT_HEIGHT = 16 |
85 | 91 | ||
86 | format binary as "" |
92 | format binary as "" |
87 | 93 | ||
88 | use32 |
94 | use32 |
89 | 95 | ||
90 | org 0x0 |
96 | org 0x0 |
91 | 97 | ||
92 | db 'MENUET01' ; 8 byte id |
98 | db 'MENUET01' ; 8 byte id |
93 | dd 1 ; header version |
99 | dd 1 ; header version |
94 | dd START ; program start |
100 | dd START ; program start |
95 | dd I_END ; program image size |
101 | dd I_END ; program image size |
96 | dd IM_END+2048 ; required amount of memory |
102 | dd IM_END+2048 ; required amount of memory |
97 | dd IM_END+2048 |
103 | dd IM_END+2048 |
98 | dd param |
104 | dd param |
99 | dd path |
105 | dd path |
100 | 106 | ||
101 | include "../../macros.inc" |
107 | include "../../macros.inc" |
102 | include "../../proc32.inc" |
108 | include "../../proc32.inc" |
103 | include "../../dll.inc" |
109 | include "../../dll.inc" |
104 | include "../../network.inc" |
110 | include "../../network.inc" |
105 | include "../../struct.inc" |
111 | include "../../struct.inc" |
106 | include "../../develop/libraries/box_lib/trunk/box_lib.mac" |
112 | include "../../develop/libraries/box_lib/trunk/box_lib.mac" |
107 | 113 | ||
108 | struct window |
114 | struct window |
109 | data_ptr dd ? |
115 | data_ptr dd ? |
110 | flags db ? |
116 | flags db ? |
111 | type db ? |
117 | type db ? |
112 | name rb MAX_WINDOWNAME_LEN |
118 | name rb MAX_WINDOWNAME_LEN |
113 | users dd ? |
119 | users dd ? |
114 | users_scroll dd ? |
120 | users_scroll dd ? |
115 | selected dd ? ; selected user, 0 if none selected |
121 | selected dd ? ; selected user, 0 if none selected |
116 | 122 | ||
117 | text_start dd ? ; pointer to current textbox data |
123 | text_start dd ? ; pointer to current textbox data |
118 | text_end dd ? |
124 | text_end dd ? |
119 | text_print dd ? ; pointer to first character to print on screen |
125 | text_print dd ? ; pointer to first character to print on screen |
120 | text_line_print dd ? ; line number of that character |
126 | text_line_print dd ? ; line number of that character |
121 | text_write dd ? ; write pointer |
127 | text_write dd ? ; write pointer |
122 | text_lines dd ? ; total number of lines |
128 | text_lines dd ? ; total number of lines |
123 | text_scanned dd ? ; pointer to beginning of unscanned data (we still need to count number of lines, insert newline characters,..) |
129 | text_scanned dd ? ; pointer to beginning of unscanned data (we still need to count number of lines, insert newline characters,..) |
124 | 130 | ||
125 | ends |
131 | ends |
126 | 132 | ||
127 | struct window_data |
133 | struct window_data |
128 | text rb TEXT_BUFFERSIZE |
134 | text rb TEXT_BUFFERSIZE |
129 | names rb MAX_NICK_LEN * MAX_USERS |
135 | names rb MAX_NICK_LEN * MAX_USERS |
130 | ends |
136 | ends |
131 | 137 | ||
132 | include "encodings.inc" |
138 | include "encodings.inc" |
133 | include "window.inc" |
139 | include "window.inc" |
134 | include "serverparser.inc" |
140 | include "serverparser.inc" |
135 | include "userparser.inc" |
141 | include "userparser.inc" |
136 | include "socket.inc" |
142 | include "socket.inc" |
137 | include "gui.inc" |
143 | include "gui.inc" |
138 | include "users.inc" |
144 | include "users.inc" |
139 | include "textbox.inc" |
145 | include "textbox.inc" |
140 | 146 | ||
141 | 147 | ||
142 | START: |
148 | START: |
143 | 149 | ||
144 | mcall 68, 11 ; init heap so we can allocate memory dynamically |
150 | mcall 68, 11 ; init heap so we can allocate memory dynamically |
145 | 151 | ||
146 | ; wanted events |
152 | ; wanted events |
147 | mcall 40, EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_STACK+EVM_MOUSE+EVM_MOUSE_FILTER |
153 | mcall 40, EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_STACK+EVM_MOUSE+EVM_MOUSE_FILTER |
148 | 154 | ||
149 | ; load libraries |
155 | ; load libraries |
150 | stdcall dll.Load, @IMPORT |
156 | stdcall dll.Load, @IMPORT |
151 | test eax, eax |
157 | test eax, eax |
152 | jnz exit |
158 | jnz exit |
153 | 159 | ||
154 | ; find path to main settings file (ircc.ini) |
160 | ; find path to main settings file (ircc.ini) |
155 | mov edi, path ; Calculate the length of zero-terminated string |
161 | mov edi, path ; Calculate the length of zero-terminated string |
156 | xor al, al |
162 | xor al, al |
157 | mov ecx, 1024 |
163 | mov ecx, PATH_SIZE |
158 | repne scasb |
164 | repne scasb |
159 | dec edi |
165 | dec edi |
160 | mov eax, '.ini' |
166 | mov eax, '.ini' |
161 | stosd |
167 | stosd |
162 | xor al, al |
168 | xor al, al |
163 | stosb |
169 | stosb |
164 | 170 | ||
165 | ; Fill the window buffer with zeros |
171 | ; Fill the window buffer with zeros |
166 | mov edi, windows |
172 | mov edi, windows |
167 | mov ecx, (sizeof.window*MAX_WINDOWS+3)/4 |
173 | mov ecx, (sizeof.window*MAX_WINDOWS+3)/4 |
168 | xor eax, eax |
174 | xor eax, eax |
169 | rep stosd |
175 | rep stosd |
170 | 176 | ||
171 | ; clear command area too |
177 | ; clear command area too |
172 | mov edi, servercommand |
178 | mov edi, servercommand |
173 | mov ecx, 600/4 |
179 | mov ecx, SERVERCOMMAND_SIZE/4 |
174 | rep stosd |
180 | rep stosd |
175 | 181 | ||
176 | ; allocate window data block |
182 | ; allocate window data block |
177 | mov ebx, windows |
183 | mov ebx, windows |
178 | call window_create_textbox |
184 | call window_create_textbox |
179 | test eax, eax |
185 | test eax, eax |
180 | jz error |
186 | jz exit |
181 | mov [ebx + window.type], WINDOWTYPE_SERVER |
187 | mov [ebx + window.type], WINDOWTYPE_SERVER |
182 | 188 | ||
183 | ; get system colors |
189 | ; get system colors |
184 | mcall 48, 3, colors, 40 |
190 | mcall 48, 3, colors, 40 |
185 | 191 | ||
186 | ; set edit box and scrollbar colors |
192 | ; set edit box and scrollbar colors |
187 | mov eax, [colors.work] |
193 | mov eax, [colors.work] |
188 | mov [scroll1.bg_color], eax |
194 | mov [scroll1.bg_color], eax |
189 | mov [scroll2.bg_color], eax |
195 | mov [scroll2.bg_color], eax |
190 | 196 | ||
191 | mov eax, [colors.work_button] |
197 | mov eax, [colors.work_button] |
192 | mov [scroll1.front_color], eax |
198 | mov [scroll1.front_color], eax |
193 | mov [scroll2.front_color], eax |
199 | mov [scroll2.front_color], eax |
194 | 200 | ||
195 | mov eax, [colors.work_text] |
201 | mov eax, [colors.work_text] |
196 | mov [scroll1.line_color], eax |
202 | mov [scroll1.line_color], eax |
197 | mov [scroll2.line_color], eax |
203 | mov [scroll2.line_color], eax |
198 | 204 | ||
199 | mov [scroll1.type], 1 ; 0 = simple, 1 = skinned |
205 | mov [scroll1.type], 1 ; 0 = simple, 1 = skinned |
200 | mov [scroll2.type], 1 |
206 | mov [scroll2.type], 1 |
201 | 207 | ||
202 | ; get settings from ini |
208 | ; get settings from ini |
203 | invoke ini.get_str, path, str_user, str_nick, user_nick, MAX_NICK_LEN, default_nick |
209 | invoke ini.get_str, path, str_user, str_nick, user_nick, MAX_NICK_LEN, default_nick |
204 | invoke ini.get_str, path, str_user, str_real, user_real_name, MAX_REAL_LEN, default_real |
210 | invoke ini.get_str, path, str_user, str_real, user_real_name, MAX_REAL_LEN, default_real |
205 | invoke ini.get_str, path, str_user, str_quitmsg, quit_msg, 250, default_quit |
211 | invoke ini.get_str, path, str_user, str_quitmsg, quit_msg, 250, default_quit |
206 | 212 | ||
207 | ; Welcome user |
213 | ; Welcome user |
208 | mov esi, str_welcome |
214 | mov esi, str_welcome |
209 | call print_asciiz |
215 | call print_asciiz |
210 | 216 | ||
211 | ; Check if parameter contains an URL |
217 | ; Check if parameter contains an URL |
212 | cmp byte[param], 0 |
218 | cmp byte[param], 0 |
213 | je @f |
219 | je @f |
214 | mov esi, param |
220 | mov esi, param |
215 | mov ecx, 1024 |
221 | mov ecx, PARAM_SIZE |
216 | call cmd_usr_server.now |
222 | call cmd_usr_server.now |
217 | @@: |
223 | @@: |
218 | 224 | ||
219 | redraw: |
225 | redraw: |
220 | call draw_window |
226 | call draw_window |
221 | 227 | ||
222 | mainloop: |
228 | mainloop: |
223 | mcall 10 ; wait for event |
229 | mcall 10 ; wait for event |
224 | 230 | ||
225 | dec eax |
231 | dec eax |
226 | jz redraw |
232 | jz redraw |
227 | 233 | ||
228 | dec eax |
234 | dec eax |
229 | jz main_window_key |
235 | jz main_window_key |
230 | 236 | ||
231 | dec eax |
237 | dec eax |
232 | jz button |
238 | jz button |
233 | 239 | ||
234 | cmp al, 3 |
240 | cmp al, 3 |
235 | je mouse |
241 | je mouse |
236 | 242 | ||
237 | call process_network_event |
243 | call process_network_event |
238 | 244 | ||
239 | mov edi, [window_active] |
245 | mov edi, [window_active] |
240 | test [edi + window.flags], FLAG_UPDATED |
246 | test [edi + window.flags], FLAG_UPDATED |
241 | jz .no_update |
247 | jz .no_update |
242 | call draw_channel_text |
248 | call draw_channel_text |
243 | mov edi, [window_active] |
249 | mov edi, [window_active] |
244 | cmp [edi + window.type], WINDOWTYPE_CHANNEL |
250 | cmp [edi + window.type], WINDOWTYPE_CHANNEL |
245 | jne .no_update |
251 | jne .no_update |
246 | call draw_user_list |
252 | call draw_user_list |
247 | .no_update: |
253 | .no_update: |
248 | call highlight_updated_tabs |
254 | call highlight_updated_tabs |
249 | 255 | ||
250 | jmp mainloop |
256 | jmp mainloop |
251 | 257 | ||
252 | button: |
258 | button: |
253 | 259 | ||
254 | mcall 17 ; get id |
260 | mcall 17 ; get id |
255 | ror eax, 8 |
261 | ror eax, 8 |
256 | 262 | ||
257 | cmp ax, 1 ; close program |
263 | cmp ax, 1 ; close program |
258 | je exit |
264 | je quit |
259 | 265 | ||
260 | cmp ax, WINDOW_BTN_CLOSE |
266 | cmp ax, WINDOW_BTN_CLOSE |
261 | jne @f |
267 | jne @f |
262 | call cmd_usr_close_window |
268 | call cmd_usr_close_window |
263 | jmp mainloop |
269 | jmp mainloop |
264 | 270 | ||
265 | @@: |
271 | @@: |
266 | cmp ax, WINDOW_BTN_LIST |
272 | cmp ax, WINDOW_BTN_LIST |
267 | jne @f |
273 | jne @f |
268 | 274 | ||
269 | push eax |
275 | push eax |
270 | 276 | ||
271 | mcall 37, 1 ; Get mouse position |
277 | mcall 37, 1 ; Get mouse position |
272 | sub ax, TEXT_Y |
278 | sub ax, TEXT_Y |
273 | mov bl, FONT_HEIGHT |
279 | mov bl, FONT_HEIGHT |
274 | div bl |
280 | div bl |
275 | and eax, 0x000000ff |
281 | and eax, 0x000000ff |
276 | inc eax |
282 | inc eax |
277 | add eax, [scroll1.position] |
283 | add eax, [scroll1.position] |
278 | mov ebx, [window_active] |
284 | mov ebx, [window_active] |
279 | mov [ebx + window.selected], eax |
285 | mov [ebx + window.selected], eax |
280 | 286 | ||
281 | call draw_user_list |
287 | call draw_user_list |
282 | 288 | ||
283 | pop eax |
289 | pop eax |
284 | test eax, 1 shl 25 ; Right mouse button pressed? |
290 | test eax, 1 shl 25 ; Right mouse button pressed? |
285 | jz mainloop |
291 | jz mainloop |
286 | 292 | ||
287 | ; TODO: check if selected nick is my nick! |
293 | ; TODO: check if selected nick is my nick! |
288 | 294 | ||
289 | ; Right mouse BTN was pressed, open chat window |
295 | ; Right mouse BTN was pressed, open chat window |
290 | mov ebx, [window_active] |
296 | mov ebx, [window_active] |
291 | mov eax, [ebx + window.selected] |
297 | mov eax, [ebx + window.selected] |
292 | dec eax |
298 | dec eax |
293 | imul eax, MAX_NICK_LEN |
299 | imul eax, MAX_NICK_LEN |
294 | mov ebx, [ebx + window.data_ptr] |
300 | mov ebx, [ebx + window.data_ptr] |
295 | lea esi, [ebx + window_data.names + eax] |
301 | lea esi, [ebx + window_data.names + eax] |
296 | ; Strip user prefixes |
302 | ; Strip user prefixes |
297 | cmp byte[esi], '~' |
303 | cmp byte[esi], '~' |
298 | je .inc |
304 | je .inc |
299 | cmp byte[esi], '&' |
305 | cmp byte[esi], '&' |
300 | je .inc |
306 | je .inc |
301 | cmp byte[esi], '@' |
307 | cmp byte[esi], '@' |
302 | je .inc |
308 | je .inc |
303 | cmp byte[esi], '%' |
309 | cmp byte[esi], '%' |
304 | je .inc |
310 | je .inc |
305 | cmp byte[esi], '+' |
311 | cmp byte[esi], '+' |
306 | je .inc |
312 | je .inc |
307 | .open: |
313 | .open: |
308 | call window_open |
314 | call window_open |
309 | test ebx, ebx |
315 | test ebx, ebx |
310 | jz mainloop |
316 | jz mainloop |
311 | mov [window_active], ebx |
317 | mov [window_active], ebx |
312 | call redraw |
318 | call redraw |
313 | 319 | ||
314 | jmp mainloop |
320 | jmp mainloop |
315 | .inc: |
321 | .inc: |
316 | inc esi |
322 | inc esi |
317 | jmp .open |
323 | jmp .open |
318 | 324 | ||
319 | @@: |
325 | @@: |
320 | sub ax, WINDOW_BTN_START |
326 | sub ax, WINDOW_BTN_START |
321 | jb exit |
327 | jb quit |
322 | 328 | ||
323 | cmp ax, MAX_WINDOWS |
329 | cmp ax, MAX_WINDOWS |
324 | ja exit |
330 | ja quit |
325 | 331 | ||
326 | ; Save users scrollbar position |
332 | ; Save users scrollbar position |
327 | push [scroll1.position] |
333 | push [scroll1.position] |
328 | mov edx, [window_active] |
334 | mov edx, [window_active] |
329 | pop [edx + window.users_scroll] |
335 | pop [edx + window.users_scroll] |
330 | 336 | ||
331 | ; OK, time to switch to another window. |
337 | ; OK, time to switch to another window. |
332 | mov dx, sizeof.window |
338 | mov dx, sizeof.window |
333 | mul dx |
339 | mul dx |
334 | shl edx, 16 |
340 | shl edx, 16 |
335 | mov dx, ax |
341 | mov dx, ax |
336 | add edx, windows |
342 | add edx, windows |
337 | cmp [edx + window.type], WINDOWTYPE_NONE |
343 | cmp [edx + window.type], WINDOWTYPE_NONE |
338 | je exit |
344 | je quit |
339 | mov [window_active], edx |
345 | mov [window_active], edx |
340 | 346 | ||
341 | push [edx + window.text_line_print] |
347 | push [edx + window.text_line_print] |
342 | pop [scroll2.position] |
348 | pop [scroll2.position] |
343 | 349 | ||
344 | push [edx + window.users_scroll] |
350 | push [edx + window.users_scroll] |
345 | pop [scroll1.position] |
351 | pop [scroll1.position] |
346 | 352 | ||
347 | call draw_window |
353 | call draw_window |
348 | jmp mainloop |
354 | jmp mainloop |
349 | 355 | ||
350 | exit: |
- | |
351 | 356 | quit: |
|
352 | cmp [socketnum], 0 |
357 | cmp [socketnum], 0 |
353 | je @f |
358 | je @f |
354 | mov esi, quit_msg |
359 | mov esi, quit_msg |
355 | call quit_server |
360 | call quit_server |
356 | @@: |
361 | @@: |
357 | 362 | ||
- | 363 | exit: |
|
- | 364 | ||
- | 365 | ; Close all open windows |
|
- | 366 | call window_close_all |
|
- | 367 | ||
- | 368 | ; Erase RAM areas which could contain the connection details |
|
- | 369 | xor eax, eax |
|
- | 370 | mov edi, irc_server_name |
|
- | 371 | mov ecx, MAX_SERVER_NAME |
|
- | 372 | rep stosb |
|
- | 373 | ||
- | 374 | mov edi, user_nick |
|
- | 375 | mov ecx, MAX_NICK_LEN |
|
- | 376 | rep stosb |
|
- | 377 | ||
- | 378 | mov edi, user_real_name |
|
- | 379 | mov ecx, MAX_REAL_LEN |
|
- | 380 | rep stosb |
|
- | 381 | ||
- | 382 | mov edi, sockaddr1 |
|
- | 383 | mov ecx, SOCKADDR1_SIZE |
|
358 | error: |
384 | rep stosb |
359 | 385 | ||
360 | mcall -1 |
386 | mcall -1 |
361 | 387 | ||
362 | 388 | ||
363 | 389 | ||
364 | main_window_key: |
390 | main_window_key: |
365 | 391 | ||
366 | mcall 2 |
392 | mcall 2 |
367 | 393 | ||
368 | push dword edit1 |
394 | push dword edit1 |
369 | call [edit_box_key] |
395 | call [edit_box_key] |
370 | 396 | ||
371 | ; cmp ah, 178 |
397 | ; cmp ah, 178 |
372 | ; jne .no_up |
398 | ; jne .no_up |
373 | ; |
399 | ; |
374 | ; jmp mainloop |
400 | ; jmp mainloop |
375 | ; |
401 | ; |
376 | ; |
402 | ; |
377 | ; .no_up: |
403 | ; .no_up: |
378 | ; cmp ah, 177 |
404 | ; cmp ah, 177 |
379 | ; jne .no_down |
405 | ; jne .no_down |
380 | ; |
406 | ; |
381 | ; jmp mainloop |
407 | ; jmp mainloop |
382 | ; |
408 | ; |
383 | ; .no_down: |
409 | ; .no_down: |
384 | cmp ah, 13 ; enter |
410 | cmp ah, 13 ; enter |
385 | jne no_send2 |
411 | jne no_send2 |
386 | 412 | ||
387 | call user_parser |
413 | call user_parser |
388 | 414 | ||
389 | mov eax, [edit1.size] |
415 | mov eax, [edit1.size] |
390 | 416 | ||
391 | mov [edit1.size], 0 |
417 | mov [edit1.size], 0 |
392 | mov [edit1.pos], 0 |
418 | mov [edit1.pos], 0 |
393 | 419 | ||
394 | invoke edit_box_draw, edit1 |
420 | invoke edit_box_draw, edit1 |
395 | 421 | ||
396 | call draw_channel_text |
422 | call draw_channel_text |
397 | 423 | ||
398 | jmp mainloop |
424 | jmp mainloop |
399 | no_send2: |
425 | no_send2: |
400 | 426 | ||
401 | jmp mainloop |
427 | jmp mainloop |
402 | 428 | ||
403 | mouse: |
429 | mouse: |
404 | invoke edit_box_mouse, edit1 |
430 | invoke edit_box_mouse, edit1 |
405 | 431 | ||
406 | ; mcall 37, 7 |
432 | ; mcall 37, 7 |
407 | ; movsx eax, ax |
433 | ; movsx eax, ax |
408 | ; add [scroll2.position], eax |
434 | ; add [scroll2.position], eax |
409 | 435 | ||
410 | ; TODO: check if scrollbar is active? |
436 | ; TODO: check if scrollbar is active? |
411 | mov edi, [window_active] |
437 | mov edi, [window_active] |
412 | cmp [edi + window.type], WINDOWTYPE_CHANNEL |
438 | cmp [edi + window.type], WINDOWTYPE_CHANNEL |
413 | jne @f |
439 | jne @f |
414 | push [scroll1.position] |
440 | push [scroll1.position] |
415 | invoke scrollbar_mouse, scroll1 |
441 | invoke scrollbar_mouse, scroll1 |
416 | pop eax |
442 | pop eax |
417 | cmp eax, [scroll1.position] ; did the scrollbar move? |
443 | cmp eax, [scroll1.position] ; did the scrollbar move? |
418 | je @f |
444 | je @f |
419 | call draw_user_list |
445 | call draw_user_list |
420 | @@: |
446 | @@: |
421 | 447 | ||
422 | ; TODO: check if scrollbar is active? |
448 | ; TODO: check if scrollbar is active? |
423 | mov edi, [window_active] |
449 | mov edi, [window_active] |
424 | mov eax, [edi + window.text_lines] |
450 | mov eax, [edi + window.text_lines] |
425 | cmp eax, [textbox_height] |
451 | cmp eax, [textbox_height] |
426 | jbe @f |
452 | jbe @f |
427 | invoke scrollbar_mouse, scroll2 |
453 | invoke scrollbar_mouse, scroll2 |
428 | mov edi, [window_active] |
454 | mov edi, [window_active] |
429 | and [edi+window.flags], not FLAG_SCROLL_LOW |
455 | and [edi+window.flags], not FLAG_SCROLL_LOW |
430 | mov edx, [scroll2.position] |
456 | mov edx, [scroll2.position] |
431 | add edx, [scroll2.cur_area] |
457 | add edx, [scroll2.cur_area] |
432 | sub edx, [scroll2.max_area] |
458 | sub edx, [scroll2.max_area] |
433 | jne .not_low |
459 | jne .not_low |
434 | or [edi+window.flags], FLAG_SCROLL_LOW |
460 | or [edi+window.flags], FLAG_SCROLL_LOW |
435 | .not_low: |
461 | .not_low: |
436 | mov edx, [scroll2.position] |
462 | mov edx, [scroll2.position] |
437 | sub edx, [edi + window.text_line_print] |
463 | sub edx, [edi + window.text_line_print] |
438 | je @f |
464 | je @f |
439 | call draw_channel_text.scroll_to_pos |
465 | call draw_channel_text.scroll_to_pos |
440 | @@: |
466 | @@: |
441 | 467 | ||
442 | jmp mainloop |
468 | jmp mainloop |
443 | 469 | ||
444 | 470 | ||
445 | ; DATA AREA |
471 | ; DATA AREA |
446 | 472 | ||
447 | encoding_text: |
473 | encoding_text: |
448 | db 'CP866 ' |
474 | db 'CP866 ' |
449 | db 'CP1251' |
475 | db 'CP1251' |
450 | db 'UTF-8 ' |
476 | db 'UTF-8 ' |
451 | encoding_text_len = 6 |
477 | encoding_text_len = 6 |
452 | 478 | ||
453 | join_header db 3, '3* ', 0 |
479 | join_header db 3, '3* ', 0 |
454 | quit_header db 3, '5* ', 0 |
480 | quit_header db 3, '5* ', 0 |
455 | nick_header db 3, '2* ', 0 |
481 | nick_header db 3, '2* ', 0 |
456 | kick_header db 3, '5* ', 0 |
482 | kick_header db 3, '5* ', 0 |
457 | mode_header db 3, '2* ', 0 |
483 | mode_header db 3, '2* ', 0 |
458 | part_header db 3, '5* ', 0 |
484 | part_header db 3, '5* ', 0 |
459 | topic_header db 3, '3* ', 0 |
485 | topic_header db 3, '3* ', 0 |
460 | action_header db 3, '6* ', 0 |
486 | action_header db 3, '6* ', 0 |
461 | ctcp_header db 3, '13-> [', 0 |
487 | ctcp_header db 3, '13-> [', 0 |
- | 488 | ctcp_header_recv db 3, '13', 0 |
|
462 | msg_header db 3, '7-> *', 0 |
489 | msg_header db 3, '7-> *', 0 |
463 | ctcp_version db '] VERSION', 10, 0 |
490 | ctcp_version db '] VERSION', 10, 0 |
464 | ctcp_ping db '] PING', 10, 0 |
491 | ctcp_ping db '] PING', 10, 0 |
465 | ctcp_time db '] TIME', 10, 0 |
492 | ctcp_time db '] TIME', 10, 0 |
466 | 493 | ||
467 | has_left_channel db ' has left ', 0 |
494 | has_left_channel db ' has left ', 0 |
468 | joins_channel db ' has joined ', 0 |
495 | joins_channel db ' has joined ', 0 |
469 | is_now_known_as db ' is now known as ', 0 |
496 | is_now_known_as db ' is now known as ', 0 |
470 | has_quit_irc db ' has quit IRC', 10, 0 |
497 | has_quit_irc db ' has quit IRC', 10, 0 |
471 | 498 | ||
472 | sets_mode db ' sets mode ', 0 |
499 | sets_mode db ' sets mode ', 0 |
473 | str_kicked db ' is kicked from ', 0 |
500 | str_kicked db ' is kicked from ', 0 |
474 | str_by db ' by ', 0 |
501 | str_by db ' by ', 0 |
475 | str_nickchange db 'Nickname is now ', 0 |
502 | str_nickchange db 'Nickname is now ', 0 |
476 | str_realchange db 'Real name is now ', 0 |
503 | str_realchange db 'Real name is now ', 0 |
477 | str_talking db 'Now talking in ', 0 |
504 | str_talking db 'Now talking in ', 0 |
478 | str_topic db 'Topic is "', 0 |
505 | str_topic db 'Topic is "', 0 |
479 | str_topic_end db '"', 10, 0 |
506 | str_topic_end db '"', 10, 0 |
480 | str_setby db 'Set by ', 0 |
507 | str_setby db 'Set by ', 0 |
481 | 508 | ||
482 | str_connecting db 3, '3* Connecting to ', 0 |
509 | str_connecting db 3, '3* Connecting to ', 0 |
483 | str_sockerr db 3, '5* Socket error', 10, 0 |
510 | str_sockerr db 3, '5* Socket error', 10, 0 |
484 | str_dnserr db 3, '5* Unable to resolve hostname', 10, 0 |
511 | str_dnserr db 3, '5* Unable to resolve hostname', 10, 0 |
485 | str_refused db 3, '5* Connection refused', 10, 0 |
512 | str_refused db 3, '5* Connection refused', 10, 0 |
486 | str_srv_disconnected db 3, '5* Server disconnected', 10, 0 |
513 | str_srv_disconnected db 3, '5* Server disconnected', 10, 0 |
487 | str_disconnected db 3, '5* Disconnected', 10, 0 |
514 | str_disconnected db 3, '5* Disconnected', 10, 0 |
488 | str_reconnect db 3, '5* Connection reset by user', 10, 0 |
515 | str_reconnect db 3, '5* Connection reset by user', 10, 0 |
489 | str_notconnected db 3, '5* You are not connected', 10, 0 |
516 | str_notconnected db 3, '5* You are not connected', 10, 0 |
490 | str_notchannel db 3, '5* You are not on a channel', 10, 0 |
517 | str_notchannel db 3, '5* You are not on a channel', 10, 0 |
491 | str_notloggedin db 3, '5* You are not logged in to the server', 10, 0 |
518 | str_notloggedin db 3, '5* You are not logged in to the server', 10, 0 |
492 | 519 | ||
493 | str_1 db 3, '13 -', 0 |
520 | str_1 db 3, '13 -', 0 |
494 | str_2 db '- ', 0 |
521 | str_2 db '- ', 0 |
495 | 522 | ||
496 | str_list db 'list', 0 |
523 | str_list db 'list', 0 |
497 | 524 | ||
498 | str_help db 'The following commands are available:', 10 |
525 | str_help db 'The following commands are available:', 10 |
499 | db 10 |
526 | db 10 |
500 | db '/nick |
527 | db '/nick |
501 | db '/real |
528 | db '/real |
502 | db '/server : connect to server', 10 |
529 | db '/server : connect to server', 10 |
503 | db '/code |
530 | db '/code |
504 | db '/join |
531 | db '/join |
505 | db '/part |
532 | db '/part |
506 | db '/quit : quit server', 10 |
533 | db '/quit : quit server', 10 |
507 | db '/msg |
534 | db '/msg |
508 | db '/ctcp |
535 | db '/ctcp |
509 | db 10 |
536 | db 10 |
510 | db 'Other commands are send straight to server.', 10 |
537 | db 'Other commands are sent straight to a server', 10 |
511 | db 10, 0 |
538 | db 10, 0 |
512 | 539 | ||
513 | str_welcome db 3, '3 ___', 3, '7__________', 3, '6_________ ', 3, '4 __ __ __', 10 |
540 | str_welcome db 3, '3 ___', 3, '7__________', 3, '6_________ ', 3, '4 __ __ __', 10 |
514 | db 3, '3| \', 3, '7______ \', 3, '6_ ___ \ ', 3, '4 ____ | | |__| ____ _____/ |_', 10 |
541 | db 3, '3| \', 3, '7______ \', 3, '6_ ___ \ ', 3, '4 ____ | | |__| ____ _____/ |_', 10 |
515 | db 3, '3| |', 3, '7| _/', 3, '6 \ \/ ', 3, '4 _/ ___\| | | |/ __ \ / \ __\', 10 |
542 | db 3, '3| |', 3, '7| _/', 3, '6 \ \/ ', 3, '4 _/ ___\| | | |/ __ \ / \ __\', 10 |
516 | db 3, '3| |', 3, '7| | \', 3, '6 \____', 3, '4 \ \___| |_| \ ___/| | \ |', 10 |
543 | db 3, '3| |', 3, '7| | \', 3, '6 \____', 3, '4 \ \___| |_| \ ___/| | \ |', 10 |
517 | db 3, '3|___|', 3, '7|____|_ /', 3, '6\______ /', 3, '4 \___ >____/__|\___ >___| /__|', 10 |
544 | db 3, '3|___|', 3, '7|____|_ /', 3, '6\______ /', 3, '4 \___ >____/__|\___ >___| /__|', 10 |
518 | db 3, '3 ', 3, '7 \/ ', 3, '6 \/ ', 3, '4 \/ \/ \/', 10 |
545 | db 3, '3 ', 3, '7 \/ ', 3, '6 \/ ', 3, '4 \/ \/ \/', 10 |
519 | db 'Welcome to KolibriOS IRC client ', version, 10 |
546 | db 'Welcome to KolibriOS IRC client ', version, 10 |
520 | db 'Type /help for help', 10, 0 |
547 | db 'Type /help for help', 10, 0 |
521 | 548 | ||
522 | str_version db 'VERSION KolibriOS ' |
549 | str_version db 'VERSION KolibriOS ' |
523 | str_programname db 'IRC client ', version, 0 |
550 | str_programname db 'IRC client ', version, 0 |
524 | 551 | ||
525 | str_user db 'user', 0 |
552 | str_user db 'user', 0 |
526 | str_nick db 'nick', 0 |
553 | str_nick db 'nick', 0 |
527 | str_real db 'realname', 0 |
554 | str_real db 'realname', 0 |
528 | str_email db 'email', 0 |
555 | str_email db 'email', 0 |
529 | str_quitmsg db 'quitmsg', 0 |
556 | str_quitmsg db 'quitmsg', 0 |
530 | 557 | ||
531 | default_nick db 'kolibri_user', 0 |
558 | default_nick db 'kolibri_user', 0 |
532 | default_real db 'Kolibri User', 0 |
559 | default_real db 'Kolibri User', 0 |
533 | default_quit db 'KolibriOS forever', 0 |
560 | default_quit db 'KolibriOS forever', 0 |
534 | 561 | ||
535 | irc_colors dd 0xffffff ; 0 white |
562 | irc_colors dd 0xffffff ; 0 white |
536 | dd 0x000000 ; 1 black |
563 | dd 0x000000 ; 1 black |
537 | dd 0x00007f ; 2 blue (navy) |
564 | dd 0x00007f ; 2 blue (navy) |
538 | dd 0x009300 ; 3 green |
565 | dd 0x009300 ; 3 green |
539 | dd 0xff0000 ; 4 red |
566 | dd 0xff0000 ; 4 red |
540 | dd 0x7f0000 ; 5 brown (maroon) |
567 | dd 0x7f0000 ; 5 brown (maroon) |
541 | dd 0x9c009c ; 6 purple |
568 | dd 0x9c009c ; 6 purple |
542 | dd 0xfc7f00 ; 7 olive |
569 | dd 0xfc7f00 ; 7 olive |
543 | dd 0xffff00 ; 8 yellow |
570 | dd 0xffff00 ; 8 yellow |
544 | dd 0x00fc00 ; 9 light green |
571 | dd 0x00fc00 ; 9 light green |
545 | dd 0x009393 ; 10 teal |
572 | dd 0x009393 ; 10 teal |
546 | dd 0x00ffff ; 11 cyan |
573 | dd 0x00ffff ; 11 cyan |
547 | dd 0x0000fc ; 12 royal blue |
574 | dd 0x0000fc ; 12 royal blue |
548 | dd 0xff00ff ; 13 pink |
575 | dd 0xff00ff ; 13 pink |
549 | dd 0x7f7f7f ; 14 grey |
576 | dd 0x7f7f7f ; 14 grey |
550 | dd 0xd4d0c4 ; 15 light grey (silver) |
577 | dd 0xd4d0c4 ; 15 light grey (silver) |
551 | 578 | ||
552 | sockaddr1: |
579 | sockaddr1: |
553 | dw AF_INET4 |
580 | dw AF_INET4 |
554 | .port dw 0x0b1a ; 6667 FIXMEEEEEE |
581 | .port dw 0x0b1a ; 6667 FIXMEEEEEE |
555 | .ip dd 0 |
582 | .ip dd 0 |
556 | rb 10 |
583 | rb 10 |
- | 584 | ||
557 | 585 | SOCKADDR1_SIZE = 18 |
|
558 | 586 | ||
559 | status dd STATUS_DISCONNECTED |
587 | status dd STATUS_DISCONNECTED |
560 | 588 | ||
561 | window_active dd windows |
589 | window_active dd windows |
562 | window_print dd windows |
590 | window_print dd windows |
563 | 591 | ||
564 | align 4 |
592 | align 4 |
565 | @IMPORT: |
593 | @IMPORT: |
566 | 594 | ||
567 | library network, 'network.obj',\ |
595 | library network, 'network.obj',\ |
568 | libini, 'libini.obj',\ |
596 | libini, 'libini.obj',\ |
569 | boxlib, 'box_lib.obj' |
597 | boxlib, 'box_lib.obj' |
570 | 598 | ||
571 | import network,\ |
599 | import network,\ |
572 | getaddrinfo, 'getaddrinfo',\ |
600 | getaddrinfo, 'getaddrinfo',\ |
573 | freeaddrinfo, 'freeaddrinfo',\ |
601 | freeaddrinfo, 'freeaddrinfo',\ |
574 | inet_ntoa, 'inet_ntoa' |
602 | inet_ntoa, 'inet_ntoa' |
575 | 603 | ||
576 | import libini,\ |
604 | import libini,\ |
577 | ini.get_str, 'ini_get_str',\ |
605 | ini.get_str, 'ini_get_str',\ |
578 | ini.get_int, 'ini_get_int' |
606 | ini.get_int, 'ini_get_int' |
579 | 607 | ||
580 | import boxlib,\ |
608 | import boxlib,\ |
581 | edit_box_draw, 'edit_box',\ |
609 | edit_box_draw, 'edit_box',\ |
582 | edit_box_key, 'edit_box_key',\ |
610 | edit_box_key, 'edit_box_key',\ |
583 | edit_box_mouse, 'edit_box_mouse',\ |
611 | edit_box_mouse, 'edit_box_mouse',\ |
584 | scrollbar_draw, 'scrollbar_v_draw',\ |
612 | scrollbar_draw, 'scrollbar_v_draw',\ |
585 | scrollbar_mouse,'scrollbar_v_mouse' |
613 | scrollbar_mouse,'scrollbar_v_mouse' |
586 | 614 | ||
587 | ; width, left, top |
615 | ; width, left, top |
588 | edit1 edit_box 0, 0, 0, 0xffffff, 0x6f9480, 0, 0, 0x000000, USERCMD_MAX_SIZE, input_text, mouse_dd, ed_always_focus, 25, 25 |
616 | edit1 edit_box 0, 0, 0, 0xffffff, 0x6f9480, 0, 0, 0x000000, USERCMD_MAX_SIZE, input_text, mouse_dd, ed_always_focus, 25, 25 |
589 | ; xsize, xpos, ysize, ypos, btn_height, max, cur, pos, bgcol, frcol, linecol |
617 | ; xsize, xpos, ysize, ypos, btn_height, max, cur, pos, bgcol, frcol, linecol |
590 | scroll1 scrollbar SCROLLBAR_WIDTH, 0, 0, TOP_Y, SCROLLBAR_WIDTH, 0, 0, 0, 0, 0, 0, 1 |
618 | scroll1 scrollbar SCROLLBAR_WIDTH, 0, 0, TOP_Y, SCROLLBAR_WIDTH, 0, 0, 0, 0, 0, 0, 1 |
591 | scroll2 scrollbar SCROLLBAR_WIDTH, 0, 0, TOP_Y, SCROLLBAR_WIDTH, 0, 0, 0, 0, 0, 0, 1 |
619 | scroll2 scrollbar SCROLLBAR_WIDTH, 0, 0, TOP_Y, SCROLLBAR_WIDTH, 0, 0, 0, 0, 0, 0, 1 |
592 | 620 | ||
593 | input_text db '/server chat.freenode.net', 0 |
621 | input_text db '/server chat.freenode.net', 0 |
594 | rb MAX_COMMAND_LEN |
622 | rb MAX_COMMAND_LEN |
595 | 623 | ||
596 | I_END: |
624 | I_END: |
597 | 625 | ||
598 | user_command rb MAX_COMMAND_LEN*4 |
626 | user_command rb MAX_COMMAND_LEN*4 |
599 | .size dd ? |
627 | .size dd ? |
600 | 628 | ||
601 | utf8_bytes_rest dd ? ; bytes rest in current UTF8 sequence |
629 | utf8_bytes_rest dd ? ; bytes rest in current UTF8 sequence |
602 | utf8_char dd ? ; first bits of current UTF8 character |
630 | utf8_char dd ? ; first bits of current UTF8 character |
603 | 631 | ||
604 | packetbuf rb 1024 ; buffer for packets to server |
632 | packetbuf rb PACKETBUF_SIZE ; buffer for packets to server |
605 | path rb 1024 |
633 | path rb PATH_SIZE |
606 | param rb 1024 |
634 | param rb PARAM_SIZE |
607 | 635 | ||
608 | servercommand rb 600 |
636 | servercommand rb SERVERCOMMAND_SIZE |
609 | 637 | ||
610 | thread_info process_information |
638 | thread_info process_information |
611 | xsize dd ? |
639 | xsize dd ? |
612 | ysize dd ? |
640 | ysize dd ? |
613 | mouse_dd dd ? |
641 | mouse_dd dd ? |
614 | 642 | ||
615 | textbox_height dd ? ; in characters |
643 | textbox_height dd ? ; in characters |
616 | textbox_width dd ? ; in characters, not pixels ;) |
644 | textbox_width dd ? ; in characters, not pixels ;) |
617 | 645 | ||
618 | colors system_colors |
646 | colors system_colors |
619 | 647 | ||
620 | irc_server_name rb MAX_SERVER_NAME ; TODO: move this server URL into window struct |
648 | irc_server_name rb MAX_SERVER_NAME ; TODO: move this server URL into window struct |
621 | socketnum dd ? ; TODO: same for socket |
649 | socketnum dd ? ; TODO: same for socket |
622 | 650 | ||
623 | user_nick rb MAX_NICK_LEN |
651 | user_nick rb MAX_NICK_LEN |
624 | user_real_name rb MAX_REAL_LEN |
652 | user_real_name rb MAX_REAL_LEN |
625 | quit_msg rb 250 |
653 | quit_msg rb QUIT_MSG_LEN |
626 | 654 | ||
627 | windows rb MAX_WINDOWS*sizeof.window |
655 | windows rb MAX_WINDOWS*sizeof.window |
628 | 656 | ||
629 | IM_END: |
657 | IM_END: |