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

View File

@ -25,7 +25,7 @@ void ImageCache::Free()
int ImageCache::GetImageNumber(dword i_path) int ImageCache::GetImageNumber(dword i_path)
{ {
int i; 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 // Load image and add it to Cache
pics_count++; pics_count++;
pics[pics_count].image = load_image(i_path); 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); 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); 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; ImageCache ImgCache;

View File

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

View File

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

View File

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

View File

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