WebView: fix <pre> tag process, fix definition of <html> tag in document

git-svn-id: svn://kolibrios.org@6783 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2016-12-04 18:51:23 +00:00
parent d04f47d335
commit 0580672a6c
4 changed files with 17 additions and 18 deletions

View File

@ -46,7 +46,6 @@ dword text_color_index;
dword link_color_inactive; dword link_color_inactive;
dword link_color_active; dword link_color_active;
dword bg_color; dword bg_color;
dword block_bg_color;
int stroka; int stroka;
int stolbec; int stolbec;
@ -80,7 +79,7 @@ void TWebBrowser::DrawStyle()
{ {
ChangeCharset("UTF-8", "CP866", #line); ChangeCharset("UTF-8", "CP866", #line);
strcpy(#header, #line); strcpy(#header, #line);
strcat(#header, " -"); strcat(#header, " - ");
strcat(#header, #version); strcat(#header, #version);
line = 0; line = 0;
return; return;
@ -125,7 +124,7 @@ void TWebBrowser::Prepare(){
style.align = ALIGN_LEFT; style.align = ALIGN_LEFT;
link_color_inactive = 0x0000FF; link_color_inactive = 0x0000FF;
link_color_active = 0xFF0000; link_color_active = 0xFF0000;
bg_color = block_bg_color = 0xFFFFFF; bg_color = 0xFFFFFF;
DrawBuf.Fill(bg_color); DrawBuf.Fill(bg_color);
PageLinks.Clear(); PageLinks.Clear();
strcpy(#header, #version); strcpy(#header, #version);
@ -133,14 +132,16 @@ void TWebBrowser::Prepare(){
stolbec = 0; stolbec = 0;
line = 0; line = 0;
//for plaint text use CP866 for other UTF //for plaint text use CP866 for other UTF
if (strstri(bufpointer, "html")) if (strstri(bufpointer, "html")!=-1)
{ {
style.pre = 0; debugln("<html> found");
style.pre = false;
cur_encoding = CH_NULL; cur_encoding = CH_NULL;
} }
else else
{ {
style.pre = 1; debugln("no <html>");
style.pre = true;
cur_encoding = CH_NULL; cur_encoding = CH_NULL;
} }
for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;) for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;)
@ -153,9 +154,11 @@ void TWebBrowser::Prepare(){
if (style.pre) if (style.pre)
{ {
DrawStyle(); DrawStyle();
line = NULL;
NewLine(); NewLine();
break; break;
} }
goto DEFAULT_MARK;
case '\9': case '\9':
if (style.pre) //otherwise go to 0x0d if (style.pre) //otherwise go to 0x0d
{ {
@ -164,7 +167,7 @@ void TWebBrowser::Prepare(){
for (j=0; j<tab_len; j++;) chrcat(#line,' '); for (j=0; j<tab_len; j++;) chrcat(#line,' ');
break; break;
} }
goto DEFAULT_MARK; goto DEFAULT_MARK;
case '&': //&nbsp; and so on case '&': //&nbsp; and so on
bufpos++; bufpos++;
tag=0; tag=0;
@ -289,7 +292,7 @@ void TWebBrowser::SetStyle() {
if (isattr("text=")) text_colors[0]=GetColor(#val); if (isattr("text=")) text_colors[0]=GetColor(#val);
if (isattr("bgcolor=")) if (isattr("bgcolor="))
{ {
bg_color = block_bg_color = GetColor(#val); bg_color = GetColor(#val);
DrawBuf.Fill(bg_color); DrawBuf.Fill(bg_color);
} }
} while(GetNextParam()); } while(GetNextParam());
@ -329,10 +332,6 @@ void TWebBrowser::SetStyle() {
else if (text_color_index > 0) text_color_index--; else if (text_color_index > 0) text_color_index--;
return; return;
} }
if (istag("bg")) {
if (opened) {block_bg_color=GetColor(#val); NewLine();}
if (!opened) block_bg_color=bg_color;
}
if (istag("div")) || (istag("header")) || (istag("article")) || (istag("footer")) { if (istag("div")) || (istag("header")) || (istag("article")) || (istag("footer")) {
IF(oldtag[0] != 'h') NewLine(); IF(oldtag[0] != 'h') NewLine();
return; return;
@ -467,7 +466,6 @@ void TWebBrowser::NewLine()
onleft = list.x + 5; onleft = list.x + 5;
ontop = stroka * list.item_h + list.y + 5; ontop = stroka * list.item_h + list.y + 5;
if (t_html) && (!t_body) return; if (t_html) && (!t_body) return;
if (block_bg_color!=bg_color) DrawBuf.DrawBar(0, stroka+1*list.item_h+5, DrawBuf.bufw, list.item_h, block_bg_color);
if (stroka * list.item_h + 5 >= 0) && ( stroka + 1 * list.item_h + 5 < list.h) && (!anchor) if (stroka * list.item_h + 5 >= 0) && ( stroka + 1 * list.item_h + 5 < list.h) && (!anchor)
{ {
if (style.align == ALIGN_CENTER) && (DrawBuf.zoom==1) DrawBuf.AlignCenter(onleft,ontop,list.w,list.item_h,stolbec * list.font_w); if (style.align == ALIGN_CENTER) && (DrawBuf.zoom==1) DrawBuf.AlignCenter(onleft,ontop,list.w,list.item_h,stolbec * list.font_w);

View File

@ -30,7 +30,7 @@
char homepage[] = FROM "html\\homepage.htm""\0"; char homepage[] = FROM "html\\homepage.htm""\0";
#ifdef LANG_RUS #ifdef LANG_RUS
char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 1.55"; char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 1.56";
?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­" ?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤­¨© á« ©¤" ?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤­¨© á« ©¤"
char loading[] = "‡ £à㧪  áâà ­¨æë...<br>"; char loading[] = "‡ £à㧪  áâà ­¨æë...<br>";
@ -43,7 +43,7 @@ char rmb_menu[] =
Žç¨áâ¨âì ªíè ª à⨭®ª Žç¨áâ¨âì ªíè ª à⨭®ª
Œ¥­¥¤¦¥à § £à㧮ª"; Œ¥­¥¤¦¥à § £à㧮ª";
#else #else
char version[]="Text-based Browser 1.55"; char version[]="Text-based Browser 1.56";
?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...<br>"; char loading[] = "Loading...<br>";
@ -464,6 +464,7 @@ DrawEditBoxWebView()
void ShowPage() void ShowPage()
{ {
DrawEditBoxWebView(); DrawEditBoxWebView();
debugval("bufsize", bufsize);
if (!bufsize) if (!bufsize)
{ {
if (http_transfer) WB1.LoadInternalPage(#loading, sizeof(loading)); if (http_transfer) WB1.LoadInternalPage(#loading, sizeof(loading));

View File

@ -570,9 +570,9 @@ void DrawStatusBar()
int go_up_folder_exists=0; int go_up_folder_exists=0;
if (!show_status_bar) return; if (!show_status_bar) return;
if (files.count>0) && (strcmp(file_mas[0]*304+buf+72,"..")==0) go_up_folder_exists=1; if (files.count>0) && (strcmp(file_mas[0]*304+buf+72,"..")==0) go_up_folder_exists=1;
DrawBar(1, Form.cheight - status_bar_h-1, Form.cwidth-2, status_bar_h, col_work); DrawBar(1, Form.cheight - status_bar_h-1, Form.cwidth-2, status_bar_h, system.color.work);
sprintf(#status_bar_str, STATUS_STR, files.count-go_up_folder_exists, count_dir-go_up_folder_exists, files.count-count_dir, selected_count); sprintf(#status_bar_str, STATUS_STR, files.count-go_up_folder_exists, count_dir-go_up_folder_exists, files.count-count_dir, selected_count);
WriteText(6,Form.cheight - 13,0x80,0x000000,#status_bar_str); WriteText(6,Form.cheight - 13,0x80,system.color.work_text,#status_bar_str);
} }
void DrawFilePanels() void DrawFilePanels()

View File

@ -59,7 +59,7 @@ void Operation_Draw_Progress(dword filename) {
DisplayOperationForm(); DisplayOperationForm();
DrawIconByExtension(filename, filename+strrchr(filename,'.'), 16, 19, system.color.work); DrawIconByExtension(filename, filename+strrchr(filename,'.'), 16, 19, system.color.work);
DrawBar(45, 32, Dialog_Form.cwidth-45, 15, system.color.work); DrawBar(45, 32, Dialog_Form.cwidth-45, 15, system.color.work);
WriteText(45, 32, 0x90, 0x000000, filename); WriteText(45, 32, 0x90, system.color.work_text, filename);
progressbar_draw stdcall (#copy_bar); progressbar_draw stdcall (#copy_bar);
progressbar_progress stdcall (#copy_bar); progressbar_progress stdcall (#copy_bar);
//copy_bar.value++; //copy_bar.value++;