From 2a73669575ea29380a54035fc41cacd121747d59 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Tue, 3 Jul 2012 17:24:00 +0000 Subject: [PATCH] HTMLv 0.95: fixed bug in utf-decoding, in opening program with params, with images, complete improvements in strings.h (now it C-like library) git-svn-id: svn://kolibrios.org@2844 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/network/htmlv/browser/HTMLv.c | 40 ++-- programs/network/htmlv/browser/TWB.h | 212 +++++++++++------- .../htmlv/browser/include/acid_0.1.htm | 69 +++++- programs/network/htmlv/lib/encoding.h | 49 ++-- programs/network/htmlv/lib/strings.h | 63 +++++- 5 files changed, 295 insertions(+), 138 deletions(-) diff --git a/programs/network/htmlv/browser/HTMLv.c b/programs/network/htmlv/browser/HTMLv.c index 2bb0e2ff8f..65d159aa86 100644 --- a/programs/network/htmlv/browser/HTMLv.c +++ b/programs/network/htmlv/browser/HTMLv.c @@ -20,9 +20,9 @@ #include "img\URLgoto.txt"; -// -char URL[4096], - editURL[4096], +#define URL param + +char editURL[4096], page_links[12000], header[300]; @@ -34,7 +34,12 @@ int mouse_dd; edit_box edit1= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,248,#editURL,#mouse_dd,2,19,19}; scroll_bar scroll1 = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; //details in scroll_lib.h-- + proc_info Form; +#define WIN_W 640 +#define WIN_H 480 + + dword stak[100]; // mouse m; @@ -55,11 +60,14 @@ void main() load_dll2(#abox_lib, #boxlib_init,0); //load_dll2(libtruetype, #truetype,0); - if (param) strcpy(#URL, #param); - else strcpy(#URL, "/sys/index.htm"); + if (!URL) strcpy(#URL, "/sys/index.htm"); strcpy(#editURL, #URL); - lines.column_max = 101; + Form.width=WIN_W; + Form.height=WIN_H; + + SetElementSizes(); + WB1.OpenPage(); SetEventMask(0x27); @@ -161,11 +169,21 @@ void main() } } +void SetElementSizes() +{ + edit1.width=Form.width-266; + WB1.top=44; + WB1.width=Form.width-13; + WB1.height=onTop(43,5); + lines.column_max = WB1.width - 30 / 6; + lines.visible = WB1.height - 3 / 10 - 2; +} + void Draw_Window() { int j; - DefineAndDrawWindow(215,100,640,480,0x73,0x00E4DFE1,0,0,0); + DefineAndDrawWindow(215,100,WIN_W,WIN_H,0x73,0x00E4DFE1,0,0,0); GetProcessInfo(#Form, SelfInfo); if (Form.status_window>2) // , @@ -189,13 +207,7 @@ void Draw_Window() DrawRegion(205,14,onLeft(58,205),18,0x94AECE); // DrawRegion(206,15,onLeft(59,205),16,0xE4ECF3); - edit1.width=Form.width-266; - WB1.top=44; - WB1.width=Form.width-13; - WB1.height=onTop(43,5); - lines.column_max = WB1.width - 30 / 6; - lines.visible = WB1.height - 3 / 10 - 2; - + SetElementSizes(); WB1.ShowPage(); DefineButton(scroll1.start_x+1, scroll1.start_y+1, 16, 16, ID1+BT_HIDE, 0xE4DFE1); diff --git a/programs/network/htmlv/browser/TWB.h b/programs/network/htmlv/browser/TWB.h index 1bee2af788..0a24a9c493 100644 --- a/programs/network/htmlv/browser/TWB.h +++ b/programs/network/htmlv/browser/TWB.h @@ -5,11 +5,10 @@ dword buf, filesize, blink; -int i; char download_path[]="/rd/1/.download"; char search_path[]="http://nigma.ru/index.php?s="; -char version[]=" Text-based Browser 0.94z"; +char version[]=" Text-based Browser 0.95"; struct TWebBrowser { @@ -21,6 +20,7 @@ struct TWebBrowser { void ShowPage(); void ParseHTML(dword); void WhatTextStyle(int left1, top1, width1); + void DrawPage(); void DrawScroller(); }; @@ -48,7 +48,6 @@ char line[500], parametr[1200], options[1000]; - #include "include\history.h" #include "include\colors.h" #include "include\unicode_tags.h" @@ -58,7 +57,7 @@ char line[500], void TWebBrowser::Scan(int id) { - if (id > 399) + if (id >= 400) { GetURLfromPageLinks(id); @@ -247,6 +246,7 @@ void TWebBrowser::OpenPage() KillProcess(downloader_id); strcpy(#editURL, #URL); BrowserHistory.AddUrl(); + strcpy(#header, #version); if (!strcmp(get_URL_part(5),"http:"))) { KillProcess(downloader_id); // @@ -286,20 +286,21 @@ void TWebBrowser::ShowPage() WriteText(left + 10, top + 18, 0x80, 0, "Page not found. May be, URL contains some errors.", 0); if (!strcmp(get_URL_part(5),"http:"))) WriteText(left + 10, top + 32, 0x80, 0, "Or Internet unavilable for your configuration.", 0); } - DrawTitle(#version); //? - return; + //return; } - - ParseHTML(buf); - IF (!strcmp(#version, #header)) DrawTitle(#header); + else + ParseHTML(buf); + + if (!header) strcpy(#header, #version); + if (!strcmp(#version, #header)) DrawTitle(#header); } void TWebBrowser::ParseHTML(dword bword){ - word bukva[1]; + word bukva[2]; int j, perenos_num; - byte ignor_param = 0; + byte ignor_param; char temp[768]; stroka = -lines.first; @@ -314,7 +315,7 @@ void TWebBrowser::ParseHTML(dword bword){ bg_color = 0xFFFFFF; line = ''; strcpy(#page_links,"|"); - strcpy(#header,#version); + strcpy(#header, #version); if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1; if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1; @@ -339,7 +340,7 @@ void TWebBrowser::ParseHTML(dword bword){ tab_len=strlen(#line)/8; tab_len=tab_len*8; tab_len=8+tab_len-strlen(#line); - for (i=0; i, { bword++; - if (ESBYTE[bword] == '-') { - HH_: + if (ESBYTE[bword] == '-') + { + HH_: do { bword++; - if (bword >= buf + filesize) break 1; + if (buf + filesize <= bword) break 2; } while (ESBYTE[bword] <>'-'); @@ -378,19 +381,18 @@ void TWebBrowser::ParseHTML(dword bword){ } bword++; } - lowcase(#tag); - lowcase(#tagparam); + strlwr(#tag); + strlwr(#tagparam); - if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=''; // XHTML- br/ - if (strlen(#tagparam) > 0) && (strlen(#tagparam) < 4000) GetNextParam(); - //while (tagparam) - //{ - // GetNextParam(); - WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); // - //} + if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=''; //for br/ + if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam(); - line = tag = parametr = tagparam = ignor_param = 0; // - + DrawPage(); + line=0; + + if (tag) WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); // + + tag = parametr = tagparam = ignor_param = '\0'; break; case '=': // , 7 if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK; @@ -406,10 +408,10 @@ void TWebBrowser::ParseHTML(dword bword){ if (bukva) goto DEFAULT_MARK; break; - case '&': //   + case '&': //  and so on bword++; - tag=''; - for (j=0; (ESBYTE[bword] <>';') && (j < 7); j++, bword++;) + tag=0; + for (j=0; (ESBYTE[bword]<>';') && (j<7); j++, bword++;) { bukva = ESBYTE[bword]; strcat(#tag, #bukva); @@ -424,14 +426,15 @@ void TWebBrowser::ParseHTML(dword bword){ } } - rez = StrToInt(#tag + 1) - 1040; + rez = atoi(#tag + 1) - 1040; if (tag[1] == '1') && (rez>=0) && (rez<=72) && (strlen(#tag) == 5) - { - bukva = unicode_chars[rez]; - GOTO DEFAULT_MARK; // - } + { + bukva = unicode_chars[rez]; + //GOTO DEFAULT_MARK; // strcat(#line, unicode_tags[j+1]); break 1; + strcat(#line, #bukva); + break; + } - //debug(#tag); // - strcat(#line,#tag); // , - break; default: @@ -445,13 +448,13 @@ void TWebBrowser::ParseHTML(dword bword){ line[perenos_num] = 0x00; NEXT_MARK: if (stroka >= lines.visible) && (lines.first <>0) break 1; //... - WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); // + DrawPage(); TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); // strcpy(#line, #temp); } if (!pre_text) && (bukva == ' ') && (!stolbec) && (!line) break; - strcat(#line, #bukva); - } + if (strlen(#line)sizeof(header)) + { + //line = 123456789 + //header = 1234 + //line = 56789 + debug("too long header"); + strcpy(#temp, #line); + temp[sizeof(header)-strlen(#version)-2]=0; + strcpy(#header, #temp); + strcpy(#line, #line+strlen(#temp)); + } + else + { + debug("normal header"); + strcpy(#header, #line); + line=0; + } + + strcat(#header, " -"); + strcat(#header, #version); + return; + } + + if (stroka >= 0) && (stroka - 2 < lines.visible) && (line) && (!anchor) + { + if (!stroka) && (!stolbec) + { + DrawBar(left, top, width-15, 15, bg_color); // + first_line_drawed=1; + } + + start_x=stolbec * 6 + left+5; + start_y=stroka * 10 + top + 5; + line_length=strlen(#line)*6; + + WriteText(start_x, start_y, 0x80, text_colors[text_color_index], #line, 0); + //line_length = get_length stdcall (#line,-1,16,line_length); + //text_out stdcall (#line, -1, 17, text_colors[text_color_index], start_x, start_y-2); + IF (b_text) { $add ebx, 1<<16 $int 0x40 } + IF (i_text) Skew(start_x, start_y, line_length+6, 10); + IF (s_text) DrawBar(start_x, start_y + 4, line_length, 1, text_colors[text_color_index]); + IF (u_text) DrawBar(start_x, start_y + 8, line_length, 1, text_colors[text_color_index]); + IF (link) { + DefineButton(start_x-2, start_y, line_length + 3, 9, blink + BT_HIDE, 0xB5BFC9); + DrawBar(start_x, start_y + 8, line_length, 1, text_colors[text_color_index]); + } + stolbec += strlen(#line); + } } @@ -478,61 +539,44 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) { dword image; char temp[4096]; - int w, h, img_lines_first, line_length; + int w=0, h=0, img_lines_first=0; // - IF(tag[0] == '/') + if (tag[0] == '/') { rez = 0; strcpy(#tag, #tag+1); } - ELSE + else rez = 1; - - // - IF(!chTag("html")) { + + if (!chTag("html")) { IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (rez==0) ignor_text = 1; ELSE ignor_text = 0; return; } - IF(!chTag("script")) || (!chTag("style")) || (!chTag("binary")) ignor_text = rez; - if(!chTag("title")) && (!rez) + if (!chTag("script")) || (!chTag("style")) || (!chTag("binary")) ignor_text = rez; + + if(!chTag("title")) { - strcpy(#header, #line); - strcat(#header, " -"); - strcat(#header, #version); - if (stroka==0) DrawTitle(#header); + if (rez) + { + header=0; + } + else // - + { + if (stroka==0) DrawTitle(#header); + } return; } - - IF (ignor_text) return; + if (ignor_text) return; + + + + IF(!chTag("q")) strcat(#line, "\""); - - // - if (stroka >= 0) && (stroka - 2 < lines.visible) && (line) && (!anchor) - { - if (stroka==0) && (stolbec==0) - { - DrawBar(left, top, width-15, 15, bg_color); // - first_line_drawed=1; - } - line_length=strlen(#line)*6; - WriteText(stolbec * 6 + left1, top1, 0x80, text_colors[text_color_index], #line, 0); // ? - //line_length = get_length stdcall (#line,-1,16,line_length); - //text_out stdcall (#line, -1, 17, text_colors[text_color_index], stolbec * 6 + left1, top1-2); - IF (b_text) { $add ebx, 1<<16 $int 0x40 } - IF (i_text) Skew(stolbec * 6 + left1, top1, line_length+6, 10); // - IF (s_text) DrawBar(stolbec * 6 + left1, top1 + 4, line_length, 1, text_colors[text_color_index]); // - IF (u_text) DrawBar(stolbec * 6 + left1, top1 + 8, line_length, 1, text_colors[text_color_index]); // - IF (link) { - DefineButton(stolbec * 6 + left1 - 2, top1, line_length + 3, 9, blink + BT_HIDE, 0xB5BFC9); // - DrawBar(stolbec * 6 + left1, top1 + 8, line_length, 1, text_colors[text_color_index]); - } - } - IF(!tag) return; - stolbec += strlen(#line); if (anchor) && (!strcmp(#parametr, "id=")) // !!! , { @@ -541,7 +585,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) { anchor_line_num=lines.first+stroka; } } - + if (!chTag("body")) { BODY_MARK: @@ -595,13 +639,14 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) { GOTO _A_MARK; } } - ELSE { + else { link = 0; IF(text_color_index > 0) text_color_index--; } return; } + if (!chTag("font")) { if (rez) @@ -748,7 +793,8 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) { h=WB1.top+WB1.height-top1-15; } - IF (h<=0) return; + if (h<=0) return; + if (anchor) return; img_draw stdcall (image,left1-5,top1+10,w, h,0,img_lines_first); DrawBar(left1+w - 5, top1 + 10, width1-w + 5, h, bg_color); diff --git a/programs/network/htmlv/browser/include/acid_0.1.htm b/programs/network/htmlv/browser/include/acid_0.1.htm index 604a69ccf5..e5abdac908 100644 --- a/programs/network/htmlv/browser/include/acid_0.1.htm +++ b/programs/network/htmlv/browser/include/acid_0.1.htm @@ -52,16 +52,75 @@ + + +Index.htm
+Kernel.mnt
+index.htm#2.1.4
+#2.1.4
+
+
+ + +
, . . . - : " & < > •   © ® „ “ — . ' .
-

index.htm

-

index.htm#2.1.4

-

#2.1.4

-

- diff --git a/programs/network/htmlv/lib/encoding.h b/programs/network/htmlv/lib/encoding.h index b5e7b2ad19..ed6be5e800 100644 --- a/programs/network/htmlv/lib/encoding.h +++ b/programs/network/htmlv/lib/encoding.h @@ -1,5 +1,5 @@ -void wintodos(dword ESI) +inline fastcall void wintodos( ESI) { while (BL=ESBYTE[ESI]) { @@ -28,7 +28,7 @@ void wintodos(dword ESI) byte mas[66] = "椥娩㦢Ꞁ"; -void koitodos(dword EDI) +inline fastcall void koitodos( EDI) { WHILE (BL=ESBYTE[EDI]) { @@ -42,10 +42,9 @@ void koitodos(dword EDI) } } - //Asper, lev //uncomplete -int utf8rutodos(dword ESI) //- +inline fastcall void utf8rutodos( ESI) { EDI=ESI; while (BL=ESBYTE[ESI]) @@ -79,8 +78,6 @@ int utf8rutodos(dword ESI) //- } } - //0xC2 - else IF (BL == 0xC2) // ? SWITCH(ESBYTE[ESI+1]) { case 0xAB: //" @@ -108,25 +105,27 @@ int utf8rutodos(dword ESI) //- ESI++; BREAK; } - CASE 0xA9: // (c) - { - ESWORD[EDI] = 'c('; -// ESBYTE[EDI] = '('; -// ESBYTE[EDI+1] = 'c'; - ESBYTE[EDI+2] = ')'; - EDI+=2; - ESI++; - BREAK; - } - CASE 0xAE: // (r) - { - ESWORD[EDI] = 'r('; - ESBYTE[EDI+2] = ')'; - EDI+=2; - ESI++; - break; - } - } + CASE 0xA9: // (c) --- _ + { + ESBYTE[EDI] = 'c'; + //ESBYTE[EDI] = '('; + //ESBYTE[EDI+1] = 'c'; + //ESBYTE[EDI+2] = ')'; + //EDI+=2; + ESI++; + BREAK; + } + CASE 0xAE: // (r) + { + ESBYTE[EDI] = 'r'; + //ESBYTE[EDI] = '('; + //ESBYTE[EDI+1] = 'r'; + //ESBYTE[EDI+2] = ')'; + //EDI+=2; + ESI++; + BREAK; + } + } ELSE IF (BL >= 0x90) && (BL <= 0xAF) { diff --git a/programs/network/htmlv/lib/strings.h b/programs/network/htmlv/lib/strings.h index ec00eedbd6..67b93e312d 100644 --- a/programs/network/htmlv/lib/strings.h +++ b/programs/network/htmlv/lib/strings.h @@ -6,11 +6,11 @@ // strchr( ESI,BL) // strrchr( ESI,BL) // strstr( EBX, EDX) -// -// IntToStr( ESI) -// StrToInt() -// upcase( ESI) -// lowcase( ESI) +// itoa( ESI) +// atoi( EAX) +// strupr( ESI) +// strlwr( ESI) +// strtok( ESI) //------------------------------------------------------------------------------ @@ -63,7 +63,7 @@ inline fastcall strcat( EDI, ESI) } char buffer[11]; -inline fastcall dword IntToStr( ESI) +inline fastcall dword itoa( ESI) { $mov edi, #buffer $mov ecx, 10 @@ -91,9 +91,10 @@ f3: } -inline fastcall dword StrToInt() +inline fastcall dword atoi( EDI) { - ESI=EDI=EAX; + //ESI=EDI=EAX; + ESI=EDI; IF(DSBYTE[ESI]=='-')ESI++; EAX=0; BH=AL; @@ -141,7 +142,7 @@ inline fastcall unsigned int strrchr( ESI,BL) } -inline fastcall upcase( ESI) +inline fastcall strupr( ESI) { do{ AL=DSBYTE[ESI]; @@ -150,7 +151,7 @@ inline fastcall upcase( ESI) }while(AL!=0); } -inline fastcall lowcase( ESI) +inline fastcall strlwr( ESI) { do{ $LODSB @@ -200,4 +201,44 @@ ls1: mov esi, edx ls2: xor eax, eax ls3: } -} \ No newline at end of file +} + +/* strtok( LPSTR dest, src, divs); +src - +dest - , +divs - , - +: 0, + 0, dest ( + src ) */ + +dword fastcall strtok( EDX, ESI, EBX) +{ + asm { + XOR ECX, ECX + MOV EDI, EBX + XOR EAX, EAX + DEC ECX + REPNE SCASB + XOR ECX, 0FFFFFFFFH + DEC ECX + PUSH ECX +L1: LODSB + OR AL, AL + JZ L4 + MOV EDI, EBX + MOV ECX, SSDWORD[ ESP] + REPNE SCASB + JZ L1 + DEC ESI +L2: LODSB + MOV EDI, EBX + MOV ECX, SSDWORD[ ESP] + REPNE SCASB + JZ L3 + MOV DSBYTE[ EDX], AL + INC EDX + JMP SHORT L2 +L3: MOV EAX, ESI +L4: POP ECX + } DSBYTE[ EDX] = 0; +}