WebView 1.93:

- handle the case when '&' is written as non special caracter like  
- handle emply lines of list to aboid more than 2 emply lines for better readability
- improve img tag display
- show colored background of all text in debug mode
- improve page display if no html or body tag but the page is still has tags to display


git-svn-id: svn://kolibrios.org@7749 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2020-03-23 15:53:56 +00:00
parent f53868d3c8
commit eaed653ad3
4 changed files with 39 additions and 24 deletions

View File

@ -96,6 +96,10 @@ void TWebBrowser::DrawStyle()
stolbec_len = strlen(#line) * zoom;
line_length = stolbec_len * list.font_w;
if (debug_mode) {
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h-1, 0xDDDddd);
}
if (style.bg_color!=page_bg) {
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h-1, style.bg_color);
}
@ -154,8 +158,10 @@ void TWebBrowser::Prepare(){
dword bufpos;
dword line_len;
SetPageDefaults();
if (strstri(bufpointer, "<html")==-1) style.pre = true; //show linebreaks for a plaint text
else if (strstri(bufpointer, "<body")==-1) t_body = true;
if (strstri(bufpointer, "<body")==-1) {
t_body = true;
if (strstri(bufpointer, "<html")==-1) style.pre = true; //show linebreaks for a plaint text
}
for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;)
{
bukva = ESBYTE[bufpos];
@ -180,14 +186,17 @@ void TWebBrowser::Prepare(){
}
goto DEFAULT_MARK;
case '&': //&nbsp; and so on
bufpos++;
tag=0;
for (j=0; (ESBYTE[bufpos]<>';') && (j<7); j++, bufpos++;)
for (j=1, tag=0; (ESBYTE[bufpos+j]<>';') && (j<8); j++)
{
bukva = ESBYTE[bufpos];
bukva = ESBYTE[bufpos+j];
chrcat(#tag, bukva);
}
if (bukva = GetUnicodeSymbol()) goto DEFAULT_MARK;
if (bukva = GetUnicodeSymbol(#tag)) {
bufpos += j;
} else {
bukva = '&';
}
goto DEFAULT_MARK;
break;
case '<':
bufpos++;
@ -224,7 +233,7 @@ void TWebBrowser::Prepare(){
sprintf(#tagparam, "</%s>", #tag);
j = strstri(bufpos, #tagparam);
if (j!=-1) {
bufpos = j;
bufpos = j-1;
}
tag = tagparam = NULL;
break;
@ -286,7 +295,7 @@ void TWebBrowser::Perenos()
}
//============================================================================================
void TWebBrowser::SetStyle() {
char img_path[4096];
char img_path[4096]=0;
int left1 = body_magrin + list.x;
int meta_encoding;
if (istag("html")) {
@ -396,14 +405,16 @@ void TWebBrowser::SetStyle() {
if (istag("img")) {
do{
if (isattr("src=")) strncpy(#img_path, #val, sizeof(img_path)-1);
if (isattr("alt=")) && (strlen(#val)<sizeof(line)-3) sprintf(#line, "[%s]", #val);
if (isattr("title=")) && (strlen(#val)<sizeof(line)-3) sprintf(#line, "[%s]", #val);
if (isattr("title=")) && (strlen(#val)<sizeof(line)-3) && (val) sprintf(#line, "[%s]", #val);
if (isattr("alt=")) && (strlen(#val)<sizeof(line)-3) && (val) sprintf(#line, "[%s]", #val);
} while(GetNextParam());
if (!img_path) return;
style.image = true;
text_color_index++;
text_colors[text_color_index] = 0x9A6F29;
if (!line) {
if (!strncmp(#img_path, "data:", 5)) img_path=0;
replace_char(#img_path, '?', NULL, strlen(#img_path));
sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/'));
line[50]= NULL;
}
@ -532,7 +543,10 @@ void TWebBrowser::NewLine()
if (!stolbec) && (draw_y==body_magrin) return;
if (!stolbec) {
if (style.li) && (stolbec == style.li_tab * 5) {
if (empty_line<1) empty_line++;
else return;
} else if (!stolbec) {
if (empty_line<1) empty_line++;
else return;
} else {

View File

@ -67,25 +67,25 @@ char *unicode_tags[]={
byte unicode_chars[] = "€亗儎厗噲墛媽崕彁憭摂晼棙櫄洔潪煚、¥ウЖ┆<EFBFBD><EFBFBD><EFBFBD>徕沅彐玷殛腱眍镳駂<EFBFBD>243i\105\244\0";
unsigned char GetUnicodeSymbol()
bool GetUnicodeSymbol(dword in_tag)
{
int j;
for (j=0; unicode_tags[j]!=0; j+=2;)
{
if (!strcmp(#tag, unicode_tags[j]))
if (!strcmp(in_tag, unicode_tags[j]))
{
strcat(#line, unicode_tags[j+1]);
return NULL;
return true;
}
}
j = atoi(#tag + 1) - 1040;
if (tag[1] == '1') && (j>=0) && (j<=72) && (strlen(#tag) == 5)
j = atoi(in_tag + 1) - 1040;
if (tag[1] == '1') && (j>=0) && (j<=72) && (strlen(in_tag) == 5)
{
return unicode_chars[j];
chrcat(#line, unicode_chars[j]);
return true;
}
strcat(#line,#tag); //âûâîäèì íà ýêðàí íåîáðàáîòàííûé òåã, òàê áðàóçåðû çà÷åì-òî äåëàþò
return NULL;
return false;
}

View File

@ -32,7 +32,7 @@ _http http = {0, 0, 0, 0, 0, 0, 0};
#ifdef LANG_RUS
char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 1.92";
char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 1.93";
#define T_LOADING "‡ £à㧪  áâà ­¨æë..."
#define T_RENDERING "<22>¥­¤¥à¨­£..."
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
@ -48,7 +48,7 @@ char link_menu[] =
"Š®¯¨à®¢ âì áá뫪ã
ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
#else
char version[]="Text-based Browser 1.9";
char version[]="Text-based Browser 1.93";
#define T_LOADING "Loading..."
#define T_RENDERING "Rendering..."
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";

View File

@ -14,6 +14,7 @@
// strcpy( EDI, ESI) --- 0 if ==
// strlcpy(dword text1,text2,signed length)
// strcat( EDI, ESI)
// chrcat(ESI, BL)
// strncat(dword text1,text2,signed length) --- pasting the text of a certain length
// strchr( ESI,BL) --- find first BL
// strrchr( ESI,BL) --- find last BL