Subversion Repositories Kolibri OS

Rev

Rev 4504 | Blame | Last modification | View Log | Download | RSS feed

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