Text-based Browser 23.67 aka HTML Viewer v0.67

git-svn-id: svn://kolibrios.org@2085 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2011-08-20 15:36:15 +00:00
parent fe72383413
commit e3f508ee0c
5 changed files with 105 additions and 88 deletions

View File

@ -16,7 +16,7 @@
#include "../lib/dll.h--" #include "../lib/dll.h--"
//ïåðåìåííûå //ïåðåìåííûå
byte URL[4096]="/sys/html/index.htm", byte URL[4096]="/sys/index.htm",
editURL[4096], editURL[4096],
page_links[12000], page_links[12000],
header[512]; header[512];
@ -75,7 +75,9 @@ void main()
} }
} }
//IF (kolichestvo<max_kolvo_strok) break; //IF (kolichestvo<max_kolvo_strok) break;
if (m.x>=WB1.width-14) && (m.x<=WB1.width+6) && (kolichestvo>max_kolvo_strok) while (m.lkm) if (m.x>=WB1.width-14) && (m.x<=WB1.width+6)
&& (m.y>WB1.top+16) && (m.y<WB1.top+WB1.height-16)
&& (kolichestvo>max_kolvo_strok) while (m.lkm)
{ {
IF (razm_scrl/2+WB1.top>m.y) || (m.y<0) || (m.y>4000) m.y=razm_scrl/2+WB1.top; //åñëè êóðñîð íàä îêíîì IF (razm_scrl/2+WB1.top>m.y) || (m.y<0) || (m.y>4000) m.y=razm_scrl/2+WB1.top; //åñëè êóðñîð íàä îêíîì
btn=za_kadrom; //ñîõðàíÿåì ñòàðîå êîëè÷åñòâî btn=za_kadrom; //ñîõðàíÿåì ñòàðîå êîëè÷åñòâî

View File

@ -1,3 +1,16 @@
20.08.11 -- v0.67 -- 11.1 Кб
- более адекватная прокрутка изображений;
- корректная обработка табов в тексте и с тегом <pre> (спасибо Nazarus и Jaeger);
- улучшена отзывчивость программы при прокрутке больших страниц (фикс изначально
был написан Gluk'ом для игры Косилка по моей просьба, сюда перенесен мной);
- небольшие исправления в реакции ползунка прокрутки;
- исправлено залезание текста в наклонном шрифте на левый ободок окна;
- кнопка "Новая вкладка" и комбинации Ctrl+N, Ctrl+T банально создают новое окно;
- правильное распознание украинской буквы ґ;
- поддержка кодировки "UTF8" для универсальности (идея фичи Joaquin).
20.06.11 -- v0.63 -- 11.32 Êá 20.06.11 -- v0.63 -- 11.32 Êá
lev lev
- íàêëîííûé øðèôò - íàêëîííûé øðèôò

View File

@ -1,14 +1,12 @@
//http://jsbeautifier.org/ //http://jsbeautifier.org/
//Web-component, Leency & Veliant 2007-2009 //Web-component, Leency & Veliant 2007-2009
//lev //lev
//èäåÿ - ëåâûå ôàéëû îòêðûâàòü ñîîòâåòñòâóþùèìè ïðîãàìè //èäåÿ - ëåâûå ôàéëû îòêðûâàòü ñîîòâåòñòâóþùèìè ïðîãàìè
//wintodos(buf); -> â ïàðñå õòìë êàê è âñå êîäèðîâêè
// wintodos(buf); -> â ïàðñå õòìë êàê è âñå êîäèðîâêè
//ol - öèôåðêè //ol - öèôåðêè
//óñêîðåíà çàãðóçêà ñòðàíèöû, ñîäåðæàùåé èçîáðàæåíèÿ
//óìåíüøåíî êîëè÷åñòâî ïåðåðèñîâîê çàãîëîâêà îêíà ïðè çàãðóçêå ñòðàíèöû
dword j, dword j,
buf, buf,
@ -19,11 +17,11 @@ dword j,
char download_path[]="/rd/1/.download"; char download_path[]="/rd/1/.download";
//char search_path[]="http://nova.rambler.ru/search?words="; //char search_path[]="http://nova.rambler.ru/search?words=";
char search_path[]="http://nigma.ru/index.php?s="; char search_path[]="http://nigma.ru/index.php?s=";
char version[]=" HTML Viewer v0.63"; char version[]=" Text-based Browser 23.67";
struct TWebBrowser { struct TWebBrowser {
dword left, int left,
top, top,
width, width,
height; height;
@ -64,15 +62,21 @@ void TWebBrowser::Scan(dword id) {
case BACK: case BACK:
BrowserHistory.GoBack(); BrowserHistory.GoBack();
return; return;
/*case FORWARD: case FORWARD:
WriteDebug(#UrlHistory); //RunProgram("@notify", "Forward button is not realized yet");
return;*/ return;
case 054: //F5 case 054: //F5
IF(edit1.flags == 66) break; IF(edit1.flags == 66) break;
case REFRESH: case REFRESH:
copystr(#URL, #editURL); copystr(#URL, #editURL);
Draw_Window(); Draw_Window();
return; return;
case 014: //Ctrl+N íîâîå îêíî
case 020: //Ctrl+T íîâàÿ âêëàäêà
case NEWTAB:
MoveSize(190,80,OLD,OLD);
RunProgram(#program_path, #URL);
return;
case HOME: case HOME:
copystr("/sys/index.htm", #editURL); copystr("/sys/index.htm", #editURL);
case GOTOURL: case GOTOURL:
@ -235,7 +239,8 @@ dword text_colors[10],
text_color_index = 0, text_color_index = 0,
link_color; link_color;
int stroka, int stroka,
stolbec; stolbec,
tab_len;
byte line[330], byte line[330],
tag[100], tag[100],
tagparam[10000], tagparam[10000],
@ -271,11 +276,18 @@ void TWebBrowser::ParseHTML(dword bword, fsize){
goto NEXT_MARK; goto NEXT_MARK;
} }
CASE '\9': CASE '\9':
CASE 0x0d: if (pre_text == 1) //èíà÷å èä¸ì íà 0x0d
//IF(pre_text == 1) {copystr(" ", #line + strlen(#line)); break;} ELSE {
tab_len=strlen(#line)/8;
tab_len=tab_len*8;
tab_len=8+tab_len-strlen(#line);
for (i=0; i<tab_len; i++;) copystr(" ", #line + strlen(#line));
break;
}
case 0x0d:
bukva = ' '; bukva = ' ';
goto DEFAULT_MARK; goto DEFAULT_MARK;
CASE '<': case '<':
bword++; //ïðîìîòàåì ñèìâîë < bword++; //ïðîìîòàåì ñèìâîë <
IF(ESBYTE[bword] == '!') //ôèëüòðàöèÿ âíóòðè <!-- -->, äåðçêî IF(ESBYTE[bword] == '!') //ôèëüòðàöèÿ âíóòðè <!-- -->, äåðçêî
{ {
@ -325,37 +337,6 @@ void TWebBrowser::ParseHTML(dword bword, fsize){
bukva=Hex2Symb(#temp); bukva=Hex2Symb(#temp);
IF (bukva) goto DEFAULT_MARK; IF (bukva) goto DEFAULT_MARK;
break; break;
/*case '\\': //ïîääåðæêà RTF, http://dev.rembish.ru/rtf.phps
IF(strcmp(#URL + strlen(#URL) - 4, ".rtf")<>0) goto DEFAULT_MARK;
rtf_text='';
//
bword++;
j = 0;
IF (ESBYTE[bword]=='\'')
{
bword++;
bukva=ESBYTE[bword];
copystr(#bukva, #rtf_text);
bword++;
bukva=ESBYTE[bword];
copystr(#bukva, #rtf_text + strlen(#rtf_text));
bukva=Hex2Symb(#rtf_text);
IF (bukva) goto DEFAULT_MARK;
}
WHILE ((ESBYTE[bword] <>' ') && (j < 25) && (ESBYTE[bword] <>'\\') && (ESBYTE[bword] <>0x0d)) {
bukva = ESBYTE[bword];
copystr(#bukva, #rtf_text + strlen(#rtf_text));
bword++;
j++;
}
IF (strcmp(#rtf_text,"par")==0) goto NEXT_MARK;
break;*/
case '&': case '&':
IF(ignor_text) break; IF(ignor_text) break;
bword++; bword++;
@ -457,7 +438,7 @@ void GetNextParam() {
char oldtag[100]; char oldtag[100];
void TWebBrowser::WhatTextStyle(word left1, top1, width1) { void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
dword hr_color; dword hr_color;
dword image=0; dword image=0;
@ -636,13 +617,28 @@ void TWebBrowser::WhatTextStyle(word left1, top1, width1) {
if (image) if (image)
{ {
IF (width1<w) w=width1; stroka+=h/10;
IF (WB1.height<h) h=WB1.height;
IF (top1<WB1.top) {h=h-top1+WB1.top; top1=WB1.top;} if (top1+h<WB1.top) || (top1>WB1.top+WB1.height-10) //åñëè ÂѨ èçîáðàæåíèå óøëî ÂÅÐÕ èëè ÂÍÈÇ
TextGoDown2(left1+w,top1,width1-w,h); return;
IF (stroka - 2 < max_kolvo_strok) img_draw stdcall (image,left1-5,top1+10,w,-stroka * 10 + WB1.height -15 + h,0,0);
if (top1<WB1.top) //åñëè ÷àñòü èçîáðàæåíèÿ ñâåðõó
{
h=h-WB1.top+top1;
top1=WB1.top-5;
}
if (top1>WB1.top+WB1.height-h-10) //åñëè ÷àñòü èçîáðàæåíèÿ ñíèçó IF (stroka - 2 < max_kolvo_strok)
{
//WriteDebug(IntToStr(top1));
//WriteDebug(IntToStr(WB1.top));
//WriteDebug(IntToStr(h));
h=WB1.top+WB1.height-top1-10;
}
img_draw stdcall (image,left1-5,top1+10,w, h,0,0);
DrawBar(left1+w - 5, top1 + 10, width1-w + 5, h, 0xFFFFFF);
} }
//else WriteDebug(#options);
} }
if (!chTag("meta")) { if (!chTag("meta")) {
@ -651,7 +647,7 @@ void TWebBrowser::WhatTextStyle(word left1, top1, width1) {
{ {
copystr(#options[find_symbol(#options, '=')],#options); //ïîèñê â content= copystr(#options[find_symbol(#options, '=')],#options); //ïîèñê â content=
IF (!strcmp(#options,"utf-8")) IF (!strcmp(#options,"utf-8")) || (!strcmp(#options,"utf8"))
{ {
ReadHtml(DONT_LOAD); ReadHtml(DONT_LOAD);
utf8rutodos(buf); utf8rutodos(buf);
@ -681,11 +677,3 @@ void TextGoDown(int left1, top1, width1) {
IF(li_text == 1) stolbec = li_tab * 5; IF(li_text == 1) stolbec = li_tab * 5;
IF(stroka >= 0) && (stroka - 2 < max_kolvo_strok) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, 0xFFFFFF); IF(stroka >= 0) && (stroka - 2 < max_kolvo_strok) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, 0xFFFFFF);
} }
void TextGoDown2(int left1,top1,width1,height1)//ASPER: Íàäî çàìåíèòü ýòó ôóíêöèþ áîëåå ïðàâèëüíîé.
{
stroka+=height1/10;
IF (blq_text==1) stolbec=8; ELSE stolbec=0;
IF (li_text==1) stolbec=5;
IF (stroka>=0) && (stroka-2<max_kolvo_strok) DrawBar(left1 - 5, top1 + 10, width1 + 5, height1, 0xFFFFFF);
}

View File

@ -3,6 +3,7 @@
#define FORWARD 301 #define FORWARD 301
#define REFRESH 302 #define REFRESH 302
#define HOME 303 #define HOME 303
#define NEWTAB 304
#define GOTOURL 305 #define GOTOURL 305
#define SEARCHWEB 306 #define SEARCHWEB 306
#define ID1 178 #define ID1 178
@ -26,6 +27,11 @@ dword get_URL_part(byte len) {
return #temp1; return #temp1;
} }
inline fastcall CopyScreen(dword EBX, ECX, EDX)
{
EAX = 36;
$int 0x40;
}
inline byte chTag(dword text) {return strcmp(#tag,text);} inline byte chTag(dword text) {return strcmp(#tag,text);}
@ -43,20 +49,14 @@ int tile_height=2,//
i, skin_width, i, skin_width,
shift=-2; shift=-2;
skin_width = GetSkinWidth();
Form.GetInfo(SelfInfo);
italic_buf = malloc(w*h*3); italic_buf = malloc(w*h*3);
//ebx = 㪠§ â¥«ì ­  ¯à¥¤¢ à¨â¥«ì­® ¢ë¤¥«¥­­ãî ®¡« áâì ¯ ¬ïâ¨, ªã¤  ¡ã¤¥â ¯®¬¥é¥­® ¨§®¡à ¦¥­¨¥ ¢ ä®à¬ â¥ BBGGRRBBGGRR... skin_width = GetSkinWidth();
EBX = italic_buf;
//ecx = [à §¬¥à ¯® ®á¨ x]*65536 + [à §¬¥à ¯® ®á¨ y] CopyScreen(italic_buf, w * 65536 + h, x + Form.left + 2 * 65536 + y + Form.top + skin_width);
ECX = w * 65536 + h;
//edx = [ª®®à¤¨­ â  ¯® ®á¨ x]*65536 + [ª®®à¤¨­ â  ¯® ®á¨ y]
EDX = x + Form.left * 65536 + y + Form.top + skin_width;
EAX = 36;
$int 0x40;
FOR (i=0;i*tile_height<h;i++){ FOR (i=0;i*tile_height<h;i++){
PutImage(w*3*tile_height*i+italic_buf,w,tile_height,x+shift-i,i*tile_height+y); PutImage(w*3*tile_height*i+italic_buf,w,tile_height,x+shift-i+1,i*tile_height+y);
} }
free(italic_buf); free(italic_buf);
} }

View File

@ -10,8 +10,9 @@ dword final_addr = #stop+32;
dword alloc_mem = #0x00100000; dword alloc_mem = #0x00100000;
dword x86esp_reg = #0x00100000; dword x86esp_reg = #0x00100000;
dword I_Param = #param; dword I_Param = #param;
dword I_Icon = 0x0; dword I_Path = #program_path;
char param[256]=""; char param[4096]="";
char program_path[4096]="";
//Events //Events
#define evMouse 6 #define evMouse 6
@ -121,9 +122,21 @@ inline fastcall ScancodesGeting(){
$int 0x40 $int 0x40
} }
inline fastcall word GetKey(){
EAX = 2; // just read this key from buffer inline fastcall word GetKey(){ //Gluk fix
$push edx
@getkey:
$mov eax,2
$int 0x40 $int 0x40
$cmp eax,1
$jne getkeyi
$mov ah,dh
$jmp getkeyii //jz?
@getkeyi:
$mov dh,ah
$jmp getkey
@getkeyii:
$pop edx
EAX = EAX >> 8; EAX = EAX >> 8;
} }
@ -361,6 +374,7 @@ inline fastcall wintodos (dword ESI)
IF (BL==186) ESBYTE[ESI] = 243; //e IF (BL==186) ESBYTE[ESI] = 243; //e
IF (BL==168) ESBYTE[ESI] = 240; //ð IF (BL==168) ESBYTE[ESI] = 240; //ð
IF (BL==184) ESBYTE[ESI] = 'e'; //e IF (BL==184) ESBYTE[ESI] = 'e'; //e
IF (BL==180) ESBYTE[ESI] = 254; //ã
IF ((BL==147) || (BL==148) || (BL==171) || (BL==187)) ESBYTE[ESI] = 34; IF ((BL==147) || (BL==148) || (BL==171) || (BL==187)) ESBYTE[ESI] = 34;
IF ((BL==150) || (BL==151)) ESBYTE[ESI] = 45; IF ((BL==150) || (BL==151)) ESBYTE[ESI] = 45;
} }