Subversion Repositories Kolibri OS

Rev

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