Subversion Repositories Kolibri OS

Rev

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