From 98eee705429e47b028d77a0de08a7b6e65df7688 Mon Sep 17 00:00:00 2001 From: pavelyakov Date: Sat, 11 Jul 2015 23:45:19 +0000 Subject: [PATCH] Fixed hover mouse Eolite. New features in Eolite (double-click). Also append new mouse events. git-svn-id: svn://kolibrios.org@5575 a494cfbc-eb01-0410-851d-a64ba20cac60 --- data/common/File Managers/eolite.ini | 1 + programs/cmm/eolite/Eolite.c | 36 +++++++++++++- programs/cmm/eolite/include/menu.h | 2 +- programs/cmm/eolite/include/settings.h | 3 +- programs/cmm/lib/kolibri.h | 38 +++++++++++---- programs/cmm/lib/random.h | 13 +++--- programs/cmm/lib/strings.h | 65 ++++++++++++++++++++++---- 7 files changed, 131 insertions(+), 27 deletions(-) diff --git a/data/common/File Managers/eolite.ini b/data/common/File Managers/eolite.ini index 659c0a6c10..3aed230773 100644 --- a/data/common/File Managers/eolite.ini +++ b/data/common/File Managers/eolite.ini @@ -4,3 +4,4 @@ LineHeight=18 ShowDeviceName=1 RealFileNamesCase=0 InfoAfterCopy=0 +TimeDoubleClick=100 \ No newline at end of file diff --git a/programs/cmm/eolite/Eolite.c b/programs/cmm/eolite/Eolite.c index 8ed75bef8d..18ca6b4f9d 100644 --- a/programs/cmm/eolite/Eolite.c +++ b/programs/cmm/eolite/Eolite.c @@ -257,7 +257,7 @@ void main() } } - + /* if (files.MouseOver(m.x, m.y)) && (!can_select) { m_selected = m.y - files.y / files.line_h; @@ -304,6 +304,40 @@ void main() break; } // } file menu + */ + + if (files.MouseOver(m.x, m.y))&&(m.up) + { + //select/open file { + if (m.key&MOUSE_LEFT) + { + if (m.y>=files.y)//&&(m.click) + { + id = m.y - files.y / files.line_h; + if (files.current!=id) + { + if (id=files.y)&&(m.click) + { + id = m.y - files.y / files.line_h; + if (files.current!=id) List_Current(id-files.current); + SwitchToAnotherThread(); + CreateThread(#FileMenu,#menu_stak+4092); + } + break; + } + // } file menu + } if (m.vert) { diff --git a/programs/cmm/eolite/include/menu.h b/programs/cmm/eolite/include/menu.h index a23d38fd31..7dc4b7630d 100644 --- a/programs/cmm/eolite/include/menu.h +++ b/programs/cmm/eolite/include/menu.h @@ -75,7 +75,7 @@ void FileMenu() if (!CheckActiveProcess(MenuForm.ID)) ExitProcess(); mm.get(); if (menu.ProcessMouse(mm.x, mm.y)) MenuListRedraw(); - if (mm.lkm) {action_buf = cur_action_buf; pause(5); ExitProcess(); } + if (mm.key&MOUSE_LEFT)&&(m.click) {action_buf = cur_action_buf; pause(5); ExitProcess(); } break; case evKey: diff --git a/programs/cmm/eolite/include/settings.h b/programs/cmm/eolite/include/settings.h index 88d221f71d..21a85d5efb 100644 --- a/programs/cmm/eolite/include/settings.h +++ b/programs/cmm/eolite/include/settings.h @@ -104,7 +104,8 @@ void LoadIniSettings() ini_get_int stdcall (eolite_ini_path, #confir_section, "InfoAfterCopy", 0); info_after_copy = EAX; ini_get_int stdcall (eolite_ini_path, #confir_section, "UseBigFonts", 0); use_big_fonts = EAX; ini_get_int stdcall (eolite_ini_path, #confir_section, "LineHeight", 18); files.line_h = EAX; - + ini_get_int stdcall (eolite_ini_path, #confir_section, "TimeDoubleClick", 50); MOUSE_TIME = EAX; + if (use_big_fonts) { font_type = 0x90; diff --git a/programs/cmm/lib/kolibri.h b/programs/cmm/lib/kolibri.h index 150539bb68..853cc7c5dc 100644 --- a/programs/cmm/lib/kolibri.h +++ b/programs/cmm/lib/kolibri.h @@ -5,7 +5,7 @@ char os_name[8] = {'M','E','N','U','E','T','0','1'}; dword os_version = 0x00000001; -dword start_addr = #main; +dword start_addr = #load_init_main; dword final_addr = #stop+32; dword alloc_mem = MEMSIZE; dword x86esp_reg = MEMSIZE; @@ -33,9 +33,9 @@ char program_path[4096]; #define BT_NOFRAME 0x20000000 //Button mouse -#define MOUSE_LEFT 100b -#define MOUSE_RIGHT 001b -#define MOUSE_CENTER 010b +#define MOUSE_LEFT 001b +#define MOUSE_RIGHT 010b +#define MOUSE_CENTER 100b //ASCII KEYS #define ASCII_KEY_BS 008 @@ -75,10 +75,14 @@ char program_path[4096]; * down - key event press * up - key release events * move - event mouse movements + * click - when clicked + * dblclick - double-click the default 50 ms */ + +dword __TMP_TIME,MOUSE_TIME; :struct mouse { - signed x,y,xx,yy,lkm,mkm,pkm,key,tmp,hor,vert,down,up,move; + signed x,y,xx,yy,lkm,mkm,pkm,key,tmp,tmp_time,hor,vert,down,up,move,click,dblclick; void get(); }; @@ -114,7 +118,10 @@ char program_path[4096]; if((down)&&!(key)){ up = true; down = false; - + if(!move) click = true; + __TMP_TIME = GetStartTime(); + if(__TMP_TIME-tmp_time<=MOUSE_TIME) dblclick = true; + tmp_time = __TMP_TIME; //returns the key code key = tmp; lkm = 1&tmp; @@ -127,9 +134,14 @@ char program_path[4096]; //when you press the mouse button else { up = false; - if(key) down = true; + click = false; + dblclick = false; + if(key) + { + down = true; + tmp = key; + } else down = false; - if(down) tmp = key; if((xx!=x)||(yy!=y)){ move = true; xx = x; @@ -650,4 +662,14 @@ inline fastcall dword GetStartTime() $mov eax,26 $mov ebx,9 $int 0x40 +} + +dword __generator; // random number generator - для генерации случайных чисел + +//The initialization of the initial data before running +void load_init_main() +{ + MOUSE_TIME = 50; //Default 50 ms. + __generator = GetStartTime(); + main(); } \ No newline at end of file diff --git a/programs/cmm/lib/random.h b/programs/cmm/lib/random.h index a6d5282f28..e974e8d28d 100644 --- a/programs/cmm/lib/random.h +++ b/programs/cmm/lib/random.h @@ -19,8 +19,6 @@ *******************************************************************************/ -dword generator; // random number generator - для генерации случайных чисел - inline fastcall int random( ECX) // get pseudo-random number - получить псевдослучайное число { @@ -30,11 +28,11 @@ inline fastcall int random( ECX) $xor eax,edx $not eax - EBX = generator; + EBX = __generator; $ror ebx,3 $xor ebx,0xdeadbeef EBX += EAX; - generator = EBX; + __generator = EBX; EAX += EBX; EAX = EAX % ECX; @@ -43,7 +41,7 @@ inline fastcall int random( ECX) } inline fastcall randomize() -// initialize random number generator - инициализировать генератор случайных чисел +// initialize random number __generator - инициализировать генератор случайных чисел { asm { @@ -51,5 +49,6 @@ inline fastcall randomize() int 0x40 ror eax,16 } - generator = EAX; -} \ No newline at end of file + __generator = EAX; +} + diff --git a/programs/cmm/lib/strings.h b/programs/cmm/lib/strings.h index 7e5834190f..af808883fc 100644 --- a/programs/cmm/lib/strings.h +++ b/programs/cmm/lib/strings.h @@ -39,7 +39,7 @@ inline fastcall signed int strcmp( ESI, EDI) } */ -int strspn(dword text1,text2) +inline int strspn(dword text1,text2) { dword beg; char s1,s2; @@ -64,7 +64,7 @@ int strspn(dword text1,text2) return ret; } -dword strpbrk(dword text1,text2) +inline dword strpbrk(dword text1,text2) { char s,ss; dword beg; @@ -112,8 +112,15 @@ inline fastcall unsigned int strlen( EDI) EAX-=2+ECX; } +inline strnlen(dword str, dword maxlen) +{ + dword cp; + for (cp = str; (maxlen != 0) && (DSBYTE[cp] != '\0'); cp++, maxlen--); + return cp - str; +} -signed int strcmp(dword text1, text2) + +inline signed int strcmp(dword text1, text2) { char s1,s2; dword p1,p2; @@ -136,6 +143,30 @@ signed int strcmp(dword text1, text2) return 0; } +/* +signed int strncmp(dword s1, s2, signed n) +unsigned char _s1,_s2; +{ + if (n == 0) + return 0; + do { + _s1 = DSBYTE[s1]; + _s2 = DSBYTE[s2]; + if (_s1 != _s2) + { + $dec s2 + return _s1 - _s2; + } + $inc s2 + if (_s1 == 0) + break; + $inc s1 + $dec n + } while (n); + return 0; +} +*/ + inline fastcall void strcpy( EDI, ESI) { @@ -147,7 +178,7 @@ L2: $jnz L2 } -void strncpy(dword text1, text2, signed len) +inline dword strncpy(dword text1, text2, signed len) signed o1,o2; { o1 = len/4; @@ -164,6 +195,8 @@ void strncpy(dword text1, text2, signed len) $inc text2 $dec o2 } + ESBYTE[text1] = 0; + return text1; } inline fastcall int strlcpy(dword ESI, EDI, EBX) @@ -198,7 +231,7 @@ inline fastcall void strtrim( ESI) */ byte __isWhite(int s){ if (s==13)||(s==32)||(s==10)||(s==9) return true; return false; } -void strltrim(dword text){ +inline void strltrim(dword text){ int s; dword back_text; back_text = text; @@ -218,7 +251,7 @@ void strltrim(dword text){ }; } -void strrtrim(dword text) +inline void strrtrim(dword text) { int s; dword p; @@ -240,7 +273,7 @@ void strrtrim(dword text) if(__isWhite(s)) ESBYTE[p] = 0; } -void strtrim(dword text){ +inline void strtrim(dword text){ int s; dword p,back_text; back_text = text; @@ -578,7 +611,7 @@ F3: } */ -dword itoa(signed long number) +inline dword itoa(signed long number) { unsigned char buf[11]; dword ret; @@ -653,7 +686,7 @@ F3: return EBX; } -dword strdup(dword text) +inline dword strdup(dword text) { dword l = strlen(text); dword ret = malloc(l+1); @@ -661,6 +694,20 @@ dword strdup(dword text) return ret; } +inline dword strndup(dword str, signed maxlen) +{ + dword copy,len; + + len = strnlen(str, maxlen); + copy = malloc(len + 1); + if (copy != NULL) + { + memcpy(copy, str, len); + DSBYTE[len+copy] = '\0'; + } + return copy; +} + void debugi(dword d_int) { char tmpch[12];