From 7b61a5afa12e2ea2386f4ab358236c2c459a9685 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Fri, 27 Mar 2020 20:18:44 +0000 Subject: [PATCH] fix searchapp git-svn-id: svn://kolibrios.org@7756 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/TWB/TWB.c | 25 +++++--------- programs/cmm/TWB/img_cache.h | 8 +++-- programs/cmm/TWB/parce_tag.h | 4 +-- programs/cmm/browser/WebView.c | 50 +++++++++++++-------------- programs/cmm/browser/history.h | 2 +- programs/cmm/browser/show_src.h | 5 +-- programs/cmm/codeview/codeview.c | 4 +-- programs/system/searchap/searchap.asm | 25 +++++++------- 8 files changed, 58 insertions(+), 65 deletions(-) diff --git a/programs/cmm/TWB/TWB.c b/programs/cmm/TWB/TWB.c index f9512ba86f..fefe1217ac 100644 --- a/programs/cmm/TWB/TWB.c +++ b/programs/cmm/TWB/TWB.c @@ -39,29 +39,25 @@ struct TWebBrowser { void BufEncode(); } WB1; +dword page_bg; +#include "..\TWB\img_cache.h" + dword link_color_inactive; dword link_color_active; -dword page_bg; -bool - link, - cur_encoding, - t_html, - t_body; +bool link, cur_encoding, t_html, t_body; -#include "..\TWB\img_cache.h" #include "..\TWB\links.h" dword bufpointer=0; dword bufsize=0; +char header[150]; + int body_magrin=6; int basic_line_h=22; -char header[150]; -char oldtag[100]; - -scroll_bar scroll_wv = { 15,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; +scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,15,0,0xeeeeee,0xBBBbbb,0xeeeeee}; //============================================================================================ void TWebBrowser::DrawStyle() @@ -251,7 +247,6 @@ void TWebBrowser::ParseHtml(){ DrawStyle(); if (tag.name) SetStyle(); } - strncpy(#oldtag, #tag.name, sizeof(oldtag)-1); break; default: AddCharToTheLine(ESBYTE[bufpos]); @@ -375,9 +370,8 @@ void TWebBrowser::SetStyle() { return; } if (tag.is("div")) { - if (streq(#oldtag,"div")) && (tag.opened) return; + if (streq(#tag.prior,"div")) && (tag.opened) return; NewLine(); - //IF (oldtag[0] != 'h') return; } if (tag.is("header")) || (tag.is("article")) || (tag.is("footer")) || (tag.is("figure")) { @@ -385,9 +379,8 @@ void TWebBrowser::SetStyle() { return; } if (tag.is("p")) { - IF (oldtag[0] == 'h') || (streq(#oldtag,"td")) || (streq(#oldtag,"p")) return; + IF (tag.prior[0] == 'h') || (streq(#tag.prior,"td")) || (streq(#tag.prior,"p")) return; NewLine(); - //IF(tag.opened) NewLine(); return; } if (tag.is("br")) { NewLine(); return; } diff --git a/programs/cmm/TWB/img_cache.h b/programs/cmm/TWB/img_cache.h index bd3e521929..3f2be1acb3 100644 --- a/programs/cmm/TWB/img_cache.h +++ b/programs/cmm/TWB/img_cache.h @@ -69,12 +69,14 @@ void ImageCache::Images(dword left1, top1, width1) img_draw stdcall (pics[cur_pic].image, left1-5, top1, imgw, imgh,0,img_lines_first); DrawBar(left1+imgw - 5, top1, WB1.list.w-imgw, imgh, page_bg); DrawBar(WB1.list.x, top1+imgh, WB1.list.w, -imgh % WB1.list.item_h + WB1.list.item_h, page_bg); + /* if (link) { - //UnsafeDefineButton(left1 - 5, top1, imgw, imgh-1, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9); - //PageLinks.AddText(0, imgw, imgh-1, NOLINE, 1); - //WB1.DrawPage(); + UnsafeDefineButton(left1 - 5, top1, imgw, imgh-1, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9); + PageLinks.AddText(0, imgw, imgh-1, NOLINE, 1); + WB1.DrawPage(); } + */ } ImageCache ImgCache; \ No newline at end of file diff --git a/programs/cmm/TWB/parce_tag.h b/programs/cmm/TWB/parce_tag.h index e00ad092d9..e67347eff0 100644 --- a/programs/cmm/TWB/parce_tag.h +++ b/programs/cmm/TWB/parce_tag.h @@ -2,6 +2,7 @@ struct _tag { char name[32]; + char prior[32]; char params[5000]; bool opened; collection attributes; @@ -25,12 +26,11 @@ bool _tag::is(dword _text) bool _tag::reset() { if (!name) return false; + strcpy(#prior, #name); name = NULL; opened = true; attributes.drop(); values.drop(); - attributes.add("ZERO"); - values.add("NULL"); return true; } diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index 95b60abc7e..e1c5e70dd0 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -58,7 +58,7 @@ char link_menu[] = Download link contents"; #endif -#define URL_SIZE 4000; +#define URL_SIZE 4000 dword col_bg = 0xE3E2E2; dword panel_color = 0xE3E2E2; @@ -400,25 +400,23 @@ void StopLoading() DrawOmnibox(); } -/* -void ReplaceSpaceInUrl() { - int i; - char new_url[URL_SIZE]; - strcpy(#new_url, history.current()); - while (i = strchr(#new_url, ' ')) - { - i -= #new_url; - strlcpy(#new_url+i+3, #new_url+i+1, URL_SIZE); - URL[i] = '%'; - URL[i+1] = '2'; - URL[i+2] = '0'; - } - strcpy(#editURL, #new_url); -} - +//rewrite into //bool strrpl(dword dst, from, to, dst_len); !!!!!!!! - -*/ +void ReplaceSpaceInUrl(dword url, size) { + unsigned int i, j; + for (i=size-3; i>0; i--) + { + if (ESBYTE[i]!=' ') continue; + for (j=size-3; j>i; j--) { + ESBYTE[j+2]=ESBYTE[j+1]; + ESBYTE[j+1]=ESBYTE[j]; + } + ESBYTE[i] = '%'; + ESBYTE[i+1] = '2'; + ESBYTE[i+2] = '0'; + } + debugln(url); +} bool GetLocalFileData(dword _path) { @@ -461,10 +459,10 @@ void OpenPage(dword _open_URL) else LoadInternalPage(#page_not_found, sizeof(page_not_found)); } else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) { //WEB PAGE - //ReplaceSpaceInUrl(); !!!!!!!! img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 85, SKIN_Y); + //ReplaceSpaceInUrl(#new_url, URL_SIZE); if (!strncmp(#new_url,"http:",5)) { http.get(#new_url); } else if (!strncmp(#new_url,"https://",8)) { @@ -486,7 +484,7 @@ void OpenPage(dword _open_URL) void EventClickLink(dword _click_URL) { - char new_url[URL_SIZE]; + char new_url[URL_SIZE+1]; if (ESBYTE[_click_URL]=='#') { if (anchors.get_pos_by_name(_click_URL+1)!=-1) { @@ -585,10 +583,6 @@ void DrawOmnibox() void LoadInternalPage(dword _bufdata, _in_bufsize){ if (!_bufdata) || (!_in_bufsize) { LoadInternalPage(#page_not_found, sizeof(page_not_found)); - } else if (source_mode) { - source_mode = false; - //WB1.ParseHtml(); - ShowSource(_bufdata, _in_bufsize); } else { bufsize = _in_bufsize; if (bufpointer!=_bufdata) free(bufpointer); @@ -600,6 +594,12 @@ void LoadInternalPage(dword _bufdata, _in_bufsize){ strcat(#editURL, #anchors.current); DrawOmnibox(); } + if (source_mode) { + source_mode = false; + WB1.ParseHtml(); + ShowSource(bufpointer, bufsize); + return; + } WB1.ParseHtml(); WB1.DrawPage(); } diff --git a/programs/cmm/browser/history.h b/programs/cmm/browser/history.h index 8add45fc56..5eb2926b86 100644 --- a/programs/cmm/browser/history.h +++ b/programs/cmm/browser/history.h @@ -30,7 +30,7 @@ ShowHistory() free(history_pointer); history_pointer = malloc(history.items.data_size+256); strcat(history_pointer, HISTORY_HEADER); - for (i=0; iSource: "); - SourceBufAdd(TEXT, #header); - SourceBufAdd(TEXT, "
");
+	SourceBufAdd(TEXT, "View Source
");
 
 	for (i=_bufdata; i<_bufdata+_in_bufsize; i++) switch (ESBYTE[i])
 	{
diff --git a/programs/cmm/codeview/codeview.c b/programs/cmm/codeview/codeview.c
index 7b2deeb1aa..6faac5c3cc 100644
--- a/programs/cmm/codeview/codeview.c
+++ b/programs/cmm/codeview/codeview.c
@@ -54,8 +54,8 @@ enum {
 #include "..\TWB\TWB.c"
 #include "show_src.h"
 
-char URL[URL_SIZE];
-char editURL[URL_SIZE];
+char URL[URL_SIZE+1];
+char editURL[URL_SIZE+1];
 int	mouse_twb;
 edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,URL_SIZE-2,#editURL,#mouse_twb,2,19,19};
 
diff --git a/programs/system/searchap/searchap.asm b/programs/system/searchap/searchap.asm
index 4b519a1b95..ccbc1e2e2a 100644
--- a/programs/system/searchap/searchap.asm
+++ b/programs/system/searchap/searchap.asm
@@ -105,9 +105,16 @@ START:
 	jmp	.convert
 .converted:
 	mov	[delay], ecx
+;--------------------------------------
+	DEBUGF	1, "Searchap: get basic file\n"
+	call	load_file	; download the master file
+	xor	eax,eax
+	cmp	[fs_error],eax
+	jne	exit
+	mov	eax,[fileinfo.size]
+	mov	[basic_file_size],eax
 .params_done:
 ;--------------------------------------
-	;mcall	5,[delay]	;first mount attempt without delay
 	mov	ebx,start_dir
 	mov	ax,[ebx]
 	mov	ebx,read_folder_name
@@ -117,15 +124,6 @@ START:
 	call	device_detect_f70
 ;--------------------------------------
 	call	print_retrieved_devices_table
-	DEBUGF	1, "Searchap: get basic file\n"
-;--------------------------------------
-	call	load_file	; download the master file
-	xor	eax,eax
-	cmp	[fs_error],eax
-	jne	exit
-	mov	eax,[fileinfo.size]
-	mov	[basic_file_size],eax
-
 	call	search_and_load_pointer_file_label
 ;---------------------------------------------------------------------
 exit:
@@ -137,6 +135,7 @@ exit:
 	cmp [mount_attempt], 1
 	je @f
 	mov [mount_attempt], 1 ;second mount attempt with delay
+	DEBUGF	2, "Searchap: second attempt after 5 seconds!\n"
 	mcall	5,[delay]
 	jmp START.params_done
 @@:
@@ -329,7 +328,8 @@ search_and_load_pointer_file_label:
 ;--------------------------------------
 	ret
 .sucess:
-	call	compare_files_and_mount
+	;call	compare_files_and_mount
+	call	compare_files_and_mount.mount_now ;no need to compare files content
 	cmp	[compare_flag],byte 0
 	jne	@b
 	cmp	[mount_dir],1
@@ -352,8 +352,9 @@ compare_files_and_mount:
 	jne	.not_match
 	dec	ecx
 	jnz	.next_char
-	mov	[compare_flag],byte 0
 	pop	esi ecx
+.mount_now:
+	mov	[compare_flag],byte 0
 ;--------------------------------------
 	DEBUGF	2, "Searchap: compare files - success!\n"
 	DEBUGF	2, "Searchap: mount directory: %s\n",esi