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