From c96f15b38ea53ed158b959cab568f833e0e02fec Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Mon, 2 Jul 2012 18:24:48 +0000 Subject: [PATCH] HTMLv 0.94u: fixed bug with colors and crash with tag, improvements in menu and strings.h git-svn-id: svn://kolibrios.org@2839 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/network/htmlv/browser/TWB.h | 71 +++++++------- .../network/htmlv/browser/include/colors.h | 5 +- .../network/htmlv/browser/include/history.h | 1 + .../network/htmlv/browser/include/menu_rmb.h | 36 +++---- .../network/htmlv/browser/include/parce_tag.h | 4 +- .../network/htmlv/browser/include/some_code.h | 14 +-- .../htmlv/browser/include/unicode_tags.h | 14 +-- programs/network/htmlv/lib/kolibri.h | 28 ++++-- programs/network/htmlv/lib/libimg_lib.h | 2 +- programs/network/htmlv/lib/mem.h | 9 +- programs/network/htmlv/lib/scroll_lib.h | 95 +++++++++++++++++++ programs/network/htmlv/lib/strings.h | 28 ++++-- 12 files changed, 209 insertions(+), 98 deletions(-) create mode 100644 programs/network/htmlv/lib/scroll_lib.h diff --git a/programs/network/htmlv/browser/TWB.h b/programs/network/htmlv/browser/TWB.h index b8b0596e7..82b09d5f3 100644 --- a/programs/network/htmlv/browser/TWB.h +++ b/programs/network/htmlv/browser/TWB.h @@ -9,7 +9,7 @@ int i; char download_path[]="/rd/1/.download"; char search_path[]="http://nigma.ru/index.php?s="; -char version[]=" Text-based Browser 0.94e"; +char version[]=" Text-based Browser 0.94u"; struct TWebBrowser { @@ -30,7 +30,7 @@ byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, link, ignor_text, li_tab, first_line_drawed; -dword text_colors[30], +dword text_colors[300], text_color_index, link_color, bg_color; @@ -38,6 +38,9 @@ dword text_colors[30], int stroka, stolbec, tab_len; + +char anchor[256]; +int anchor_line_num; char line[500], tag[100], @@ -45,9 +48,6 @@ char line[500], parametr[1200], options[1000]; -char anchor[256]; -int anchor_line_num; - #include "include\history.h" #include "include\colors.h" @@ -65,7 +65,7 @@ void TWebBrowser::Scan(int id) //#1 if (URL[0] == '#') { - strcpy(#anchor, #URL+find_symbol(#URL, '#')); + strcpy(#anchor, #URL+strrchr(#URL, '#')); strcpy(#URL, BrowserHistory.CurrentUrl()); @@ -74,10 +74,10 @@ void TWebBrowser::Scan(int id) return; } //liner.ru#1 - if (find_symbol(#URL, '#')<>-1) + if (strrchr(#URL, '#')<>-1) { - strcpy(#anchor, #URL+find_symbol(#URL, '#')); - URL[find_symbol(#URL, '#')-1] = 0x00; //чруыє°ър + strcpy(#anchor, #URL+strrchr(#URL, '#')); + URL[strrchr(#URL, '#')-1] = 0x00; //чруыє°ър } GetNewUrl(); @@ -197,15 +197,15 @@ void TWebBrowser::GetNewUrl(){ _CUT_ST_LEVEL_MARK: - if (editURL[find_symbol(#editURL, '/')-2]<>'/') // хёыш эх http://pagename.ua <-- эрїЁхэр ¤Єр ёЄЁюър??? + if (editURL[strrchr(#editURL, '/')-2]<>'/') // хёыш эх http://pagename.ua <-- эрїЁхэр ¤Єр ёЄЁюър??? { - editURL[find_symbol(#editURL, '/')] = 0x00; //юсЁхчрхь х╕ єЁы фю яюёыхфэхую / + editURL[strrchr(#editURL, '/')] = 0x00; //юсЁхчрхь х╕ єЁы фю яюёыхфэхую / } IF (!strcmp(get_URL_part(3),"../")) //эр єЁютхэ№ ттхЁї { strcpy(#URL,#URL+3); - editURL[find_symbol(#editURL, '/')-1] = 0x00; //юсЁхчрхь х╕ єЁы фю яюёыхфэхую / + editURL[strrchr(#editURL, '/')-1] = 0x00; //юсЁхчрхь х╕ єЁы фю яюёыхфэхую / goto _CUT_ST_LEVEL_MARK; } @@ -318,9 +318,7 @@ void TWebBrowser::ParseHTML(dword bword){ if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1; if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1; - #ifdef DEBUG_ON - debug("Start parsing"); - #endif + debug("Start parsing"); for ( ; buf+filesize > bword; bword++;) {//ESBYTE[bword] bukva = ESBYTE[bword]; @@ -438,7 +436,7 @@ void TWebBrowser::ParseHTML(dword bword){ // if (stolbec + strlen(#line) > lines.column_max) { - perenos_num = find_symbol(#line, ' '); + perenos_num = strrchr(#line, ' '); strcpy(#temp, #line + perenos_num); //яхЁхэюё яю ёыютрь line[perenos_num] = 0x00; NEXT_MARK: @@ -465,9 +463,7 @@ void TWebBrowser::ParseHTML(dword bword){ ParseHTML(buf); } - #ifdef DEBUG_ON - debug("End parsing"); - #endif + debug("End parsing"); DrawScroller(); //Ёшёєхь ёъЁюыы } @@ -568,14 +564,16 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) { { if (rez) { + text_color_index++; + text_colors[text_color_index] = text_colors[text_color_index-1]; + _A_MARK: if (!strcmp(#parametr, "href=")) { if (stroka - 1 > lines.visible) || (stroka < -2) return; - if (link == 1) text_color_index--; //хёыш ъръющ-Єю фюысю╕с эх чръЁ√ы Є¤у + if (link) && (text_color_index > 0) text_color_index--; //хёыш эх чръЁ√Є Є¤у link = 1; blink++; - text_color_index++; text_colors[text_color_index] = link_color; strcat(#page_links, #options); strcat(#page_links, "|"); @@ -602,18 +600,23 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) { ///////////////////////// if (!chTag("font")) { - IF (stroka - 1 > lines.visible) return; - COL_MARK: - if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#') + if (rez) { text_color_index++; - text_colors[text_color_index] = GetColor(#options); + text_colors[text_color_index] = text_colors[text_color_index-1]; + + COL_MARK: + if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#') + { + text_colors[text_color_index] = GetColor(#options); + } + IF(tagparam) { + GetNextParam(); + GOTO COL_MARK; + } } - IF(tagparam) { - GetNextParam(); - GOTO COL_MARK; - } - IF(!rez) && (text_color_index > 0) text_color_index--; + else + if (text_color_index > 0) text_color_index--; return; } ////////////////////////// @@ -694,18 +697,18 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) { if (!strcmp(#parametr,"src=")) //эрфю юс·хфшэшЄ№ ё GetNewUrl() { strcpy(#temp, BrowserHistory.CurrentUrl()); //фюёЄр╕ь рфЁхё Єхъє∙хщ ёЄЁрэшЎ√ - temp[find_symbol(#temp, '/')] = 0x00; //юсЁхчрхь х╕ єЁы фю яюёыхфэхую / + temp[strrchr(#temp, '/')] = 0x00; //юсЁхчрхь х╕ єЁы фю яюёыхфэхую / strcat(#temp, #options); image=load_image(#temp); w=DSWORD[image+4]; h=DSWORD[image+8]; } - if (!strcmp(#parametr,"alt=")) + /*if (!strcmp(#parametr,"alt=")) { strcpy(#tag, "[Image: "); strcat(#tag, #options); strcat(#tag, "]"); - } + }*/ IF(tagparam) { @@ -758,7 +761,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) { META: if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding=")) { - strcpy(#options, #options[find_symbol(#options, '=')]); //яюшёъ т content= + strcpy(#options, #options[strrchr(#options, '=')]); //яюшёъ т content= if (!strcmp(#options,"utf-8")) || (!strcmp(#options,"utf8")) ReadHtml(_UTF); if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) ReadHtml(_KOI); diff --git a/programs/network/htmlv/browser/include/colors.h b/programs/network/htmlv/browser/include/colors.h index 10022088b..a9e8dfb7f 100644 --- a/programs/network/htmlv/browser/include/colors.h +++ b/programs/network/htmlv/browser/include/colors.h @@ -317,10 +317,7 @@ dword GetColor(char* color_str) ELSE FOR (ii=0; color_names[ii]!=0; ii++) { - IF(!strcmp(color_str, color_names[ii])) - { - return colors[ii]; - } + IF(!strcmp(color_str, color_names[ii])) return colors[ii]; } return text_colors[0]; } diff --git a/programs/network/htmlv/browser/include/history.h b/programs/network/htmlv/browser/include/history.h index 8e4b6f99a..7b99a8403 100644 --- a/programs/network/htmlv/browser/include/history.h +++ b/programs/network/htmlv/browser/include/history.h @@ -23,6 +23,7 @@ dword UrlsHistory::CurrentUrl() void UrlsHistory::AddUrl() //ЄєЄ эєцхэ ттюфшь√щ ¤ыхьхэЄ - фы  єэштхЁёры№эюёЄш { + int i; if (history_num>0) && (strcmp(#URL,#history_list[history_current].Item)==0) return; if (history_current>=MAX_HISTORY_NUM-1) diff --git a/programs/network/htmlv/browser/include/menu_rmb.h b/programs/network/htmlv/browser/include/menu_rmb.h index f56d47aff..cdd960982 100644 --- a/programs/network/htmlv/browser/include/menu_rmb.h +++ b/programs/network/htmlv/browser/include/menu_rmb.h @@ -4,13 +4,14 @@ #define ITEM_WIDTH 138 char *ITEMS_LIST[]={ -"View in Tinypad F3", -"View in TextEdit F4", -"-", -"KOI-8 Ctrl+K", -"UTF Ctrl+U", +"View in Tinypad F3",52, +"View in TextEdit F4",53, +"-",0, +"KOI-8 Ctrl+K",11, +"UTF Ctrl+U",21, 0}; + proc_info MenuForm; @@ -19,7 +20,7 @@ void menu_rmb() mouse mm; int items_num, items_cur; - int id1, key; + int id1, key, i; SetEventMask(100111b); @@ -43,7 +44,9 @@ void menu_rmb() break; case evButton: - ItemProcess(GetButtonID()); + id1=GetButtonID()-10; + WB1.Scan(ITEMS_LIST[id1*2+1]); + ExitProcess(); break; case evKey: @@ -61,19 +64,20 @@ void menu_rmb() } if (key==13) { - ItemProcess(items_cur+10); + WB1.Scan(ITEMS_LIST[items_cur*2+1]); + ExitProcess(); } break; case evReDraw: - for (items_num=0; ITEMS_LIST[items_num]<>0; items_num++;) {}; + while (ITEMS_LIST[items_num*2]) items_num++; DefineAndDrawWindow(Form.left+m.x,Form.top+m.y+GetSkinWidth()+3,ITEM_WIDTH,items_num*ITEM_HEIGHT+1,0x01,0x10FFFFFF,0,0,0); DrawRegion(0,0,ITEM_WIDTH,items_num*ITEM_HEIGHT+1,0x777777); //юсюфюъ _ITEMS_DRAW: for (i=0; iitems_cur) EDX=0xFFFFFF; else EDX=0x94AECE; DrawBar(1, i*ITEM_HEIGHT+1, ITEM_WIDTH-1, ITEM_HEIGHT, EDX); - WriteText(8,i*ITEM_HEIGHT+6,0x80,0x000000,ITEMS_LIST[i],0); + WriteText(8,i*ITEM_HEIGHT+6,0x80,0x000000,ITEMS_LIST[i*2],0); } } } -void ItemProcess(int num_id) -{ - if (num_id==10) WB1.Scan(52); - if (num_id==11) WB1.Scan(53); - //----------------------- - if (num_id==13) WB1.Scan(11); //KOI - if (num_id==14) WB1.Scan(21); //UTF - ExitProcess(); -} - diff --git a/programs/network/htmlv/browser/include/parce_tag.h b/programs/network/htmlv/browser/include/parce_tag.h index 2757d319b..28e48b823 100644 --- a/programs/network/htmlv/browser/include/parce_tag.h +++ b/programs/network/htmlv/browser/include/parce_tag.h @@ -12,12 +12,12 @@ void GetNextParam() IF (kavichki) { - i=find_symbol(#tagparam, kavichki); + i=strrchr(#tagparam, kavichki); strcpy(#options, #tagparam + i); } ELSE { - WHILE((i > 0) && (tagparam[i] <>'=')) i--; //i=find_symbol(#tagparam, '=')+1; + WHILE((i > 0) && (tagparam[i] <>'=')) i--; //i=strrchr(#tagparam, '=')+1; i++; strcpy(#options, #tagparam + i); //ъюяшЁєхь юяЎш■ diff --git a/programs/network/htmlv/browser/include/some_code.h b/programs/network/htmlv/browser/include/some_code.h index 50b53ae3d..d2c6d7dd4 100644 --- a/programs/network/htmlv/browser/include/some_code.h +++ b/programs/network/htmlv/browser/include/some_code.h @@ -27,14 +27,14 @@ inline byte chTag(dword text) {return strcmp(#tag,text);} void GetURLfromPageLinks(int id) { - int j = 0; + int i, j = 0; for (i = 0; i <= id - 401; i++) { do j++; while (page_links[j] <>'|'); } page_links[j] = 0x00; - strcpy(#URL, #page_links[find_symbol(#page_links, '|')]); + strcpy(#URL, #page_links[strrchr(#page_links, '|')]); } @@ -49,14 +49,14 @@ inline void Skew(dword x,y,w,h) dword italic_buf; int tile_height=2, //сєфхь т√тюфшЄ№ фтєїяшъёхы№э√ьш яюыюёърьш shift=-2, //ё фтєїяшъёхы№э√ь ёьх∙хэшхь - i; + i, skin_width; italic_buf = mem_Alloc(w*h*3); + skin_width = GetSkinWidth(); + CopyScreen(italic_buf, x+Form.left+2, y+Form.top+skin_width, w, h); - CopyScreen(italic_buf, x+Form.left+2, GetSkinWidth()+y+Form.top, w, h); - - FOR (i=0;i*tile_height