HTMLv 0.77: <body> bgcolor= and text= support, fixes

git-svn-id: svn://kolibrios.org@2420 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2012-02-29 12:29:47 +00:00
parent 26b134521c
commit febf6bf8c4
4 changed files with 38 additions and 25 deletions

View File

@ -1,5 +1,5 @@
//HTML Viewer in C--
//Copyright 2007-2009 by Veliant & Leency
//Copyright 2007-20012 by Veliant & Leency
//Asper, Lrz, Nable, lev.
#include "..\lib\kolibri.h--"
@ -56,6 +56,8 @@ void main()
BrowserHistory.AddUrl();
copystr(#URL,#editURL);
if (!strcmp(get_URL_part(5),"http:"))) HttpLoad();
SetEventMask(0x27);
loop()
{

View File

@ -1,4 +1,4 @@
//Web-component, Leency & Veliant 2007-2009
//Web-component, Leency & Veliant 2007-20012
//lev
//èäåÿ - ëåâûå ôàéëû îòêðûâàòü ñîîòâåòñòâóþùèìè ïðîãàìè
@ -17,7 +17,7 @@ dword j,
char download_path[]="/rd/1/.download";
//char search_path[]="http://nova.rambler.ru/search?words=";
char search_path[]="http://nigma.ru/index.php?s=";
char version[]=" Text-based Browser 0.76";
char version[]=" Text-based Browser 0.77";
struct TWebBrowser {
@ -34,12 +34,13 @@ struct TWebBrowser {
TWebBrowser WB1;
byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, link, ignor_text, li_tab;
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],
text_color_index = 0,
link_color;
link_color,
bg_color=0xFFFFFF;
int stroka,
stolbec,
@ -200,6 +201,7 @@ void GetNewUrl(){
void HttpLoad()
{
//count = 0; ÿ äóìàþ åìó ìåñòî çäåñü
copystr(#version, #header);
KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ
DeleteFile(#download_path);
IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]='';
@ -252,7 +254,6 @@ void TWebBrowser::ShowPage(dword adress) {
return;
}
DrawBar(left, top, width-15, 15, 0xFFFFFF); //çàêðàøèâàåì ïåðâóþ ñòðîêó
wintodos(buf);
ParseHTML(buf, filesize);
IF (!strcmp(#version, #header)) DrawTitle(#header);
@ -267,15 +268,19 @@ void TWebBrowser::ParseHTML(dword bword, fsize){
stroka = -za_kadrom;
stolbec = 0;
FOR(j = 400; j < blink + 1; j++;) DeleteButton(j);
b_text = i_text = u_text = s_text = pre_text = blq_text =
b_text = i_text = u_text = s_text = pre_text = blq_text = body_present =
li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 0; //îáíóëÿåì òåãè
link_color = 0x0000FF;
bg_color = 0xFFFFFF;
blink = 400;
line = '';
copystr("|", #page_links);
copystr(#version, #header);
IF(!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1; //çà÷¸òíîå îòîáðàæåíèå òåêñòà
//IF(!strcmp(#URL + strlen(#URL) - 4, ".rtf")) pre_text = 1;
IF(!strcmp(#URL + strlen(#URL) - 4, ".txt"))
{
DrawBar(left, top, width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
pre_text = 1; //çà÷¸òíîå îòîáðàæåíèå òåêñòà
}
IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
for (; buf + fsize > bword; bword++;) {
bukva = ESBYTE[bword];
@ -394,11 +399,14 @@ void TWebBrowser::ParseHTML(dword bword, fsize){
copystr(#bukva, #line + strlen(#line));
}
}
IF(max_kolvo_strok * 10 + 25 <= height)
DrawBar(left, max_kolvo_strok * 10 + top + 25, width - 15, -max_kolvo_strok * 10 + height - 25, 0xFFFFFF);
IF(stroka * 10 + 15 <= height)
DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, 0xFFFFFF); //çàêðàøèâàåì âñ¸ äî êîíöà
IF(za_kadrom == 0) count = stroka;
if (strcmp(#URL + strlen(#URL) - 4, ".txt")<>0) && (body_present==0)
DrawBar(left, top, width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó åñëè êàêîé-òî ðàõèò íå ñîçäàë òåã áîäè
if (max_kolvo_strok * 10 + 25 <= height)
DrawBar(left, max_kolvo_strok * 10 + top + 25, width - 15, -max_kolvo_strok * 10 + height - 25, bg_color);
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;
DrawScroller(); //ðèñóåì ñêðîëë
}
@ -500,7 +508,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
//
IF(!tag) return;
stolbec += strlen(#line);
////////////////////////// <body bgcolor="#000000" text="#FFFFFF">
if (!chTag("body"))
{
BODY_MARK:
@ -508,22 +516,25 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
if (strcmp(#parametr, "link=") == 0)
link_color = GetColor(#options);
/*if (strcmp(#parametr, "text=") == 0)
if (strcmp(#parametr, "text=") == 0)
{
text_colors[0]=GetColor(#options);
}
if (strcmp(#parametr, "bgcolor=") == 0)
{
//text_colors[0]=GetColor(#options);
WriteDebug("bgcolor=");
WriteDebug(#options);
}*/
bg_color=GetColor(#options);
}
IF(tagparam) {
GetNextParam();
GOTO BODY_MARK;
}
}
body_present = 1; //åñëè êàëè÷ íå ñîçäàë òåã áîäè íóæíî èçâðàùàòüñÿ
if (rez) DrawBar(WB1.left, WB1.top, WB1.width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
return;
}
//////////////////////////
if (!chTag("a")) {
@ -669,7 +680,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
IF (h<=0) return;
img_draw stdcall (image,left1-5,top1+10,w, h,0,img_za_kadrom);
DrawBar(left1+w - 5, top1 + 10, width1-w + 5, h, 0xFFFFFF);
DrawBar(left1+w - 5, top1 + 10, width1-w + 5, h, bg_color);
}
/*else
{
@ -715,7 +726,7 @@ void TextGoDown(int left1, top1, width1) {
IF(blq_text == 1) stolbec = 8;
ELSE stolbec = 0;
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, bg_color);
}

View File

@ -1,5 +1,5 @@
..\C--\c-- HTMLv.c--
del HTMLv
rename HTMLv.com HTMLv
..\C--\kpack HTMLv
rem ..\C--\kpack HTMLv
rem pause

View File

@ -29,7 +29,7 @@
<font color="#FFC005">c</font>
<font color="red">y</font><br>
</b>
ニ頸黑頏 2008-2011
ニ頸黑頏 2008-2012
<p>
Íåáîëüøîé ñïèñîê:<ol>