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