Rev 3449 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3067 | leency | 1 | |
2 | |||
3 | |||
4 | buf, |
||
5 | filesize, |
||
6 | blink; |
||
7 | |||
8 | |||
9 | char search_path[]="http://nigma.ru/index.php?s="; |
||
10 | char version[]=" Text-based Browser 0.98.2"; |
||
3129 | leency | 11 | |
3067 | leency | 12 | |
13 | |||
14 | int left, top, width, height, line_h; |
||
3464 | leency | 15 | void Scan(int); |
3067 | leency | 16 | void GetNewUrl(); |
17 | void OpenPage(); |
||
18 | void ReadHtml(byte); |
||
19 | void ShowPage(); |
||
20 | void ParseHTML(dword); |
||
21 | void WhatTextStyle(int left1, top1, width1); |
||
22 | void DrawPage(); |
||
23 | void DrawScroller(); |
||
24 | }; |
||
25 | |||
26 | |||
3128 | leency | 27 | link, ignor_text, li_tab, first_line_drawed, cur_encoding; |
28 | |||
29 | |||
3067 | leency | 30 | |
31 | |||
32 | |||
33 | text_color_index, |
||
34 | link_color, |
||
35 | bg_color; |
||
36 | |||
37 | |||
38 | stolbec, |
||
39 | tab_len; |
||
40 | |||
41 | |||
42 | int anchor_line_num; |
||
43 | |||
44 | |||
45 | tag[100], |
||
46 | tagparam[10000], |
||
47 | parametr[1200], |
||
48 | options[4096]; |
||
49 | |||
50 | |||
51 | #include "include\colors.h" |
||
52 | #include "include\unicode_tags.h" |
||
53 | #include "include\some_code.h" |
||
54 | #include "include\parce_tag.h" |
||
55 | |||
56 | |||
57 | |||
58 | { |
||
59 | if (id >= 400) |
||
60 | { |
||
61 | GetURLfromPageLinks(id); |
||
62 | |||
63 | |||
64 | if (URL[0] == '#') |
||
65 | { |
||
66 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
||
67 | |||
68 | |||
69 | |||
70 | |||
71 | ShowPage(); |
||
72 | return; |
||
73 | } |
||
74 | //liner.ru#1 |
||
75 | if (strrchr(#URL, '#')<>-1) |
||
76 | { |
||
77 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
||
78 | URL[strrchr(#URL, '#')-1] = 0x00; //заглушка |
||
79 | } |
||
80 | |||
81 | |||
82 | |||
83 | |||
84 | { |
||
85 | //if (strstr(#URL,"http:")) |
||
86 | RunProgram("/sys/media/kiv", #URL); |
||
87 | strcpy(#editURL, BrowserHistory.CurrentUrl()); |
||
88 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
||
89 | return; |
||
90 | } |
||
91 | if (!strcmpn(#URL,"mailto:", 7)) |
||
92 | { |
||
93 | RunProgram("@notify", #URL); |
||
94 | strcpy(#editURL, BrowserHistory.CurrentUrl()); |
||
95 | strcpy(#URL, BrowserHistory.CurrentUrl()); |
||
96 | return; |
||
97 | } |
||
98 | |||
99 | |||
100 | return; |
||
101 | } |
||
102 | |||
103 | |||
104 | { CASE 183: CASE 184: CASE 180: CASE 181: return; } |
||
105 | |||
106 | |||
107 | { |
||
108 | case 011: //Ctrk+K |
||
109 | ReadHtml(_KOI); |
||
110 | break; |
||
111 | case 021: //Ctrl+U |
||
112 | ReadHtml(_UTF); |
||
113 | break; |
||
114 | case 004: //Ctrl+D |
||
115 | ReadHtml(_DOS); |
||
116 | break; |
||
117 | case 001: |
||
118 | if (!pre_text) pre_text=2; |
||
119 | else pre_text=0; |
||
120 | break; |
||
121 | case 002: //free img cache |
||
122 | FreeImgCache(); |
||
123 | break; |
||
124 | case 005: //truetype |
||
125 | if (use_truetype == 2) |
||
126 | { |
||
127 | RunProgram("@notify", "Library does not exists /rd/1/lib/truetype.obj"w); |
||
128 | return; |
||
129 | } |
||
130 | if (use_truetype == 1) use_truetype=0; else use_truetype=1; |
||
131 | break; |
||
132 | case BACK: |
||
133 | if (!BrowserHistory.GoBack()) return; |
||
134 | OpenPage(); |
||
135 | return; |
||
136 | case FORWARD: |
||
137 | if (!BrowserHistory.GoForward()) return; |
||
138 | OpenPage(); |
||
139 | return; |
||
140 | case 052: //Нажата F3 |
||
141 | if (strcmp(get_URL_part(5),"http:")<>0) RunProgram("/rd/1/tinypad", #URL); else RunProgram("/rd/1/tinypad", #download_path); |
||
142 | return; |
||
143 | case 054: //F5 |
||
144 | IF(edit1.flags & 0b10) break; |
||
3081 | leency | 145 | case REFRESH: |
3067 | leency | 146 | if (GetProcessSlot(downloader_id)<>0) |
147 | { |
||
148 | KillProcess(downloader_id); |
||
149 | pause(20); |
||
3078 | leency | 150 | Draw_Window(); |
3067 | leency | 151 | return; |
152 | } |
||
153 | anchor_line_num=lines.first; //весёлый костыль :Р |
||
154 | anchor[0]='|'; |
||
155 | OpenPage(); |
||
156 | return; |
||
157 | case 014: //Ctrl+N новое окно |
||
158 | case 020: //Ctrl+T новая вкладка |
||
159 | case NEWTAB: |
||
160 | MoveSize(190,80,OLD,OLD); |
||
161 | RunProgram(#program_path, #URL); |
||
162 | return; |
||
163 | |||
164 | |||
165 | strcpy(#editURL, "http://kolibri-n.org/index.php"); |
||
3449 | leency | 166 | case GOTOURL: |
3067 | leency | 167 | case 0x0D: //enter |
168 | strcpy(#URL, #editURL); |
||
169 | OpenPage(); |
||
170 | return; |
||
171 | case 173: //ctrl+enter |
||
172 | case SEARCHWEB: |
||
173 | strcpy(#URL, #search_path); |
||
174 | strcat(#URL, #editURL); |
||
175 | OpenPage(); |
||
176 | return; |
||
177 | |||
178 | |||
179 | IF(lines.first <= 0) return; |
||
180 | lines.first--; |
||
181 | break; |
||
182 | case ID2: //мотаем вниз |
||
183 | IF(lines.visible + lines.first >= lines.all) return; |
||
184 | lines.first++; |
||
185 | break; |
||
186 | case 183: //PgDown |
||
187 | IF(lines.first == lines.all - lines.visible) return; |
||
188 | lines.first += lines.visible + 2; |
||
189 | IF(lines.visible + lines.first > lines.all) lines.first = lines.all - lines.visible; |
||
190 | break; |
||
191 | case 184: //PgUp |
||
192 | IF(lines.first == 0) return; |
||
193 | lines.first -= lines.visible - 2; |
||
194 | IF(lines.first < 0) lines.first = 0; |
||
195 | break; |
||
196 | case 180: //home |
||
197 | IF(lines.first == 0) return; |
||
198 | lines.first = 0; |
||
199 | break; |
||
200 | case 181: //end |
||
201 | IF (lines.first == lines.all - lines.visible) return; |
||
202 | lines.first = lines.all - lines.visible; |
||
203 | break; |
||
204 | default: |
||
205 | return; |
||
206 | } |
||
207 | ParseHTML(buf); |
||
208 | } |
||
209 | |||
210 | |||
211 | |||
212 | |||
213 | |||
214 | void TWebBrowser::GetNewUrl(){ |
||
215 | int i, len; |
||
216 | |||
217 | |||
218 | { |
||
219 | len=strlen(ABSOLUTE_LINKS[i]); |
||
220 | if (!strcmpn(#URL, ABSOLUTE_LINKS[i], len)) return; |
||
221 | } |
||
222 | |||
223 | |||
224 | if (URL[0] == '/') strcpy(#URL, #URL+1); |
||
225 | |||
226 | |||
227 | |||
228 | |||
229 | |||
230 | |||
231 | { |
||
232 | editURL[strrchr(#editURL, '/')] = 0x00; //обрезаем её урл до последнего / |
||
233 | } |
||
234 | |||
235 | |||
236 | { |
||
237 | strcpy(#URL,#URL+3); |
||
238 | editURL[strrchr(#editURL, '/')-1] = 0x00; //обрезаем её урл до последнего / |
||
239 | goto _CUT_ST_LEVEL_MARK; |
||
240 | } |
||
241 | |||
242 | |||
243 | |||
244 | |||
245 | strcpy(#URL, #editURL); |
||
246 | } |
||
247 | |||
248 | |||
249 | |||
250 | |||
251 | { |
||
252 | if (!strcmp(get_URL_part(5),"http:"))) |
||
253 | file_size stdcall (#download_path); |
||
254 | else |
||
255 | file_size stdcall (#URL); |
||
256 | |||
257 | |||
258 | if (!filesize) return; |
||
259 | |||
260 | |||
261 | buf = mem_Alloc(filesize); |
||
262 | if (!strcmp(get_URL_part(5),"http:"))) |
||
263 | ReadFile(0, filesize, buf, #download_path); |
||
264 | else |
||
265 | ReadFile(0, filesize, buf, #URL); |
||
266 | |||
267 | |||
268 | if (encoding==_WIN) wintodos(buf); |
||
269 | if (encoding==_UTF) utf8rutodos(buf); |
||
270 | if (encoding==_KOI) koitodos(buf); |
||
271 | } |
||
272 | |||
273 | |||
274 | |||
275 | { |
||
276 | if (GetProcessSlot(downloader_id)<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal); |
||
277 | KillProcess(downloader_id); |
||
278 | strcpy(#editURL, #URL); |
||
279 | BrowserHistory.AddUrl(); |
||
280 | strcpy(#header, #version); |
||
281 | pre_text =0; |
||
282 | if (!strcmp(get_URL_part(5),"http:"))) |
||
283 | { |
||
284 | KillProcess(downloader_id); //убиваем старый процесс |
||
285 | DeleteFile(#download_path); |
||
286 | IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]=NULL; |
||
287 | downloader_id = RunProgram("/sys/network/downloader", #URL); |
||
288 | //Browser Hack v2.0 |
||
289 | pause(60); |
||
3079 | leency | 290 | if (GetProcessSlot(downloader_id)<>0) |
3067 | leency | 291 | { |
292 | debug("Browser Hack v2.0: Killing downloader and trying to run it one more!"); |
||
293 | KillProcess(downloader_id); //убиваем старый процесс |
||
294 | downloader_id = RunProgram("/sys/network/downloader", #URL); |
||
295 | } |
||
296 | // |
||
297 | IF (downloader_id<0) RunProgram("@notify", "Error running Downloader. Internet unavilable."); |
||
298 | Draw_Window(); |
||
299 | return; |
||
300 | } |
||
301 | lines.first = lines.all =0; |
||
302 | ReadHtml(_WIN); |
||
303 | WB1.ShowPage(); |
||
304 | } |
||
305 | |||
306 | |||
307 | |||
308 | { |
||
309 | edit1.size = edit1.pos = strlen(#editURL); |
||
310 | edit1.offset=0; |
||
311 | edit_box_draw stdcall(#edit1); //рисуем строку адреса |
||
312 | |||
3128 | leency | 313 | |
3067 | leency | 314 | { |
315 | DrawBar(left, top, width+4, height, 0xFFFFFF); //закрашиваем всё донизу |
||
316 | if (GetProcessSlot(downloader_id)<>0) WriteText(left + 10, top + 18, 0x80, 0, "Loading..."); |
||
3107 | leency | 317 | else |
3067 | leency | 318 | { |
319 | WriteText(left + 10, top + 18, 0x80, 0, "Page not found. May be, URL contains some errors."); |
||
3107 | leency | 320 | if (!strcmp(get_URL_part(5),"http:"))) WriteText(left + 10, top + 32, 0x80, 0, "Or Internet unavilable for your configuration."); |
321 | } |
||
3067 | leency | 322 | //return; |
323 | } |
||
324 | else |
||
325 | ParseHTML(buf); |
||
326 | |||
327 | |||
328 | if (!strcmp(#version, #header)) DrawTitle(#header); |
||
329 | } |
||
330 | |||
331 | |||
332 | |||
333 | |||
334 | word bukva[2]; |
||
335 | int j, perenos_num; |
||
336 | byte ignor_param; |
||
337 | char temp[768]; |
||
338 | |||
339 | |||
340 | stolbec = 0; |
||
341 | |||
342 | |||
343 | blink = 400; |
||
344 | |||
345 | |||
346 | li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 0; //обнуляем теги |
||
347 | link_color = 0x0000FF; |
||
348 | bg_color = 0xFFFFFF; |
||
349 | line = NULL; |
||
350 | strcpy(#page_links,"|"); |
||
351 | strcpy(#header, #version); |
||
352 | |||
353 | |||
354 | { |
||
355 | pre_text=0; |
||
356 | if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1; |
||
357 | if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1; |
||
358 | } |
||
359 | |||
360 | |||
361 | { |
||
362 | bukva = ESBYTE[bword]; |
||
363 | if (ignor_text) && (bukva<>'<') continue; |
||
364 | switch (bukva) |
||
365 | { |
||
366 | case 0x0a: |
||
367 | if (pre_text) |
||
368 | { |
||
369 | bukva = temp = NULL; |
||
370 | goto NEXT_MARK; |
||
371 | } |
||
372 | case '\9': |
||
373 | if (pre_text) //иначе идём на 0x0d |
||
374 | { |
||
375 | tab_len=strlen(#line)/8; |
||
376 | tab_len=tab_len*8; |
||
377 | tab_len=8+tab_len-strlen(#line); |
||
378 | for (j=0; j |
||
379 | break; |
||
380 | } |
||
381 | case 0x0d: |
||
382 | bukva = ' '; |
||
383 | goto DEFAULT_MARK; |
||
384 | case '=': //поддержка шайтанской кодировки страниц, сохранённых через ИЕ7 |
||
385 | if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK; |
||
386 | |||
387 | |||
388 | bukva=ESBYTE[bword]; |
||
389 | strcpy(#temp,#bukva); |
||
390 | bword++; |
||
391 | bukva=ESBYTE[bword]; |
||
392 | strcat(#temp,#bukva); |
||
393 | |||
394 | |||
395 | if (bukva) goto DEFAULT_MARK; |
||
396 | break; |
||
397 | |||
398 | |||
399 | bword++; |
||
400 | tag=0; |
||
401 | for (j=0; (ESBYTE[bword]<>';') && (j<7); j++, bword++;) |
||
402 | { |
||
403 | bukva = ESBYTE[bword]; |
||
404 | strcat(#tag, #bukva); |
||
405 | } |
||
406 | |||
407 | |||
408 | if (bukva) goto DEFAULT_MARK; |
||
409 | break; |
||
410 | case '<': |
||
411 | bword++; //промотаем символ < |
||
412 | tag = parametr = tagparam = ignor_param = NULL; |
||
413 | if (ESBYTE[bword] == '!') //фильтрация внутри , дерзко |
||
414 | { |
||
415 | bword++; |
||
416 | if (ESBYTE[bword] == '-') |
||
417 | { |
||
418 | HH_: |
||
419 | do |
||
420 | { |
||
421 | bword++; |
||
422 | if (buf + filesize <= bword) break 2; |
||
423 | } |
||
424 | while (ESBYTE[bword] <>'-'); |
||
425 | |||
426 | |||
427 | if (ESBYTE[bword] <>'-') goto HH_; |
||
428 | } |
||
429 | } |
||
430 | while (ESBYTE[bword] !='>') && (bword < buf + filesize) //получаем тег и его параметры |
||
431 | { |
||
432 | bukva = ESBYTE[bword]; |
||
433 | if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' '; |
||
434 | if (!ignor_param) && (bukva <>' ') |
||
435 | { |
||
436 | if (strlen(#tag) |
||
437 | } |
||
438 | else |
||
439 | { |
||
440 | ignor_param = true; |
||
441 | if (!ignor_text) && (strlen(#tagparam)+1 |
||
442 | } |
||
443 | bword++; |
||
444 | } |
||
445 | strlwr(#tag); |
||
446 | strlwr(#tagparam); |
||
447 | |||
448 | |||
449 | if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam(); |
||
450 | |||
451 | |||
452 | { |
||
453 | perenos_num = strrchr(#line, ' '); |
||
454 | if (!perenos_num) && (strlen(#line)>lines.column_max) perenos_num=lines.column_max; |
||
455 | strcpy(#temp, #line + perenos_num); //перенос по словам |
||
456 | line[perenos_num] = 0x00; |
||
457 | if (stroka >= lines.visible) && (lines.first <>0) break 1; //уходим... |
||
458 | DrawPage(); |
||
459 | strcpy(#line, #temp); |
||
460 | |||
461 | |||
462 | } |
||
463 | DrawPage(); |
||
464 | line=NULL; |
||
465 | |||
466 | |||
467 | |||
468 | |||
469 | break; |
||
470 | default: |
||
471 | DEFAULT_MARK: |
||
472 | if (!pre_text) && (bukva == ' ') |
||
473 | { |
||
474 | if (line[strlen(#line)-1]==' ') break; //убрать 2 пробела подряд |
||
475 | if (!stolbec) && (!line) break; //строка не может начинаться с пробела |
||
476 | } |
||
477 | if (strlen(#line) |
||
3363 | leency | 478 | |
3067 | leency | 479 | |
480 | { |
||
481 | NEXT_MARK: |
||
482 | perenos_num = strrchr(#line, ' '); |
||
483 | if (!perenos_num) && (strlen(#line)>lines.column_max) perenos_num=lines.column_max; |
||
484 | strcpy(#temp, #line + perenos_num); //перенос по словам |
||
485 | line[perenos_num] = 0x00; |
||
486 | if (stroka >= lines.visible) && (lines.first <>0) break 1; //уходим... |
||
487 | DrawPage(); |
||
488 | strcpy(#line, #temp); |
||
489 | |||
490 | |||
491 | } |
||
492 | } |
||
493 | } |
||
494 | |||
495 | |||
496 | if (lines.visible * 10 + 25 <= height) |
||
497 | DrawBar(left, lines.visible * 10 + top + 25, width - 15, -lines.visible * 10 + height - 25, bg_color); |
||
498 | if (stroka * 10 + 15 <= height) |
||
499 | DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, bg_color); //закрашиваем всё до конца |
||
500 | if (lines.first == 0) lines.all = stroka; |
||
501 | if (anchor) //если посреди текста появится новый якорь - будет бесконечный цикл |
||
502 | { |
||
503 | anchor=NULL; |
||
504 | lines.first=anchor_line_num; |
||
505 | ParseHTML(buf); |
||
506 | } |
||
507 | DrawScroller(); |
||
508 | } |
||
509 | |||
510 | |||
3464 | leency | 511 | |
512 | |||
513 | { |
||
3067 | leency | 514 | int start_x, start_y, line_length; |
515 | |||
516 | |||
3464 | leency | 517 | { |
3067 | leency | 518 | strcpy(#header, #line); |
3464 | leency | 519 | strcat(#header, " -"); |
3067 | leency | 520 | strcat(#header, #version); |
521 | line = 0; |
||
3464 | leency | 522 | return; |
3067 | leency | 523 | } |
524 | |||
525 | |||
526 | { |
||
527 | if (!stroka) && (!stolbec) |
||
528 | { |
||
529 | DrawBar(left, top, width-15, 15, bg_color); //first line |
||
3464 | leency | 530 | first_line_drawed=1; |
3067 | leency | 531 | } |
532 | |||
533 | |||
3464 | leency | 534 | start_y = stroka * 10 + top + 5; |
535 | line_length = strlen(#line) * 6; |
||
536 | |||
3067 | leency | 537 | |
538 | { |
||
539 | //line_length = get_length stdcall (#line,-1,16,line_length); |
||
540 | text_out stdcall (#line, #fontlol, 17, text_colors[text_color_index], start_x, start_y-3); |
||
541 | } |
||
542 | else |
||
543 | { |
||
544 | WriteText(start_x, start_y, 0x80, text_colors[text_color_index], #line); |
||
3107 | leency | 545 | IF (b_text) { $add ebx, 1<<16 $int 0x40 } |
3067 | leency | 546 | } |
547 | IF (i_text) Skew(start_x, start_y, line_length+6, 10); |
||
548 | IF (s_text) DrawBar(start_x, start_y + 4, line_length, 1, text_colors[text_color_index]); |
||
549 | IF (u_text) DrawBar(start_x, start_y + 8, line_length, 1, text_colors[text_color_index]); |
||
550 | IF (link) { |
||
551 | UnsafeDefineButton(start_x-2, start_y, line_length + 3, 9, blink + BT_HIDE, 0xB5BFC9); |
||
3107 | leency | 552 | DrawBar(start_x, start_y + 8, line_length, 1, text_colors[text_color_index]); |
3067 | leency | 553 | } |
554 | stolbec += strlen(#line); |
||
555 | } |
||
556 | } |
||
557 | |||
558 | |||
559 | |||
560 | void TWebBrowser::WhatTextStyle(int left1, top1, width1) { |
||
561 | dword hr_color; |
||
562 | |||
563 | |||
564 | if (tag[0] == '/') |
||
565 | { |
||
566 | rez = 0; |
||
567 | strcpy(#tag, #tag+1); |
||
568 | } |
||
569 | else rez = 1; |
||
570 | |||
571 | |||
572 | { |
||
573 | IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (rez==0) ignor_text = 1; ELSE ignor_text = 0; |
||
574 | return; |
||
575 | } |
||
576 | |||
577 | |||
578 | |||
579 | |||
580 | { |
||
581 | if (rez) header=NULL; |
||
582 | else if (!stroka) DrawTitle(#header); //тег закрылся - вывели строку |
||
583 | return; |
||
584 | } |
||
585 | |||
586 | |||
587 | |||
588 | |||
589 | |||
590 | |||
591 | |||
592 | |||
593 | { |
||
594 | if (!strcmp(#anchor, #options)) anchor_line_num=lines.first+stroka; |
||
595 | } |
||
596 | |||
597 | |||
598 | { |
||
599 | do{ |
||
600 | if (!strcmp(#parametr, "link=")) link_color = GetColor(#options); |
||
601 | if (!strcmp(#parametr, "text=")) text_colors[0]=GetColor(#options); |
||
602 | if (!strcmp(#parametr, "bgcolor=")) bg_color=GetColor(#options); |
||
603 | } while(GetNextParam()); |
||
604 | return; |
||
605 | } |
||
606 | |||
607 | |||
608 | { |
||
609 | if (rez) |
||
610 | { |
||
611 | if (link) IF(text_color_index > 0) text_color_index--; //если предыдущий тег а не был закрыт |
||
612 | |||
613 | |||
614 | if (!strcmp(#parametr, "href=")) |
||
615 | { |
||
616 | if (stroka - 1 > lines.visible) || (stroka < -2) return; |
||
617 | |||
618 | |||
619 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
||
620 | |||
621 | |||
622 | blink++; |
||
623 | text_colors[text_color_index] = link_color; |
||
624 | strcat(#page_links, #options); |
||
625 | strcat(#page_links, "|"); |
||
626 | } |
||
627 | if (anchor) && (!strcmp(#parametr, "name=")) |
||
628 | { |
||
629 | if (!strcmp(#anchor, #options)) |
||
630 | { |
||
631 | anchor_line_num=lines.first+stroka; |
||
632 | } |
||
633 | } |
||
634 | } while(GetNextParam()); |
||
635 | } |
||
636 | else { |
||
637 | link = 0; |
||
638 | IF(text_color_index > 0) text_color_index--; |
||
639 | } |
||
640 | return; |
||
641 | } |
||
642 | |||
643 | |||
644 | { |
||
645 | if (rez) |
||
646 | { |
||
647 | text_color_index++; |
||
648 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
||
649 | |||
650 | |||
651 | if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#') |
||
652 | { |
||
653 | text_colors[text_color_index] = GetColor(#options); |
||
654 | } |
||
655 | } while(GetNextParam()); |
||
656 | } |
||
657 | else |
||
658 | if (text_color_index > 0) text_color_index--; |
||
659 | return; |
||
660 | } |
||
661 | if(!chTag("tr")) || (!chTag("br")) { |
||
662 | TextGoDown(left1, top1, width1); |
||
663 | return; |
||
664 | } |
||
665 | if (!chTag("div")) { |
||
666 | IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1); |
||
667 | return; |
||
668 | } |
||
669 | if (!chTag("p")) { |
||
670 | IF(oldtag[0] == 'h') return; |
||
671 | TextGoDown(left1, top1, width1); |
||
672 | IF(rez) TextGoDown(left1, top1 + 10, width1); |
||
673 | return; |
||
674 | } |
||
675 | if (!chTag("h1")) || (!chTag("h2")) || (!chTag("h3")) || (!chTag("h4")) { |
||
676 | TextGoDown(left1, top1, width1); |
||
677 | IF(rez) TextGoDown(left1, top1 + 10, width1); |
||
678 | b_text = rez; |
||
679 | strcpy(#oldtag, #tag); |
||
680 | return; |
||
681 | } |
||
682 | else |
||
683 | oldtag=NULL; |
||
684 | |||
685 | |||
686 | b_text = rez; |
||
687 | return; |
||
688 | } |
||
689 | if(!chTag("i")) || (!chTag("em")) || (!chTag("subtitle")) { |
||
690 | i_text = rez; |
||
691 | return; |
||
692 | } |
||
693 | if (!chTag("dt")) |
||
694 | { |
||
695 | li_text = rez; |
||
696 | IF(rez == 0) return; |
||
697 | TextGoDown(left1, top1, width1); |
||
698 | return; |
||
699 | } |
||
700 | if(!chTag("li")) || (!chTag("dt")) //надо сделать вложенные списки |
||
701 | { |
||
702 | li_text = rez; |
||
703 | IF(rez == 0) return; |
||
704 | TextGoDown(left1, top1, width1); |
||
705 | IF(stroka > -1) && (stroka - 2 < lines.visible) DrawBar(li_tab * 5 * 6 + left1 - 5, top1 + 12, 2, 2, 0); |
||
706 | return; |
||
707 | } |
||
708 | if (!chTag("u")) || (!chTag("ins")) u_text = rez; |
||
709 | if (!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez; |
||
710 | if (!chTag("ul")) || (!chTag("ol")) IF(!rez) |
||
711 | { |
||
712 | li_text = rez; |
||
713 | li_tab--; |
||
714 | TextGoDown(left1, top1, width1); |
||
715 | } ELSE li_tab++; |
||
716 | if (!chTag("dd")) stolbec += 5; |
||
717 | if (!chTag("blockquote")) blq_text = rez; |
||
718 | if (!chTag("pre")) pre_text = rez; |
||
719 | if (!chTag("hr")) |
||
720 | { |
||
721 | TextGoDown(left1, top1, width1); |
||
722 | TextGoDown(left1, top1 + 10, width1); |
||
723 | if (anchor) return; |
||
3129 | leency | 724 | IF(strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); |
3067 | leency | 725 | ELSE hr_color = 0x999999; |
726 | IF(stroka > 0) DrawBar(left1, top1 + 14, width1 - 8, 1, hr_color); |
||
727 | } |
||
728 | if (!chTag("input")) |
||
3129 | leency | 729 | { |
730 | do{ |
||
731 | if (!strcmp(#parametr, "type=")) if ((!strcmp(#options, "radio")) || (!strcmp(#options, "checkbox"))) |
||
732 | { |
||
733 | if (!anchor) && (stroka > 0) CheckBox(stolbec*6 + left1,top1-2,10,10, 0, "\0", 0x888888, text_colors[text_color_index], 0); |
||
734 | stolbec+=2; |
||
735 | } |
||
736 | if (!strcmp(#parametr, "type=")) if ((!strcmp(#options, "text")) || (!strcmp(#options, "password"))) |
||
737 | { |
||
738 | if (!anchor) && (stroka > 0) CheckBox(stolbec*6 + left1,top1-2,90,10, 0, "\0", 0x555555, 0, 0); |
||
739 | stolbec+=16; |
||
740 | } |
||
741 | if (!strcmp(#parametr, "type=")) if ((!strcmp(#options, "button")) || (!strcmp(#options, "file")) || (!strcmp(#options, "submit"))) |
||
742 | { |
||
743 | if (!anchor) && (stroka > 0) DrawCaptButton(stolbec*6 + left1,top1-2,60,10, 0, 0xCCCccc, 0, "Button"); |
||
744 | stolbec+=21; |
||
745 | } |
||
746 | } while(GetNextParam()); |
||
747 | } |
||
748 | if (!chTag("img")) |
||
3067 | leency | 749 | { |
750 | Images( left1, top1, width1); |
||
751 | return; |
||
752 | } |
||
753 | if (!chTag("meta")) || (!chTag("?xml")) |
||
754 | { |
||
755 | do{ |
||
756 | if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding=")) |
||
757 | { |
||
758 | strcpy(#options, #options[strrchr(#options, '=')]); //поиск в content= |
||
759 | if (!strcmp(#options,"utf-8")) || (!strcmp(#options,"utf8")) ReadHtml(_UTF); |
||
760 | if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) ReadHtml(_KOI); |
||
761 | if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866")) ReadHtml(_DOS); |
||
762 | } |
||
763 | } while(GetNextParam()); |
||
764 | return; |
||
765 | } |
||
766 | } |
||
767 | |||
768 | |||
769 | |||
770 | { |
||
771 | if (!stroka) && (!stolbec) && (!first_line_drawed) |
||
772 | { |
||
773 | DrawBar(WB1.left, WB1.top, WB1.width-15, 15, bg_color); //закрашиваем первую строку |
||
774 | first_line_drawed=1; |
||
775 | } |
||
776 | stroka++; |
||
777 | if (blq_text) stolbec = 8; |
||
778 | ELSE stolbec = 0; |
||
779 | if (li_text) stolbec = li_tab * 5; |
||
780 | IF(stroka >= 0) && (stroka - 2 < lines.visible) && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color); |
||
781 | } |
||
782 | |||
783 | |||
784 | |||
785 | { |
||
786 | dword *image; |
||
787 | char path[4096]; |
||
788 | }; |
||
789 | s_image pics[100]; //pics = mem_Alloc( 100*sizeof(s_image) ); |
||
790 | int num_of_pics; |
||
791 | |||
792 | |||
793 | { |
||
794 | int i; |
||
795 | for (i=0; i |
||
796 | { |
||
797 | if (!strcmp(#pics[i].path, i_path)) return i; |
||
798 | } |
||
799 | num_of_pics++; |
||
800 | return num_of_pics; |
||
801 | } |
||
802 | |||
803 | |||
804 | { |
||
805 | int i; |
||
806 | for (i=0; i<=num_of_pics; i++) |
||
807 | { |
||
808 | img_destroy stdcall (pics[num_of_pics].image); |
||
3129 | leency | 809 | pics[num_of_pics].path = NULL; |
810 | } |
||
3067 | leency | 811 | num_of_pics=0; |
812 | } |
||
813 | |||
814 | |||
815 | |||
816 | { |
||
817 | dword image; |
||
818 | char img_path[4096], alt[4096]; |
||
819 | int w=0, h=0, img_lines_first=0, cur_pic=0; |
||
820 | |||
821 | |||
3363 | leency | 822 | if (!strcmp(#parametr,"src=")) //надо объединить с GetNewUrl() |
823 | { |
||
824 | if (downloader_id) strcpy(#img_path, #history_list[history_current-1].Item); |
||
825 | else strcpy(#img_path, BrowserHistory.CurrentUrl()); //достаём адрес текущей страницы |
||
826 | |||
827 | |||
828 | { |
||
3067 | leency | 829 | img_path[strrchr(#img_path, '/')] = '\0'; //обрезаем её урл до последнего / |
3363 | leency | 830 | strcat(#img_path, #options); |
831 | |||
3067 | leency | 832 | |
3363 | leency | 833 | if (!pics[cur_pic].path) |
834 | { |
||
3067 | leency | 835 | pics[cur_pic].image=load_image(#img_path); |
3363 | leency | 836 | strcpy(#pics[cur_pic].path, #img_path); |
837 | } |
||
3067 | leency | 838 | } |
839 | } |
||
840 | if (!strcmp(#parametr,"alt=")) |
||
3363 | leency | 841 | { |
3067 | leency | 842 | strcpy(#alt, "["); |
3363 | leency | 843 | strcat(#alt, #options); |
844 | strcat(#alt, "]"); |
||
845 | } |
||
3067 | leency | 846 | |
3363 | leency | 847 | |
848 | |||
849 | |||
850 | { |
||
851 | if (alt) && (link) strcat(#line, #alt); |
||
852 | return; |
||
853 | } |
||
854 | |||
855 | |||
856 | h=DSWORD[pics[cur_pic].image+8]; |
||
857 | if (w>width1) w=width1; |
||
858 | |||
859 | |||
860 | stroka+=h/10; |
||
861 | if (top1+h |
||
862 | if (top1 |
||
863 | { |
||
864 | DrawBar(WB1.left, WB1.top, WB1.width-15, 10, bg_color); //закрашиваем первую строку |
||
865 | img_lines_first=WB1.top-top1; |
||
866 | h=h-img_lines_first; |
||
867 | top1=WB1.top; |
||
868 | } |
||
869 | if (top1>WB1.top+WB1.height-h-15) //если часть изображения снизу |
||
870 | { |
||
871 | h=WB1.top+WB1.height-top1-15; |
||
872 | } |
||
873 | if (h<=0) return; |
||
874 | if (anchor) return; |
||
875 | |||
876 | |||
877 | DrawBar(left1+w - 5, top1 + 10, width1-w + 5, h, bg_color); |
||
878 | IF (link) UnsafeDefineButton(left1 - 5, top1+10, w, h, blink + BT_HIDE, 0xB5BFC9); |
||
3464 | leency | 879 | } |
3067 | leency | 880 | |
881 | |||
882 | |||
883 | void TWebBrowser::DrawScroller() //не оптимальная отрисовка, но зато в одном месте |
||
884 | { |
||
885 | scroll1.max_area = lines.all; |
||
886 | scroll1.cur_area = lines.visible; |
||
887 | scroll1.position = lines.first; |
||
888 | |||
889 | |||
890 | scroll1.start_x=Form.width-28; //left + width - 15 |
||
891 | scroll1.size_y=WB1.height; |
||
892 | |||
893 | |||
894 | }=0)>=num_of_pics;>>>>>16><16>>=>=>>>>>>>>=>!--> |
||
895 | >': |