Subversion Repositories Kolibri OS

Rev

Rev 7742 | Rev 7746 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. //HTML Viewer in C--
  2. //Copyright 2007-2020 by Veliant & Leency
  3. //Asper, lev, Lrz, Barsuk, Nable, hidnplayr...
  4.  
  5. #ifndef AUTOBUILD
  6.         #include "lang.h--"
  7. #endif
  8.  
  9. //libraries
  10. #define MEMSIZE 1024 * 800
  11. #include "..\lib\gui.h"
  12. #include "..\lib\draw_buf.h"
  13. #include "..\lib\list_box.h"
  14. #include "..\lib\cursor.h"
  15. #include "..\lib\collection.h"
  16. #include "..\lib\random.h"
  17. #include "..\lib\clipboard.h"
  18.  
  19. // *.obj libraries
  20. #include "..\lib\obj\box_lib.h"
  21. #include "..\lib\obj\libio.h"
  22. #include "..\lib\obj\libimg.h"
  23. #include "..\lib\obj\http.h"
  24. #include "..\lib\obj\iconv.h"
  25. //useful patterns
  26. #include "..\lib\patterns\history.h"
  27. #include "..\lib\patterns\http_downloader.h"
  28.  
  29. _http http = {0, 0, 0, 0, 0, 0, 0};
  30.  
  31.  
  32. #ifdef LANG_RUS
  33. char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 1.85";
  34. ?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
  35. ?define T_LAST_SLIDE "â® ¯®á«¥¤­¨© á« ©¤"
  36. char loading[] = "‡ £à㧪  áâà ­¨æë...<br>";
  37. char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
  38. char homepage[] = FROM "html\\homepage_ru.htm""\0";
  39. char help[] = FROM "html\\help_ru.htm""\0";
  40. char accept_language[]= "Accept-Language: ru\n";
  41. char rmb_menu[] =
  42. "®á¬®âà¥âì ¨á室­¨ª
  43. ¥¤ ªâ¨à®¢ âì ¨á室­¨ª
  44. ˆáâ®à¨ï
  45. Œ¥­¥¤¦¥à § £à㧮ª";
  46. char link_menu[] =
  47. "Š®¯¨à®¢ âì áá뫪ã
  48. ‘ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
  49. #else
  50. char version[]="Text-based Browser 1.85";
  51. ?define IMAGES_CACHE_CLEARED "Images cache cleared"
  52. ?define T_LAST_SLIDE "This slide is the last"
  53. char loading[] = "Loading...<br>";
  54. char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
  55. char homepage[] = FROM "html\\homepage_en.htm""\0";
  56. char help[] = FROM "html\\help_en.htm""\0";
  57. char accept_language[]= "Accept-Language: en\n";
  58. char rmb_menu[] =
  59. "View source
  60. Edit source
  61. History
  62. Download Manager";
  63. char link_menu[] =
  64. "Copy link
  65. Download link contents";
  66. #endif
  67.  
  68.  
  69. #define URL_SERVICE_HISTORY "WebView://history"
  70. #define URL_SERVICE_HOMEPAGE "WebView://home"
  71. #define URL_SERVICE_HELP "WebView://help"
  72. #define URL_SERVICE_SOURCE "WebView://source:"
  73.  
  74. proc_info Form;
  75.  
  76. //char search_path[]="http://nigma.ru/index.php?s=";
  77. int redirected = 0;
  78.  
  79. char stak[4096];
  80.  
  81. int action_buf;
  82.  
  83. dword TOOLBAR_H = 40;
  84. dword STATUSBAR_H = 15;
  85.  
  86. dword col_bg = 0xE3E2E2;
  87. dword panel_color  = 0xE3E2E2;
  88. dword border_color = 0x8C8C8C;
  89.  
  90. bool debug_mode = false;
  91. bool old_tag_parser_mode = false;
  92.  
  93. progress_bar wv_progress_bar;
  94. bool souce_mode = false;
  95. bool open_in_a_new_window = false;
  96.  
  97. enum {
  98.         BACK_BUTTON=1000,
  99.         FORWARD_BUTTON,
  100.         REFRESH_BUTTON,
  101.         GOTOURL_BUTTON,
  102.         SANDWICH_BUTTON,
  103.         VIEW_SOURCE=1100,
  104.         EDIT_SOURCE,
  105.         VIEW_HISTORY,
  106.         //FREE_IMG_CACHE,
  107.         DOWNLOAD_MANAGER,
  108.         COPY_LINK_URL=1200,
  109.         DOWNLOAD_LINK_CONTENTS,
  110. };
  111.  
  112. #include "..\TWB\TWB.c"
  113. #include "history.h"
  114. #include "show_src.h"
  115. #include "download_manager.h"
  116.  
  117. char editURL[sizeof(URL)];
  118. edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(URL)-2,#editURL,0,2,19,19};
  119.  
  120. #define SKIN_Y 24
  121.  
  122. void main()
  123. {
  124.         int i;
  125.         load_dll(boxlib, #box_lib_init,0);
  126.         load_dll(libio, #libio_init,1);
  127.         load_dll(libimg, #libimg_init,1);
  128.         load_dll(libHTTP, #http_lib_init,1);
  129.         load_dll(iconv_lib, #iconv_open,0);
  130.         Libimg_LoadImage(#skin, "/sys/toolbar.png");
  131.         skin.h = 26;
  132.         wv_progress_bar.progress_color = 0x72B7EB;
  133.         CreateDir("/tmp0/1/downloads");
  134.         if (param) && (param[0]=='-') && (param[1]=='d') {
  135.                 strcpy(#downloader_edit, #param+3);
  136.                 CreateThread(#Downloader,#downloader_stak+4092);
  137.                 ExitProcess();
  138.         }
  139.         else if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOMEPAGE);
  140.         WB1.list.SetFont(8, 14, 10011000b);
  141.         WB1.list.no_selection = true;
  142.         SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
  143.         loop() switch(WaitEvent())
  144.         {
  145.                 case evMouse:
  146.                         edit_box_mouse stdcall (#address_box);
  147.                         mouse.get();
  148.                         if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y))
  149.                         && (bufsize) && (mouse.pkm) && (mouse.up) {
  150.                                 if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu(mouse.x, mouse.y);
  151.                                 break;
  152.                         }
  153.                         if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
  154.                         scrollbar_v_mouse (#scroll_wv);
  155.                         if (WB1.list.first != scroll_wv.position)
  156.                         {
  157.                                 WB1.list.first = scroll_wv.position;
  158.                                 WB1.DrawPage();
  159.                                 break;
  160.                         }
  161.                         break;
  162.  
  163.                 case evButton:
  164.                         ProcessEvent(GetButtonID());
  165.                         break;
  166.  
  167.                 case evKey:
  168.                         GetKeys();
  169.                         if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
  170.                                 if (key_scancode == SCAN_CODE_KEY_H) ProcessEvent(VIEW_HISTORY);
  171.                                 if (key_scancode == SCAN_CODE_KEY_U) ProcessEvent(VIEW_SOURCE);
  172.                                 if (key_scancode == SCAN_CODE_KEY_T)
  173.                                 || (key_scancode == SCAN_CODE_KEY_N) RunProgram(#program_path, NULL);
  174.                                 if (key_scancode == SCAN_CODE_KEY_W) ExitProcess();
  175.                                 if (key_scancode == SCAN_CODE_KEY_J) ProcessEvent(DOWNLOAD_MANAGER);
  176.                                 if (key_scancode == SCAN_CODE_KEY_R) ProcessEvent(REFRESH_BUTTON);
  177.                                 if (key_scancode == SCAN_CODE_ENTER) EventSeachWeb();
  178.                                 if (key_scancode == SCAN_CODE_LEFT)  ProcessEvent(BACK_BUTTON);
  179.                                 if (key_scancode == SCAN_CODE_RIGHT) ProcessEvent(FORWARD_BUTTON);
  180.                         }
  181.                        
  182.                         if (key_scancode == SCAN_CODE_F5) ProcessEvent(REFRESH_BUTTON);
  183.                        
  184.                         if (address_box.flags & ed_focus)  
  185.                         {
  186.                                 if (key_scancode == SCAN_CODE_ENTER) {
  187.                                         ProcessEvent(key_scancode);
  188.                                 }
  189.                                 else {
  190.                                         EAX = key_editbox;
  191.                                         edit_box_key stdcall(#address_box);
  192.                                 }
  193.                         }
  194.                         else
  195.                         {
  196.                                 #define KEY_SCROLL_N 11
  197.                                 if (SCAN_CODE_UP   == key_scancode) for (i=0;i<KEY_SCROLL_N;i++) WB1.list.KeyUp();
  198.                                 if (SCAN_CODE_DOWN == key_scancode) for (i=0;i<KEY_SCROLL_N;i++) WB1.list.KeyDown();
  199.                                 if (key_scancode == SCAN_CODE_F6) {address_box.flags=ed_focus; DrawOmnibox();}
  200.                                 if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage();
  201.                                 else ProcessEvent(key_scancode);
  202.                         }
  203.                         break;
  204.  
  205.                 case evReDraw:
  206.                         if (menu.cur_y) {
  207.                                 ProcessEvent(menu.cur_y);
  208.                                 menu.cur_y = 0;
  209.                         }
  210.                         DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,col_bg,0,0);
  211.                         GetProcessInfo(#Form, SelfInfo);
  212.                         if (Form.status_window>2) { DrawTitle(#header); break; }
  213.                         if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
  214.                         if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
  215.                         Draw_Window();
  216.                         break;
  217.                        
  218.                 case evNetwork:
  219.                         if (http.transfer > 0) {
  220.                                 http.receive();
  221.                                 EventUpdateProgressBar();
  222.                                 if (http.receive_result == 0) {
  223.                                         // Handle redirects
  224.                                         if (http.status_code >= 300) && (http.status_code < 400)
  225.                                         {
  226.                                                 redirected++;
  227.                                                 if (redirected>5)
  228.                                                 {
  229.                                                         notify("'Too many redirects.' -E");
  230.                                                         StopLoading();
  231.                                                 }
  232.                                                 else
  233.                                                 {
  234.                                                         http.handle_redirect();
  235.                                                         http.free();
  236.                                                         GetAbsoluteURL(#http.redirect_url);
  237.                                                         history.back();
  238.                                                         strcpy(#editURL, #URL);
  239.                                                         DrawOmnibox();
  240.                                                         OpenPage();
  241.                                                         //ProcessLink(history.current());
  242.                                                 }
  243.                                                 break;
  244.                                         }
  245.                                         redirected = 0;
  246.                                         // Loading the page is complete, free resources
  247.                                         history.add(#URL);
  248.                                         bufpointer = http.content_pointer;
  249.                                         bufsize = http.content_received;
  250.                                         http.free();
  251.                                         SetPageDefaults();
  252.                                         ShowPage();
  253.                                 }
  254.                         }
  255.         }
  256. }
  257.  
  258. void SetElementSizes()
  259. {
  260.         address_box.top = TOOLBAR_H/2-10;
  261.         basic_line_h = calc(WB1.list.font_h * 130) / 100;
  262.         address_box.width = Form.cwidth - address_box.left - 50;
  263.         WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x,
  264.                 Form.cheight - TOOLBAR_H - STATUSBAR_H, basic_line_h);
  265.         WB1.list.wheel_size = 7 * basic_line_h;
  266.         WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w;
  267.         WB1.list.visible = WB1.list.h;
  268.         if (WB1.list.w!=WB1.DrawBuf.bufw) {
  269.                 WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 800*20);
  270.                 ProcessEvent(REFRESH_BUTTON);
  271.         }
  272. }
  273.  
  274.  
  275.  
  276. void Draw_Window()
  277. {
  278.         DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color);
  279.         DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3);
  280.         DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color);
  281.         SetElementSizes();
  282.         DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+5, 25,border_color);
  283.         DefineButton(address_box.left-52, address_box.top-2, 24, skin.h-2, BACK_BUTTON+BT_HIDE, 0);
  284.         DefineButton(address_box.left-27, address_box.top-2, 24, skin.h-2, FORWARD_BUTTON+BT_HIDE, 0);
  285.         img_draw stdcall(skin.image, address_box.left-53, address_box.top-3, 51, skin.h, 0, SKIN_Y);
  286.         DefineButton(address_box.left+address_box.width+1, address_box.top-3, 16, skin.h-1, REFRESH_BUTTON+BT_HIDE+BT_NOFRAME, 0);
  287.         DefineButton(Form.cwidth-27, address_box.top-3, 23, skin.h-1, SANDWICH_BUTTON+BT_HIDE, 0);
  288.         img_draw stdcall(skin.image, Form.cwidth-24, address_box.top-3, 17, skin.h, 102, SKIN_Y);
  289.         DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg);
  290.         DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color);
  291.         if (!header)
  292.                 OpenPage();
  293.         else {
  294.                 WB1.DrawPage();
  295.                 DrawOmnibox();
  296.         }
  297.         DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col);
  298.         DrawProgress();
  299. }
  300.  
  301.  
  302. void ProcessEvent(dword id__)
  303. {
  304.         switch (id__)
  305.         {
  306.                 case 1:
  307.                         ExitProcess();
  308.                         return;
  309.                 case SCAN_CODE_BS:
  310.                 case BACK_BUTTON:
  311.                         if (history.back()) {
  312.                                 strcpy(#URL, history.current());
  313.                                 OpenPage();
  314.                         }
  315.                         return;
  316.                 case FORWARD_BUTTON:
  317.                         if (history.forward()) {
  318.                                 strcpy(#URL, history.current());
  319.                                 OpenPage();
  320.                         }
  321.                         return;
  322.                 case GOTOURL_BUTTON:
  323.                 case SCAN_CODE_ENTER:
  324.                         EventSubmitOmnibox();
  325.                         return;
  326.                 case REFRESH_BUTTON:
  327.                         if (http.transfer > 0)
  328.                         {
  329.                                 StopLoading();
  330.                                 Draw_Window();
  331.                         }
  332.                         else OpenPage();
  333.                         return;
  334.                 case SANDWICH_BUTTON:
  335.                         EventShowPageMenu(Form.cwidth - 215, TOOLBAR_H-6);
  336.                         return;
  337.                 case VIEW_SOURCE:
  338.                         WB1.list.first = 0;
  339.                         ShowSource();
  340.                         WB1.LoadInternalPage(bufpointer, bufsize);
  341.                         break;
  342.                 case EDIT_SOURCE:
  343.                         if (!strncmp(#URL,"http",4))
  344.                         {
  345.                                 CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
  346.                                 if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
  347.                         }
  348.                         else RunProgram("/rd/1/tinypad", #URL);
  349.                         return;
  350.                 // case FREE_IMG_CACHE:
  351.                 //      ImgCache.Free();
  352.                 //      notify(IMAGES_CACHE_CLEARED);
  353.                 //      WB1.DrawPage();
  354.                 //      return;
  355.                 case VIEW_HISTORY:
  356.                         strcpy(#URL, URL_SERVICE_HISTORY);
  357.                         OpenPage();
  358.                         return;
  359.                 case DOWNLOAD_MANAGER:
  360.                         if (!downloader_opened) {
  361.                                 downloader_edit = NULL;
  362.                                 CreateThread(#Downloader,#downloader_stak+4092);
  363.                         }
  364.                         return;
  365.                 case COPY_LINK_URL:
  366.                         Clipboard__CopyText(PageLinks.GetURL(PageLinks.active));
  367.                         notify("'URL copied to clipboard'O");
  368.                         return;
  369.                 case DOWNLOAD_LINK_CONTENTS:
  370.                         if (!downloader_opened) {
  371.                                 strcpy(#downloader_edit, PageLinks.GetURL(PageLinks.active));
  372.                                 CreateThread(#Downloader,#downloader_stak+4092);
  373.                         }
  374.                         return;
  375.                 case SCAN_CODE_F12:
  376.                         debug_mode ^= 1;
  377.                         if (debug_mode) notify("'Debug mode ON'-I");
  378.                         else notify("'Debug mode OFF'-I");
  379.                         return;
  380.                 case SCAN_CODE_F11:
  381.                         old_tag_parser_mode ^= 1;
  382.                         if (old_tag_parser_mode) notify("'Old tag parser ON'-I");
  383.                         else notify("'Old tag parser OFF'-I");
  384.                         return;
  385.         }
  386. }
  387.  
  388. void StopLoading()
  389. {
  390.         if (http.transfer)
  391.         {
  392.                 EAX = http.transfer;
  393.                 EAX = EAX.http_msg.content_ptr;         // get pointer to data
  394.                 $push   EAX                                                     // save it on the stack
  395.                 http_free stdcall (http.transfer);      // abort connection
  396.                 $pop    EAX                                                    
  397.                 free(EAX);                                              // free data
  398.                 http.transfer=0;
  399.                 bufsize = 0;
  400.                 bufpointer = free(bufpointer);
  401.         }
  402.         wv_progress_bar.value = 0;
  403.         DrawOmnibox();
  404. }
  405.  
  406. void SetPageDefaults()
  407. {
  408.         strcpy(#header, #version);
  409.         WB1.list.count = WB1.list.first = 0;
  410.         cur_encoding = CH_NULL;
  411.         if (o_bufpointer) o_bufpointer = free(o_bufpointer);
  412. }
  413.  
  414. void ReplaceSpaceInUrl() {
  415.         int i;
  416.         strcpy(#editURL, #URL);
  417.         while (i = strchr(#URL, ' '))
  418.         {
  419.                 i -= #URL;
  420.                 strlcpy(#URL+i+3, #editURL+i+1, sizeof(URL)-i-4);
  421.                 URL[i] = '%';
  422.                 URL[i+1] = '2';
  423.                 URL[i+2] = '0';
  424.         }
  425.         strcpy(#editURL, #URL);
  426. }
  427.  
  428. void OpenPage()
  429. {
  430.         char getUrl[sizeof(URL)];
  431.         StopLoading();
  432.         souce_mode = false;
  433.         strcpy(#editURL, #URL);
  434.         history.add(#URL);
  435.         if (!strncmp(#URL,"WebView:",8))
  436.         {
  437.                 SetPageDefaults();
  438.                 if (!strcmp(#URL, URL_SERVICE_HOMEPAGE)) WB1.LoadInternalPage(#homepage, sizeof(homepage));
  439.                 else if (!strcmp(#URL, URL_SERVICE_HELP)) WB1.LoadInternalPage(#help, sizeof(help));
  440.                 else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
  441.                 else {bufsize=0; ShowPage();} //page not found
  442.                 DrawOmnibox();
  443.                 return;
  444.         }
  445.         if (!strncmp(#URL,"http:",5)) || (!strncmp(#URL,"https://",8))
  446.         {
  447.                 ReplaceSpaceInUrl();
  448.                 img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 68, SKIN_Y);
  449.  
  450.                 if (!strncmp(#URL,"http:",5)) {
  451.                         http.get(#URL);
  452.                 }
  453.                 if (!strncmp(#URL,"https://",8)) {
  454.                         sprintf(#getUrl, "http://gate.aspero.pro/?site=%s", #URL);
  455.                         http.get(#getUrl);
  456.                 }
  457.                 //http.get(#URL);
  458.                 if (!http.transfer)
  459.                 {
  460.                         StopLoading();
  461.                         bufsize = 0;
  462.                         bufpointer = free(bufpointer);
  463.                         ShowPage();
  464.                         return;
  465.                 }
  466.         }
  467.         else
  468.         {
  469.                 file_size stdcall (#URL);
  470.                 if (EBX)
  471.                 {
  472.                         bufsize = EBX;
  473.                         free(bufpointer);
  474.                         bufpointer = malloc(bufsize);
  475.                         SetPageDefaults();
  476.                         ReadFile(0, bufsize, bufpointer, #URL);
  477.                 }
  478.                 ShowPage();
  479.         }
  480. }
  481.  
  482. void ProcessAnchor()
  483. {
  484.         char anchor[256];
  485.         int anchor_pos;
  486.        
  487.         anchor_pos = strrchr(#URL, '#')-1;
  488.         strlcpy(#anchor, #URL+anchor_pos, sizeof(anchor));
  489.         URL[anchor_pos] = 0x00;
  490.  
  491.         //#1
  492.         if (URL[0] == NULL)
  493.         {
  494.                 if (anchor[1] == NULL) {
  495.                         WB1.list.first = 0;
  496.                 }
  497.                 else {
  498.                         if (anchors.get_anchor_pos(#anchor+1)!=-1) WB1.list.first = anchors.get_anchor_pos(#anchor+1);
  499.                 }
  500.                 strcpy(#URL, history.current());
  501.         }
  502.         //liner.ru#1
  503.         else
  504.         {
  505.                 GetAbsoluteURL(#URL);
  506.                 OpenPage();
  507.                 if (anchors.get_anchor_pos(#anchor+1)!=-1) WB1.list.first = anchors.get_anchor_pos(#anchor+1);
  508.         }
  509.  
  510.         WB1.DrawPage();
  511.         strcpy(#editURL, #URL);
  512.         strcat(#editURL, #anchor);
  513.         DrawOmnibox();
  514. }
  515.  
  516. void EventSubmitOmnibox()
  517. {
  518.         if (!editURL[0]) return;
  519.         if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/')
  520.         || (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8))
  521.         {
  522.                 strcpy(#URL, #editURL);
  523.         }
  524.         else
  525.         {
  526.                 strlcpy(#URL,"http://",7);
  527.                 strcat(#URL, #editURL);
  528.         }
  529.         ProcessLink();
  530. }
  531.  
  532. void EventClickLink()
  533. {
  534.         strcpy(#URL, PageLinks.GetURL(PageLinks.active));
  535.         GetAbsoluteURL(#URL);
  536.         ProcessLink();
  537. }
  538.  
  539. void ProcessLink()
  540. {
  541.         if (http.transfer > 0)
  542.         {
  543.                 StopLoading();
  544.                 history.back();
  545.         }
  546.        
  547.         if (strrchr(#URL, '#')!=0) {
  548.                 ProcessAnchor();
  549.                 return;
  550.         }
  551.  
  552.         if (!strncmp(#URL,"mailto:", 7)) || (!strncmp(#URL,"tel:", 4))
  553.         {
  554.                 notify(#URL);
  555.                 strcpy(#editURL, history.current());
  556.                 strcpy(#URL, history.current());
  557.                 return;
  558.         }
  559.  
  560.         if (!strncmp(#URL,"WebView:",8)) {
  561.                 OpenPage();
  562.                 return;
  563.         }
  564.  
  565.         if (strncmp(#URL,"http://",7)!=0) && (strncmp(#URL,"https://",8)!=0)
  566.         {
  567.                 if (UrlExtIs(".htm")!=true) && (UrlExtIs(".html")!=true)
  568.                 {      
  569.                         if (strchr(#URL, '|')) {
  570.                                 ESBYTE[strchr(#URL, '|')] = NULL;
  571.                                 RunProgram(#URL, strlen(#URL)+1+#URL);
  572.                         }
  573.                         else {
  574.                                 RunProgram("/sys/@open", #URL);
  575.                         }
  576.                         strcpy(#editURL, history.current());
  577.                         strcpy(#URL, history.current());
  578.                         return;
  579.                 }
  580.         }
  581.         else   
  582.         {
  583.                 if (UrlExtIs(".png")==true) || (UrlExtIs(".gif")==true) || (UrlExtIs(".jpg")==true)
  584.                 || (UrlExtIs(".zip")==true) || (UrlExtIs(".kex")==true) || (UrlExtIs(".pdf")==true)
  585.                 || (UrlExtIs(".7z")==true) {
  586.                         if (!downloader_opened) {
  587.                                 strcpy(#downloader_edit, #URL);
  588.                                 CreateThread(#Downloader,#downloader_stak+4092);
  589.                                 strcpy(#editURL, history.current());
  590.                                 strcpy(#URL, history.current());
  591.                         }
  592.                         else notify("'WebView\nPlease, start a new download only when previous ended.'Et");
  593.                         return;
  594.                 }
  595.         }
  596.         if (open_in_a_new_window)
  597.         {
  598.                 RunProgram(#program_path, #URL);
  599.                 strcpy(#editURL, history.current());
  600.                 strcpy(#URL, history.current());
  601.         }
  602.         else
  603.         {
  604.                 OpenPage();
  605.         }
  606.         open_in_a_new_window = false;
  607. }
  608.  
  609. void DrawOmnibox()
  610. {
  611.         int skin_x_offset;
  612.         DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color);
  613.         DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color);
  614.         //address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL);
  615.         //address_box.offset = 0;
  616.         EditBox_UpdateText(#address_box, address_box.flags);
  617.         edit_box_draw stdcall(#address_box);
  618.         if (http.transfer > 0) skin_x_offset = 68; else skin_x_offset = 51;
  619.         img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y);
  620. }
  621.  
  622.  
  623. void ShowPage()
  624. {
  625.         DrawOmnibox();
  626.         if (!bufsize)
  627.         {
  628.                 if (http.transfer) WB1.LoadInternalPage(#loading, sizeof(loading));
  629.                 else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
  630.         }
  631.         else
  632.         {
  633.                 WB1.Prepare();
  634.         }
  635. }
  636.  
  637. byte UrlExtIs(dword ext)
  638. {
  639.         if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true;
  640.         return false;
  641. }
  642.  
  643. void DrawProgress()
  644. {
  645.         dword persent;
  646.         if (http.transfer == 0) return;
  647.         if (wv_progress_bar.max) persent = wv_progress_bar.value*100/wv_progress_bar.max; else persent = 10;
  648.         DrawBar(address_box.left-2, address_box.top+20, persent*address_box.width/100, 2, wv_progress_bar.progress_color);
  649. }
  650.  
  651. void EventShowPageMenu(dword _left, _top)
  652. {
  653.         menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #rmb_menu, VIEW_SOURCE);
  654. }
  655.  
  656. void EventShowLinkMenu(dword _left, _top)
  657. {
  658.         menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #link_menu, COPY_LINK_URL);
  659. }
  660.  
  661. void EventUpdateProgressBar()
  662. {
  663.         wv_progress_bar.max = http.content_length;
  664.         if (wv_progress_bar.value != http.content_received)
  665.         {
  666.                 wv_progress_bar.value = http.content_received; 
  667.                 DrawProgress();
  668.         }
  669. }
  670.  
  671. void EventSeachWeb()
  672. {
  673.         sprintf(#URL, "https://www.google.com/search?q=%s", #editURL);
  674.         ProcessLink();
  675. }
  676.  
  677. void DrawStatusBar(dword _status_text)
  678. {
  679.         status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10;
  680.         status_text.start_y = Form.cheight - STATUSBAR_H + 3;
  681.         status_text.area_size_x = Form.cwidth - status_text.start_x -3;
  682.         DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
  683.         status_text.text_pointer = _status_text;
  684.         PathShow_prepare stdcall(#status_text);
  685.         PathShow_draw stdcall(#status_text);
  686. }
  687.  
  688. stop: