Subversion Repositories Kolibri OS

Rev

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

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