Subversion Repositories Kolibri OS

Rev

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

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