Subversion Repositories Kolibri OS

Rev

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