WebView 1.0 Beta 5.5: View Source fixes & optimizations (thanks 0CodErr)

git-svn-id: svn://kolibrios.org@4725 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2014-03-31 17:14:16 +00:00
parent fe79d0bc25
commit caaecffc19
3 changed files with 32 additions and 26 deletions

View File

@ -169,9 +169,8 @@ void TWebBrowser::Parse(){
case '\9': case '\9':
if (pre_text) //èíà÷å èä¸ì íà 0x0d if (pre_text) //èíà÷å èä¸ì íà 0x0d
{ {
tab_len=strlen(#line)/8; tab_len = strlen(#line) % 4;
tab_len=tab_len*8; if (!tab_len) tab_len = 4;
tab_len=8+tab_len-strlen(#line);
for (j=0; j<tab_len; j++;) chrcat(#line,' '); for (j=0; j<tab_len; j++;) chrcat(#line,' ');
break; break;
} }

View File

@ -29,7 +29,7 @@
char homepage[] = FROM "html\homepage.htm"; char homepage[] = FROM "html\homepage.htm";
#ifdef LANG_RUS #ifdef LANG_RUS
char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 1.0 Beta 5"; char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 1.0 Beta 5.5";
?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­" ?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤­¨© á« ©¤" ?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤­¨© á« ©¤"
char loading[] = "‡ £à㧪  áâà ­¨æë...<br>"; char loading[] = "‡ £à㧪  áâà ­¨æë...<br>";
@ -210,6 +210,11 @@ void main()
break; break;
case evReDraw: case evReDraw:
if (action_buf) Scan(action_buf); if (action_buf) Scan(action_buf);
DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,col_bg,0,0);
GetProcessInfo(#Form, SelfInfo);
if (Form.status_window>2) { DrawTitle(#header); return; }
if (Form.height<120) MoveSize(OLD,OLD,OLD,120);
if (Form.width<280) MoveSize(OLD,OLD,280,OLD);
Draw_Window(); Draw_Window();
break; break;
@ -293,11 +298,6 @@ void SetElementSizes()
void Draw_Window() void Draw_Window()
{ {
int img_off; int img_off;
DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,col_bg,0,0);
GetProcessInfo(#Form, SelfInfo);
if (Form.status_window>2) { DrawTitle(#header); return; }
if (Form.height<120) MoveSize(OLD,OLD,OLD,120);
if (Form.width<280) MoveSize(OLD,OLD,280,OLD);
// tab { // tab {
if (TAB_H) if (TAB_H)
{ {
@ -389,6 +389,7 @@ void Scan(int id)
OpenPage(); OpenPage();
return; return;
case 052: //F3 case 052: //F3
WB1.list.first = 0;
ShowSource(); ShowSource();
WB1.Parse(); WB1.Parse();
break; break;

View File

@ -8,45 +8,49 @@ dword ShowSource()
if (souce_mode) return; if (souce_mode) return;
souce_mode = true; souce_mode = true;
new_buf_start = new_buf = malloc(bufsize*5); new_buf = malloc(bufsize*5);
strcat(new_buf, "<pre>"); new_buf_start = new_buf;
strcpy(new_buf, "<html><head><title>");
if (strlen(#header)-strlen(#version)>0) header[strlen(#header)-strlen(#version)-2] = 0; else strcpy(#header, "Source");
strcat(new_buf, #header);
strcat(new_buf, "</title><body><pre>");
new_buf += strlen(new_buf);
for (i=bufpointer; i<bufpointer+bufsize; i++) for (i=bufpointer; i<bufpointer+bufsize; i++)
{ {
ww = ESBYTE[i]; ww = ESBYTE[i];
new_buf++;
switch (ww) switch (ww)
{ {
case '<': case '<':
if (ESBYTE[i+1]=='!') && (ESBYTE[i+2]=='-') && (ESBYTE[i+3]=='-') if (ESBYTE[i+1]=='!') && (ESBYTE[i+2]=='-') && (ESBYTE[i+3]=='-')
{ {
strcat(new_buf, "<font color=#ccc>&lt;"); strcpy(new_buf, "<font color=#ccc>&lt;");
new_buf+=20; new_buf+=21;
mode = COMMENT; mode = COMMENT;
} }
else else
{ {
strcat(new_buf, "<font color=#00f>&lt;"); strcpy(new_buf, "<font color=#00f>&lt;");
new_buf+=20; new_buf+=21;
mode = TAG; mode = TAG;
} }
break; break;
case '>': case '>':
if (mode == OPTION_VALUE) //fix non-closed quote in TAG if (mode == OPTION_VALUE) //fix non-closed quote in TAG
{ {
strcat(new_buf, "&quot;</font>"); strcpy(new_buf, "&quot;</font>");
new_buf+=12; new_buf+=13;
mode = TAG; mode = TAG;
} }
if (mode == COMMENT) && (ESBYTE[i-1]=='-') && (ESBYTE[i-2]=='-') if (mode == COMMENT) && (ESBYTE[i-1]=='-') && (ESBYTE[i-2]=='-')
{ {
strcat(new_buf, "&gt;</font>"); strcpy(new_buf, "&gt;</font>");
new_buf+=10; new_buf+=11;
mode = TEXT; mode = TEXT;
} }
if (mode == TAG) if (mode == TAG)
{ {
strcat(new_buf, "&gt;</font>"); strcpy(new_buf, "&gt;</font>");
new_buf+=10; new_buf+=11;
mode = TEXT; mode = TEXT;
} }
break; break;
@ -54,23 +58,25 @@ dword ShowSource()
case '\'': case '\'':
if (mode == TAG) if (mode == TAG)
{ {
strcat(new_buf, "<font color=#f0f>&quot;"); strcpy(new_buf, "<font color=#f0f>&#39;");
new_buf+=22; new_buf+=22;
mode = OPTION_VALUE; mode = OPTION_VALUE;
break; break;
} }
if (mode == OPTION_VALUE) if (mode == OPTION_VALUE)
{ {
strcat(new_buf, "&quot;</font>"); strcpy(new_buf, "&#39;</font>");
new_buf+=12; new_buf+=12;
mode = TAG; mode = TAG;
break; break;
} }
default: default:
chrcat(new_buf, ww); ESBYTE[new_buf] = ww;
new_buf++;
} }
} }
bufsize = new_buf; ESBYTE[new_buf] = 0;
bufsize = new_buf - new_buf_start;
free(bufpointer); free(bufpointer);
bufpointer = new_buf_start; bufpointer = new_buf_start;
} }