Subversion Repositories Kolibri OS

Rev

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

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