Subversion Repositories Kolibri OS

Rev

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

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