HTMLv: several fixes

git-svn-id: svn://kolibrios.org@4550 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2014-01-30 18:28:50 +00:00
parent 437347b036
commit b29e77e550
6 changed files with 55 additions and 51 deletions

View File

@ -17,7 +17,7 @@ struct TWebBrowser {
DrawBufer DrawBuf;
void GetNewUrl();
void ReadHtml();
void ParseHTML();
void Parse();
void WhatTextStyle();
void DrawPage();
void DrawScroller();
@ -90,7 +90,7 @@ void TWebBrowser::DrawPage()
IF (link) {
UnsafeDefineButton(start_x-2, start_y, line_length + 3, 9, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
DrawBuf.DrawBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
PageLinks.AddText(#line, line_length, list.line_h);
PageLinks.AddText(#line, line_length, list.line_h, UNDERLINE);
}
stolbec += strlen(#line);
}
@ -166,12 +166,13 @@ void TWebBrowser::ReadHtml(byte encoding)
}
void TWebBrowser::ParseHTML(dword bufpos){
void TWebBrowser::Parse(dword bufpos, in_filesize){
word bukva[2];
int j, perenos_num;
byte ignor_param;
char temp[768];
dword bufstart = bufpos;
bufsize = in_filesize;
bufpointer = bufpos;
b_text = i_text = u_text = s_text = blq_text =
li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab =
@ -195,7 +196,7 @@ void TWebBrowser::ParseHTML(dword bufpos){
if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
}
for ( ; bufstart+bufsize > bufpos; bufpos++;)
for ( ; bufpointer+bufsize > bufpos; bufpos++;)
{
bukva = ESBYTE[bufpos];
if (ignor_text) && (bukva!='<') continue;
@ -253,7 +254,7 @@ void TWebBrowser::ParseHTML(dword bufpos){
do
{
bufpos++;
if (bufstart + bufsize <= bufpos) break 2;
if (bufpointer + bufsize <= bufpos) break 2;
}
while (ESBYTE[bufpos] <>'-');
@ -261,7 +262,7 @@ void TWebBrowser::ParseHTML(dword bufpos){
if (ESBYTE[bufpos] <>'-') goto HH_;
}
}
while (ESBYTE[bufpos] !='>') && (bufpos < bufstart + bufsize) //ïîëó÷àåì òåã è åãî ïàğàìåòğû
while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàğàìåòğû
{
bukva = ESBYTE[bufpos];
if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
@ -299,8 +300,8 @@ void TWebBrowser::ParseHTML(dword bufpos){
}
DrawPage();
if (tag) WhatTextStyle(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //îáğàáîòêà òåãîâ
line=NULL;
if (tag) WhatTextStyle(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //îáğàáîòêà òåãîâ
tag = parametr = tagparam = ignor_param = NULL;
break;
@ -341,7 +342,7 @@ void TWebBrowser::ParseHTML(dword bufpos){
{
anchor=NULL;
list.first=anchor_line_num;
ParseHTML(bufstart);
Parse(bufpointer, bufsize);
}
DrawScroller();
}

View File

@ -25,7 +25,7 @@ void ImageCache::Free()
int ImageCache::GetImageNumber(dword i_path)
{
int i;
for (i=0; i<pics_count; i++) if (!strcmp(#pics[i].path, i_path)) return i; //image exists
for (i=0; i<=pics_count; i++) if (!strcmp(#pics[i].path, i_path)) return i; //image exists
// Load image and add it to Cache
pics_count++;
pics[pics_count].image = load_image(i_path);
@ -95,7 +95,12 @@ void ImageCache::Images(int left1, top1, width1)
img_draw stdcall (pics[cur_pic].image, left1-5, top1, w, h,0,img_lines_first);
DrawBar(left1+w - 5, top1, WB1.list.w-w, h, bg_color);
IF (link) UnsafeDefineButton(left1 - 5, top1, w, h-1, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
IF (link)
{
UnsafeDefineButton(left1 - 5, top1, w, h-1, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
PageLinks.AddText(0, w, h-1, NOLINE);
// WB1.DrawPage();
}
}
ImageCache ImgCache;

View File

@ -1,9 +1,14 @@
CustomCursor CursorPointer;
dword CursorFile = FROM "../TWB/pointer.cur";
#define NOLINE 0
#define UNDERLINE 1
struct array_link {
dword link, text;
int x,y,w,h;
int underline;
};
struct LinksArray
@ -31,11 +36,12 @@ void LinksArray::AddLink(dword new_link, int link_x, link_y)
count++;
}
void LinksArray::AddText(dword new_text, int link_w, link_h)
void LinksArray::AddText(dword new_text, int link_w, link_h, link_underline)
{
if (count<1) return;
links[count-1].w = link_w;
links[count-1].h = link_h;
links[count-1].underline = link_underline;
links[count-1].text = buflen;
strcpy(buflen, new_text);
@ -67,8 +73,8 @@ void LinksArray::Hover(dword mx, my, link_col_in, link_col_a, bg_col)
{
if (active==i) return;
CursorPointer.Set();
DrawBar(links[active].x,links[active].y+8,links[active].w,1, link_col_in);
DrawBar(links[i].x,links[i].y+8,links[i].w,1, bg_col);
if (links[active].underline) DrawBar(links[active].x,links[active].y+8,links[active].w,1, link_col_in);
if (links[i].underline) DrawBar(links[i].x,links[i].y+8,links[i].w,1, bg_col);
active = i;
return;
}
@ -76,7 +82,7 @@ void LinksArray::Hover(dword mx, my, link_col_in, link_col_a, bg_col)
if (active!=-1)
{
CursorPointer.Restore();
DrawBar(links[active].x,links[active].y+8,links[active].w,1, link_col_in);
if (links[active].underline) DrawBar(links[active].x,links[active].y+8,links[active].w,1, link_col_in);
active = -1;
}
}

View File

@ -30,16 +30,16 @@
#include "img\URLgoto.txt";
#ifdef LANG_RUS
char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 0.99.66";
char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 0.99.67";
?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤­¨© á« ©¤"
char loading[] = "‡ £à㧪  áâà ­¨æë...";
char loading[] = "‡ £à㧪  áâà ­¨æë...<br>";
unsigned char page_not_found[] = FROM "html\page_not_found_ru.htm";
#else
char version[]=" Text-based Browser 0.99.66";
char version[]=" Text-based Browser 0.99.67";
?define IMAGES_CACHE_CLEARED "Images cache cleared"
?define T_LAST_SLIDE "This slide is the last"
char loading[] = "Loading...";
char loading[] = "Loading...<br>";
unsigned char page_not_found[] = FROM "html\page_not_found_en.htm";
#endif
@ -101,7 +101,7 @@ void main()
edit_box_mouse stdcall (#address_box);
m.get();
PageLinks.Hover(m.x, m.y, link_color_inactive, link_color_active, bg_color);
if (m.y>WB1.list.y) PageLinks.Hover(m.x, m.y, link_color_inactive, link_color_active, bg_color);
if (m.y>WB1.list.y) && (m.y<Form.height) && (bufsize)
{
@ -120,7 +120,7 @@ void main()
if (m.vert)
{
if (WB1.list.MouseScroll(m.vert)) WB1.ParseHTML(bufpointer);
if (WB1.list.MouseScroll(m.vert)) WB1.Parse(bufpointer, bufsize);
}
if (!m.lkm) scroll_used=0;
@ -138,7 +138,7 @@ void main()
btn=WB1.list.first;
WB1.list.first = m.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h;
if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible;
if (btn<>WB1.list.first) WB1.ParseHTML(bufpointer);
if (btn<>WB1.list.first) WB1.Parse(bufpointer, bufsize);
}
break;
@ -185,7 +185,7 @@ void main()
//bufsize = ESI.http_msg.content_received;
bufsize = strlen(bufpointer)-2;
debugi(bufsize);
WB1.ParseHTML(bufpointer);
WB1.Parse(bufpointer, bufsize);
$pop EAX
if (EAX == 0) {
http_free stdcall (http_transfer);
@ -259,28 +259,28 @@ void Scan(int id)
{
case 011: //Ctrk+K
WB1.ReadHtml(_KOI);
WB1.ParseHTML(bufpointer);
WB1.Parse(bufpointer, bufsize);
return;
case 021: //Ctrl+U
WB1.ReadHtml(_UTF);
WB1.ParseHTML(bufpointer);
WB1.Parse(bufpointer, bufsize);
return;
case 004: //Ctrl+D
WB1.ReadHtml(_DOS);
WB1.ParseHTML(bufpointer);
WB1.Parse(bufpointer, bufsize);
return;
case 005: //Win encoding
WB1.ReadHtml(_WIN);
WB1.ParseHTML(bufpointer);
WB1.Parse(bufpointer, bufsize);
return;
case 009: //free img cache
ImgCache.Free();
notify(IMAGES_CACHE_CLEARED);
WB1.ParseHTML(bufpointer);
WB1.Parse(bufpointer, bufsize);
return;
case 003: //history
@ -301,7 +301,7 @@ void Scan(int id)
else RunProgram("/rd/1/tinypad", #download_path);
return;
case 054: //F5
IF(address_box.flags & 0b10) WB1.ParseHTML(bufpointer);
IF(address_box.flags & 0b10) WB1.Parse(bufpointer, bufsize);
return;
case REFRESH:
@ -342,7 +342,7 @@ void Scan(int id)
IF(WB1.list.first == WB1.list.count - WB1.list.visible) return;
WB1.list.first += WB1.list.visible + 2;
IF(WB1.list.visible + WB1.list.first > WB1.list.count) WB1.list.first = WB1.list.count - WB1.list.visible;
WB1.ParseHTML(bufpointer);
WB1.Parse(bufpointer, bufsize);
return;
case 184: //PgUp
@ -350,30 +350,30 @@ void Scan(int id)
IF(WB1.list.first == 0) return;
WB1.list.first -= WB1.list.visible - 2;
IF(WB1.list.first < 0) WB1.list.first = 0;
WB1.ParseHTML(bufpointer);
WB1.Parse(bufpointer, bufsize);
return;
case 178:
case BTN_UP:
if (WB1.list.first <= 0) return;
WB1.list.first--;
WB1.ParseHTML(bufpointer);
WB1.Parse(bufpointer, bufsize);
return;
case 177:
case BTN_DOWN:
if (WB1.list.visible + WB1.list.first >= WB1.list.count) return;
WB1.list.first++;
WB1.ParseHTML(bufpointer);
WB1.Parse(bufpointer, bufsize);
return;
case 180: //home
if (WB1.list.KeyHome()) WB1.ParseHTML(bufpointer);
if (WB1.list.KeyHome()) WB1.Parse(bufpointer, bufsize);
return;
case 181: //end
if (WB1.list.count < WB1.list.visible) return;
if (WB1.list.KeyEnd()) WB1.ParseHTML(bufpointer);
if (WB1.list.KeyEnd()) WB1.Parse(bufpointer, bufsize);
return;
}
}
@ -468,19 +468,12 @@ void ShowPage()
{
PageLinks.Clear();
if (GetProcessSlot(downloader_id)<>0)
{
bufsize = sizeof(loading);
WB1.ParseHTML(#loading);
}
WB1.Parse(#loading, sizeof(loading));
else
{
bufsize = sizeof(page_not_found);
WB1.ParseHTML(#page_not_found);
}
bufsize = 0;
WB1.Parse(#page_not_found, sizeof(page_not_found));
}
else
WB1.ParseHTML(bufpointer);
WB1.Parse(bufpointer, bufsize);
if (!header) strcpy(#header, #version);
if (!strcmp(#version, #header)) DrawTitle(#header);
@ -493,7 +486,7 @@ ShowHistory()
free(history_pointer);
history_pointer = malloc(64000);
strcat(history_pointer, "<h1>History</h1>");
strcat(history_pointer, " <title>History</title><h1>History</h1>");
strcat(history_pointer, "<h2>Visited pages</h2><blockquote><br>");
for (i=1; i<BrowserHistory.links_count; i++)
{
@ -509,10 +502,10 @@ ShowHistory()
strcat(history_pointer, "<img src='");
strcat(history_pointer, #pics[i].path);
strcat(history_pointer, "' /><br>");
strcat(history_pointer, #pics[i].path);
}
bufsize = strlen(history_pointer);
bufpointer = history_pointer;
WB1.ParseHTML(history_pointer);
WB1.Parse(history_pointer, strlen(history_pointer));
}

View File

@ -5,7 +5,7 @@
</head>
<body>
<h1><EFBFBD>ЅЁ-стр ­Јц  ­ЅЄЎстуЏ­ </h1>
<h2>—в® ¤Ґ« вм:</h2>
<h2>—в® ¬®¦­® ᤥ« вм:</h2>
<ul>
<li>
<09>ЁЅЄЈтЅсь, чтЎ Ѕсть ЏЎЄЊЋючЅ­ЈЅ Њ сЅтЈ <20>­тЅр­Ѕт.<br>

View File

@ -421,7 +421,6 @@ void debugi(dword d_int)
}
#define strncpy strcpyn
#define strnmov strmovn
#define stricmp strcmpi