From 5f5baa4e63929d7d8657994591982c384a201089 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" <lipatov.kiril@gmail.com> Date: Sat, 16 Jun 2012 13:39:38 +0000 Subject: [PATCH] HTMLv 0.93: anchors, upgrade menu git-svn-id: svn://kolibrios.org@2793 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/network/htmlv/browser/History.txt | 4 + programs/network/htmlv/browser/TWB.h | 88 +++++++++++++++---- .../htmlv/browser/include/acid_0.1.htm | 4 +- .../network/htmlv/browser/include/menu_rmb.h | 57 ++++++++---- .../network/htmlv/browser/include/some_code.h | 37 ++++---- 5 files changed, 132 insertions(+), 58 deletions(-) diff --git a/programs/network/htmlv/browser/History.txt b/programs/network/htmlv/browser/History.txt index aa62675259..caf80c4c53 100644 --- a/programs/network/htmlv/browser/History.txt +++ b/programs/network/htmlv/browser/History.txt @@ -1,3 +1,7 @@ +14.06.12 -- v0.93 +- ���������� �����; +- �������� ����. + 13.06.12 -- v0.92 - ������� ���� ���; - ������ ���������� �������� �������� ��� ����������� ����; diff --git a/programs/network/htmlv/browser/TWB.h b/programs/network/htmlv/browser/TWB.h index 3c801cd625..5da3107974 100644 --- a/programs/network/htmlv/browser/TWB.h +++ b/programs/network/htmlv/browser/TWB.h @@ -9,7 +9,10 @@ dword j, char download_path[]="/rd/1/.download"; char search_path[]="http://nigma.ru/index.php?s="; -char version[]=" Text-based Browser 0.92"; +char version[]=" Text-based Browser 0.93"; + +char tinypad_path[]="/sys/tinypad"; +char t_edit_path[]="/sys/develop/t_edit"; struct TWebBrowser { @@ -17,7 +20,7 @@ struct TWebBrowser { void DrawScroller(); void ShowPage(); void ParseHTML(dword, dword); - void Scan(dword); + void Scan(int); void WhatTextStyle(int left1, top1, width1); }; @@ -26,7 +29,7 @@ TWebBrowser WB1; byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, link, ignor_text, li_tab, body_present; -dword text_colors[10], +dword text_colors[30], text_color_index, link_color, bg_color; @@ -41,6 +44,9 @@ char line[330], parametr[1200], options[1000]; +char anchor[256]; +int anchor_line_num; + #include "include\history.h" #include "include\colors.h" @@ -48,19 +54,30 @@ char line[330], #include "include\some_code.h" -void TWebBrowser::Scan(dword id) { +void TWebBrowser::Scan(int id) { if (id > 399) { GetURLfromPageLinks(id); - //��� ��� ����� ����� � GetNewUrl() ����������� - if (URL[0] == '#') { //�� �� ����� ���������� �� ������ ������ ���������. ���� ���... - copystr(BrowserHistory.CurrentUrl(), #editURL); - copystr(#URL, #editURL + strlen(#editURL)); + + //#1 + if (URL[0] == '#') + { + copystr(#URL+find_symbol(#URL, '#'), #anchor); + copystr(BrowserHistory.CurrentUrl(), #URL); + //copystr(#editURL, #URL + strlen(#URL)); + //copystr(#URL, #editURL); + + za_kadrom=count-max_kolvo_strok; ShowPage(#URL); return; } - URL[find_symbol(#URL, '#')-1] = 0x00; //��������, �� ��� �� ������ ��������� - � ������� ������ ���������� + //liner.ru#1 + if (find_symbol(#URL, '#')<>-1) + { + copystr(#URL+find_symbol(#URL, '#'), #anchor); + URL[find_symbol(#URL, '#')-1] = 0x00; //�������� + } GetNewUrl(); @@ -117,9 +134,13 @@ void TWebBrowser::Scan(dword id) { return; case 052: //������ F3 IF(edit1.flags <> 66) - IF (strcmp(get_URL_part(5),"http:")<>0) RunProgram("tinypad", #URL); ELSE RunProgram("tinypad", #download_path); + IF (!strcmp(get_URL_part(5),"http:")) RunProgram(#tinypad_path, #download_path); ELSE RunProgram(#tinypad_path, #URL); return; - + case 053: //������ F4 + IF(edit1.flags <> 66) + IF (!strcmp(get_URL_part(5),"http:")) RunProgram(#t_edit_path, #download_path); ELSE RunProgram(#t_edit_path, #URL); + return; + case HOME: copystr("http://kolibri-os.narod.ru", #editURL); case GOTOURL: @@ -349,6 +370,7 @@ void TWebBrowser::ParseHTML(dword bword, fsize){ WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //��������� ����� line = tag = parametr = tagparam = ignor_param = 0; //�� �������� + break; case '=': //��������� ���������� ��������� �������, ����������� ����� ��7 IF(strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK; @@ -420,6 +442,14 @@ void TWebBrowser::ParseHTML(dword bword, fsize){ if (stroka * 10 + 15 <= height) DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, bg_color); //����������� �� �� ����� if (za_kadrom == 0) count = stroka; + + if (anchor) + { + anchor[0]=''; + za_kadrom=anchor_line_num; + ParseHTML(buf, filesize); + } + DrawScroller(); //������ ������ } @@ -501,7 +531,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) { IF (ignor_text == 1) return; // - + // IF(!chTag("q")) copystr("\"", #line + strlen(#line)); @@ -522,6 +552,14 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) { IF(!tag) return; stolbec += strlen(#line); + if (anchor) && (!strcmp(#parametr, "id=")) //����� �����!!! ������ ��� ���� �� ��������� ���, �������� �� ����� + { + if (!strcmp(#anchor, #options)) + { + anchor_line_num=za_kadrom+stroka; + } + } + if (!chTag("body")) { BODY_MARK: @@ -550,11 +588,15 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) { return; } ////////////////////////// - if (!chTag("a")) { - IF (stroka - 1 > max_kolvo_strok) || (stroka < -2) return; - if (rez) { - HREF: IF(strcmp(#parametr, "href=") == 0) { - IF(link == 1) text_color_index--; //���� �����-�� ������ �� ������ ��� + if (!chTag("a")) + { + if (rez) + { + _A_MARK: + if (!strcmp(#parametr, "href=")) + { + if (stroka - 1 > max_kolvo_strok) || (stroka < -2) return; + if (link == 1) text_color_index--; //���� �����-�� ������ �� ������ ��� link = 1; blink++; text_color_index++; @@ -562,9 +604,17 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) { copystr(#options, #page_links + strlen(#page_links)); copystr("|", #page_links + strlen(#page_links)); } - IF(tagparam) { + if (anchor) && (!strcmp(#parametr, "name=")) + { + if (!strcmp(#anchor, #options)) + { + anchor_line_num=za_kadrom+stroka; + } + } + if (tagparam) + { GetNextParam(); - GOTO HREF; + GOTO _A_MARK; } } ELSE { diff --git a/programs/network/htmlv/browser/include/acid_0.1.htm b/programs/network/htmlv/browser/include/acid_0.1.htm index 79dccbc2da..2084bff625 100644 --- a/programs/network/htmlv/browser/include/acid_0.1.htm +++ b/programs/network/htmlv/browser/include/acid_0.1.htm @@ -57,8 +57,8 @@ <hr color="grey"> <p><a href='index.htm'>�� ������� �������� index.htm</a></p> -<p><a href="index.htm#home" id="#end">index.htm#home</a></p> -<p><a href="#home">#home</a></p> +<p><a href="index.htm#2.1.4">index.htm#2.1.4</a></p> +<p><a href="#2.1.4">#2.1.4</a></p> <p><a href="background.gif">������� ��������</a></p> </body> diff --git a/programs/network/htmlv/browser/include/menu_rmb.h b/programs/network/htmlv/browser/include/menu_rmb.h index c22ca30943..4c6237becf 100644 --- a/programs/network/htmlv/browser/include/menu_rmb.h +++ b/programs/network/htmlv/browser/include/menu_rmb.h @@ -4,7 +4,8 @@ #define ITEM_WIDTH 138 char *ITEMS_LIST[]={ -"View html code F3", +"View in Tinypad F3", +"View in TextEdit F4", "--------------------", //������� ����������� ����� ����� � �������� �� "KOI-8 Ctrl+K", "UTF Ctrl+U", @@ -17,46 +18,70 @@ void menu_rmb() { mouse mm; - int items_num; - int id, letitclose=0; + int items_num, items_cur; + byte id, key; SetEventMask(100111b); loop() switch(CheckEvent()) { case evMouse: - /*mm.get(); - //������ - if (mm.x>85) && (mm.x<155) && (mm.y>190) && (mm.y<190+22) - if (mm.lkm) {DrawRegion_3D(86,191,68,20,0xC7C7C7,0xFFFFFF); letitclose=1;} - ELSE {IF (letitclose) {DrawRegion_3D(86,191,68,20,0xFFFFFF,0xC7C7C7); Pause(7); ExitProcess();}} - ELSE IF (letitclose) {letitclose=0; DrawRegion_3D(86,191,68,20,0xFFFFFF,0xC7C7C7);}*/ + mm.get(); + id=mm.y/ITEM_HEIGHT; + if (id<0) || (id+1>items_num) break; + if (items_cur<>id) + { + items_cur=id; + goto _ITEMS_DRAW; + } + break; case evButton: id=GetButtonID(); if (id==1) ExitProcess(); + _BUTTON_MARK: if (id==10) WB1.Scan(52); //View html code - if (id==11) break; - if (id==12) WB1.Scan(11); //KOI - if (id==13) WB1.Scan(21); //UTF + if (id==11) WB1.Scan(53); //View html code + if (id==12) break; + if (id==13) WB1.Scan(11); //KOI + if (id==14) WB1.Scan(21); //UTF ExitProcess(); break; case evKey: - if (GetKey()==27) ExitProcess(); + key = GetKey(); + if (key==27) ExitProcess(); + if (key==178) && (items_cur) + { + items_cur--; + goto _ITEMS_DRAW; + } + if (key==177) && (items_cur+1<items_num) + { + items_cur++; + goto _ITEMS_DRAW; + } + if (key==13) + { + id=items_cur+10; + //WriteDebug(IntToStr(id)); + goto _BUTTON_MARK; + } break; case evReDraw: for (items_num=0; ITEMS_LIST[items_num]<>0; items_num++;) {}; - DefineAndDrawWindow(Form.left+m.x,Form.top+m.y+GetSkinWidth()+3,ITEM_WIDTH,items_num*ITEM_HEIGHT,0x01,0x10FFFFFF,0,0,0); + 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,0x777777); //������ - DrawBar(1,1,ITEM_WIDTH-1,items_num*ITEM_HEIGHT-1,0xFFFFFF); //��� + DrawRegion(0,0,ITEM_WIDTH,items_num*ITEM_HEIGHT+1,0x777777); //������ + _ITEMS_DRAW: for (i=0; i<items_num; i++;) { DefineButton(0, i*ITEM_HEIGHT, ITEM_WIDTH, ITEM_HEIGHT, i+10+BT_HIDE, 0xFFFFFF); + if (i<>items_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); } default: diff --git a/programs/network/htmlv/browser/include/some_code.h b/programs/network/htmlv/browser/include/some_code.h index 6561799d5d..7962c07528 100644 --- a/programs/network/htmlv/browser/include/some_code.h +++ b/programs/network/htmlv/browser/include/some_code.h @@ -25,7 +25,7 @@ dword get_URL_part(byte len) { inline byte chTag(dword text) {return strcmp(#tag,text);} -void GetURLfromPageLinks(int id) //������� �����, ������ ��� ������ ������� ������ �������� +void GetURLfromPageLinks(int id) { j = 0; for (i = 0; i <= id - 401; i++) @@ -38,30 +38,25 @@ void GetURLfromPageLinks(int id) // } +//� ��� ��� ��������� �������, ������� ������ ������� �� +//������� ��� ���������� � ����������� �������: +//������� ������� ������ � ������� � ������� ��������� �� ���������, +//��� ��� ������� �������� +//��� ������� ���� � �.�. ��������� ��� ������������ ������� :) -//� ��� ��� ��������� ���⮢, ���⮬� ������ ������ �� -//����祪 ��� ������� � ����⥫쭮� १����: -//������� ������� ��࠭� � �뢮��� �� ���⭮ ����᪠�� � ᬥ饭���, -//�� ���� ��४�� ���⨭�� -//�� ����稨 䮭� � �.�. ����� ��� �����쭮��� �襭�� :) - -//���� ������ 㦥 ����祭� � TBW - skin_width, Form.top, ������祭�� memory inline void Skew(dword x,y,w,h) { -dword italic_buf; -int tile_height=2,//�㤥� �뢮���� ���寨�ᥫ�묨 ����᪠�� -i, skin_width, -shift=-2; + dword italic_buf; + int tile_height=2, //����� �������� ��������������� ��������� + shift=-2, //� �������������� ��������� + i; - italic_buf = mem_Alloc(w*h*3); - - skin_width = GetSkinWidth(); + italic_buf = mem_Alloc(w*h*3); - 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<h;i++){ - PutImage(w*3*tile_height*i+italic_buf,w,tile_height,x+shift-i+1,i*tile_height+y); - } - mem_Free(italic_buf); + FOR (i=0;i*tile_height<h;i++){ + PutImage(w*3*tile_height*i+italic_buf,w,tile_height,x+shift-i+1,i*tile_height+y); + } + mem_Free(italic_buf); }