From caaecffc192df9721a5388d9bb4af8e41e88cddb Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Mon, 31 Mar 2014 17:14:16 +0000 Subject: [PATCH] WebView 1.0 Beta 5.5: View Source fixes & optimizations (thanks 0CodErr) git-svn-id: svn://kolibrios.org@4725 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/TWB/TWB.c | 5 ++--- programs/cmm/browser/WebView.c | 13 ++++++----- programs/cmm/browser/show_src.h | 40 +++++++++++++++++++-------------- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/programs/cmm/TWB/TWB.c b/programs/cmm/TWB/TWB.c index 4214df1c3..0c9c56c8d 100644 --- a/programs/cmm/TWB/TWB.c +++ b/programs/cmm/TWB/TWB.c @@ -169,9 +169,8 @@ void TWebBrowser::Parse(){ case '\9': if (pre_text) //шэрўх шф╕ь эр 0x0d { - tab_len=strlen(#line)/8; - tab_len=tab_len*8; - tab_len=8+tab_len-strlen(#line); + tab_len = strlen(#line) % 4; + if (!tab_len) tab_len = 4; for (j=0; j2) { DrawTitle(#header); return; } + if (Form.height<120) MoveSize(OLD,OLD,OLD,120); + if (Form.width<280) MoveSize(OLD,OLD,280,OLD); Draw_Window(); break; @@ -293,11 +298,6 @@ void SetElementSizes() void Draw_Window() { 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 { if (TAB_H) { @@ -389,6 +389,7 @@ void Scan(int id) OpenPage(); return; case 052: //F3 + WB1.list.first = 0; ShowSource(); WB1.Parse(); break; diff --git a/programs/cmm/browser/show_src.h b/programs/cmm/browser/show_src.h index 3b2faf720..fcc79b850 100644 --- a/programs/cmm/browser/show_src.h +++ b/programs/cmm/browser/show_src.h @@ -8,45 +8,49 @@ dword ShowSource() if (souce_mode) return; souce_mode = true; - new_buf_start = new_buf = malloc(bufsize*5); - strcat(new_buf, "
");
+	new_buf = malloc(bufsize*5);
+	new_buf_start = new_buf;
+	strcpy(new_buf, "");
+	if (strlen(#header)-strlen(#version)>0) header[strlen(#header)-strlen(#version)-2] = 0; else strcpy(#header, "Source");
+	strcat(new_buf, #header);
+	strcat(new_buf, "
");
+	new_buf += strlen(new_buf);
 	for (i=bufpointer; i<");
-					new_buf+=20;
+					strcpy(new_buf, "<");
+					new_buf+=21;
 					mode = COMMENT;
 				}
 				else
 				{
-					strcat(new_buf, "<");
-					new_buf+=20;
+					strcpy(new_buf, "<");
+					new_buf+=21;
 					mode = TAG;
 				}
 				break;
 			case '>':
 				if (mode == OPTION_VALUE) //fix non-closed quote in TAG
 				{
-					strcat(new_buf, """);
-					new_buf+=12;					
+					strcpy(new_buf, """);
+					new_buf+=13;					
 					mode = TAG;
 				}
 				if (mode == COMMENT) && (ESBYTE[i-1]=='-') && (ESBYTE[i-2]=='-')
 				{
-					strcat(new_buf, ">");
-					new_buf+=10;
+					strcpy(new_buf, ">");
+					new_buf+=11;
 					mode = TEXT;
 				}
 				if (mode == TAG)
 				{
-					strcat(new_buf, ">");
-					new_buf+=10;
+					strcpy(new_buf, ">");
+					new_buf+=11;
 					mode = TEXT;
 				}
 				break;
@@ -54,23 +58,25 @@ dword ShowSource()
 			case '\'':
 				if (mode == TAG)
 				{
-					strcat(new_buf, """);
+					strcpy(new_buf, "'");
 					new_buf+=22;
 					mode = OPTION_VALUE;
 					break;
 				}
 				if (mode == OPTION_VALUE)
 				{
-					strcat(new_buf, """);
+					strcpy(new_buf, "'");
 					new_buf+=12;
 					mode = TAG;
 					break;
 				}
 			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);
 	bufpointer = new_buf_start;
 }
\ No newline at end of file