Subversion Repositories Kolibri OS

Rev

Rev 2368 | Blame | Last modification | View Log | Download | RSS feed

  1. //Web-component, Leency & Veliant 2007-2009
  2. //lev
  3.  
  4. //èäåÿ - ëåâûå ôàéëû îòêðûâàòü ñîîòâåòñòâóþùèìè ïðîãàìè
  5. //ol - öèôåðêè
  6.  
  7. int     downloader_id;
  8.  
  9. dword j,
  10.         buf,
  11.         filesize,
  12.         blink = 400;
  13.  int i;
  14.  
  15.  char download_path[]="/rd/1/.download";
  16. //char search_path[]="http://nova.rambler.ru/search?words=";
  17.  char search_path[]="http://nigma.ru/index.php?s=";
  18.  char version[]=" Text-based Browser 0.71";
  19.  
  20.  
  21. struct TWebBrowser {
  22.         int left,
  23.         top,
  24.         width,
  25.         height;
  26.         void DrawScroller();
  27.         void ShowPage();
  28.         void ParseHTML(dword, dword);
  29.         void Scan(dword);
  30.         void WhatTextStyle(int left1, top1, width1);
  31. };
  32.  
  33. TWebBrowser WB1;
  34.  
  35. byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, link, ignor_text, li_tab;
  36.  
  37.  
  38. dword text_colors[10],
  39.         text_color_index = 0,
  40.         link_color;
  41.  
  42. int stroka,
  43.         stolbec,
  44.         tab_len;
  45.        
  46. char line[330],
  47.         tag[100],
  48.         tagparam[10000],
  49.         parametr[1200],
  50.         options[1000];
  51.  
  52.  
  53. #include "include\history.h--"
  54. #include "include\colors.h--"
  55. #include "include\unicode_tags.h--"
  56.  
  57. void TWebBrowser::Scan(dword id) {
  58.         if (id > 399)
  59.         {
  60.                 j = 0;
  61.                 FOR(i = 0; i <= id - 401; i++) {
  62.                         do j++;
  63.                         while (page_links[j] <>'|');
  64.                 }
  65.                 page_links[j] = 0x00;
  66.                 copystr(#page_links[find_symbol(#page_links, '|')], #URL);
  67.                
  68.                 //Lee 21.02 {
  69.                 IF (URL[0] == '#') {  //ìû íå óìååì ïåðåõîäèòü ïî ññûëêå âíóòðè äîêóìåíòà. Ïîêà ÷òî...
  70.                         copystr(#editURL, #URL);
  71.                         return;
  72.                 }
  73.                 URL[find_symbol(#URL, '#')-1] = 0x00; //çàãëóøêà, ëó÷øå, ÷åì íè÷åãî (õàáð, íàïðèìåð, áóäåò ðàáîòàòü)
  74.  
  75.                 GetNewUrl();
  76.                
  77.                 if (!strcmp(get_URL_part(5),"http:"))) HttpLoad();
  78.                 //Lee 21.02 }
  79.                
  80.                 ShowPage(#URL);
  81.                 Draw_Window();
  82.                 return;
  83.         }
  84.        
  85.         //edit1.flags=64;
  86.         IF(count < max_kolvo_strok) SWITCH(id) //åñëè ìàëî ñòðîê èãíîðèðóåì íåêîòîðûå êíîïêè
  87.         { CASE 183: CASE 184: CASE 180: CASE 181: return; }
  88.        
  89.         switch (id)
  90.         {
  91.                 case 011: //Ctrk+K
  92.                         ReadHtml();
  93.                         koitodos(buf);
  94.                         break;
  95.                 case BACK:
  96.                         BrowserHistory.GoBack();
  97.                         return;
  98.                 case FORWARD:
  99.                         RunProgram("@notify", "Forward button is not realized yet");
  100.                         return;
  101.                 case 054: //F5
  102.                         IF(edit1.flags == 66) break;
  103.                 case REFRESH:
  104.                         copystr(#URL, #editURL);
  105.                         Draw_Window();
  106.                         return;
  107.                 case 014: //Ctrl+N íîâîå îêíî
  108.                 case 020: //Ctrl+T íîâàÿ âêëàäêà
  109.                 case NEWTAB:
  110.                         MoveSize(190,80,OLD,OLD);
  111.                         RunProgram(#program_path, #URL);
  112.                         return;
  113.                 case 052:  //Íàæàòà F3
  114.                         IF(edit1.flags <> 66)
  115.                         IF (strcmp(get_URL_part(5),"http:")<>0) RunProgram("tinypad", #URL); ELSE RunProgram("tinypad", #download_path);
  116.                         return;
  117.  
  118.                 case HOME:
  119.                         copystr("http://bash.org.ru", #editURL);
  120.                 case GOTOURL:
  121.                 case 0x0D: //enter
  122.                         copystr(#editURL, #URL);
  123.                         if (!strcmp(get_URL_part(5),"http:"))) HttpLoad();
  124.                         ShowPage(#URL);
  125.                         return;
  126.                 case 173:       //ctrl+enter
  127.                 case SEARCHWEB:
  128.                         copystr(#search_path, #URL);
  129.                         copystr(#editURL, #URL + strlen(#URL));
  130.                         if (!strcmp(get_URL_part(5),"http:"))) HttpLoad();
  131.                         ShowPage(#URL);
  132.                         return;
  133.  
  134.                 case ID1: //ìîòàåì ââåðõ
  135.                         IF(za_kadrom <= 0) return;
  136.                         za_kadrom--;
  137.                         break;
  138.                 case ID2: //ìîòàåì âíèç
  139.                         IF(max_kolvo_strok + za_kadrom >= count) return;
  140.                         za_kadrom++;
  141.                         break;
  142.                 case 183: //PgDown
  143.                         IF(za_kadrom == count - max_kolvo_strok) return;
  144.                         za_kadrom += max_kolvo_strok + 2;
  145.                         IF(max_kolvo_strok + za_kadrom > count) za_kadrom = count - max_kolvo_strok;
  146.                         BREAK;
  147.                 case 184: //PgUp
  148.                         IF(za_kadrom == 0) RETURN;
  149.                         za_kadrom -= max_kolvo_strok - 2;
  150.                         IF(za_kadrom < 0) za_kadrom = 0;
  151.                         BREAK;
  152.                 case 180: //home
  153.                         IF(za_kadrom == 0) RETURN;
  154.                         za_kadrom = 0;
  155.                         BREAK;
  156.                 case 181: //end
  157.                         IF (za_kadrom == count - max_kolvo_strok) RETURN;
  158.                         za_kadrom = count - max_kolvo_strok;
  159.                         BREAK;
  160.                 default:
  161.                         RETURN;
  162.         }
  163.         ParseHTML(buf, filesize);
  164. }
  165.  
  166. void GetNewUrl(){
  167.   IF (!strcmp(get_URL_part(2),"./")) copystr(#URL+1,#URL);
  168.         //IF (!strcmp(get_URL_part(3),"../"))
  169.         //{
  170.         //      //DrawTitle(#URL+7);
  171.         //}
  172.         if (strcmp(get_URL_part(3),"/rd")<>0) && (strcmp(get_URL_part(5),"/sys/")<>0) && (strcmp(get_URL_part(3),"/hd")<>0)
  173.         && (strcmp(get_URL_part(3),"/bd")<>0) && (strcmp(get_URL_part(3),"/fd")<>0) && (strcmp(get_URL_part(3),"/cd")<>0)
  174.         && (strcmp(get_URL_part(5),"http:")<>0) && (strcmp(get_URL_part(5),"mailt")<>0) && (strcmp(get_URL_part(5),"ftp:/")<>0)
  175.         {
  176.                 copystr(BrowserHistory.CurrentUrl(), #editURL); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
  177.                
  178.                 IF (editURL[find_symbol(#editURL, '/')-2]<>'/')  // åñëè íå http://pagename.ua
  179.                 {
  180.                         editURL[find_symbol(#editURL, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
  181.                         IF (URL[0]=='/') copystr(#URL+1,#URL);
  182.                 }
  183.                 copystr(#URL, #editURL + strlen(#editURL)); //êëåèì íîâûé àäðåñ
  184.                 copystr(#editURL, #URL);
  185.         }
  186. }
  187.  
  188. void HttpLoad()
  189. {
  190.         DeleteFile(#download_path);
  191.         IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]='';
  192.         downloader_id = RunProgram("/sys/network/downloader", #URL);
  193.         IF (downloader_id<0) RunProgram("@notify", "Error running Downloader. Internet unavilable.");
  194. }
  195.  
  196.        
  197. void ReadHtml()
  198. {
  199.         if (!strcmp(get_URL_part(5),"http:")))
  200.                 file_size stdcall (#download_path);
  201.         else
  202.                 file_size stdcall (#URL);
  203.        
  204.         filesize = EBX;
  205.         if (!filesize) /*{Pause(200); ReadHtml();}*/ return; //Lee 22.09
  206.         mem_Free(buf);
  207.         buf = mem_Alloc(filesize);
  208.         if (!strcmp(get_URL_part(5),"http:")))
  209.                 ReadFile(0, filesize, buf, #download_path);
  210.         else
  211.                 ReadFile(0, filesize, buf, #URL);
  212. }
  213.  
  214.  
  215.  
  216. void TWebBrowser::ShowPage(dword adress) {
  217.         max_kolvo_stolbcov = width - 30 / 6;
  218.         max_kolvo_strok = height - 3 / 10 - 2;
  219.         copystr(#version, #header);
  220.         IF (!WindowRePaint) {
  221.                 za_kadrom = 0;
  222.                 copystr(#URL, #editURL);
  223.                 BrowserHistory.AddUrl();
  224.         }
  225.         edit1.size = edit1.pos = strlen(#editURL);
  226.         edit_box_draw stdcall(#edit1); //ðèñóåì ñòðîêó àäðåñà
  227.  
  228.         //LETS_LOAD
  229.         ReadHtml();
  230.        
  231.         IF (!filesize) return; //Lee 22.09
  232.        
  233.         wintodos(buf);
  234.         ParseHTML(buf, filesize);
  235.         IF(!strlen(buf)) {
  236.                 IF (strcmp(get_URL_part(5),"http:")==0)
  237.                 {
  238.                         PutImage(#stop_btn, 24, 24, 88, 10);
  239.                         WriteText(left + 10, top + 18, 0x80, 0, "Loading...", 0);
  240.                 }
  241.                 ELSE
  242.                         WriteText(left + 10, top + 18, 0x80, 0, "Page not found. May be, URL contains some errors.", 0);
  243.         }
  244.  
  245.         IF (!strcmp(#version, #header)) DrawTitle(#header);
  246. }
  247.  
  248.  
  249.  
  250. void TWebBrowser::ParseHTML(dword bword, fsize){
  251.         word bukva[1];
  252.         byte ignor_param = 0;
  253.         char temp[768];
  254.         stroka = -za_kadrom;
  255.         stolbec = 0;
  256.         FOR(j = 400; j < blink + 1; j++;) DeleteButton(j);
  257.         b_text = i_text = u_text = s_text = pre_text = blq_text =
  258.         li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 0; //îáíóëÿåì òåãè
  259.         link_color = 0x0000FF;
  260.         blink = 400;
  261.         line = '';
  262.         copystr("|", #page_links);
  263.         IF(!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1; //çà÷¸òíîå îòîáðàæåíèå òåêñòà
  264.         //IF(!strcmp(#URL + strlen(#URL) - 4, ".rtf")) pre_text = 1;
  265.         IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
  266.         IF(za_kadrom == 0) || (WindowRePaint) DrawBar(left, top, width - 15, 15, 0xFFFFFF); //çàêðàøèâàåì ïåðâóþ ñòðîêó
  267.         for (; buf + fsize > bword; bword++;) {
  268.           bukva = ESBYTE[bword];
  269.           switch (bukva) {
  270.                 case 0x0a:
  271.                         IF(pre_text == 1) {
  272.                                 bukva = '';
  273.                                 temp = '';
  274.                                 goto NEXT_MARK;
  275.                         }
  276.                 CASE '\9':
  277.                         if (pre_text == 1) //èíà÷å èä¸ì íà 0x0d
  278.                         {
  279.                                 tab_len=strlen(#line)/8;
  280.                                 tab_len=tab_len*8;
  281.                                 tab_len=8+tab_len-strlen(#line);
  282.                                 for (i=0; i<tab_len; i++;) copystr(" ", #line + strlen(#line));
  283.                                 break;
  284.                         }              
  285.                 case 0x0d:
  286.                         bukva = ' ';
  287.                         goto DEFAULT_MARK;
  288.                 case '<':
  289.                         bword++; //ïðîìîòàåì ñèìâîë <
  290.                         IF(ESBYTE[bword] == '!') //ôèëüòðàöèÿ âíóòðè <!-- -->, äåðçêî
  291.                         {
  292.                                 bword++;
  293.                                 IF(ESBYTE[bword] == '-') {
  294.                                         HH_: do {
  295.                                                 bword++;
  296.                                                 IF(bword >= buf + fsize) break 1;
  297.                                         } while (ESBYTE[bword] <>'-');
  298.                                         bword++;
  299.                                         IF(ESBYTE[bword] <>'-') GOTO HH_;
  300.                                 }
  301.                         }
  302.                         WHILE (ESBYTE[bword] <>'>') && (bword < buf + fsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
  303.                         {
  304.                                 bukva = ESBYTE[bword];
  305.                                 IF(bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
  306.                                 IF(!ignor_param) && (bukva <>' ') copystr(#bukva, #tag + strlen(#tag));
  307.                                 ELSE {
  308.                                         ignor_param = true;
  309.                                         copystr(#bukva, #tagparam + strlen(#tagparam));
  310.                                 }
  311.                                 bword++;
  312.                         }
  313.                         lowcase(#tag);
  314.                         lowcase(#tagparam);
  315.                         //WriteDebug(#tagparam);
  316.                         //WriteDebug(#tag); Pause(50);
  317.                         //
  318.                         IF (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=''; //íåáîëüøîé ôèêñ äëÿ ðàáîòû ñ XHTML-òåãàìè òèïà br/
  319.                         IF(strlen(#tagparam) > 0) && (strlen(#tagparam) < 4000) GetNextParam();
  320.                         WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //îáðàáîòêà òåãîâ
  321.  
  322.                         line = tag = parametr = tagparam = ignor_param = 0; //âñ¸ îáíóëÿåì
  323.                         break;
  324.                 case '=': //ïîääåðæêà øàéòàíñêîé êîäèðîâêè ñòðàíèö, ñîõðàí¸ííûõ ÷åðåç ÈÅ7
  325.                         IF(strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK;
  326.  
  327.                         bword++;
  328.                         bukva=ESBYTE[bword];
  329.                         copystr(#bukva, #temp);
  330.  
  331.                         bword++;
  332.                         bukva=ESBYTE[bword];
  333.                         copystr(#bukva, #temp + strlen(#temp));
  334.                        
  335.                         bukva=Hex2Symb(#temp);
  336.                         IF (bukva) goto DEFAULT_MARK;
  337.                         break;
  338.                 /*case '\\': //ïîääåðæêà rtf
  339.                         IF(strcmp(#URL + strlen(#URL) - 4, ".rtf")<>0) goto DEFAULT_MARK;
  340.  
  341.                         bword++;
  342.                         IF (ESBYTE[bword] =='\'')
  343.                         {
  344.                                 bword++;
  345.                                 bukva=ESBYTE[bword];
  346.                                 copystr(#bukva, #temp);
  347.  
  348.                                 bword++;
  349.                                 bukva=ESBYTE[bword];
  350.                                 copystr(#bukva, #temp + strlen(#temp));
  351.                                
  352.                                 bukva=Hex2Symb(#temp);
  353.                                 IF (bukva) goto DEFAULT_MARK;
  354.                         }
  355.                         else
  356.                         {
  357.                                 FOR (j=0;   (ESBYTE[bword] <>'\\') && (buf + fsize < bword);     j++; bword++;)
  358.                                 {
  359.                                         bukva = ESBYTE[bword];
  360.                                         copystr(#bukva, #tag + strlen(#tag));
  361.                                 }
  362.                                 IF ((!strcmp(#tag, "par\0x0a")) || (!strcmp(#tag, "par\0x0b"))) stroka++;
  363.                                 tag='';
  364.                                 bword--;
  365.                         }
  366.                         break;*/
  367.                        
  368.                 case '&': //îáðàáîòêà òåãîâ òèïà &nbsp;
  369.                         IF(ignor_text) break;
  370.                         bword++;
  371.                         tag='';
  372.                         FOR (j=0;   (ESBYTE[bword] <>';') && (j < 7);     j++; bword++;)
  373.                         {
  374.                                 bukva = ESBYTE[bword];
  375.                                 copystr(#bukva, #tag + strlen(#tag));
  376.                         }
  377.                        
  378.                         FOR (j=0; unicode_tags[j]!=0; j+=2;)
  379.                         {
  380.                                 IF(!strcmp(#tag, unicode_tags[j]))
  381.                                 {
  382.                                         copystr(unicode_tags[j+1], #line + strlen(#line));
  383.                                         break 1;
  384.                                 }
  385.                         }
  386.                        
  387.                         rez = StrToInt(#tag + 1) - 1040;
  388.                         IF(tag[1] == '1') && (rez>=0) && (rez<=72) && (strlen(#tag) == 5)
  389.                                 {
  390.                                         bukva = unicode_chars[rez];
  391.                                         GOTO DEFAULT_MARK; //îáðàáàòûâàåì áóêâó
  392.                                 }
  393.                        
  394.                         WriteDebug(#tag); //òýã íå íàéäåí - âûâîäèì íà äîñêó îòëàäêè
  395.                         copystr(#tag, #line + strlen(#line)); //âûâîäèì íà ýêðàí íåîáðàáîòàííûé òåã, òàê áðàóçåðû çà÷åì-òî äåëàþò
  396.                         break;
  397.                 default:
  398.                         DEFAULT_MARK:
  399.                         IF(ignor_text) break;
  400.                         IF(pre_text == 0) && (bukva == ' ') && (strcmp(#line + strlen(#line) - 1, " ") == 0) continue;
  401.                         //
  402.                         if (stolbec + strlen(#line) > max_kolvo_stolbcov)
  403.                         {
  404.                                 copystr(#line + find_symbol(#line, ' '), #temp); //ïåðåíîñ ïî ñëîâàì
  405.                                 line[find_symbol(#line, ' ')] = 0x00;
  406.                                 NEXT_MARK: IF(stroka - 1 > max_kolvo_strok) && (za_kadrom <>0) break 1; //óõîäèì...
  407.                                 WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //âûâîä ñòðîêè
  408.                                 TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
  409.                                 copystr(#temp, #line);
  410.                         }
  411.                         IF(pre_text == 0) && (bukva == ' ') && (stolbec == 0) && (strlen(#line) == 0) CONTINUE;
  412.                         copystr(#bukva, #line + strlen(#line));
  413.           }
  414.         }
  415.         IF(max_kolvo_strok * 10 + 25 <= height)
  416.                 DrawBar(left, max_kolvo_strok * 10 + top + 25, width - 15, -max_kolvo_strok * 10 + height - 25, 0xFFFFFF);
  417.         IF(stroka * 10 + 15 <= height)
  418.                 DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, 0xFFFFFF); //çàêðàøèâàåì âñ¸ äî êîíöà
  419.         IF(za_kadrom == 0) count = stroka;
  420.         DrawScroller(); //ðèñóåì ñêðîëë
  421. }
  422.  
  423.  
  424. void GetNextParam()
  425. {
  426.         byte    kavichki = false;
  427.         int             i = strlen(#tagparam) - 1;
  428.        
  429.         WHILE((i > 0) && ((tagparam[i] == '"') || (tagparam[i] == ' ') || (tagparam[i] == '\'') || (tagparam[i] == '/')))
  430.         {
  431.                 IF (tagparam[i] == '"') || (tagparam[i] == '\'') kavichki=tagparam[i];
  432.                 tagparam[i] = 0x00;
  433.                 i--;
  434.         }
  435.  
  436.         IF (kavichki)
  437.         {
  438.                 i=find_symbol(#tagparam, kavichki);
  439.                 copystr(#tagparam + i, #options);
  440.         }
  441.         ELSE
  442.         {
  443.                 WHILE((i > 0) && (tagparam[i] <>'=')) i--; //i=find_symbol(#tagparam, '=')+1;
  444.                 i++;
  445.                
  446.                 copystr(#tagparam + i, #options); //êîïèðóåì îïöèþ
  447.                 WHILE (options[0] == ' ') copystr(#options + 1, #options);
  448.         }
  449.         tagparam[i] = 0x00;
  450.  
  451.         FOR ( ; ((tagparam[i] <>' ') && (i > 0); i--)
  452.         {
  453.                 IF (tagparam[i] == '=') //äåðçêàÿ çàãëóøêà
  454.                 {
  455.                         //copystr(#tagparam+i+2,#options);
  456.                         tagparam[i + 1] = 0x00;
  457.                 }
  458.         }
  459.  
  460.         copystr(#tagparam + i + 1, #parametr); //êîïèðóåì ïàðàìåòð
  461.         tagparam[i] = 0x00;
  462. }
  463.  
  464.  
  465.  
  466. char oldtag[100];
  467. void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
  468.         dword hr_color;
  469.  
  470.     dword image=0;
  471.     char temp[4096];
  472.     int w, h, img_za_kadrom=0;
  473.  
  474.         //ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ
  475.         IF(tag[0] == '/')
  476.         {
  477.                 rez = 0;
  478.                 copystr(#tag + 1, #tag);
  479.         }
  480.         ELSE
  481.                 rez = 1;
  482.  
  483.         //
  484.         IF(!chTag("html")) {
  485.                 IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (rez==0) ignor_text = 1; ELSE ignor_text = 0;
  486.                 return;
  487.         }
  488.         IF(!chTag("script")) || (!chTag("style")) ignor_text = rez;
  489.         IF (ignor_text == 1) return;
  490.         //
  491.  
  492.         if(!chTag("title")) && (!rez) && (stroka == 0)
  493.         {
  494.                 copystr(#line, #header);
  495.                 copystr(" -", #header + strlen(#header));
  496.                 copystr(#version, #header + strlen(#header));
  497.                 DrawTitle(#header);
  498.                 return;
  499.         }
  500.        
  501.         //
  502.         IF(!chTag("q")) copystr("\"", #line + strlen(#line));
  503.        
  504.         //âûâîä íà ýêðàí
  505.         if (stroka >= 0) && (stroka - 2 < max_kolvo_strok) && (line)
  506.         {
  507.                 WriteText(stolbec * 6 + left1, top1, 0x80, text_colors[text_color_index], #line, 0);
  508.                 IF (b_text) WriteText(stolbec * 6 + left1 + 1, top1, 0x80, text_colors[text_color_index], #line, 0);
  509.                 IF (i_text) Skew(stolbec * 6 + left1, top1, strlen(#line)+1*6, 10); //íàêëîííûé òåêñò
  510.                 IF (s_text) DrawBar(stolbec * 6 + left1, top1 + 4, strlen(#line) * 6, 1, text_colors[text_color_index]); //çà÷¸ðêíóòûé
  511.                 IF (u_text) DrawBar(stolbec * 6 + left1, top1 + 8, strlen(#line) * 6, 1, text_colors[text_color_index]); //ïîä÷¸ðêíóòûé
  512.                 IF (link) {
  513.                         DefineButton(stolbec * 6 + left1 - 2, top1, strlen(#line) * 6 + 3, 9, blink + BT_HIDE, 0xB5BFC9); //
  514.                         DrawBar(stolbec * 6 + left1, top1 + 8, strlen(#line) * 6, 1, text_colors[text_color_index]);
  515.                 }
  516.         }
  517.         //
  518.         IF(!tag) return;
  519.         stolbec += strlen(#line);
  520.         ////////////////////////// <body bgcolor="#000000" text="#FFFFFF">
  521.         if (!chTag("body"))
  522.         {
  523.                 BODY_MARK:
  524.                
  525.                 if (strcmp(#parametr, "link=") == 0)
  526.                         link_color = GetColor(#options);
  527.                
  528.                 /*if (strcmp(#parametr, "text=") == 0)
  529.                 {
  530.                         text_colors[0]=GetColor(#options);
  531.                 }
  532.                
  533.                 if (strcmp(#parametr, "bgcolor=") == 0)
  534.                 {
  535.                         //text_colors[0]=GetColor(#options);
  536.                         WriteDebug("bgcolor=");
  537.                         WriteDebug(#options);
  538.                 }*/
  539.                
  540.                 IF(tagparam) {
  541.                         GetNextParam();
  542.                         GOTO BODY_MARK;
  543.                 }              
  544.         }
  545.         //////////////////////////
  546.         if (!chTag("a")) {
  547.                 IF (stroka - 1 > max_kolvo_strok) || (stroka < -2) return;
  548.                 if (rez) {
  549.                         HREF: IF(strcmp(#parametr, "href=") == 0) {
  550.                                 IF(link == 1) text_color_index--; //åñëè êàêîé-òî äîëáî¸á íå çàêðûë òýã
  551.                                 link = 1;
  552.                                 blink++;
  553.                                 text_color_index++;
  554.                                 text_colors[text_color_index] = link_color;
  555.                                 copystr(#options, #page_links + strlen(#page_links));
  556.                                 copystr("|", #page_links + strlen(#page_links));
  557.                         }
  558.                         IF(tagparam) {
  559.                                 GetNextParam();
  560.                                 GOTO HREF;
  561.                         }
  562.                 }
  563.                 ELSE {
  564.                         link = 0;
  565.                         IF(text_color_index > 0) text_color_index--;
  566.                 }
  567.                 return;
  568.         }
  569.         /////////////////////////
  570.         if (!chTag("font"))
  571.         {
  572.                 IF(stroka < 0) || (stroka - 1 > max_kolvo_strok) return;
  573.                 COL_MARK:
  574.                 if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#')
  575.                 {
  576.                         text_color_index++;
  577.                         text_colors[text_color_index] = GetColor(#options);
  578.                 }
  579.                 IF(tagparam) {
  580.                         GetNextParam();
  581.                         GOTO COL_MARK;
  582.                 }
  583.                 IF(!rez) && (text_color_index > 0) text_color_index--;
  584.                 return;
  585.         }
  586.         //////////////////////////
  587.         IF(!chTag("tr")) || (!chTag("br")) {
  588.                 TextGoDown(left1, top1, width1);
  589.                 return;
  590.         }
  591.         IF(!chTag("div")) {
  592.                 IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1);
  593.                 return;
  594.         }
  595.         IF(!chTag("p")) {
  596.                 IF(oldtag[0] == 'h') return;
  597.                 TextGoDown(left1, top1, width1);
  598.                 IF(rez) TextGoDown(left1, top1 + 10, width1);
  599.                 return;
  600.         }
  601.         ////////////////////////////
  602.         IF(!chTag("h1")) || (!chTag("h2")) || (!chTag("h3")) || (!chTag("h4")) {
  603.                 TextGoDown(left1, top1, width1);
  604.                 IF(rez) TextGoDown(left1, top1 + 10, width1);
  605.                 b_text = rez;
  606.                 copystr(#tag, #oldtag);
  607.                 return;
  608.         } ELSE copystr("", #oldtag);
  609.         IF(!chTag("b")) || (!chTag("strong")) || (!chTag("big")) {
  610.                 b_text = rez;
  611.                 return;
  612.         }
  613.         ////////////////////////////
  614.         IF(!chTag("i")) || (!chTag("em")) {
  615.                 i_text = rez;
  616.                 return;
  617.         }      
  618.         ////////////////////////////
  619.         if(!chTag("li")) || (!chTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
  620.         {
  621.                 li_text = rez;
  622.                 IF(rez == 0) return;
  623.                 TextGoDown(left1, top1, width1);
  624.                 IF(stroka > -1) && (stroka - 2 < max_kolvo_strok) IF(!chTag("li")) DrawBar(li_tab * 5 * 6 + left1 - 5, top1 + 12, 2, 2, 0);
  625.                 return;
  626.         }
  627.         ////////////////////////////
  628.         IF(!chTag("u")) || (!chTag("ins")) u_text = rez;
  629.         IF(!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez;
  630.         IF(!chTag("ul")) || (!chTag("ol")) IF(!rez) {
  631.                 li_text = rez;
  632.                 li_tab--;
  633.                 TextGoDown(left1, top1, width1);
  634.         } ELSE li_tab++;
  635.         IF(!chTag("dd")) stolbec += 5;
  636.         IF(!chTag("blockquote")) blq_text = rez;
  637.         IF(!chTag("pre")) pre_text = rez;
  638.         IF(!chTag("hr")) {
  639.                 TextGoDown(left1, top1, width1);
  640.                 TextGoDown(left1, top1 + 10, width1);
  641.                 IF(strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options);
  642.                 ELSE hr_color = 0x999999;
  643.                 IF(stroka > 0) DrawBar(left1, top1 + 14, width1 - 8, 1, hr_color);
  644.         }
  645.  
  646.         if (!chTag("img"))
  647.         {
  648.                 //IF (GetFileInfo(#libimg)<>0) return;  //åñëè áèáëèîòåêè íåò
  649.                 IMG_TAG:
  650.                         IF (strcmp(#parametr,"src=")==0)   //íàäî îáúåäèíèòü ñ GetNewUrl()
  651.                   {
  652.                                 copystr(BrowserHistory.CurrentUrl(), #temp); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
  653.                                 temp[find_symbol(#temp, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
  654.                                 copystr(#options,#temp+strlen(#temp));
  655.                                 image=load_image(#temp);
  656.        
  657.                         w=DSWORD[image+4];
  658.                         h=DSWORD[image+8];
  659.                   }
  660.                 IF(tagparam) {
  661.                         GetNextParam();
  662.                         GOTO IMG_TAG;
  663.                 }
  664.  
  665.                 if (w>width1) w=width1;
  666.                
  667.         if (image)
  668.         {
  669.                         stroka+=h/10;
  670.                        
  671.                         if (top1+h<WB1.top) || (top1>WB1.top+WB1.height-10) //åñëè ÂѨ èçîáðàæåíèå óøëî ÂÅÐÕ èëè ÂÍÈÇ
  672.                                 return;
  673.  
  674.                         if (top1<WB1.top) //åñëè ÷àñòü èçîáðàæåíèÿ ñâåðõó
  675.                         {
  676.                                 img_za_kadrom=WB1.top-top1;
  677.                                 h=h-img_za_kadrom;
  678.                                 top1=WB1.top-5;
  679.                         }
  680.                        
  681.                         if (top1>WB1.top+WB1.height-h-10) //åñëè ÷àñòü èçîáðàæåíèÿ ñíèçó     IF (stroka - 2 < max_kolvo_strok)
  682.                         {
  683.                                 h=WB1.top+WB1.height-top1-10;
  684.                         }      
  685.  
  686.                         IF (h<=0) return;
  687.                        
  688.                         img_draw stdcall (image,left1-5,top1+10,w, h,0,img_za_kadrom);
  689.                         DrawBar(left1+w - 5, top1 + 10, width1-w + 5, h, 0xFFFFFF);
  690.         }
  691.                 return;
  692.         }
  693.  
  694.         if (!chTag("meta"))
  695.         {
  696.                 META:
  697.                 if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content="))
  698.                 {
  699.                         copystr(#options[find_symbol(#options, '=')],#options); //ïîèñê â content=
  700.  
  701.                         IF (!strcmp(#options,"utf-8")) || (!strcmp(#options,"utf8"))
  702.                         {
  703.                                 ReadHtml();
  704.                                 utf8rutodos(buf);
  705.                         }
  706.                         IF(!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u"))
  707.                         {
  708.                                 ReadHtml();
  709.                                 koitodos(buf);
  710.                         }
  711.                         IF(!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866"))
  712.                         {
  713.                                 ReadHtml();
  714.                         }
  715.                 }
  716.                 IF(tagparam)
  717.                 {
  718.                         GetNextParam();
  719.                         goto META;
  720.                 }
  721.                 return;
  722.         }
  723. }
  724.  
  725.  
  726. void TextGoDown(int left1, top1, width1) {
  727.         stroka++;
  728.         IF(blq_text == 1) stolbec = 8;
  729.         ELSE stolbec = 0;
  730.         IF(li_text == 1) stolbec = li_tab * 5;
  731.         IF(stroka >= 0) && (stroka - 2 < max_kolvo_strok) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, 0xFFFFFF);
  732. }
  733.  
  734.  
  735. //ñêðîëë
  736. void TWebBrowser::DrawScroller() {
  737.         dword on_y;
  738.         DrawBar(left + width - 15, top + 17, 1, height - 34, 0x94AECE); //ëèíèÿ ñëåâà îò ïðîêðóòêè
  739.         DrawFlatButton(left + width - 15, top + height - 17, 16, 16, ID2, 0xE4DFE1, "\x19");
  740.         DrawFlatButton(left + width - 15, top, 16, 16, ID1, 0xE4DFE1, "\x18");
  741.  
  742.         IF(count <= max_kolvo_strok) {
  743.                 DrawBar(left + width - 14, top + 17, 16, height - 34, 0xCED0D0);
  744.                 return;
  745.         }
  746.  
  747.         scroll_size = height - 16 * max_kolvo_strok / count - 3;
  748.         IF(scroll_size < 10) scroll_size = 10;
  749.         IF(za_kadrom + max_kolvo_strok >= count) on_y = height - scroll_size + top - 17;
  750.         ELSE on_y = height - 32 * za_kadrom / count + top + 16;
  751.         DrawFlatButton(left + width - 15, on_y, 16, scroll_size, 0, 0xE4DFE1, ""); //ïîëçóíîê
  752.         IF(on_y > top + 17) DrawBar(left + width - 14, top + 17, 16, on_y - top - 17, 0xCED0D0); //ïîëå äî ïîëçóíêà
  753.         IF(height - scroll_size + top - 17 > on_y)
  754.                 DrawBar(left + width - 14, on_y + scroll_size + 1, 16, height - scroll_size - on_y + top - 18, 0xCED0D0); //ïîëå ïîñëå ïîëçóíêà
  755. }