From cdfc1d7c00066a917591693cd6349eca9260796b Mon Sep 17 00:00:00 2001 From: pavelyakov Date: Thu, 30 Jul 2015 15:49:09 +0000 Subject: [PATCH] mouse_cfg: speed x>=1 lexer.h : alloc tokens git-svn-id: svn://kolibrios.org@5631 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/browser/WebView.c | 90 +++++++----------- programs/cmm/browser/menu_rmb.h | 6 +- programs/cmm/browser/show_src.h | 5 +- programs/cmm/eolite/Eolite.c | 2 - programs/cmm/eolite/include/icons.h | 2 +- programs/cmm/eolite/include/left_panel.h | 2 +- programs/cmm/eolite/include/sorting.h | 9 +- programs/cmm/lib/dll.h | 34 ++++--- programs/cmm/lib/file_system.h | 10 +- programs/cmm/lib/kolibri.h | 1 - programs/cmm/lib/lexer.h | 112 +++++++++++++++++++++-- programs/cmm/lib/obj/http.h | 1 + programs/cmm/mouse_cfg/mouse_cfg.c | 2 +- 13 files changed, 176 insertions(+), 100 deletions(-) diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index e58bf8222e..869d88bc62 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -9,13 +9,11 @@ //libraries #define MEMSIZE 0x100000 -#include "..\lib\kolibri.h" #include "..\lib\strings.h" #include "..\lib\gui.h" #include "..\lib\encoding.h" #include "..\lib\file_system.h" #include "..\lib\mem.h" -#include "..\lib\dll.h" #include "..\lib\draw_buf.h" #include "..\lib\list_box.h" #include "..\lib\cursor.h" @@ -47,6 +45,8 @@ char homepage[] = FROM "html\\homepage.htm"; char accept_language[]= "Accept-Language: en\n"; #endif + + proc_info Form; #define WIN_W 799 #define WIN_H 559 @@ -141,8 +141,7 @@ void main() CreateDir("/tmp0/1/downloads"); SetEventMask(0xa7); - loop() - { + BEGIN_LOOP_APPLICATION: WaitEventTimeout(2); switch(EAX & 0xFF) { @@ -156,13 +155,8 @@ void main() //Menu if (m.y>WB1.list.y) && (m.yWB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible; - if (btn<>WB1.list.first) WB1.Parse(); + if (btn!=WB1.list.first) WB1.Parse(); } break; case evButton: @@ -203,7 +197,7 @@ void main() if (address_box.flags & 0b10) { if (key==ASCII_KEY_ENTER) Scan(key); else - if (key<>0x0d) && (key<>183) && (key<>184) {EAX=key<<8; edit_box_key stdcall(#address_box);} + if (key!=0x0d) && (key!=183) && (key!=184) {EAX=key<<8; edit_box_key stdcall(#address_box);} } else Scan(key); break; @@ -282,7 +276,7 @@ void main() } } } - } + goto BEGIN_LOOP_APPLICATION; } void SetElementSizes() @@ -382,7 +376,7 @@ void Scan(int id) case 006: //download manager if (!downloader_opened) { - strcpy(#DL_URL, "http://"); + strncpy(#DL_URL, "http://",7); CreateThread(#Downloader,#downloader_stak+4092); } return; @@ -402,15 +396,12 @@ void Scan(int id) WB1.Parse(); break; case 053: //F4 - if (strncmp(#URL,"http:",5)==0) + if (!strncmp(#URL,"http:",5)) { WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm"); - if (EAX==0) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); - } - else - { - RunProgram("/rd/1/tinypad", #URL); + if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); } + else RunProgram("/rd/1/tinypad", #URL); return; case 054: //F5 IF(address_box.flags & 0b10) return; @@ -431,18 +422,14 @@ void Scan(int id) case GOTOURL: case 0x0D: //enter if (!editURL[0]) return; - if ((strncmp(#editURL,"http:",5)!=0) && (editURL[0]!='/') && ((strncmp(#editURL,"WebView:",8)!=0)) - { - strcpy(#URL,"http://"); - } + if (strncmp(#editURL,"http:",5)) && (editURL[0]!='/') && (strncmp(#editURL,"WebView:",9)) strncpy(#URL,"http://",7); else URL[0] = 0; strcat(#URL, #editURL); OpenPage(); return; case SEARCHWEB: - strcpy(#URL, #search_path); - strcat(#URL, #editURL); + sprintf(#URL,"%s%s",#search_path,#editURL); OpenPage(); return; @@ -511,11 +498,11 @@ void ProcessLinks(int id) if (URL[0] == '$') { if (URL[1]=='-') && (condition_href) condition_href--; - if (URL[1]=='+') + else if (URL[1]=='+') { if (condition_href0) + if (http_transfer) { EAX = http_transfer; EAX = EAX.http_msg.content_ptr; // get pointer to data $push EAX // save it on the stack http_free stdcall (http_transfer); // abort connection $pop EAX - mem_Free(EAX); // free data + free(EAX); // free data http_transfer=0; bufsize = 0; - bufpointer = mem_Free(bufpointer); + bufpointer = free(bufpointer); } wv_progress_bar.value = 0; img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 52, 0); @@ -602,29 +586,23 @@ void OpenPage() souce_mode = false; strcpy(#editURL, #URL); BrowserHistory.AddUrl(); - if (strncmp(#URL,"WebView:",8)==0) + if (!strncmp(#URL,"WebView:",8)) { SetPageDefaults(); - if (strcmp(#URL, URL_SERVICE_HOME)==0) - { - WB1.Prepare(#homepage, sizeof(homepage)); - } - if (strcmp(#URL, URL_SERVICE_HISTORY)==0) - { - ShowHistory(); - } + if (!strcmp(#URL, URL_SERVICE_HOME)) WB1.Prepare(#homepage, sizeof(homepage)); + else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory(); return; } - if (strncmp(#URL,"http:",5)==0) + if (!strncmp(#URL,"http:",5)) { img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 131, 0); http_get stdcall (#URL, 0, 0, #accept_language); http_transfer = EAX; - if (http_transfer == 0) + if (!http_transfer) { StopLoading(); bufsize = 0; - bufpointer = mem_Free(bufpointer); + bufpointer = free(bufpointer); ShowPage(); return; } @@ -635,8 +613,8 @@ void OpenPage() bufsize = EBX; if (bufsize) { - mem_Free(bufpointer); - bufpointer = mem_Alloc(bufsize); + free(bufpointer); + bufpointer = malloc(bufsize); SetPageDefaults(); ReadFile(0, bufsize, bufpointer, #URL); //ShowSource(); @@ -659,7 +637,7 @@ void ShowPage() if (!bufsize) { PageLinks.Clear(); - if (http_transfer<>0) + if (http_transfer) { WB1.Prepare(#loading, sizeof(loading)); } @@ -675,12 +653,10 @@ void ShowPage() byte UrlExtIs(dword ext) { - if (strcmpi(#URL + strlen(#URL) - strlen(ext), ext)==0) return 1; else return 0; + if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true; + return false; } - - -stop: - char downloader_stak[4096]; +stop: \ No newline at end of file diff --git a/programs/cmm/browser/menu_rmb.h b/programs/cmm/browser/menu_rmb.h index 3e232cf25b..b60721a009 100644 --- a/programs/cmm/browser/menu_rmb.h +++ b/programs/cmm/browser/menu_rmb.h @@ -35,7 +35,8 @@ void menu_rmb() menu.SetSizes(2,2,177,menu.count*19,0,19); SetEventMask(100111b); - loop() switch(WaitEvent()) + _BEGIN_APPLICATION_MENU: + switch(WaitEvent()) { case evMouse: GetProcessInfo(#MenuForm, SelfInfo); @@ -43,7 +44,7 @@ void menu_rmb() mm.get(); if (menu.ProcessMouse(mm.x, mm.y)) DrawMenuList(); - if (mm.lkm) || (mm.pkm) { action_buf = ITEMS_LIST[menu.current*2+1]; ExitProcess(); } + if (mm.lkm)&&(mm.up) { action_buf = ITEMS_LIST[menu.current*2+1]; ExitProcess(); } break; case evKey: @@ -62,6 +63,7 @@ void menu_rmb() DrawPopup(0,0,menu.w,menu.h+3,0, col_bg,border_color); DrawMenuList(); } + goto _BEGIN_APPLICATION_MENU; } void DrawMenuList() diff --git a/programs/cmm/browser/show_src.h b/programs/cmm/browser/show_src.h index 9977325fa3..5f1727c063 100644 --- a/programs/cmm/browser/show_src.h +++ b/programs/cmm/browser/show_src.h @@ -10,11 +10,8 @@ dword ShowSource() souce_mode = true; 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);
+	new_buf += sprintf(new_buf,"%s
",#header);
 	for (i=bufpointer; i17) && (strlen(extension)<9) WriteText(-strlen(extension)*font_half_width+Form.cwidth-120,yy+4,font_type,0,extension);
+	if (icon_n!=17) && (strlen(extension)<9) WriteText(-strlen(extension)*font_half_width+Form.cwidth-120,yy+4,font_type,0,extension);
 }
 
 
diff --git a/programs/cmm/eolite/include/left_panel.h b/programs/cmm/eolite/include/left_panel.h
index a5d1d51896..90821d1123 100644
--- a/programs/cmm/eolite/include/left_panel.h
+++ b/programs/cmm/eolite/include/left_panel.h
@@ -63,7 +63,7 @@ void Tip(int y, dword caption, id, arrow)
 	DrawBar(17,y,160,1,0xEFEDEE);
 	DrawFilledBar(17, y+1, 160, 16);
 	WriteText(25,y+5,0x80,sc.work_text,caption);
-	IF (id<>0) DefineButton(159,y+1,16,16,id+BT_HIDE+BT_NOFRAME,0); //arrow button
+	if (id) DefineButton(159,y+1,16,16,id+BT_HIDE+BT_NOFRAME,0); //arrow button
 	WriteText(165,y+5,0x80,sc.work_text,arrow); //arrow
 	DrawBar(17,y+17,160,1,sc.work_graph);
 }
diff --git a/programs/cmm/eolite/include/sorting.h b/programs/cmm/eolite/include/sorting.h
index e5b5bb3b2c..ce6964b2e9 100644
--- a/programs/cmm/eolite/include/sorting.h
+++ b/programs/cmm/eolite/include/sorting.h
@@ -33,15 +33,16 @@ void Sort_by_Type(int a, b)   // 
 		filename2 = file_mas[b]*304 + buf+72;
 
 		n=strlen(filename1)-1;
-		WHILE (n>0) && (ESBYTE[filename1+n]<>'.') n--;
+		WHILE (n>0) && (ESBYTE[filename1+n]!='.') n--;
 		if (n) ext1 = filename1+n+1; else ext1=0;
-		n=strlen(filename2)-1;
-		WHILE (n>0) && (ESBYTE[filename2+n]<>'.') n--;
+		n=strlen(filename2);
+		n--;
+		WHILE (n>0) && (ESBYTE[filename2+n]!='.') n--;
 		if (n) ext2 = filename2+n+1; else ext2=0;
 
 		n=strcmp(ext1, ext2);
 		if (n<0) { file_mas[isn] >< file_mas[j];   isn++;} 
-		if (n==0) && (strcmp(filename1, filename2)<=0) { file_mas[isn] >< file_mas[j];   isn++;}
+		if (!n) && (strcmp(filename1, filename2)<=0) { file_mas[isn] >< file_mas[j];   isn++;}
 	}
 	Sort_by_Type(a, isn-2);
 	Sort_by_Type(isn, b);
diff --git a/programs/cmm/lib/dll.h b/programs/cmm/lib/dll.h
index f84c399d2c..d95fc294d0 100644
--- a/programs/cmm/lib/dll.h
+++ b/programs/cmm/lib/dll.h
@@ -1,25 +1,24 @@
 #ifndef INCLUDE_DLL_H
 #define INCLUDE_DLL_H
 
-#ifndef INCLUDE_KOLIBRI_H
+#ifndef INCLUDE_FILESYSTEM_H
 #include "../lib/file_system.h"
 #endif
 
+#ifdef LANG_RUS
+	#define _TEXT_ERROR_ADD "'Žè¨¡ª  ¯à¨ § £à㧪¥ ¡¨¡«¨®â¥ª¨"
+#elif LANG_EST
+	#define _TEXT_ERROR_ADD "'Viga teegi laadimisel"
+#else
+	#define _TEXT_ERROR_ADD "'Error while loading library"
+#endif
 
 char a_libdir[43]  = "/sys/lib/\0";
 
 :inline void error_init(dword text)
 {
 	dword TEXT_ERROR = malloc(1024);
-	#ifdef LANG_RUS
-		strcpy(TEXT_ERROR,"'Žè¨¡ª  ¯à¨ § £à㧪¥ ¡¨¡«¨®â¥ª¨ `");
-	#elif LANG_EST
-		strcpy(TEXT_ERROR,"'Viga teegi laadimisel `");
-	#else
-		strcpy(TEXT_ERROR,"'Error while loading library `");
-	#endif
-	strcat(TEXT_ERROR,text);
-	strcat(TEXT_ERROR,"`' -E");
+	sprintf("%s `%s`' -E",_TEXT_ERROR_ADD,text);
 	notify(TEXT_ERROR);
 	free(TEXT_ERROR);
 }
@@ -118,9 +117,9 @@ asm {
         push    ebp
         mov     ebp, esp
         pushad
-        mov     eax, #mem_Alloc
-        mov     ebx, #mem_Free;
-        mov     ecx, #mem_ReAlloc;
+        mov     eax, #malloc
+        mov     ebx, #free;
+        mov     ecx, #realloc;
         mov     edx, #dll_Load;
         call    SSDWORD[EBP+8]
         popad
@@ -239,9 +238,14 @@ int load_dll2(dword dllname, import_table, byte need_init)
         return -1;
 }
 
-void load_dll(dword dllname, import_table, byte need_init)
+byte load_dll(dword dllname, import_table, byte need_init)
 {
-	if (load_dll2(dllname, import_table, need_init)!=0) error_init(dllname);
+	if (load_dll2(dllname, import_table, need_init))
+	{
+		error_init(dllname);
+		return false;
+	}
+	return true;
 }
 
 
diff --git a/programs/cmm/lib/file_system.h b/programs/cmm/lib/file_system.h
index 1267fabc91..9c984c4ee8 100644
--- a/programs/cmm/lib/file_system.h
+++ b/programs/cmm/lib/file_system.h
@@ -291,11 +291,6 @@ enum
 	return error;
 }
 
-:dword notify(dword notify_param)
-{
-	return RunProgram("@notify", notify_param);
-}
-
 :dword abspath(dword relative_path) //GetAbsolutePathFromRelative()
 {
 	char absolute_path[4096];
@@ -324,7 +319,10 @@ enum
   sprintf(#ConvertSize_size_prefix,"%d %s",bytes,#size_nm);
   return #ConvertSize_size_prefix;
 }
-
+:dword notify(dword notify_param)
+{
+	return RunProgram("@notify", notify_param);
+}
 :dword ConvertSizeToKb(unsigned int bytes)
 {
 	unsigned char size[25]=0;
diff --git a/programs/cmm/lib/kolibri.h b/programs/cmm/lib/kolibri.h
index adea342ded..e09ae5894e 100644
--- a/programs/cmm/lib/kolibri.h
+++ b/programs/cmm/lib/kolibri.h
@@ -826,7 +826,6 @@ inline fastcall dword GetStartTime()
 	$int 0x40
 }
 
-
 :dword X_EventRedrawWindow,Y_EventRedrawWindow;
 :void _EventRedrawWindow()
 {
diff --git a/programs/cmm/lib/lexer.h b/programs/cmm/lib/lexer.h
index a41c356d51..6edc224225 100644
--- a/programs/cmm/lib/lexer.h
+++ b/programs/cmm/lib/lexer.h
@@ -4,9 +4,14 @@
 #ifndef INCLUDE_STRING_H
 #include "../lib/strings.h"
 #endif
+
+#ifndef INCLUDE_MEM_H
+#include "../lib/mem.h"
+#endif
 /** Splits text into tokens
  *  Author  :Pavel Yakovlev
  *  Homepage:https://vk.com/pavelyakov39
+ *  Ver.    : 1.51
  */
 
 /** Example:
@@ -49,18 +54,75 @@
 :struct lexer
 {
 	byte cmd;
-	dword token,text;
+	dword token,text,mem_list,count,buffer_loading;
+	dword str_buffer;
 	byte type;
 	char quote;
-	signed count,length;
+	signed length;
 	dword next(void);
 	dword back(void);
+	dword list(void);
+	void free(void);
+	dword position(dword __);
 	void load(dword _text);
 	void expected(dword _text);
 };
-
-
-:void expected(dword _text)
+:dword back(void)
+{
+	
+}
+:dword lexer::list(void)
+{
+	dword count_mem,buf_loop,pos;
+	count_mem = 0;
+	buf_loop  = 5000; // на Ñ‚Ñ‹Ñ Ñлементов.
+	count = 0;
+	buffer_loading = malloc(buf_loop);
+	pos = buffer_loading;
+	while(type!=LEX_END)
+	{
+		pos+=count_mem;
+		next();
+		DSDWORD[pos] = strndup(token,length);
+		pos+=4;
+		DSBYTE [pos] = type;
+		pos++;
+		count++;
+		if(pos-buffer_loading>buf_loop)
+		{
+			buf_loop*=2;
+			buffer_loading = realloc(buffer_loading,buf_loop);
+		}
+	}
+	return buffer_loading;
+}
+:void lexer::free(void)
+{
+	dword z;
+	z = count;
+	while(z)
+	{
+		z--;
+		position(z);
+		::free(token);
+	}
+	count = 0;
+	::free(buffer_loading);
+}
+:dword lexer::position(dword __)
+{
+	dword pos1;
+	if(!count)list();
+	if(__>=count)__=count-1;
+	else if(__<0)__=0;
+	pos1 = __*5;
+	pos1 += buffer_loading;
+	token = DSDWORD[pos1];
+	pos1++;
+	type = DSBYTE[pos1];
+	return token;
+}
+:void lexer::expected(dword _text)
 {
 	notify(_text);
 	ExitProcess();
@@ -69,15 +131,19 @@
 :void lexer::load(dword _text)
 {
 	text = _text;
+	count = 0;
+	str_buffer = 0;
 }
 
 :dword lexer::next(void)
 {
 	char s;
+	dword len_str_buf,tmp;
 	dword pos,in;
 	pos = #const_token_lexer;
 	in = text;
-	
+	//len_str_buf = 1024;
+	if(str_buffer)::free(str_buffer);
 	NEXT_TOKEN:
 	length = 0;
 	loop()
@@ -184,6 +250,7 @@
 	{
 		quote = s;
 		in++;
+		tmp = in;
 		s = DSBYTE[in];
 		loop()
 		{
@@ -210,9 +277,42 @@
 			DSBYTE[pos] = s;
 			pos++;
 			in++;
+			/*if(in-tmp>len_str_buf)
+			{
+				if(str_buffer)
+				{
+					tmp = len_str_buf;
+					len_str_buf+=1024;
+					str_buffer = realloc(str_buffer,len_str_buf+1);
+					strlcpy(str_buffer+tmp,#const_token_lexer,1024);
+					pos = #const_token_lexer;
+				}
+				else {
+					len_str_buf+=1024;
+					str_buffer = malloc(len_str_buf+1);
+					strlcpy(str_buffer,#const_token_lexer,1024);
+					pos = #const_token_lexer;
+				}
+			}*/
 			s = DSBYTE[in];
 		}
 		in++;
+		/*tmp = pos-in;
+		if(str_buffer)
+		{
+			if(tmp)
+			{
+				str_buffer = realloc(str_buffer,tmp+1);
+				strlcpy(str_buffer+len_str_buf,#const_token_lexer,tmp);
+			}
+			type = LEX_STR;
+			length = len_str_buf+tmp;
+			text = in;
+			tmp = str_buffer+length;
+			DSBYTE[tmp] = 0;
+			token = str_buffer;
+			return token;
+		}*/
 		type = LEX_STR;
 	}
 	else {
diff --git a/programs/cmm/lib/obj/http.h b/programs/cmm/lib/obj/http.h
index 40e6df259c..6ae57eaea6 100644
--- a/programs/cmm/lib/obj/http.h
+++ b/programs/cmm/lib/obj/http.h
@@ -10,6 +10,7 @@
 #include "../lib/dll.h"
 #endif
 
+dword NOT_INIT_LIBHTTP = true;
 dword libHTTP = #alibHTTP;
 char alibHTTP[23] = "/sys/lib/http.obj\0";
 
diff --git a/programs/cmm/mouse_cfg/mouse_cfg.c b/programs/cmm/mouse_cfg/mouse_cfg.c
index 0efd373138..2ce65356e8 100644
--- a/programs/cmm/mouse_cfg/mouse_cfg.c
+++ b/programs/cmm/mouse_cfg/mouse_cfg.c
@@ -107,7 +107,7 @@ void main() {
 					mouse_cfg.pointer_speed++;
 					SetMouseSpeed(mouse_cfg.pointer_speed);
 				}
-				if (id==121) && (mouse_cfg.pointer_speed>0)
+				if (id==121) && (mouse_cfg.pointer_speed>1)
 				{
 					mouse_cfg.pointer_speed--;
 					SetMouseSpeed(mouse_cfg.pointer_speed);