Subversion Repositories Kolibri OS

Rev

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

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