Subversion Repositories Kolibri OS

Rev

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

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