From c23bb9bf230cc7cc4f705196baaeaac05b9be385 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Sun, 23 Mar 2014 17:12:21 +0000 Subject: [PATCH] WebView 1.0 Beta 2: a lot of fixes & small changes git-svn-id: svn://kolibrios.org@4686 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/TWB/TWB.c | 63 +++++-------------------------- programs/cmm/TWB/links.h | 46 +++++++++++++++++++++- programs/cmm/browser/WebView.c | 41 +++++++++++++------- programs/cmm/browser/wv_skin.png | Bin 1317 -> 2104 bytes programs/cmm/lib/figures.h | 9 +---- 5 files changed, 83 insertions(+), 76 deletions(-) diff --git a/programs/cmm/TWB/TWB.c b/programs/cmm/TWB/TWB.c index 1917500bd3..e1ab88544f 100644 --- a/programs/cmm/TWB/TWB.c +++ b/programs/cmm/TWB/TWB.c @@ -1,5 +1,3 @@ -#include "..\TWB\links.h" - dword bufpointer; dword o_bufpointer; dword bufsize; @@ -13,16 +11,13 @@ char header[2048]; struct TWebBrowser { llist list; DrawBufer DrawBuf; - void GetNewUrl(); void Prepare(); void Parse(); void SetTextStyle(); void DrawPage(); void DrawScroller(); void NewLine(); -}; - -TWebBrowser WB1; +} WB1; byte b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab, link, ignor_text, cur_encoding, text_align, t_html, t_body; @@ -51,6 +46,7 @@ char options[4096]; char anchor[256]; #include "..\TWB\history.h" +#include "..\TWB\links.h" #include "..\TWB\colors.h" #include "..\TWB\unicode_tags.h" #include "..\TWB\img_cache.h" @@ -98,48 +94,6 @@ void TWebBrowser::DrawPage() //======================================================================= - -char *ABSOLUTE_LINKS[]={ "http:", "mailto:", "ftp:", "/sys/", "/kolibrios/", "/rd/", "/bd", "/hd", "/cd", "/tmp", "/usbhd", 0}; -void TWebBrowser::GetNewUrl(){ - int i, len; - char newurl[4096]; - - for (i=0; ABSOLUTE_LINKS[i]; i++) - { - len=strlen(ABSOLUTE_LINKS[i]); - if (!strcmpn(#URL, ABSOLUTE_LINKS[i], len)) return; - } - - IF (!strcmpn(#URL,"./", 2)) strcpy(#URL, #URL+2); - strcpy(#newurl, BrowserHistory.CurrentUrl()); - - if (URL[0] == '/') - { - i = strchr(#newurl+8, '/'); - if (i>0) newurl[i+7]=0; - strcpy(#URL, #URL+1); - } - - _CUT_ST_LEVEL_MARK: - - if (newurl[strrchr(#newurl, '/')-2]<>'/') - { - newurl[strrchr(#newurl, '/')] = 0x00; - } - - IF (!strncmp(#URL,"../",3)) - { - strcpy(#URL,#URL+3); - newurl[strrchr(#newurl, '/')-1] = 0x00; - goto _CUT_ST_LEVEL_MARK; - } - - if (newurl[strlen(#newurl)-1]<>'/') strcat(#newurl, "/"); - - strcat(#newurl, #URL); - strcpy(#URL, #newurl); -} - void BufEncode(int set_new_encoding) { int bufpointer_realsize; @@ -213,6 +167,7 @@ void TWebBrowser::Parse(){ case 0x0a: if (pre_text) { + chrcat(#line, ' '); bukva = temp = NULL; goto NEXT_MARK; } @@ -324,12 +279,12 @@ void TWebBrowser::Parse(){ NEXT_MARK: perenos_num = strrchr(#line, ' '); if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max; - strcpy(#temp, #line + perenos_num); //яхЁхэюё яю ёыютрь + strcpy(#temp, #line + perenos_num); line[perenos_num] = 0x00; - if (stroka-1 > list.visible) && (list.first <>0) break 1; //єїюфшь... + if (stroka-1 > list.visible) && (list.first <>0) break 1; DrawPage(); - strcpy(#line, #temp); - NewLine(list.x + 5, stroka * 10 + list.y + 5); //чръЁр°штрхь ёыхфє∙є■ ёЄЁюъє + strcpy(#line, #temp); + NewLine(list.x + 5, stroka * 10 + list.y + 5); } } } @@ -373,7 +328,7 @@ void TWebBrowser::SetTextStyle(int left1, top1) { return; } - if (isTag("script")) || (isTag("style")) || (isTag("binary")) ignor_text = opened; + if (isTag("script")) || (isTag("style")) || (isTag("binary")) || (isTag("select")) ignor_text = opened; if(isTag("title")) { @@ -481,7 +436,7 @@ void TWebBrowser::SetTextStyle(int left1, top1) { NewLine(left1, top1); return; } - if (isTag("div")) || (isTag("header")) || (isTag("footer")) { + if (isTag("div")) || (isTag("header")) || (isTag("article")) || (isTag("footer")) { IF(oldtag[0] <>'h') NewLine(left1, top1); return; } diff --git a/programs/cmm/TWB/links.h b/programs/cmm/TWB/links.h index 0dc6507d15..2bcffe134a 100644 --- a/programs/cmm/TWB/links.h +++ b/programs/cmm/TWB/links.h @@ -23,6 +23,7 @@ struct LinksArray void AddText(); dword GetURL(); void Clear(); + void GetAbsoluteURL(); }; void LinksArray::AddLink(dword new_link, int link_x, link_y) @@ -63,7 +64,7 @@ void LinksArray::Clear() CursorPointer.Restore(); } -char temp[4096]; +char temp[sizeof(URL)]; PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, #temp, 0}; void LinksArray::Hover(dword mx, my, link_col_in, link_col_a, bg_col) @@ -97,5 +98,48 @@ void LinksArray::Hover(dword mx, my, link_col_in, link_col_a, bg_col) } } +char *ABSOLUTE_LINKS[]={ "http:", "mailto:", "ftp:", "/sys/", +"/kolibrios/", "/rd/", "/bd", "/hd", "/cd", "/tmp", "/usbhd", "WebView:", 0}; +void LinksArray::GetAbsoluteURL(dword in_URL){ + int i, len; + dword orig_URL = in_URL; + char newurl[sizeof(URL)]; + + for (i=0; ABSOLUTE_LINKS[i]; i++) + { + len=strlen(ABSOLUTE_LINKS[i]); + if (!strcmpn(in_URL, ABSOLUTE_LINKS[i], len)) return; + } + IF (!strcmpn(in_URL,"./", 2)) in_URL+=2; + strcpy(#newurl, BrowserHistory.CurrentUrl()); + + if (ESBYTE[in_URL] == '/') + { + i = strchr(#newurl+8, '/'); + if (i>0) newurl[i+7]=0; + in_URL+=1; + } + + _CUT_ST_LEVEL_MARK: + + if (newurl[strrchr(#newurl, '/')-2]<>'/') + { + newurl[strrchr(#newurl, '/')] = 0x00; + } + + IF (!strncmp(in_URL,"../",3)) + { + in_URL+=3; + newurl[strrchr(#newurl, '/')-1] = 0x00; + goto _CUT_ST_LEVEL_MARK; + } + + if (newurl[strlen(#newurl)-1]<>'/') strcat(#newurl, "/"); + + strcat(#newurl, in_URL); + strcpy(orig_URL, #newurl); +} + + LinksArray PageLinks; diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index f613b12b1b..95bfa40996 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -29,14 +29,14 @@ char homepage[] = FROM "html\homepage.htm"; #ifdef LANG_RUS - char version[]=" Текстовый браузер 1.0 Beta 1"; + char version[]=" Текстовый браузер 1.0 Beta 2"; ?define IMAGES_CACHE_CLEARED "Кэш картинок очищен" ?define T_LAST_SLIDE "Это последний слайд" char loading[] = "Загрузка страницы...
"; char page_not_found[] = FROM "html\page_not_found_ru.htm"; char accept_language[]= "Accept-Language: ru\n"; #else - char version[]=" Text-based Browser 1.0 Beta 1"; + char version[]=" Text-based Browser 1.0 Beta 2"; ?define IMAGES_CACHE_CLEARED "Images cache cleared" ?define T_LAST_SLIDE "This slide is the last" char loading[] = "Loading...
"; @@ -67,7 +67,7 @@ dword col_bg = 0xE4DFE1; dword panel_color = 0xF1F1F1; dword border_color = 0x9F9F9F; -pb progress_bar = {0, 10, 83, 150, 13, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F}; +pb progress_bar = {0, 10, 83, 150, 12, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F}; #include "..\TWB\TWB.c" #include "menu_rmb.h" @@ -89,19 +89,30 @@ struct skin { int LoadSkin() { skin.image = load_image(abspath("wv_skin.png")); + if (!skin.image) notify("WebView skin file 'wv_skin.png' not found, program will terminate"); skin.w = DSWORD[skin.image+4]; skin.h = DSWORD[skin.image+8]; } +void DrawProgress() +{ + unsigned long btn; + //progressbar_draw stdcall(#progress_bar); + progress_bar.width = progress_bar.left = 0; + if (http_transfer == 0) return; + if (progress_bar.max) btn = address_box.width*progress_bar.value/progress_bar.max; else btn = 30; + DrawBar(address_box.left-1, address_box.top+14, btn, 2, progress_bar.progress_color); +} + void main() { - int key, btn; + unsigned long key, btn; int half_scroll_size; int scroll_used=0, show_menu; mem_Init(); CursorPointer.Load(#CursorFile); - if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();} + if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio"); if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg"); if (load_dll2(libHTTP, #http_lib_init,1)!=0) notify("Error: library doesn't exists - http"); @@ -192,8 +203,11 @@ void main() $push EAX ESI = http_transfer; progress_bar.max = ESI.http_msg.content_length; - progress_bar.value = ESI.http_msg.content_received; - progressbar_draw stdcall(#progress_bar); + if (progress_bar.value != ESI.http_msg.content_received) + { + progress_bar.value = ESI.http_msg.content_received; + DrawProgress(); + } $pop EAX if (EAX == 0) { ESI = http_transfer; @@ -228,13 +242,13 @@ void main() { http_free stdcall (http_transfer); http_transfer=0; - WB1.GetNewUrl(); + PageLinks.GetAbsoluteURL(#URL); strcpy(#editURL, #URL); - BrowserHistory.current--; OpenPage(); } else { + BrowserHistory.AddUrl(); ESI = http_transfer; bufpointer = ESI.http_msg.content_ptr; bufsize = ESI.http_msg.content_received; @@ -274,7 +288,8 @@ void Draw_Window() // } DrawBar(TAB_W,0, Form.cwidth-TAB_W,TAB_H, col_bg); DrawBar(TAB_W-1,TAB_H, Form.cwidth-TAB_W+1,1, border_color); - DrawBar(0,TAB_H+1, Form.cwidth,TOOLBAR_H-TAB_H-2, panel_color); + DrawBar(0,TAB_H+1, Form.cwidth,TOOLBAR_H-TAB_H-3, panel_color); + DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xe9e9e9); DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color); img_draw stdcall(skin.image, TAB_W-13, 0, 30, skin.h, 101, 0); @@ -299,7 +314,7 @@ void Draw_Window() DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); progress_bar.top = Form.cheight - STATUSBAR_H + 4; - progressbar_draw stdcall(#progress_bar); + DrawProgress(); } @@ -478,7 +493,7 @@ void ProcessLinks(int id) URL[strrchr(#URL, '#')-1] = 0x00; } - WB1.GetNewUrl(); + PageLinks.GetAbsoluteURL(#URL); if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg")) { @@ -533,7 +548,6 @@ void OpenPage() { StopLoading(); strcpy(#editURL, #URL); - BrowserHistory.AddUrl(); if (strncmp(#URL,"WebView:",8)==0) return; if (strncmp(#URL,"http:",5)==0) { @@ -551,6 +565,7 @@ void OpenPage() } else { + BrowserHistory.AddUrl(); file_size stdcall (#URL); bufsize = EBX; if (bufsize) diff --git a/programs/cmm/browser/wv_skin.png b/programs/cmm/browser/wv_skin.png index bd474183fb7f66242b97969168891b19d6b0ccb6..90bf50f3fb282e41a459ddad8e745ddcfb8c9e52 100644 GIT binary patch delta 2082 zcmV+-2;KLk3b+uE86^e)004H0B(wkk00DDSM?wIu&K&6g000DMK}|sb0I`n?{9y%= zAs2rK%}GQ-RA@u(nrTc_R}{w&g9sup$R-LRaRG5@&_X3H5gSp7m6BL2E(yzr)}-MJ zv`q+K3f5YU8?{Z0Rby(gm>7d=tXqgIE1$rS7cvB==)#p8{Uj>m^X{K#9wmr z?!EKgxo_tF?>XnbH&*ozY6gkZ(%DXT?%aRjt#^+XFJ6$1jSX*^Mqpr|S-%0UpE6|% zZ;cM8PMxB#&`){Gbh7huc+E8M-L(V-gBv$)q=A6}-eXxZGczeVI-0jE&#`02C^j~h zw@f1=BZD?=+QeJNgX`C>UCUdegQW!Jd@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CG?i&C3?b6*RZw`v6CIFvFAfO+xpYZy`gsRbtHX2=p zqNgKkbp%x1T4Y**P4^5HV$)&&V2(7=Q|MGG=k?>UV;Gg$<^pf?f%3D+#4&_M*PgkbBfO;2-taG<%=r$NTt1cY?1Ep|W%nee0;r?tO-a9&eu`Gs%XW z>u@mHT{bomN;?w%0%`}JF8?uVm%lu9C|$YVxPoH11+P@y00000NkvXXu0mjfwkgAn diff --git a/programs/cmm/lib/figures.h b/programs/cmm/lib/figures.h index 16e826cf1e..1eb3eda733 100644 --- a/programs/cmm/lib/figures.h +++ b/programs/cmm/lib/figures.h @@ -60,7 +60,7 @@ } } -:void DrawProgressBar(dword st_x, st_y, st_w, st_h, col_fon, col_border, col_fill, col_text, progress_percent, status_text) +:void DrawProgressBar(dword st_x, st_y, st_w, st_h, col_fon, col_border, col_fill, col_text, progress_percent) { int progress_w; static int fill_old; @@ -77,13 +77,6 @@ DrawBar(st_x+2, st_y+2, progress_w, st_h-3, col_fill); DrawBar(st_x+2+progress_w, st_y+2, st_w-progress_w-3, st_h-3, 0xFFFfff); } - - if (status_text) - { - DrawBar(st_x+st_w+15, st_h/2-4+st_y, fill_old, 9, col_fon); - WriteText(st_x+st_w+15, st_h/2-4+st_y, 0x80, col_text, status_text); - fill_old = strlen(status_text) * 6; - } } :void DrawLink(dword x,y,font_type,btn_id, inscription)