Subversion Repositories Kolibri OS

Rev

Rev 2840 | 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.  
  9. char download_path[]="/rd/1/.download";
  10. char search_path[]="http://nigma.ru/index.php?s=";
  11. char version[]=" Text-based Browser 0.95";
  12.  
  13.  
  14. struct TWebBrowser {
  15.         int left, top, width, height;
  16.         void Scan(int);
  17.         void GetNewUrl();
  18.         void OpenPage();
  19.         void ReadHtml(byte);
  20.         void ShowPage();
  21.         void ParseHTML(dword);
  22.         void WhatTextStyle(int left1, top1, width1);
  23.         void DrawPage();
  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[300],
  34.         text_color_index,
  35.         link_color,
  36.         bg_color;
  37.  
  38. int stroka,
  39.         stolbec,
  40.         tab_len;
  41.  
  42. char anchor[256];
  43. int anchor_line_num;
  44.        
  45. char line[500],
  46.         tag[100],
  47.         tagparam[10000],
  48.         parametr[1200],
  49.         options[1000];
  50.  
  51. #include "include\history.h"
  52. #include "include\colors.h"
  53. #include "include\unicode_tags.h"
  54. #include "include\some_code.h"
  55. #include "include\parce_tag.h"
  56.  
  57.  
  58. void TWebBrowser::Scan(int id)
  59. {
  60.         if (id >= 400)
  61.         {
  62.                 GetURLfromPageLinks(id);
  63.                
  64.                 //#1
  65.                 if (URL[0] == '#')
  66.                 {
  67.                         strcpy(#anchor, #URL+strrchr(#URL, '#'));
  68.                        
  69.                         strcpy(#URL, BrowserHistory.CurrentUrl());
  70.                        
  71.                         lines.first=lines.all-lines.visible;
  72.                         ShowPage();
  73.                         return;
  74.                 }
  75.                 //liner.ru#1
  76.                 if (strrchr(#URL, '#')<>-1)
  77.                 {
  78.                         strcpy(#anchor, #URL+strrchr(#URL, '#'));
  79.                         URL[strrchr(#URL, '#')-1] = 0x00; //çàãëóøêà
  80.                 }
  81.  
  82.                 GetNewUrl();
  83.                
  84.                 if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg"))
  85.                 {
  86.                         RunProgram("/sys/media/kiv", #URL);
  87.                         strcpy(#editURL, BrowserHistory.CurrentUrl());
  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[strrchr(#editURL, '/')-2]<>'/')  // åñëè íå http://pagename.ua <-- íàõðåíà ýòà ñòðîêà???
  201.                 {
  202.                         editURL[strrchr(#editURL, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
  203.                 }
  204.                
  205.                 IF (!strcmp(get_URL_part(3),"../")) //íà óðîâåíü ââåðõ
  206.                 {
  207.                         strcpy(#URL,#URL+3);
  208.                         editURL[strrchr(#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.         strcpy(#header, #version);
  250.         if (!strcmp(get_URL_part(5),"http:")))
  251.         {
  252.                 KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ
  253.                 DeleteFile(#download_path);
  254.                 IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]='';
  255.                 downloader_id = RunProgram("/sys/network/downloader", #URL);
  256.                 //ýòî ãåíèàëüíî è ýòî ïèçäåö!!!
  257.                 Pause(60);
  258.                 if (GetProcessSlot(downloader_id)<>0)
  259.                 {
  260.                         debug("Browser Hack v2.0: Killing downloader and trying to run it one more!");
  261.                         KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ
  262.                         downloader_id = RunProgram("/sys/network/downloader", #URL);
  263.                 }
  264.                 //
  265.                 IF (downloader_id<0) RunProgram("@notify", "Error running Downloader. Internet unavilable.");
  266.                 Draw_Window();
  267.                 return;
  268.         }
  269.         lines.first = lines.all = 0;
  270.         ReadHtml(_WIN);
  271.         WB1.ShowPage();
  272. }
  273.  
  274.  
  275. void TWebBrowser::ShowPage()
  276. {
  277.         edit1.size = edit1.pos = strlen(#editURL);
  278.         edit_box_draw stdcall(#edit1); //ðèñóåì ñòðîêó àäðåñà
  279.        
  280.         if (!filesize)
  281.         {
  282.                 DrawBar(left, top, width+4, height, 0xFFFFFF); //çàêðàøèâàåì âñ¸ äîíèçó
  283.                 if (GetProcessSlot(downloader_id)<>0) WriteText(left + 10, top + 18, 0x80, 0, "Loading...", 0);
  284.                 else
  285.                 {
  286.                         WriteText(left + 10, top + 18, 0x80, 0, "Page not found. May be, URL contains some errors.", 0);
  287.                         if (!strcmp(get_URL_part(5),"http:"))) WriteText(left + 10, top + 32, 0x80, 0, "Or Internet unavilable for your configuration.", 0);
  288.                 }
  289.                 //return;
  290.         }
  291.         else
  292.                 ParseHTML(buf);
  293.  
  294.         if (!header) strcpy(#header, #version);
  295.         if (!strcmp(#version, #header)) DrawTitle(#header);
  296. }
  297.  
  298.  
  299.  
  300. void TWebBrowser::ParseHTML(dword bword){
  301.         word bukva[2];
  302.         int j, perenos_num;
  303.         byte ignor_param;
  304.         char temp[768];
  305.        
  306.         stroka = -lines.first;
  307.         stolbec = 0;
  308.        
  309.         for (j = 400; j < blink + 1; j++;) DeleteButton(j);
  310.         blink = 400;
  311.  
  312.         b_text = i_text = u_text = s_text = pre_text = blq_text = first_line_drawed =
  313.         li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 0; //îáíóëÿåì òåãè
  314.         link_color = 0x0000FF;
  315.         bg_color = 0xFFFFFF;
  316.         line = '';
  317.         strcpy(#page_links,"|");
  318.         strcpy(#header, #version);
  319.  
  320.         if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1;
  321.         if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
  322.        
  323.         debug("Start parsing");
  324.        
  325.         for ( ; buf+filesize > bword; bword++;)
  326.         {
  327.                 bukva = ESBYTE[bword];
  328.                 if (ignor_text) && (bukva<>'<') continue;
  329.                 switch (bukva)
  330.                 {
  331.                 case 0x0a:
  332.                         if (pre_text)
  333.                         {
  334.                                 bukva = temp = '';
  335.                                 goto NEXT_MARK;
  336.                         }
  337.                 case '\9':
  338.                         if (pre_text) //èíà÷å èä¸ì íà 0x0d     
  339.                         {
  340.                                 tab_len=strlen(#line)/8;
  341.                                 tab_len=tab_len*8;
  342.                                 tab_len=8+tab_len-strlen(#line);
  343.                                 for (j=0; j<tab_len; j++;) strcat(#line," ");
  344.                                 break;
  345.                         }              
  346.                 case 0x0d:
  347.                         bukva = ' ';
  348.                         goto DEFAULT_MARK;
  349.                 case '<':
  350.                         bword++; //ïðîìîòàåì ñèìâîë <
  351.                         tag = parametr = tagparam = ignor_param = 0;
  352.                         if (ESBYTE[bword] == '!') //ôèëüòðàöèÿ âíóòðè <!-- -->, äåðçêî
  353.                         {
  354.                                 bword++;
  355.                                 if (ESBYTE[bword] == '-')
  356.                                 {
  357.                                 HH_:
  358.                                         do
  359.                                         {
  360.                                                 bword++;
  361.                                                 if (buf + filesize <= bword) break 2;
  362.                                         }
  363.                                         while (ESBYTE[bword] <>'-');
  364.                                        
  365.                                         bword++;
  366.                                         if (ESBYTE[bword] <>'-') goto HH_;
  367.                                 }
  368.                         }
  369.                         while (ESBYTE[bword] <>'>') && (bword < buf + filesize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
  370.                         {
  371.                                 bukva = ESBYTE[bword];
  372.                                 if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
  373.                                 if (!ignor_param) && (bukva <>' ')
  374.                                 {
  375.                                         if (strlen(#tag)<sizeof(tag)) strcat(#tag, #bukva);
  376.                                 }
  377.                                 else
  378.                                 {
  379.                                         ignor_param = true;
  380.                                         if (!ignor_text) && (strlen(#tagparam)+1<sizeof(tagparam)) strcat(#tagparam, #bukva);
  381.                                 }
  382.                                 bword++;
  383.                         }
  384.                         strlwr(#tag);
  385.                         strlwr(#tagparam);
  386.  
  387.                         if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=''; //for br/
  388.                         if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam();
  389.  
  390.                         DrawPage();
  391.                         line=0;
  392.  
  393.                         if (tag) WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //îáðàáîòêà òåãîâ
  394.  
  395.                         tag = parametr = tagparam = ignor_param = '\0';
  396.                         break;
  397.                 case '=': //ïîääåðæêà øàéòàíñêîé êîäèðîâêè ñòðàíèö, ñîõðàí¸ííûõ ÷åðåç ÈÅ7
  398.                         if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK;
  399.  
  400.                         bword++;
  401.                         bukva=ESBYTE[bword];
  402.                         strcpy(#temp,#bukva);
  403.                         bword++;
  404.                         bukva=ESBYTE[bword];
  405.                         strcat(#temp,#bukva);
  406.                        
  407.                         bukva=Hex2Symb(#temp);
  408.                         if (bukva) goto DEFAULT_MARK;
  409.                         break;
  410.                        
  411.                 case '&': //&nbsp; and so on
  412.                         bword++;
  413.                         tag=0;
  414.                         for (j=0; (ESBYTE[bword]<>';') && (j<7);   j++, bword++;)
  415.                         {
  416.                                 bukva = ESBYTE[bword];
  417.                                 strcat(#tag, #bukva);
  418.                         }
  419.                        
  420.                         for (j=0; unicode_tags[j]!=0; j+=2;)
  421.                         {
  422.                                 if (!strcmp(#tag, unicode_tags[j]))
  423.                                 {
  424.                                         strcat(#line, unicode_tags[j+1]);
  425.                                         break 1;
  426.                                 }
  427.                         }
  428.                        
  429.                         rez = atoi(#tag + 1) - 1040;
  430.                         if (tag[1] == '1') && (rez>=0) && (rez<=72) && (strlen(#tag) == 5)
  431.                         {
  432.                                 bukva = unicode_chars[rez];
  433.                                 //GOTO DEFAULT_MARK; //îáðàáàòûâàåì áóêâó ëó÷øå íàâåðíî strcat(#line, unicode_tags[j+1]); è break 1;
  434.                                 strcat(#line, #bukva);
  435.                                 break;
  436.                         }
  437.                        
  438.                         strcat(#line,#tag); //âûâîäèì íà ýêðàí íåîáðàáîòàííûé òåã, òàê áðàóçåðû çà÷åì-òî äåëàþò
  439.                         break;
  440.                 default:
  441.                         DEFAULT_MARK:
  442.                         if (!pre_text) && (bukva == ' ') && (line[strlen(#line)-1]==' ') break;
  443.                         //
  444.                         if (stolbec + strlen(#line) > lines.column_max)
  445.                         {
  446.                                 perenos_num = strrchr(#line, ' ');
  447.                                 strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
  448.                                 line[perenos_num] = 0x00;
  449.                         NEXT_MARK:
  450.                                 if (stroka >= lines.visible) && (lines.first <>0) break 1; //óõîäèì...
  451.                                 DrawPage();
  452.                                 TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
  453.                                 strcpy(#line, #temp);
  454.                         }
  455.                         if (!pre_text) && (bukva == ' ') && (!stolbec) && (!line) break;
  456.                         if (strlen(#line)<sizeof(line)) strcat(#line, #bukva);
  457.                 }
  458.         }
  459.  
  460.         if (lines.visible * 10 + 25 <= height)
  461.                 DrawBar(left, lines.visible * 10 + top + 25, width - 15, -lines.visible * 10 + height - 25, bg_color);
  462.         if (stroka * 10 + 15 <= height)
  463.                 DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà
  464.         if (lines.first == 0) lines.all = stroka;
  465.         debug ("Pre end - anchor");
  466.         if (anchor)
  467.         {
  468.                 //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë
  469.                 anchor='';
  470.                 lines.first=anchor_line_num;
  471.                 ParseHTML(buf);
  472.         }
  473.         debug("End parsing");
  474.  
  475.         DrawScroller();
  476. }
  477.  
  478. void TWebBrowser::DrawPage() //ðåçàòü çäåñü!!1!
  479. {
  480.         int start_x, start_y, line_length;
  481.         char temp[sizeof(line)];
  482.        
  483.         if (!header) //&& (tag)
  484.         {
  485.                 if (strlen(#version)+strlen(#line)+2>sizeof(header))
  486.                 {
  487.                         //line = 123456789
  488.                         //header = 1234
  489.                         //line = 56789
  490.                         debug("too long header");
  491.                         strcpy(#temp, #line);
  492.                         temp[sizeof(header)-strlen(#version)-2]=0;
  493.                         strcpy(#header, #temp);
  494.                         strcpy(#line, #line+strlen(#temp));
  495.                 }
  496.                 else
  497.                 {
  498.                         debug("normal header");
  499.                         strcpy(#header, #line);
  500.                         line=0;
  501.                 }
  502.                        
  503.                 strcat(#header, " -");
  504.                 strcat(#header, #version);
  505.                 return;
  506.         }
  507.  
  508.         if (stroka >= 0) && (stroka - 2 < lines.visible) && (line) && (!anchor)
  509.         {
  510.                 if (!stroka) && (!stolbec)
  511.                 {
  512.                         DrawBar(left, top, width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
  513.                         first_line_drawed=1;
  514.                 }
  515.                
  516.                 start_x=stolbec * 6 + left+5;
  517.                 start_y=stroka * 10 + top + 5;
  518.                 line_length=strlen(#line)*6;
  519.                
  520.                 WriteText(start_x, start_y, 0x80, text_colors[text_color_index], #line, 0);
  521.                 //line_length =  get_length stdcall (#line,-1,16,line_length);
  522.                 //text_out stdcall (#line, -1, 17, text_colors[text_color_index], start_x, start_y-2);
  523.                 IF (b_text)     { $add ebx, 1<<16   $int 0x40 }
  524.                 IF (i_text) Skew(start_x, start_y, line_length+6, 10);
  525.                 IF (s_text) DrawBar(start_x, start_y + 4, line_length, 1, text_colors[text_color_index]);
  526.                 IF (u_text) DrawBar(start_x, start_y + 8, line_length, 1, text_colors[text_color_index]);
  527.                 IF (link) {
  528.                         DefineButton(start_x-2, start_y, line_length + 3, 9, blink + BT_HIDE, 0xB5BFC9);
  529.                         DrawBar(start_x, start_y + 8, line_length, 1, text_colors[text_color_index]);
  530.                 }
  531.                 stolbec += strlen(#line);
  532.         }
  533. }
  534.  
  535.  
  536. char oldtag[100];
  537. void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
  538.         dword hr_color;
  539.  
  540.     dword image;
  541.     char temp[4096];
  542.     int w=0, h=0, img_lines_first=0;
  543.  
  544.         //ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ
  545.         if (tag[0] == '/')
  546.         {
  547.                 rez = 0;
  548.                 strcpy(#tag, #tag+1);
  549.         }
  550.         else
  551.                 rez = 1;
  552.                
  553.         if (!chTag("html")) {
  554.                 IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (rez==0) ignor_text = 1; ELSE ignor_text = 0;
  555.                 return;
  556.         }
  557.  
  558.         if (!chTag("script")) || (!chTag("style")) || (!chTag("binary")) ignor_text = rez;
  559.  
  560.         if(!chTag("title"))
  561.         {
  562.                 if (rez)
  563.                 {
  564.                         header=0;
  565.                 }
  566.                 else //òåã çàêðûëñÿ - âûâåëè ñòðîêó
  567.                 {
  568.                         if (stroka==0) DrawTitle(#header);
  569.                 }
  570.                 return;
  571.         }
  572.  
  573.         if (ignor_text) return;
  574.  
  575.  
  576.  
  577.        
  578.         IF(!chTag("q")) strcat(#line, "\"");
  579.  
  580.  
  581.         if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò
  582.         {
  583.                 if (!strcmp(#anchor, #options))
  584.                 {
  585.                         anchor_line_num=lines.first+stroka;
  586.                 }
  587.         }
  588.        
  589.         if (!chTag("body"))
  590.         {
  591.                 BODY_MARK:
  592.                
  593.                 if (!strcmp(#parametr, "link="))
  594.                         link_color = GetColor(#options);
  595.                
  596.                 if (!strcmp(#parametr, "text="))
  597.                         text_colors[0]=GetColor(#options);
  598.                
  599.                 if (!strcmp(#parametr, "bgcolor="))
  600.                         bg_color=GetColor(#options);
  601.                
  602.                 IF(tagparam)
  603.                 {
  604.                         GetNextParam();
  605.                         GOTO BODY_MARK;
  606.                 }
  607.                
  608.                 return;
  609.         }
  610.  
  611.         if (!chTag("a"))
  612.         {
  613.                 if (rez)
  614.                 {
  615.                         text_color_index++;
  616.                         text_colors[text_color_index] = text_colors[text_color_index-1];
  617.  
  618.                         _A_MARK:
  619.                         if (!strcmp(#parametr, "href="))
  620.                         {
  621.                                 if (stroka - 1 > lines.visible) || (stroka < -2) return;
  622.                                 if (link) && (text_color_index > 0) text_color_index--; //åñëè íå çàêðûò òýã
  623.                                 link = 1;
  624.                                 blink++;
  625.                                 text_colors[text_color_index] = link_color;
  626.                                 strcat(#page_links, #options);
  627.                                 strcat(#page_links, "|");
  628.                         }
  629.                         if (anchor) && (!strcmp(#parametr, "name="))
  630.                         {
  631.                                 if (!strcmp(#anchor, #options))
  632.                                 {
  633.                                         anchor_line_num=lines.first+stroka;
  634.                                 }
  635.                         }
  636.                         if (tagparam)
  637.                         {
  638.                                 GetNextParam();
  639.                                 GOTO _A_MARK;
  640.                         }
  641.                 }
  642.                 else {
  643.                         link = 0;
  644.                         IF(text_color_index > 0) text_color_index--;
  645.                 }
  646.                 return;
  647.         }
  648.  
  649.  
  650.         if (!chTag("font"))
  651.         {
  652.                 if (rez)
  653.                 {
  654.                         text_color_index++;
  655.                         text_colors[text_color_index] = text_colors[text_color_index-1];
  656.                
  657.                         COL_MARK:
  658.                         if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#')
  659.                         {
  660.                                 text_colors[text_color_index] = GetColor(#options);
  661.                         }
  662.                         IF(tagparam) {
  663.                                 GetNextParam();
  664.                                 GOTO COL_MARK;
  665.                         }
  666.                 }
  667.                 else
  668.                         if (text_color_index > 0) text_color_index--;
  669.                 return;
  670.         }
  671.  
  672.         if(!chTag("tr")) || (!chTag("br")) {
  673.                 TextGoDown(left1, top1, width1);
  674.                 return;
  675.         }
  676.         if (!chTag("div")) {
  677.                 IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1);
  678.                 return;
  679.         }
  680.         if (!chTag("p")) {
  681.                 IF(oldtag[0] == 'h') return;
  682.                 TextGoDown(left1, top1, width1);
  683.                 IF(rez) TextGoDown(left1, top1 + 10, width1);
  684.                 return;
  685.         }
  686.  
  687.         if (!chTag("h1")) || (!chTag("h2")) || (!chTag("h3")) || (!chTag("h4")) {
  688.                 TextGoDown(left1, top1, width1);
  689.                 IF(rez) TextGoDown(left1, top1 + 10, width1);
  690.                 b_text = rez;
  691.                 strcpy(#oldtag, #tag);
  692.                 return;
  693.         }
  694.         else
  695.                 oldtag='';
  696.                
  697.         if (!chTag("b")) || (!chTag("strong")) || (!chTag("big")) {
  698.                 b_text = rez;
  699.                 return;
  700.         }
  701.         ////////////////////////////
  702.         if(!chTag("i")) || (!chTag("em")) || (!chTag("subtitle")) {
  703.                 i_text = rez;
  704.                 return;
  705.         }      
  706.         ////////////////////////////
  707.         if (!chTag("dt"))
  708.         {
  709.                 li_text = rez;
  710.                 IF(rez == 0) return;
  711.                 TextGoDown(left1, top1, width1);
  712.                 return;
  713.         }
  714.         /////////////////////////////
  715.         if(!chTag("li")) || (!chTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
  716.         {
  717.                 li_text = rez;
  718.                 IF(rez == 0) return;
  719.                 TextGoDown(left1, top1, width1);
  720.                 IF(stroka > -1) && (stroka - 2 < lines.visible) DrawBar(li_tab * 5 * 6 + left1 - 5, top1 + 12, 2, 2, 0);
  721.                 return;
  722.         }
  723.         ////////////////////////////
  724.         IF(!chTag("u")) || (!chTag("ins")) u_text = rez;
  725.         IF(!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez;
  726.         IF(!chTag("ul")) || (!chTag("ol")) IF(!rez) {
  727.                 li_text = rez;
  728.                 li_tab--;
  729.                 TextGoDown(left1, top1, width1);
  730.         } ELSE li_tab++;
  731.         IF(!chTag("dd")) stolbec += 5;
  732.         IF(!chTag("blockquote")) blq_text = rez;
  733.         IF(!chTag("pre")) pre_text = rez;
  734.         IF(!chTag("hr")) {
  735.                 TextGoDown(left1, top1, width1);
  736.                 TextGoDown(left1, top1 + 10, width1);
  737.                 IF(strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options);
  738.                 ELSE hr_color = 0x999999;
  739.                 IF(stroka > 0) DrawBar(left1, top1 + 14, width1 - 8, 1, hr_color);
  740.         }
  741.  
  742.         if (!chTag("img"))
  743.         {
  744.                 //if (GetFileInfo(#libimg)<>0) return;  //åñëè áèáëèîòåêè íåò
  745.                 IMG_TAG:
  746.                         if (!strcmp(#parametr,"src="))   //íàäî îáúåäèíèòü ñ GetNewUrl()
  747.                         {
  748.                                 strcpy(#temp, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
  749.                                 temp[strrchr(#temp, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
  750.                                 strcat(#temp, #options);
  751.                                 image=load_image(#temp);
  752.                                 w=DSWORD[image+4];
  753.                                 h=DSWORD[image+8];
  754.                         }
  755.                         /*if (!strcmp(#parametr,"alt="))
  756.                         {
  757.                                 strcpy(#tag, "[Image: ");
  758.                                 strcat(#tag, #options);
  759.                                 strcat(#tag, "]");
  760.                         }*/
  761.  
  762.                 IF(tagparam)
  763.                 {
  764.                         GetNextParam();
  765.                         GOTO IMG_TAG;
  766.                 }
  767.                
  768.                 if (!image)
  769.                 {
  770.                         //debug(#tag);
  771.                         return;
  772.                 }
  773.  
  774.                 if (w>width1) w=width1;
  775.        
  776.                 if (stroka==0) DrawBar(left, top, width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
  777.                
  778.                 stroka+=h/10;
  779.                
  780.                 if (top1+h<WB1.top) || (top1>WB1.top+WB1.height-10) //åñëè ÂѨ èçîáðàæåíèå óøëî ÂÅÐÕ èëè ÂÍÈÇ
  781.                         return;
  782.  
  783.                 if (top1<WB1.top) //åñëè ÷àñòü èçîáðàæåíèÿ ñâåðõó
  784.                 {
  785.                         DrawBar(left, top, width-15, 10, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
  786.                         img_lines_first=WB1.top-top1;
  787.                         h=h-img_lines_first;
  788.                         top1=WB1.top;
  789.                 }
  790.                
  791.                 if (top1>WB1.top+WB1.height-h-15) //åñëè ÷àñòü èçîáðàæåíèÿ ñíèçó     IF (stroka - 2 < lines.visible)
  792.                 {
  793.                         h=WB1.top+WB1.height-top1-15;
  794.                 }      
  795.  
  796.                 if (h<=0) return;
  797.                 if (anchor) return;
  798.                
  799.                 img_draw stdcall (image,left1-5,top1+10,w, h,0,img_lines_first);
  800.                 DrawBar(left1+w - 5, top1 + 10, width1-w + 5, h, bg_color);
  801.                 IF (link)
  802.                 {
  803.                         DefineButton(left1 - 5, top1+10, w, h, blink + BT_HIDE, 0xB5BFC9);
  804.                 }
  805.  
  806.                 return;
  807.         }
  808.  
  809.         if (!chTag("meta")) || (!chTag("?xml"))
  810.         {
  811.                 META:
  812.                 if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
  813.                 {
  814.                         strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content=
  815.  
  816.                         if (!strcmp(#options,"utf-8")) || (!strcmp(#options,"utf8"))            ReadHtml(_UTF);
  817.                         if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u"))       ReadHtml(_KOI);
  818.                         if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866"))          ReadHtml(_DOS);
  819.                 }
  820.                 if (tagparam)
  821.                 {
  822.                         GetNextParam();
  823.                         goto META;
  824.                 }
  825.                 return;
  826.         }
  827. }
  828.  
  829.  
  830. void TextGoDown(int left1, top1, width1)
  831. {
  832.         if (!stroka) && (!stolbec) && (!first_line_drawed)
  833.         {
  834.                 DrawBar(WB1.left, WB1.top, WB1.width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
  835.                 first_line_drawed=1;
  836.         }
  837.         stroka++;
  838.         if (blq_text) stolbec = 8;
  839.         ELSE stolbec = 0;
  840.         if (li_text) stolbec = li_tab * 5;
  841.         IF(stroka >= 0) && (stroka - 2 < lines.visible)  && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color);
  842. }
  843.  
  844.  
  845. //ñêðîëë
  846. void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
  847. {
  848.         scroll1.max_area = lines.all;
  849.         scroll1.cur_area = lines.visible;
  850.         scroll1.position = lines.first;
  851.  
  852.         scroll1.all_redraw=1;
  853.         scroll1.start_x=Form.width-28; //left + width - 15
  854.         scroll1.size_y=WB1.height;
  855.  
  856.         scrollbar_v_draw(#scroll1);
  857. }