Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

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