diff --git a/programs/cmm/TWB/TWB.c b/programs/cmm/TWB/TWB.c index 2f35c28934..f9512ba86f 100644 --- a/programs/cmm/TWB/TWB.c +++ b/programs/cmm/TWB/TWB.c @@ -260,7 +260,8 @@ void TWebBrowser::ParseHtml(){ DrawStyle(); NewLine(); list.count = draw_y; - DrawPage(); + list.CheckDoesValuesOkey(); + anchors.current = NULL; } //============================================================================================ bool TWebBrowser::CheckForLineBreak() @@ -292,6 +293,14 @@ void TWebBrowser::SetStyle() { dword value; + if (value = tag.get_value_of("name=")) || (value = tag.get_value_of("id=")) { + anchors.add(value, draw_y); + if (anchors.current) && (streq(value, #anchors.current+1)) { + list.first = draw_y; + anchors.current = NULL; + } + } + if (tag.is("html")) { t_html = tag.opened; return; @@ -311,9 +320,6 @@ void TWebBrowser::SetStyle() { if (!tag.opened) strcat(#line, "\" "); return; } - if (value = tag.get_value_of("name=")) || (value = tag.get_value_of("id=")) { - anchors.add(value, draw_y); - } if (tag.is("body")) { t_body = tag.opened; if (value = tag.get_value_of("link=")) link_color_inactive = GetColor(value); diff --git a/programs/cmm/TWB/absolute_url.h b/programs/cmm/TWB/absolute_url.h index 6dbf7e0216..9115f9c0ac 100644 --- a/programs/cmm/TWB/absolute_url.h +++ b/programs/cmm/TWB/absolute_url.h @@ -1,23 +1,23 @@ -void GetAbsoluteURL(dword in_URL) +dword GetAbsoluteURL(dword in_URL) { int i; dword orig_URL = in_URL; - char newurl[URL_SIZE]; + char newurl[URL_SIZE+1]; while (i=strstr(in_URL, "&")) { strcpy(i+1, i+5); } - if (check_is_the_url_absolute(in_URL)) return; + if (check_is_the_url_absolute(in_URL)) return orig_URL; IF (!strncmp(in_URL,"//", 2)) { strcpy(#newurl, "http:"); strcat(#newurl, in_URL); strcpy(orig_URL, #newurl); - return; + return orig_URL; } IF (!strncmp(in_URL,"./", 2)) in_URL+=2; @@ -55,5 +55,6 @@ void GetAbsoluteURL(dword in_URL) strcat(#newurl, in_URL); strcpy(orig_URL, #newurl); + return orig_URL; } diff --git a/programs/cmm/TWB/anchors.h b/programs/cmm/TWB/anchors.h index 98f5972be1..df88b3fbbb 100644 --- a/programs/cmm/TWB/anchors.h +++ b/programs/cmm/TWB/anchors.h @@ -1,10 +1,12 @@ struct _anchors { + char current[256]; collection anchor_name; collection anchor_position; void add(); int get_pos_by_name(); void clear(); + void take_anchor_from(); } anchors; void _anchors::add(dword _name, _pos) @@ -30,3 +32,12 @@ void _anchors::clear() anchor_position.drop(); } +void _anchors::take_anchor_from(dword _URL) +{ + int anchor_pos; + if (!current) && (_URL) && (anchor_pos = strrchr(_URL, '#')) { + strncpy(#current, _URL+anchor_pos-1, sizeof(_anchors.current)-1); + ESBYTE[_URL+anchor_pos-1] = EOS; + } +} + diff --git a/programs/cmm/TWB/links.h b/programs/cmm/TWB/links.h index 0d310983ff..5a6ee590f6 100644 --- a/programs/cmm/TWB/links.h +++ b/programs/cmm/TWB/links.h @@ -58,8 +58,7 @@ void LinksArray::Clear() CursorPointer.Restore(); } -char temp[URL_SIZE]; -PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, #temp, 0}; +PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, NULL, 0}; bool LinksArray::HoverAndProceed(dword mx, my) { @@ -77,13 +76,12 @@ bool LinksArray::HoverAndProceed(dword mx, my) return false; } if (mouse.mkm) && (mouse.up) { - open_in_a_new_window = true; - EventClickLink(); + RunProgram(#program_path, PageLinks.GetURL(PageLinks.active)); return false; } if (mouse.lkm) && (mouse.up) { CursorPointer.Restore(); - EventClickLink(); + EventClickLink(PageLinks.GetURL(PageLinks.active)); return false; } if (mouse.pkm) && (mouse.up) { diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index 6a867fdf45..95b60abc7e 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -7,7 +7,7 @@ #endif //libraries -#define MEMSIZE 1024 * 800 +#define MEMSIZE 1024 * 850 #include "..\lib\gui.h" #include "..\lib\draw_buf.h" #include "..\lib\list_box.h" @@ -29,9 +29,7 @@ #include "..\lib\patterns\simple_open_dialog.h" #ifdef LANG_RUS -char version[]="Текстовый браузер 2.0 beta1"; -#define T_LOADING "Загрузка страницы..." -#define T_RENDERING "Рендеринг..." +char version[]="Текстовый браузер 2.0 beta2"; char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0"; char homepage[] = FROM "html\\homepage_ru.htm""\0"; char help[] = FROM "html\\help_ru.htm""\0"; @@ -45,9 +43,7 @@ char link_menu[] = "Копировать ссылку Скачать содержимое ссылки"; #else -char version[]="Text-based Browser 2.0 beta1"; -#define T_LOADING "Loading..." -#define T_RENDERING "Rendering..." +char version[]="Text-based Browser 2.0 beta2"; char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; char homepage[] = FROM "html\\homepage_en.htm""\0"; char help[] = FROM "html\\help_en.htm""\0"; @@ -66,10 +62,9 @@ Download link contents"; dword col_bg = 0xE3E2E2; dword panel_color = 0xE3E2E2; -dword border_color = 0x8C8C8C; +dword border_color = 0x787878; bool debug_mode = false; -bool open_in_a_new_window = false; _http http = {0, 0, 0, 0, 0, 0, 0}; @@ -82,6 +77,7 @@ _http http = {0, 0, 0, 0, 0, 0, 0}; #define URL_SERVICE_HOMEPAGE "WebView:home" #define URL_SERVICE_HELP "WebView:help" +#define TOOLBAR_GAPS 10 dword TOOLBAR_H = 40; dword STATUSBAR_H = 15; @@ -110,9 +106,9 @@ enum { char default_dir[] = "/rd/1"; od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" }; -char URL[URL_SIZE]; -char editURL[URL_SIZE]; -edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,URL_SIZE-2,#editURL,0,NULL,19,19}; +char editURL[URL_SIZE+1]; +edit_box address_box = {NULL,TOOLBAR_GAPS+TOOLBAR_GAPS+51,10,0xffffff,0x94AECE,0xffffff, + 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,NULL,19,19}; #define SKIN_Y 24 @@ -136,12 +132,12 @@ void HandleParam() ExitProcess(); } else if (!strncmp(#param, "-s ", 3)) { source_mode = true; - strcpy(#URL, #param + 3); + history.add(#param + 3); } else { - strcpy(#URL, #param); + history.add(#param); } } else { - strcpy(#URL, URL_SERVICE_HOMEPAGE); + history.add(URL_SERVICE_HOMEPAGE); } } @@ -163,7 +159,7 @@ void main() edit_box_mouse stdcall (#address_box); mouse.get(); if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y)) - && (bufsize) && (mouse.pkm) && (mouse.up) { + && (mouse.pkm) && (mouse.up) { if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu(mouse.x, mouse.y); break; } @@ -225,7 +221,8 @@ void main() ProcessEvent(menu.cur_y); menu.cur_y = 0; } - DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0); + DefineAndDrawWindow(GetScreenWidth()-800/2-random(80), + GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0); GetProcessInfo(#Form, SelfInfo); system.color.get(); col_bg = system.color.work; @@ -239,7 +236,6 @@ void main() if (http.transfer > 0) { http.receive(); EventUpdateProgressBar(); - DrawStatusBar(T_LOADING); if (http.receive_result == 0) { // Handle redirects if (http.status_code >= 300) && (http.status_code < 400) @@ -257,23 +253,14 @@ void main() GetAbsoluteURL(#http.redirect_url); debug("Redirect: "); debugln(#http.redirect_url); history.back(); - strcpy(#URL, #http.redirect_url); - strcpy(#editURL, #URL); - DrawOmnibox(); - OpenPage(); - //ProcessLink(history.current()); + OpenPage(#http.redirect_url); } break; } redirect_count = 0; // Loading the page is complete, free resources - history.add(#URL); - bufpointer = http.content_pointer; - bufsize = http.content_received; http.free(); - DrawStatusBar(T_RENDERING); - ShowPage(); - DrawStatusBar(NULL); + LoadInternalPage(http.content_pointer, http.content_received); } } } @@ -283,7 +270,7 @@ void SetElementSizes() { address_box.top = TOOLBAR_H/2-10; basic_line_h = calc(WB1.list.font_h * 130) / 100; - address_box.width = Form.cwidth - address_box.left - 50; + address_box.width = Form.cwidth - address_box.left - 55; WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, Form.cheight - TOOLBAR_H - STATUSBAR_H, basic_line_h); WB1.list.wheel_size = 7 * basic_line_h; @@ -291,7 +278,7 @@ void SetElementSizes() WB1.list.visible = WB1.list.h; if (WB1.list.w!=WB1.DrawBuf.bufw) { WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 800*20); - ProcessEvent(REFRESH_BUTTON); + OpenPage(history.current()); } } @@ -303,24 +290,24 @@ void draw_window() DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3); DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color); SetElementSizes(); - DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+5, 25,border_color); - DefineButton(address_box.left-52, address_box.top-2, 24, skin.h-2, BACK_BUTTON+BT_HIDE, 0); - DefineButton(address_box.left-27, address_box.top-2, 24, skin.h-2, FORWARD_BUTTON+BT_HIDE, 0); - img_draw stdcall(skin.image, address_box.left-53, address_box.top-3, 51, skin.h, 0, SKIN_Y); - DefineButton(address_box.left+address_box.width+1, address_box.top-3, 16, skin.h-1, REFRESH_BUTTON+BT_HIDE+BT_NOFRAME, 0); - DefineButton(Form.cwidth-27, address_box.top-3, 23, skin.h-1, SANDWICH_BUTTON+BT_HIDE, 0); - img_draw stdcall(skin.image, Form.cwidth-24, address_box.top-3, 17, skin.h, 102, SKIN_Y); + DefineHiddenButton(TOOLBAR_GAPS, address_box.top-2, 24, skin.h-2, BACK_BUTTON); + DefineHiddenButton(TOOLBAR_GAPS+25, address_box.top-2, 24, skin.h-2, FORWARD_BUTTON); + img_draw stdcall(skin.image, TOOLBAR_GAPS-1, address_box.top-3, 51, skin.h, 0, SKIN_Y); + DefineHiddenButton(address_box.left+address_box.width-4, address_box.top-2, 20, skin.h-3, REFRESH_BUTTON); + DefineHiddenButton(Form.cwidth-31, address_box.top-3, 24, skin.h-1, SANDWICH_BUTTON); + img_draw stdcall(skin.image, Form.cwidth-27, address_box.top+1, 17, 18, 51, SKIN_Y); DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); if (!header) { - OpenPage(); + OpenPage(history.current()); WB1.DrawScroller(); } else { WB1.DrawPage(); DrawOmnibox(); } - DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); + DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, + scroll_wv.size_y-1, scroll_wv.bckg_col); DrawProgress(); } @@ -335,14 +322,12 @@ void ProcessEvent(dword id__) case SCAN_CODE_BS: case BACK_BUTTON: if (history.back()) { - strcpy(#URL, history.current()); - OpenPage(); + OpenPage(history.current()); } return; case FORWARD_BUTTON: if (history.forward()) { - strcpy(#URL, history.current()); - OpenPage(); + OpenPage(history.current()); } return; case GOTOURL_BUTTON: @@ -350,12 +335,12 @@ void ProcessEvent(dword id__) EventSubmitOmnibox(); return; case REFRESH_BUTTON: - if (http.transfer > 0) - { + if (http.transfer > 0) { StopLoading(); draw_window(); + } else { + OpenPage(history.current()); } - else OpenPage(); return; case SANDWICH_BUTTON: EventShowPageMenu(Form.cwidth - 215, TOOLBAR_H-6); @@ -364,16 +349,15 @@ void ProcessEvent(dword id__) EventViewSource(); break; case EDIT_SOURCE: - if (check_is_the_adress_local(#URL)) { - RunProgram("/rd/1/tinypad", #URL); + if (check_is_the_adress_local(history.current())) { + RunProgram("/rd/1/tinypad", history.current()); } else { CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm"); if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); } return; case VIEW_HISTORY: - strcpy(#URL, URL_SERVICE_HISTORY); - OpenPage(); + OpenPage(URL_SERVICE_HISTORY); return; case DOWNLOAD_MANAGER: if (!downloader_opened) { @@ -410,235 +394,220 @@ void StopLoading() $pop EAX free(EAX); // free data http.transfer=0; - bufsize = 0; - bufpointer = free(bufpointer); pause(10); } wv_progress_bar.value = 0; DrawOmnibox(); } +/* void ReplaceSpaceInUrl() { int i; - strcpy(#editURL, #URL); - while (i = strchr(#URL, ' ')) + char new_url[URL_SIZE]; + strcpy(#new_url, history.current()); + while (i = strchr(#new_url, ' ')) { - i -= #URL; - strlcpy(#URL+i+3, #editURL+i+1, sizeof(URL)-i-4); + i -= #new_url; + strlcpy(#new_url+i+3, #new_url+i+1, URL_SIZE); URL[i] = '%'; URL[i+1] = '2'; URL[i+2] = '0'; } - strcpy(#editURL, #URL); + strcpy(#editURL, #new_url); } -void OpenPage() +//bool strrpl(dword dst, from, to, dst_len); !!!!!!!! + +*/ + +bool GetLocalFileData(dword _path) { - char getUrl[sizeof(URL)]; + dword data, size; + file_size stdcall (_path); + if (!EBX) { + return false; + } else { + size = EBX; + data = malloc(size); + ReadFile(0, size, data, _path); + LoadInternalPage(data, size); + free(data); + return true; + } +} + +void OpenPage(dword _open_URL) +{ + char new_url[URL_SIZE+1]; + StopLoading(); - strcpy(#editURL, #URL); - history.add(#URL); - if (!strncmp(#URL,"WebView:",8)) - { - if (!strcmp(#URL, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#homepage, sizeof(homepage)); - else if (!strcmp(#URL, URL_SERVICE_HELP)) LoadInternalPage(#help, sizeof(help)); - else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory(); - else {bufsize=0; ShowPage();} //page not found + + strcpy(#editURL, _open_URL); + DrawOmnibox(); + + strncpy(#new_url, _open_URL, URL_SIZE); + + //Exclude # from the URL to the load page + //We will bring it back when we get the buffer + if (strrchr(#new_url, '#')) anchors.take_anchor_from(#new_url); + + history.add(#new_url); + + if (!strncmp(#new_url,"WebView:",8)) { + //INTERNAL PAGE + if (!strcmp(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#homepage, sizeof(homepage)); + else if (!strcmp(#new_url, URL_SERVICE_HELP)) LoadInternalPage(#help, sizeof(help)); + else if (!strcmp(#new_url, URL_SERVICE_HISTORY)) ShowHistory(); + else LoadInternalPage(#page_not_found, sizeof(page_not_found)); + } else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) { + //WEB PAGE + //ReplaceSpaceInUrl(); !!!!!!!! + img_draw stdcall(skin.image, address_box.left+address_box.width+1, + address_box.top-3, 17, skin.h, 85, SKIN_Y); + + if (!strncmp(#new_url,"http:",5)) { + http.get(#new_url); + } else if (!strncmp(#new_url,"https://",8)) { + strcpy(#new_url, "http://gate.aspero.pro/?site="); + strncat(#new_url, _open_URL, URL_SIZE); + http.get(#new_url); + } + if (!http.transfer) { + StopLoading(); + LoadInternalPage(#page_not_found, sizeof(page_not_found)); + } + } else { + //LOCAL PAGE + if (!GetLocalFileData(#new_url)) { + LoadInternalPage(#page_not_found, sizeof(page_not_found)); + } + } +} + +void EventClickLink(dword _click_URL) +{ + char new_url[URL_SIZE]; + + if (ESBYTE[_click_URL]=='#') { + if (anchors.get_pos_by_name(_click_URL+1)!=-1) { + WB1.list.first = anchors.get_pos_by_name(_click_URL+1); + WB1.list.CheckDoesValuesOkey(); + } + strcpy(#editURL, history.current()); + strcat(#editURL, _click_URL); DrawOmnibox(); + WB1.DrawPage(); return; } - if (!strncmp(#URL,"http:",5)) || (!strncmp(#URL,"https://",8)) - { - ReplaceSpaceInUrl(); - img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 68, SKIN_Y); - if (!strncmp(#URL,"http:",5)) { - http.get(#URL); - } else if (!strncmp(#URL,"https://",8)) { - sprintf(#getUrl, "http://gate.aspero.pro/?site=%s", #URL); - http.get(#getUrl); - } - - if (!http.transfer) - { - StopLoading(); - bufsize = 0; - bufpointer = free(bufpointer); - ShowPage(); - return; - } - } - else - { - file_size stdcall (#URL); - if (EBX) { - bufsize = EBX; - free(bufpointer); - bufpointer = malloc(bufsize); - ReadFile(0, bufsize, bufpointer, #URL); - } else { - bufsize = bufpointer = 0; - } - ShowPage(); - } -} - -void ProcessAnchor() -{ - char anchor[256]; - dword anchor_pos; - - anchor_pos = strrchr(#URL, '#')-1; - strlcpy(#anchor, #URL+anchor_pos, sizeof(anchor)-1); - URL[anchor_pos] = 0x00; - - if (URL[0] == NULL) { - //case when URL consists of anchor only - if (anchors.get_pos_by_name(#anchor+1)!=-1) WB1.list.first = anchors.get_pos_by_name(#anchor+1); - strcpy(#URL, history.current()); - } else { - GetAbsoluteURL(#URL); - OpenPage(); - if (anchors.get_pos_by_name(#anchor+1)!=-1) WB1.list.first = anchors.get_pos_by_name(#anchor+1); + if (!strncmp(_click_URL,"mailto:", 7)) || (!strncmp(_click_URL,"tel:", 4)) { + notify(_click_URL); + return; } - WB1.DrawPage(); - strcpy(#editURL, #URL); - strcat(#editURL, #anchor); - DrawOmnibox(); -} - -void EventSubmitOmnibox() -{ - if (!editURL[0]) return; - if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') - || (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) - { - strcpy(#URL, #editURL); - } - else - { - strlcpy(#URL,"http://",7); - strcat(#URL, #editURL); - } - OpenPage(); -} - -void EventClickLink() -{ - strcpy(#URL, PageLinks.GetURL(PageLinks.active)); - GetAbsoluteURL(#URL); - ProcessLink(); -} - -void ProcessLink() -{ - if (http.transfer > 0) - { + if (http.transfer > 0) { StopLoading(); history.back(); } - - if (strrchr(#URL, '#')!=0) { - ProcessAnchor(); + + strcpy(#new_url, _click_URL); + GetAbsoluteURL(#new_url); + + if (strrchr(#new_url, '#')!=0) { + anchors.take_anchor_from(#new_url); + OpenPage(#new_url); return; } - if (!strncmp(#URL,"mailto:", 7)) || (!strncmp(#URL,"tel:", 4)) + if (!strncmp(#new_url,"WebView:",8)) { + OpenPage(#new_url); + return; + } + + if (strncmp(#new_url,"http://",7)!=0) && (strncmp(#new_url,"https://",8)!=0) { - notify(#URL); - strcpy(#editURL, history.current()); - strcpy(#URL, history.current()); - return; - } - - if (!strncmp(#URL,"WebView:",8)) { - OpenPage(); - return; - } - - if (strncmp(#URL,"http://",7)!=0) && (strncmp(#URL,"https://",8)!=0) - { - if (UrlExtIs(".htm")!=true) && (UrlExtIs(".html")!=true) + if (UrlExtIs(#new_url,".htm")!=true) && (UrlExtIs(#new_url,".html")!=true) { - if (strchr(#URL, '|')) { - ESBYTE[strchr(#URL, '|')] = NULL; - RunProgram(#URL, strlen(#URL)+1+#URL); + if (strchr(#new_url, '|')) { + ESBYTE[strchr(#new_url, '|')] = NULL; + RunProgram(#new_url, strlen(#new_url)+1+#new_url); + } else { + RunProgram("/sys/@open", #new_url); } - else { - RunProgram("/sys/@open", #URL); - } - strcpy(#editURL, history.current()); - strcpy(#URL, history.current()); return; } - } - else - { - if (UrlExtIs(".png")==true) || (UrlExtIs(".gif")==true) || (UrlExtIs(".jpg")==true) - || (UrlExtIs(".zip")==true) || (UrlExtIs(".kex")==true) || (UrlExtIs(".pdf")==true) - || (UrlExtIs(".7z")==true) { + } else { + if (UrlExtIs(#new_url,".png")==true) || (UrlExtIs(#new_url,".jpg")==true) + || (UrlExtIs(#new_url,".zip")==true) || (UrlExtIs(#new_url,".kex")==true) || (UrlExtIs(#new_url,".pdf")==true) + || (UrlExtIs(#new_url,".7z")==true) { if (!downloader_opened) { - strcpy(#downloader_edit, #URL); + strcpy(#downloader_edit, #new_url); CreateThread(#Downloader,#downloader_stak+4092); - strcpy(#editURL, history.current()); - strcpy(#URL, history.current()); } else notify("'WebView\nPlease, start a new download only when previous ended.'Et"); return; } } - if (open_in_a_new_window) - { - RunProgram(#program_path, #URL); - strcpy(#editURL, history.current()); - strcpy(#URL, history.current()); + OpenPage(#new_url); +} + +void EventSubmitOmnibox() +{ + char new_url[URL_SIZE+1]; + if (!editURL[0]) return; + if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') + || (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) { + OpenPage(#editURL); + } else { + strcpy(#new_url, "http://"); + strncat(#new_url, #editURL, sizeof(new_url)-1); + OpenPage(#new_url); } - else - { - OpenPage(); - } - open_in_a_new_window = false; } void DrawOmnibox() { int skin_x_offset; - DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color); - DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color); + + DrawRectangle(address_box.left-2, address_box.top-3, address_box.width+5, 25,border_color); + + DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 1,0xD8DCD8); + DrawBar(address_box.left-2, address_box.top-1, address_box.width+3, 1, address_box.color); + img_draw stdcall(skin.image, address_box.left-2, address_box.top-3, 2, skin.h, 102, SKIN_Y); if (address_box.flags & ed_focus) address_box.flags = ed_focus; else address_box.flags = 0; EditBox_UpdateText(#address_box, address_box.flags); edit_box_draw stdcall(#address_box); - if (http.transfer > 0) skin_x_offset = 68; else skin_x_offset = 51; - img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y); + if (http.transfer > 0) skin_x_offset = 85; else skin_x_offset = 68; + img_draw stdcall(skin.image, address_box.left+address_box.width+1, + address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y); } -void LoadInternalPage(dword _bufpos, _in_filesize){ - bufsize = _in_filesize; - if (bufpointer!=_bufpos) free(bufpointer); - bufpointer = malloc(bufsize); - memmov(bufpointer, _bufpos, bufsize); - ShowPage(); -} - -void ShowPage() -{ - WB1.list.first = 0; //scroll page to the top - DrawOmnibox(); - if (!bufsize) || (!bufpointer) { +void LoadInternalPage(dword _bufdata, _in_bufsize){ + if (!_bufdata) || (!_in_bufsize) { LoadInternalPage(#page_not_found, sizeof(page_not_found)); - } - WB1.ParseHtml(); - if (source_mode) { + } else if (source_mode) { source_mode = false; - ShowSource(); - LoadInternalPage(bufpointer, bufsize); + //WB1.ParseHtml(); + ShowSource(_bufdata, _in_bufsize); + } else { + bufsize = _in_bufsize; + if (bufpointer!=_bufdata) free(bufpointer); + bufpointer = malloc(bufsize); + memmov(bufpointer, _bufdata, bufsize); + WB1.list.first = 0; //scroll page to the top + DrawOmnibox(); + if(!strrchr(#editURL, '#')) { + strcat(#editURL, #anchors.current); + DrawOmnibox(); + } + WB1.ParseHtml(); + WB1.DrawPage(); } } -byte UrlExtIs(dword ext) +byte UrlExtIs(dword base, ext) { - if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true; + if (!strcmpi(base + strlen(base) - strlen(ext), ext)) return true; return false; } @@ -646,8 +615,12 @@ void DrawProgress() { dword persent; if (http.transfer == 0) return; - if (wv_progress_bar.max) persent = wv_progress_bar.value*100/wv_progress_bar.max; else persent = 10; - DrawBar(address_box.left-2, address_box.top+20, persent*address_box.width/100, 2, 0x72B7EB); + if (wv_progress_bar.max) { + persent = wv_progress_bar.value*100/wv_progress_bar.max; + } else { + persent = 10; + } + DrawBar(address_box.left-1, address_box.top+20, persent*address_box.width/100, 2, 0x72B7EB); } void EventShowPageMenu(dword _left, _top) @@ -672,25 +645,26 @@ void EventUpdateProgressBar() void EventSeachWeb() { - sprintf(#URL, "https://www.google.com/search?q=%s", #editURL); - replace_char(#URL, ' ', '_', sizeof(URL)); - ProcessLink(); + char new_url[URL_SIZE+1]; + replace_char(#editURL, ' ', '_', URL_SIZE); + strcpy(#new_url, "https://www.google.com/search?q="); + strncat(#new_url, #editURL, URL_SIZE); + OpenPage(#new_url); } void EventOpenDialog() { OpenDialog_start stdcall (#o_dialog); if (o_dialog.status) { - strcpy(#URL, #openfile_path); - OpenPage(); + OpenPage(#openfile_path); } } void EventViewSource() { - char source_view_param[sizeof(URL)+4]; + char source_view_param[URL_SIZE+1]; strcpy(#source_view_param, "-s "); - strcat(#source_view_param, #URL); + strncat(#source_view_param, history.current(), URL_SIZE); RunProgram(#program_path, #source_view_param); } diff --git a/programs/cmm/browser/html/help_en.htm b/programs/cmm/browser/html/help_en.htm index c9cbacf8bb..5869d9b391 100644 --- a/programs/cmm/browser/html/help_en.htm +++ b/programs/cmm/browser/html/help_en.htm @@ -9,6 +9,7 @@ [CTRL + N or CTRL + T] New window [CTRL + R or F5] Refresh the current page +[CTRL + O] Start OpenDialog to open local file [CTRL + U] View a web page's source code [CTRL + H] Open browser history [CTRL + J] Display the file downloader diff --git a/programs/cmm/browser/html/help_ru.htm b/programs/cmm/browser/html/help_ru.htm index 2d228bdbaf..1dc897d80b 100644 --- a/programs/cmm/browser/html/help_ru.htm +++ b/programs/cmm/browser/html/help_ru.htm @@ -6,6 +6,7 @@

Справка WebView

[CTRL + N или CTRL + T] Новое окно [CTRL + R или F5] Перезагрузить страницу +[CTRL + O] Вызвать диалог выбора файла [CTRL + U] Смотреть исходный код страницы [CTRL + H] Смотреть историю посещенных страниц [CTRL + J] Открыть загрузчик файлов diff --git a/programs/cmm/browser/show_src.h b/programs/cmm/browser/show_src.h index e4a643a23c..eef3335255 100644 --- a/programs/cmm/browser/show_src.h +++ b/programs/cmm/browser/show_src.h @@ -1,8 +1,10 @@ +enum { TAG=1, VALUE, TEXT, COMMENT, SCRIPT}; -dword source_buf_start, source_buf_end; -int opened_font=0; +int opened_font_counter=0; int mode; +dword source_buf_end; + void SourceBufAdd(dword _mode, src) { dword font_found_pointer, src_orig = src; @@ -13,37 +15,38 @@ void SourceBufAdd(dword _mode, src) source_buf_end += strlen(source_buf_end); if (font_found_pointer = strstr(src, "")) { - opened_font--; + opened_font_counter--; src = font_found_pointer+2; } src = src_orig; if (font_found_pointer = strstr(src, ""); + while (opened_font_counter) SourceBufAdd(_mode, ""); } -enum { TAG=1, VALUE, TEXT, COMMENT, SCRIPT}; -dword ShowSource() +dword ShowSource(dword _bufdata, _in_bufsize) { dword i, j; bool activate_script_mode = false; + dword source_buf_start; - opened_font=0; - source_buf_start = source_buf_end = malloc(bufsize*5); + opened_font_counter=0; + source_buf_end = malloc(_in_bufsize*5); + source_buf_start = source_buf_end; header[strrchr(#header, '-')-2]=0; SourceBufAdd(TEXT, "Source: "); SourceBufAdd(TEXT, #header); SourceBufAdd(TEXT, "
");
 
-	for (i=bufpointer; i<");
@@ -89,7 +92,6 @@ dword ShowSource()
 			source_buf_end++;
 	}
 	ESBYTE[source_buf_end] = 0;
-	bufsize = source_buf_end - source_buf_start;
-	free(bufpointer);
-	bufpointer = source_buf_start;
+	LoadInternalPage(source_buf_start, _in_bufsize);
+	free(source_buf_start);
 }
diff --git a/programs/cmm/codeview/codeview.c b/programs/cmm/codeview/codeview.c
index ea7266006e..7b2deeb1aa 100644
--- a/programs/cmm/codeview/codeview.c
+++ b/programs/cmm/codeview/codeview.c
@@ -189,7 +189,7 @@ void SetPageDefaults()
 
 void OpenPage()
 {
-	char getUrl[URL_SIZE];
+	char getUrl[URL_SIZE+1];
 	strcpy(#editURL, #URL);
 	history.add(#URL);
 	if (!strncmp(#URL,"CodeView:",8))
@@ -239,6 +239,7 @@ void ShowPage()
 	DrawEditBoxWebView();
 	if (!bufsize) LoadInternalPage(#page_not_found, sizeof(page_not_found));
 	WB1.ParseHtml();
+	WB1.DrawPage();
 }
 
 void DrawStatusBar() {return;};
diff --git a/programs/cmm/lib/draw_buf.h b/programs/cmm/lib/draw_buf.h
index f3ff69eea7..7afea06780 100644
--- a/programs/cmm/lib/draw_buf.h
+++ b/programs/cmm/lib/draw_buf.h
@@ -39,7 +39,6 @@ bool DrawBufer::Init(dword i_bufx, i_bufy, i_bufw, i_bufh)
 	bufh = i_bufh;
 	buf_data = free(buf_data);
 	IncreaseBufSize();
-	//debugval("buf_data",buf_data);
 	if (!buf_data) return false;
 	ESDWORD[buf_data] = bufw;
 	ESDWORD[buf_data+4] = bufh;
diff --git a/programs/cmm/liza/mail_box.c b/programs/cmm/liza/mail_box.c
index 245db5269d..0010ca2564 100644
--- a/programs/cmm/liza/mail_box.c
+++ b/programs/cmm/liza/mail_box.c
@@ -362,7 +362,10 @@ void InitTWB() {
 void DrawLetter() {
 	bufsize = strlen(mdata);
 	bufpointer = mdata;
-	if (bufsize) && (bufpointer) WB1.ParseHtml();
+	if (bufsize) && (bufpointer) {
+		WB1.ParseHtml();
+		WB1.DrawPage();
+	}
 	DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, 0xFFFfff);
 }
 
diff --git a/programs/cmm/txtread/toolbar.png b/programs/cmm/txtread/toolbar.png
index 7f5df16c2d..d8739076d8 100644
Binary files a/programs/cmm/txtread/toolbar.png and b/programs/cmm/txtread/toolbar.png differ