Rev 4486 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4486 | Rev 4488 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include "..\lib\draw_buf.h" |
1 | #include "..\lib\draw_buf.h" |
- | 2 | #include "..\lib\list_box.h" |
|
- | 3 | ||
Line 2... | Line 4... | ||
2 | 4 | ||
Line 3... | Line 5... | ||
3 | int downloader_id; |
5 | int downloader_id; |
4 | 6 | ||
Line 11... | Line 13... | ||
11 | int mouse_twb; |
13 | int mouse_twb; |
12 | edit_box address_box= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19}; |
14 | edit_box address_box= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19}; |
13 | scroll_bar scroll_wv = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; |
15 | scroll_bar scroll_wv = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; |
Line 14... | Line 16... | ||
14 | 16 | ||
15 | char editURL[sizeof(URL)]; |
- | |
16 | char page_links[12000]; |
17 | char editURL[sizeof(URL)]; |
Line 17... | Line 18... | ||
17 | char header[2048]; |
18 | char header[2048]; |
Line 36... | Line 37... | ||
36 | 37 | ||
37 | byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab, |
38 | byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab, |
38 | link, ignor_text, cur_encoding, text_align; |
39 | link, ignor_text, cur_encoding, text_align; |
Line -... | Line 40... | ||
- | 40 | byte condition_text_active, condition_text_val, condition_href, condition_max; |
|
Line 39... | Line 41... | ||
39 | byte condition_text_active, condition_text_val, condition_href, condition_max; |
41 | |
Line 40... | Line 42... | ||
40 | 42 | enum { _WIN, _DOS, _KOI, _UTF }; |
|
41 | 43 | ||
Line 60... | Line 62... | ||
60 | 62 | ||
61 | #include "..\TWB\history.h" |
63 | #include "..\TWB\history.h" |
62 | #include "..\TWB\colors.h" |
64 | #include "..\TWB\colors.h" |
63 | #include "..\TWB\unicode_tags.h" |
65 | #include "..\TWB\unicode_tags.h" |
64 | #include "..\TWB\img_cache.h" |
- | |
65 | #include "..\TWB\some_code.h" |
66 | #include "..\TWB\img_cache.h" |
- | 67 | #include "..\TWB\parce_tag.h" |
|
Line 66... | Line 68... | ||
66 | #include "..\TWB\parce_tag.h" |
68 | #include "..\TWB\links.h" |
Line 131... | Line 133... | ||
131 | if (editURL[strrchr(#editURL, '/')-2]<>'/') // åñëè íå http:// |
133 | if (editURL[strrchr(#editURL, '/')-2]<>'/') // åñëè íå http:// |
132 | { |
134 | { |
133 | editURL[strrchr(#editURL, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî / |
135 | editURL[strrchr(#editURL, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî / |
134 | } |
136 | } |
Line 135... | Line 137... | ||
135 | 137 | ||
136 | IF (!strcmp(get_URL_part(3),"../")) //íà óðîâåíü ââåðõ |
138 | IF (!strncmp(#URL,"../",3)) //íà óðîâåíü ââåðõ |
137 | { |
139 | { |
138 | strcpy(#URL,#URL+3); |
140 | strcpy(#URL,#URL+3); |
139 | editURL[strrchr(#editURL, '/')-1] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî / |
141 | editURL[strrchr(#editURL, '/')-1] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî / |
140 | goto _CUT_ST_LEVEL_MARK; |
142 | goto _CUT_ST_LEVEL_MARK; |
Line 148... | Line 150... | ||
148 | 150 | ||
149 | 151 | ||
150 | 152 | ||
151 | void TWebBrowser::ReadHtml(byte encoding) |
153 | void TWebBrowser::ReadHtml(byte encoding) |
152 | { |
154 | { |
153 | if (!strcmp(get_URL_part(5),"http:"))) |
155 | if (!strncmp(#URL,"http:",5)) |
Line 154... | Line 156... | ||
154 | file_size stdcall (#download_path); |
156 | file_size stdcall (#download_path); |
155 | else |
157 | else |
Line 156... | Line 158... | ||
156 | file_size stdcall (#URL); |
158 | file_size stdcall (#URL); |
157 | 159 | ||
158 | filesize = EBX; |
160 | filesize = EBX; |
159 | if (!filesize) return; |
161 | if (!filesize) return; |
160 | 162 | ||
161 | mem_Free(buf); |
163 | mem_Free(buf); |
Line 162... | Line 164... | ||
162 | buf = mem_Alloc(filesize); |
164 | buf = mem_Alloc(filesize); |
Line 183... | Line 185... | ||
183 | DrawBar(list.x, list.y, list.w+scroll_wv.size_x+1, list.h, 0xFFFFFF); //fill all |
185 | DrawBar(list.x, list.y, list.w+scroll_wv.size_x+1, list.h, 0xFFFFFF); //fill all |
184 | if (GetProcessSlot(downloader_id)<>0) WriteText(list.x + 10, list.y + 18, 0x80, 0, "Loading..."); |
186 | if (GetProcessSlot(downloader_id)<>0) WriteText(list.x + 10, list.y + 18, 0x80, 0, "Loading..."); |
185 | else |
187 | else |
186 | { |
188 | { |
187 | WriteText(list.x + 10, list.y + 18, 0x80, 0, "Page not found. May be, URL contains some errors."); |
189 | WriteText(list.x + 10, list.y + 18, 0x80, 0, "Page not found. May be, URL contains some errors."); |
188 | if (!strcmp(get_URL_part(5),"http:"))) WriteText(list.x + 10, list.y + 32, 0x80, 0, "Or Internet unavilable for your configuration."); |
190 | if (!strncmp(#URL,"http:",5)) WriteText(list.x + 10, list.y + 32, 0x80, 0, "Or Internet unavilable for your configuration."); |
189 | } |
191 | } |
190 | //return; |
192 | //return; |
191 | } |
193 | } |
192 | else |
194 | else |
193 | ParseHTML(buf); |
195 | ParseHTML(buf); |
Line 211... | Line 213... | ||
211 | condition_max = 255; |
213 | condition_max = 255; |
212 | text_align = ALIGN_LEFT; |
214 | text_align = ALIGN_LEFT; |
213 | link_color = 0x0000FF; |
215 | link_color = 0x0000FF; |
214 | bg_color = 0xFFFFFF; |
216 | bg_color = 0xFFFFFF; |
215 | DrawBuf.Fill(bg_color); |
217 | DrawBuf.Fill(bg_color); |
216 | strcpy(#page_links,"|"); |
218 | PageLinks.Clear(); |
217 | strcpy(#header, #version); |
219 | strcpy(#header, #version); |
218 | stroka = -list.first; |
220 | stroka = -list.first; |
219 | stolbec = 0; |
221 | stolbec = 0; |
220 | line = 0; |
222 | line = 0; |
Line 389... | Line 391... | ||
389 | rez = 0; |
391 | rez = 0; |
390 | strcpy(#tag, #tag+1); |
392 | strcpy(#tag, #tag+1); |
391 | } |
393 | } |
392 | else rez = 1; |
394 | else rez = 1; |
Line 393... | Line 395... | ||
393 | 395 | ||
394 | if (!chTag("html")) |
396 | if (isTag("html")) |
395 | { |
397 | { |
396 | IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (rez==0) ignor_text = 1; ELSE ignor_text = 0; |
398 | IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (rez==0) ignor_text = 1; ELSE ignor_text = 0; |
397 | return; |
399 | return; |
Line 398... | Line 400... | ||
398 | } |
400 | } |
Line 399... | Line 401... | ||
399 | 401 | ||
400 | if (!chTag("script")) || (!chTag("style")) || (!chTag("binary")) ignor_text = rez; |
402 | if (isTag("script")) || (isTag("style")) || (isTag("binary")) ignor_text = rez; |
401 | 403 | ||
402 | if(!chTag("title")) |
404 | if(isTag("title")) |
403 | { |
405 | { |
404 | if (rez) header=NULL; |
406 | if (rez) header=NULL; |
Line 405... | Line 407... | ||
405 | else if (!stroka) DrawTitle(#header); //òåã çàêðûëñÿ - âûâåëè ñòðîêó |
407 | else if (!stroka) DrawTitle(#header); //òåã çàêðûëñÿ - âûâåëè ñòðîêó |
Line 406... | Line 408... | ||
406 | return; |
408 | return; |
Line 407... | Line 409... | ||
407 | } |
409 | } |
408 | 410 | ||
409 | if (ignor_text) return; |
411 | if (ignor_text) return; |
410 | 412 | ||
Line 411... | Line 413... | ||
411 | 413 | ||
412 | 414 | ||
413 | IF(!chTag("q")) chrcat(#line, '\"'); |
415 | IF(isTag("q")) chrcat(#line, '\"'); |
414 | 416 | ||
415 | if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò |
417 | if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò |
416 | { |
418 | { |
Line 430... | Line 432... | ||
430 | } |
432 | } |
431 | } while(GetNextParam()); |
433 | } while(GetNextParam()); |
432 | return; |
434 | return; |
433 | } |
435 | } |
Line 434... | Line 436... | ||
434 | 436 | ||
435 | if (!chTag("a")) |
437 | if (isTag("a")) |
436 | { |
438 | { |
437 | if (rez) |
439 | if (rez) |
438 | { |
440 | { |
Line 447... | Line 449... | ||
447 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
449 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
Line 448... | Line 450... | ||
448 | 450 | ||
449 | link = 1; |
451 | link = 1; |
450 | blink++; |
452 | blink++; |
451 | text_colors[text_color_index] = link_color; |
453 | text_colors[text_color_index] = link_color; |
452 | strcat(#page_links, #options); |
- | |
453 | strcat(#page_links, "|"); |
454 | PageLinks.Add(#options); |
454 | } |
455 | } |
455 | if (anchor) && (!strcmp(#parametr, "name=")) |
456 | if (anchor) && (!strcmp(#parametr, "name=")) |
456 | { |
457 | { |
457 | if (!strcmp(#anchor, #options)) |
458 | if (!strcmp(#anchor, #options)) |
Line 466... | Line 467... | ||
466 | IF(text_color_index > 0) text_color_index--; |
467 | IF(text_color_index > 0) text_color_index--; |
467 | } |
468 | } |
468 | return; |
469 | return; |
469 | } |
470 | } |
Line 470... | Line 471... | ||
470 | 471 | ||
471 | if (!chTag("font")) |
472 | if (isTag("font")) |
472 | { |
473 | { |
473 | if (rez) |
474 | if (rez) |
474 | { |
475 | { |
475 | text_color_index++; |
476 | text_color_index++; |
Line 484... | Line 485... | ||
484 | } |
485 | } |
485 | else |
486 | else |
486 | if (text_color_index > 0) text_color_index--; |
487 | if (text_color_index > 0) text_color_index--; |
487 | return; |
488 | return; |
488 | } |
489 | } |
489 | if(!chTag("tr")) || (!chTag("br")) { |
490 | if(isTag("tr")) || (isTag("br")) { |
490 | TextGoDown(left1, top1, width1); |
491 | TextGoDown(left1, top1, width1); |
491 | return; |
492 | return; |
492 | } |
493 | } |
493 | if (!chTag("div")) { |
494 | if (isTag("div")) { |
494 | IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1); |
495 | IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1); |
495 | return; |
496 | return; |
496 | } |
497 | } |
497 | if (!chTag("p")) { |
498 | if (isTag("p")) { |
498 | IF(oldtag[0] == 'h') return; |
499 | IF(oldtag[0] == 'h') return; |
499 | TextGoDown(left1, top1, width1); |
500 | TextGoDown(left1, top1, width1); |
500 | IF(rez) TextGoDown(left1, top1 + 10, width1); |
501 | IF(rez) TextGoDown(left1, top1 + 10, width1); |
501 | return; |
502 | return; |
502 | } |
503 | } |
503 | /* |
504 | /* |
504 | if (!chTag("center")) |
505 | if (isTag("center")) |
505 | { |
506 | { |
506 | if (rez) text_align = ALIGN_CENTER; |
507 | if (rez) text_align = ALIGN_CENTER; |
507 | if (!rez) |
508 | if (!rez) |
508 | { |
509 | { |
509 | TextGoDown(left1, top1, width1); |
510 | TextGoDown(left1, top1, width1); |
510 | text_align = ALIGN_LEFT; |
511 | text_align = ALIGN_LEFT; |
511 | } |
512 | } |
512 | return; |
513 | return; |
513 | } |
514 | } |
514 | if (!chTag("right")) |
515 | if (isTag("right")) |
515 | { |
516 | { |
516 | if (rez) text_align = ALIGN_RIGHT; |
517 | if (rez) text_align = ALIGN_RIGHT; |
517 | if (!rez) |
518 | if (!rez) |
518 | { |
519 | { |
519 | TextGoDown(left1, top1, width1); |
520 | TextGoDown(left1, top1, width1); |
520 | text_align = ALIGN_LEFT; |
521 | text_align = ALIGN_LEFT; |
521 | } |
522 | } |
522 | return; |
523 | return; |
523 | } |
524 | } |
524 | */ |
525 | */ |
525 | if (!chTag("h1")) || (!chTag("h2")) || (!chTag("h3")) || (!chTag("h4")) { |
526 | if (isTag("h1")) || (isTag("h2")) || (isTag("h3")) || (isTag("h4")) { |
526 | TextGoDown(left1, top1, width1); |
527 | TextGoDown(left1, top1, width1); |
527 | if (rez) && (stroka>1) TextGoDown(left1, top1 + 10, width1); |
528 | if (rez) && (stroka>1) TextGoDown(left1, top1 + 10, width1); |
528 | strcpy(#oldtag, #tag); |
529 | strcpy(#oldtag, #tag); |
529 | if (rez) |
530 | if (rez) |
530 | { |
531 | { |
Line 540... | Line 541... | ||
540 | return; |
541 | return; |
541 | } |
542 | } |
542 | else |
543 | else |
543 | oldtag=NULL; |
544 | oldtag=NULL; |
Line 544... | Line 545... | ||
544 | 545 | ||
545 | if (!chTag("b")) || (!chTag("strong")) || (!chTag("big")) { |
546 | if (isTag("b")) || (isTag("strong")) || (isTag("big")) { |
546 | b_text = rez; |
547 | b_text = rez; |
547 | return; |
548 | return; |
548 | } |
549 | } |
549 | if(!chTag("i")) || (!chTag("em")) || (!chTag("subtitle")) { |
550 | if(isTag("i")) || (isTag("em")) || (isTag("subtitle")) { |
550 | i_text = rez; |
551 | i_text = rez; |
551 | return; |
552 | return; |
552 | } |
553 | } |
553 | if (!chTag("dt")) |
554 | if (isTag("dt")) |
554 | { |
555 | { |
555 | li_text = rez; |
556 | li_text = rez; |
556 | IF(rez == 0) return; |
557 | IF(rez == 0) return; |
557 | TextGoDown(left1, top1, width1); |
558 | TextGoDown(left1, top1, width1); |
558 | return; |
559 | return; |
559 | } |
560 | } |
560 | if (!chTag("condition")) |
561 | if (isTag("condition")) |
561 | { |
562 | { |
562 | condition_text_active = rez; |
563 | condition_text_active = rez; |
563 | if (rez) && (!strcmp(#parametr, "show_if=")) condition_text_val = atoi(#options); |
564 | if (rez) && (!strcmp(#parametr, "show_if=")) condition_text_val = atoi(#options); |
564 | return; |
565 | return; |
565 | } |
566 | } |
566 | if(!chTag("li")) || (!chTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè |
567 | if (isTag("li")) || (isTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè |
567 | { |
568 | { |
568 | li_text = rez; |
569 | li_text = rez; |
569 | if (rez) |
570 | if (rez) |
570 | { |
571 | { |
571 | TextGoDown(left1, top1, width1); |
572 | TextGoDown(left1, top1, width1); |
572 | if (stroka > -1) && (stroka - 2 < list.visible) DrawBuf.DrawBar(li_tab * 5 * 6 + left1 - 5, list.line_h/2-3, 2, 2, 0x555555); |
573 | if (stroka > -1) && (stroka - 2 < list.visible) DrawBuf.DrawBar(li_tab * 5 * 6 + left1 - 5, list.line_h/2-3, 2, 2, 0x555555); |
573 | } |
574 | } |
574 | return; |
575 | return; |
575 | } |
576 | } |
576 | if (!chTag("u")) || (!chTag("ins")) u_text = rez; |
577 | if (isTag("u")) || (isTag("ins")) u_text = rez; |
577 | if (!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez; |
578 | if (isTag("s")) || (isTag("strike")) || (isTag("del")) s_text = rez; |
578 | if (!chTag("ul")) || (!chTag("ol")) IF(!rez) |
579 | if (isTag("ul")) || (isTag("ol")) IF(!rez) |
579 | { |
580 | { |
580 | li_text = rez; |
581 | li_text = rez; |
581 | li_tab--; |
582 | li_tab--; |
582 | TextGoDown(left1, top1, width1); |
583 | TextGoDown(left1, top1, width1); |
583 | } ELSE li_tab++; |
584 | } ELSE li_tab++; |
584 | if (!chTag("dd")) stolbec += 5; |
585 | if (isTag("dd")) stolbec += 5; |
585 | if (!chTag("blockquote")) blq_text = rez; |
586 | if (isTag("blockquote")) blq_text = rez; |
586 | if (!chTag("pre")) pre_text = rez; |
587 | if (isTag("pre")) pre_text = rez; |
587 | if (!chTag("hr")) |
588 | if (isTag("hr")) |
588 | { |
589 | { |
589 | if (anchor) || (stroka < -1) |
590 | if (anchor) || (stroka < -1) |
590 | { |
591 | { |
591 | stroka+=2; |
592 | stroka+=2; |
Line 594... | Line 595... | ||
594 | if (strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); else hr_color = 0x999999; |
595 | if (strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); else hr_color = 0x999999; |
595 | TextGoDown(left1, top1, width1); |
596 | TextGoDown(left1, top1, width1); |
596 | DrawBuf.DrawBar(5, list.line_h/2, list.w-10, 1, hr_color); |
597 | DrawBuf.DrawBar(5, list.line_h/2, list.w-10, 1, hr_color); |
597 | TextGoDown(left1, top1+list.line_h, width1); |
598 | TextGoDown(left1, top1+list.line_h, width1); |
598 | } |
599 | } |
599 | if (!chTag("img")) |
600 | if (isTag("img")) |
600 | { |
601 | { |
601 | ImgCache1.Images( left1, top1, width1); |
602 | ImgCache1.Images( left1, top1, width1); |
602 | return; |
603 | return; |
603 | } |
604 | } |
604 | if (!chTag("meta")) || (!chTag("?xml")) |
605 | if (isTag("meta")) || (isTag("?xml")) |
605 | { |
606 | { |
606 | do{ |
607 | do{ |
607 | if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding=")) |
608 | if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding=")) |
608 | { |
609 | { |
609 | strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content= |
610 | strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content= |
Line 643... | Line 644... | ||
643 | } |
644 | } |
644 | stroka++; |
645 | stroka++; |
645 | if (blq_text) stolbec = 8; else stolbec = 0; |
646 | if (blq_text) stolbec = 8; else stolbec = 0; |
646 | if (li_text) stolbec = li_tab * 5; |
647 | if (li_text) stolbec = li_tab * 5; |
647 | }>>>>>=>=>>=15)>>>>>>>=>!--> |
648 | } |
648 | >': |
649 | |
- | 650 | ||
- | 651 | ||
- | 652 | int isTag(dword text) |
|
- | 653 | { |
|
- | 654 | if (!strcmp(#tag,text)) return 1; else return 0; |
|
- | 655 | }>>>>>=>=>>=15)>>>>>>>=>!--> |
|
- | 656 | >': |