From 31165f9b8dede575a44fe0787da2c727d8df1ec6 Mon Sep 17 00:00:00 2001 From: Serhii Sakhno Date: Thu, 14 Nov 2013 00:22:55 +0000 Subject: [PATCH] (From Leency) Eolite 2.15: RealFileNamesCase support; show OpenWithDialog if associated program not found; add ram disk free space bar; small fix; git-svn-id: svn://kolibrios.org@4225 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/eolite/Eolite.c | 35 +++++----- programs/cmm/eolite/include/icons.h | 18 ++++-- programs/cmm/eolite/include/ini.h | 10 ++- programs/cmm/eolite/include/left_panel.h | 81 ++++++++++++++---------- programs/cmm/eolite/include/open_with.h | 6 ++ programs/cmm/eolite/include/other.h | 35 ++++++++++ 6 files changed, 126 insertions(+), 59 deletions(-) diff --git a/programs/cmm/eolite/Eolite.c b/programs/cmm/eolite/Eolite.c index eaabf38062..efa2a70a48 100644 --- a/programs/cmm/eolite/Eolite.c +++ b/programs/cmm/eolite/Eolite.c @@ -79,8 +79,8 @@ enum {ONLY_SHOW, WITH_REDRAW, ONLY_OPEN}; //OpenDir -#define TITLE "Eolite File Manager v2.0.4" -#define ABOUT_TITLE "Eolite v2.0.4" +#define TITLE "Eolite File Manager v2.15" +#define ABOUT_TITLE "Eolite v2.15" dword col_padding, col_selec, col_lpanel; int toolbar_buttons_x[7]={9,46,85,134,167,203}; @@ -103,6 +103,7 @@ byte rename_active=0, del_active=0, show_dev_name=1, + real_files_names_case=0, sort_num=2, itdir; @@ -310,6 +311,13 @@ void main() case 26: //paste CreateThread(#Paste,#copy_stak+4092); break; + case 27: + strcpy(#temp, "Ram Disk free space: "); + i = GetFreeRamDiskClusters() / 2; + itoa_(#temp+21, i); + strcat(#temp, "Kb"); + notify(#temp); + break; case 31...33: //sort IF(sort_num==1) DrawFilledBar(sorting_arrow_x,42,6,10); IF(sort_num==2) DrawFilledBar(sorting_arrow_x,42,6,10); @@ -396,11 +404,7 @@ void main() CreateThread(#FileMenu,#menu_stak+4092); break; case 173: //Ctrl+Enter - if (!itdir) - { - SwitchToAnotherThread(); - CreateThread(#OpenWith,#open_with_stak+4092); - } + if (!itdir) ShowOpenWithDialog(); break; case 178: //up List_Current(-1); @@ -444,6 +448,8 @@ void main() } } + + void menu_action(dword id) { if (id==COPY_PASTE_END) @@ -452,11 +458,7 @@ void menu_action(dword id) SelectFile(#copy_to+strrchr(#copy_to,'/')); } if (id==100) Open(); - if (id==201) - { - SwitchToAnotherThread(); - CreateThread(#OpenWith,#open_with_stak+4092); - } + if (id==201) ShowOpenWithDialog(); if (id==202) FnProcess(3); //F3 if (id==203) FnProcess(4); //F4 if (id==104) Copy(#file_path, NOCUT); @@ -470,7 +472,7 @@ void menu_action(dword id) void draw_window() { - DefineAndDrawWindow(40,20,550,500,0x73,sc.work,TITLE); + DefineAndDrawWindow(40,20,550,500,0x73,sc.work,TITLE,0); GetProcessInfo(#Form, SelfInfo); if (Form.status_window>2) return; files.SetSizes(192, 57, onLeft(192,27), onTop(57,6), disc_num*16+195,files.line_h); @@ -650,7 +652,8 @@ void Open_Dir(dword dir_path, redraw){ return; } maxcount = sizeof(file_mas)/sizeof(dword)-1; - if (files.count>maxcount) files.count = maxcount; + if (files.count>maxcount) files.count = maxcount; + DrawRamDiskSpace(); } if (files.count!=-1) { @@ -680,7 +683,7 @@ inline Sorting() } FOR (j=files.count-1, off=files.count-1*304+buf+32; j>=0; j--, off-=304;) //files | folders { - strttl(off+40); + if (!real_files_names_case) strttl(off+40); if (TestBit(ESDWORD[off],4)) //directory? { file_mas[k]=j; @@ -823,7 +826,7 @@ void SelectFile(dword that_file) { files.first=files.current=0; Open_Dir(#path,ONLY_OPEN); - strttl(that_file); + if (!real_files_names_case) strttl(that_file); for (i=files.count-1; i>=0; i--;) if (!strcmp(file_mas[i]*304+buf+72,that_file)) break; List_Current(i); diff --git a/programs/cmm/eolite/include/icons.h b/programs/cmm/eolite/include/icons.h index 12c7639031..41af12e98e 100644 --- a/programs/cmm/eolite/include/icons.h +++ b/programs/cmm/eolite/include/icons.h @@ -1,6 +1,6 @@ char *ext[]={ "..", 17, -"",16, +"",16, "",16, "txt", 1, "doc", 1, "rtf", 1, "odt", 1, "log", 1, "docx",1, "htm", 2, "html",2, "mht", 2, "ini", 3, "js", 3, "conf",3, "inf", 3, @@ -30,10 +30,18 @@ char *ext[]={ #include "imgs\icons.txt" -void Put_icon(dword extension, xx, yy, fairing_color, default_icon) -{ - int icon_n=default_icon, i; - for (i=0; ext[i]!=0; i+=2;) if (!strcmp(extension, ext[i])) { icon_n = ext[i+1]; break; } +void Put_icon(dword extension, xx, yy, fairing_color, icon_n) +{ + int i; + + if (extension) for (i=0; ext[i]!=0; i+=2;) + { + if (strcmpi(extension, ext[i])==0) + { + icon_n = ext[i+1]; + break; + } + } ficons_pal[0] = fairing_color; PutPaletteImage(icon_n*16*15+#ficons,16,15,xx,yy,8,#ficons_pal); diff --git a/programs/cmm/eolite/include/ini.h b/programs/cmm/eolite/include/ini.h index 5727334fbe..66d99bc8c6 100644 --- a/programs/cmm/eolite/include/ini.h +++ b/programs/cmm/eolite/include/ini.h @@ -33,11 +33,15 @@ void GetIni(byte onload) IF (!strcmp(#parametr,"SelectionColor")) edit2.shift_color=col_selec=StrToCol(#option); IF (!strcmp(#parametr,"LineHeight")) files.line_h = atoi(#option); IF (!strcmp(#parametr,"ShowDeviceName")) show_dev_name=atoi(#option); + IF (!strcmp(#parametr,"RealFileNamesCase")) real_files_names_case=atoi(#option); IF (parametr) && (!strcmp(#file_name+strrchr(#file_name,'.'),#parametr)) && (!onload) { - errornum=RunProgram(#option,#file_path); - IF (errornum<0) Write_Error(errornum); + errornum = RunProgram(#option,#file_path); + if (errornum<0) + { + if (errornum==-5) ShowOpenWithDialog(); else Write_Error(errornum); + } return; } parametr=option=NULL; @@ -50,7 +54,7 @@ void GetIni(byte onload) } if (file_path) && (!onload) { - errornum=RunProgram(#file_path,NULL); + errornum = RunProgram(#file_path,NULL); if (errornum==-31) menu_action(201); else if (errornum<0) Write_Error(errornum); return; } diff --git a/programs/cmm/eolite/include/left_panel.h b/programs/cmm/eolite/include/left_panel.h index 2c236d0f5e..99842195f4 100644 --- a/programs/cmm/eolite/include/left_panel.h +++ b/programs/cmm/eolite/include/left_panel.h @@ -1,36 +1,32 @@ //Leency 2008-2013 #ifdef LANG_RUS -char *actions[] = { - 57, "Новый файл", "F7", - 56, "Новая папка", "F6", - 60, "Настройки", "F10", - 0,0,0 -}; -?define T_DEVICES "Устройства" -?define T_ACTIONS "Действия" - + ?define T_DEVICES "Устройства" + ?define T_ACTIONS "Действия" + char *actions[] = { + 57, "Новый файл", "F7", + 56, "Новая папка", "F6", + 60, "Настройки", "F10", + 0,0,0 + }; #elif LANG_EST -char *actions[] = { - 57, "Uus fail", "F7", - 56, "Uus kataloog", "F6", - 60, "Seaded", "F10", - 0,0,0 -}; - -?define T_DEVICES "Seadmed" -?define T_ACTIONS "Toimingud" - + ?define T_DEVICES "Seadmed" + ?define T_ACTIONS "Toimingud" + char *actions[] = { + 57, "Uus fail", "F7", + 56, "Uus kataloog", "F6", + 60, "Seaded", "F10", + 0,0,0 + }; #else -char *actions[] = { - 57, "New file", "F7", - 56, "New folder", "F6", - 60, "Options", "F10", - 0,0,0 -}; - -?define T_DEVICES "Devices" -?define T_ACTIONS "Actions" + ?define T_DEVICES "Devices" + ?define T_ACTIONS "Actions" + char *actions[] = { + 57, "New file", "F7", + 56, "New folder", "F6", + 60, "Options", "F10", + 0,0,0 + }; #endif @@ -77,15 +73,30 @@ void SystemDiscsGet() strcpy(#disk_list[disc_num].Item, #sys_discs); disc_num++; } - if (strcmp(#disk_list[disc_num-1].Item, "/rd/1/")==0) if (GetDir(nullbuf, nullbuf, "/kolibrios/", DIRS_ALL)==0) + if (strcmp(#disk_list[disc_num-1].Item, "/rd/1/")==0) { - strcpy(#disk_list[disc_num].Item, "/kolibrios/"); - kolibrios_drive = true; - disc_num++; - } else kolibrios_drive = false; + if (GetDir(nullbuf, nullbuf, "/kolibrios/", DIRS_ALL)==0) + { + strcpy(#disk_list[disc_num].Item, "/kolibrios/"); + kolibrios_drive = true; + disc_num++; + } else kolibrios_drive = false; + } } } +void DrawRamDiskSpace() +{ + int free_rd_space = GetFreeRamDiskClusters() * 49 / ALL_RD_CLUSTERS; + DefineButton(120, 80, 49, 4, 27+BT_HIDE, 0); + if (!free_rd_space) + DrawBar(121, 81, 49-free_rd_space, 3, 0xFF0000); + else + { + DrawBar(121, 81, 49-free_rd_space, 3, 0x7A7F84); + DrawBar(121+49-free_rd_space, 81, free_rd_space, 3, 0xC4C4C4); + } +} void SystemDiscsDraw() { @@ -109,6 +120,7 @@ void SystemDiscsDraw() case 'r': dev_icon=0; strcpy(#disc_name, "System "); + DrawRamDiskSpace(); break; case 'c': dev_icon=1; @@ -143,8 +155,7 @@ void SystemDiscsDraw() strcpy(#disc_name, "Unknown "); } strcat(#disc_name, #dev_name); - if (show_dev_name) WriteText(45,i*16+79,0x80,0,#disc_name); - else WriteText(45,i*16+79,0x80,0,#dev_name); + if (show_dev_name) WriteText(45,i*16+79,0x80,0,#disc_name); else WriteText(45,i*16+79,0x80,0,#dev_name); _PutImage(21,i*16+76, 14,13, dev_icon*14*13*3+#devices); } } diff --git a/programs/cmm/eolite/include/open_with.h b/programs/cmm/eolite/include/open_with.h index ce2f545764..5484efe8aa 100644 --- a/programs/cmm/eolite/include/open_with.h +++ b/programs/cmm/eolite/include/open_with.h @@ -1,5 +1,11 @@ //Leency 2013 +void ShowOpenWithDialog() +{ + SwitchToAnotherThread(); + CreateThread(#OpenWith,#open_with_stak+4092); +} + llist app_list; struct app_list_string { char item[1024]; char ext[5]; }; app_list_string app_paths[100]; diff --git a/programs/cmm/eolite/include/other.h b/programs/cmm/eolite/include/other.h index 785eb35214..60fd66f15d 100644 --- a/programs/cmm/eolite/include/other.h +++ b/programs/cmm/eolite/include/other.h @@ -74,4 +74,39 @@ void DrawFilledBar(dword x, y, w, h) if (h <= 14) fill_h = h; else fill_h = 14; for (i=0; i