From 684ee81f3eafb2bb188e5c34f60565b70f98d6e5 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Sun, 6 Feb 2022 23:16:38 +0000 Subject: [PATCH] Eolite: show correct size in bytes in Properties dialog (thanks Mario for the code snippet) git-svn-id: svn://kolibrios.org@9693 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/eolite/Eolite.c | 6 +- programs/cmm/eolite/include/const.h | 24 ++++--- programs/cmm/eolite/include/properties.h | 90 +++++++++++------------- programs/cmm/lib/fs.h | 10 +-- programs/cmm/lib/kolibri.h | 4 +- programs/cmm/misc/mblocks.c | 2 +- programs/cmm/misc/pipet.c | 6 +- 7 files changed, 69 insertions(+), 73 deletions(-) diff --git a/programs/cmm/eolite/Eolite.c b/programs/cmm/eolite/Eolite.c index 2a0a4b533f..e78718d136 100644 --- a/programs/cmm/eolite/Eolite.c +++ b/programs/cmm/eolite/Eolite.c @@ -11,9 +11,9 @@ TODO: http://board.kolibrios.org/viewtopic.php?f=23&t=4521&p=77334#p77334 */ -#define ABOUT_TITLE "EOLITE 5.22" -#define TITLE_EOLITE "Eolite File Manager 5.22" -#define TITLE_KFM "Kolibri File Manager 2.22"; +#define ABOUT_TITLE "EOLITE 5.25" +#define TITLE_EOLITE "Eolite File Manager 5.25" +#define TITLE_KFM "Kolibri File Manager 2.25"; #define MEMSIZE 1024 * 250 #include "../lib/clipboard.h" diff --git a/programs/cmm/eolite/include/const.h b/programs/cmm/eolite/include/const.h index 52e5f32d41..d5bb8671f7 100644 --- a/programs/cmm/eolite/include/const.h +++ b/programs/cmm/eolite/include/const.h @@ -71,16 +71,17 @@ char *actions[] = { #define T_APPLY "Применить" #define QUEST_1 "Применить ко всем вложенным" #define QUEST_2 "файлам и папкам?" -#define PR_T_NAME "Имя:" -#define PR_T_DEST "Расположение:" +#define T_NAME "Имя:" +#define T_DATA "Данные" +#define T_BULK_SELECTION "Выделено несколько элементов" +#define T_PATH_SIZE "Путь:\nРазмер:\nВ байтах:\nСодержит:" +#define T_FILES_FOLDERS "Файлов %i, Папок %i" #define CREATED_OPENED_MODIFIED "Создан:\nОткрыт:\nИзменен:" -#define T_FILES_FOLDERS "Файлов: %i Папок: %i" -#define PR_T_CONTAINS "Содержит: " + #define FLAGS " Атрибуты " +#define PR_T_ONLY_READ "Только чтение" #define PR_T_HIDDEN "Скрытый" #define PR_T_SYSTEM "Системный" -#define PR_T_ONLY_READ "Только чтение" -#define T_PROP_SIZE "Размер: %s (%i байт)" #define TITLE_SETT "Настройки" #define SHOW_DEVICE_CLASS "Выводить названия класса устройств" @@ -168,16 +169,17 @@ char *actions[] = { #define T_APPLY "Apply" #define QUEST_1 "Apply to all subfolders" #define QUEST_2 "files and Folders?" -#define PR_T_NAME "Name:" -#define PR_T_DEST "Location:" +#define T_NAME "Name:" +#define T_DATA "Data" +#define T_BULK_SELECTION "A bunch of items is selected" +#define T_PATH_SIZE "Location:\nSize:\nBytes:\nContains:" +#define T_FILES_FOLDERS "Files %i, Folders %i" #define CREATED_OPENED_MODIFIED "Created:\nOpened:\nModified:" -#define T_FILES_FOLDERS "Files: %i Folders: %i" -#define PR_T_CONTAINS "Contains: " + #define FLAGS " Attributes " #define PR_T_HIDDEN "Hidden" #define PR_T_SYSTEM "System" #define PR_T_ONLY_READ "Read-only" -#define T_PROP_SIZE "Size: %s (%i byte)" #define TITLE_SETT "Settings" #define SHOW_DEVICE_CLASS "Show device class name" diff --git a/programs/cmm/eolite/include/properties.h b/programs/cmm/eolite/include/properties.h index 00ccedc597..2dba936a92 100644 --- a/programs/cmm/eolite/include/properties.h +++ b/programs/cmm/eolite/include/properties.h @@ -119,8 +119,8 @@ void GetSizeMoreFiles(dword way) else { GetFileInfo(#cur_file, #file_info_dirsize); - more_files_count.bytes += file_info_dirsize.sizelo; - more_files_count.bytes += file_info_dirsize.sizehi; + more_files_count.sizelo += file_info_dirsize.sizelo; + more_files_count.sizehi += file_info_dirsize.sizehi; more_files_count.files++; } } @@ -171,7 +171,7 @@ void properties_dialog() cmd_free=3; ExitProcess(); } - if (id==B_APPLY) EventApplyProperties(); + if (id==B_APPLY) goto _APPLY_PROPERTIES; break; case evMouse: @@ -199,7 +199,12 @@ void properties_dialog() break; case SCAN_CODE_ENTER: - EventApplyProperties(); + _APPLY_PROPERTIES: + if (getSelectedCount()) || (itdir) { + ShowConfirmQuestionPopin(); + } else { + SetProperties(SET_PROPERTIES_SINGLE_FILE); + } break; case SCAN_CODE_KEY_A: @@ -220,62 +225,60 @@ void properties_dialog() void DrawPropertiesWindow() { proc_info pform; - char size_lbl[32]; - char folder_info[200]; dword ext1; incn y; char temp_path[PATHLEN]; bool show_date = false; + dword p_t_formated_size; + dword p_q_size_bytes; + dword t_contains_files_and_folders[200]; + if (chrnum(path, '/')>1) || (streq(path, "/kolibrios")) || (streq(path, "/sys")) show_date = true; if (getSelectedCount()) show_date = false; - DefineAndDrawWindow(Form.left + 150,150,315,show_date*60+300+skin_h,0x34,sc.work,WINDOW_TITLE_PROPERTIES,0); + DefineAndDrawWindow(Form.left + 150,150,315,show_date*60+342+skin_h,0x34,sc.work,WINDOW_TITLE_PROPERTIES,0); GetProcessInfo(#pform, SelfInfo); DrawStandartCaptButton(pform.cwidth - 96, pform.cheight-34, B_CLOSE, T_CLOSE); DrawStandartCaptButton(pform.cwidth -208, pform.cheight-34, B_APPLY, T_APPLY); - WriteText(10, 78, 0x90, sc.work_text, PR_T_DEST); - edit_box_draw stdcall (#path_to_file_ed); - if (getSelectedCount()) { PropertiesDrawIcon(NULL, ""); - sprintf(#folder_info,T_FILES_FOLDERS,more_files_count.files,more_files_count.folders); - WriteText(file_name_ed.left+4, 30, 0x90, sc.work_text, #folder_info); - sprintf(#size_lbl,T_PROP_SIZE,ConvertSize64(more_files_count.bytes, more_files_count.bytes>>32),more_files_count.bytes); - WriteText(10, 97, 0x90, sc.work_text, #size_lbl); - } - else - { - if ( file_info_general.isfolder ) - PropertiesDrawIcon(NULL, ""); - else { - sprintf(#temp_path,"%s/%s",path,#file_name2); - ext1 = strrchr(#file_name2,'.'); - if (ext1) ext1 += #file_name2; - PropertiesDrawIcon(#temp_path, ext1); - } - WriteText(file_name_ed.left, file_name_ed.top-15, 0x80, sc.work_text, PR_T_NAME); + WriteText(file_name_ed.left+4, 30, 0x90, sc.work_text, T_BULK_SELECTION); + p_t_formated_size = ConvertSize64(more_files_count.sizelo, more_files_count.sizehi); + p_q_size_bytes = #more_files_count.sizelo; + sprintf(#t_contains_files_and_folders,T_FILES_FOLDERS,more_files_count.files,more_files_count.folders); + } else { + WriteText(file_name_ed.left, file_name_ed.top-15, 0x80, sc.work_text, T_NAME); DrawEditBox(#file_name_ed); - - if (!itdir) { - sprintf(#size_lbl,T_PROP_SIZE,ConvertSize64(file_info_general.sizelo, file_info_general.sizehi),file_info_general.sizelo); + if (itdir) { + PropertiesDrawIcon(NULL, ""); + p_t_formated_size = ConvertSize64(dir_size.sizelo, dir_size.sizehi); + p_q_size_bytes = #dir_size.sizelo; + sprintf(#t_contains_files_and_folders,T_FILES_FOLDERS,dir_size.files,dir_size.folders); } else { - sprintf(#folder_info,T_FILES_FOLDERS,dir_size.files,dir_size.folders); - WriteText(10, 117, 0x90, sc.work_text, PR_T_CONTAINS); - WriteText(120, 117, 0x90, sc.work_text, #folder_info); - sprintf(#size_lbl,T_PROP_SIZE,ConvertSize64(dir_size.bytes, dir_size.bytes_high),dir_size.bytes); - } - WriteText(10, 99, 0x90, sc.work_text, #size_lbl); + sprintf(#temp_path,"%s/%s",path,#file_name2); + if (ext1 = strrchr(#file_name2,'.')) ext1 += #file_name2; + PropertiesDrawIcon(#temp_path, ext1); + p_t_formated_size = ConvertSize64(file_info_general.sizelo, file_info_general.sizehi); + p_q_size_bytes = #file_info_general.sizelo; + sprintf(#t_contains_files_and_folders,T_DATA); + } } + WriteTextLines(10, y.set(78), 0x90, sc.work_text, T_PATH_SIZE, 20); + edit_box_draw stdcall (#path_to_file_ed); + + WriteText(120, y.inc(20), 0x90, sc.work_text, p_t_formated_size); + WriteNumber(120, y.inc(20), 0x90, sc.work_text, 0xc0140001, p_q_size_bytes); + WriteText(120, y.inc(20), 0x90, sc.work_text, #t_contains_files_and_folders); if (show_date) { - WriteTextLines(10, 136, 0x90, sc.work_text, CREATED_OPENED_MODIFIED, 20); - DrawDateTime(120, 136, sc.work_text, #file_info_general.datecreate, #file_info_general.timecreate); - DrawDateTime(120, 156, sc.work_text, #file_info_general.datelastaccess, #file_info_general.timelastaccess); - DrawDateTime(120, 176, sc.work_text, #file_info_general.datelastedit, #file_info_general.timelastedit); + WriteTextLines(10, y.inc(32), 0x90, sc.work_text, CREATED_OPENED_MODIFIED, 20); + DrawDateTime(120, y.n, sc.work_text, #file_info_general.datecreate, #file_info_general.timecreate); + DrawDateTime(120, y.inc(20), sc.work_text, #file_info_general.datelastaccess, #file_info_general.timelastaccess); + DrawDateTime(120, y.inc(20), sc.work_text, #file_info_general.datelastedit, #file_info_general.timelastedit); } DrawFrame(10, y.set(pform.cheight - 143), -10*2 + pform.cwidth - 2, 92, FLAGS); @@ -290,12 +293,3 @@ void PropertiesDrawIcon(dword file_path, extension) int icon_n = ini_icons.get(file_path, extension, 32); draw_icon_32(12, 22, sc.work, icon_n); } - -void EventApplyProperties() -{ - if (getSelectedCount()) || (itdir) { - ShowConfirmQuestionPopin(); - } else { - SetProperties(SET_PROPERTIES_SINGLE_FILE); - } -} \ No newline at end of file diff --git a/programs/cmm/lib/fs.h b/programs/cmm/lib/fs.h index c96eb54690..bdb54966ad 100644 --- a/programs/cmm/lib/fs.h +++ b/programs/cmm/lib/fs.h @@ -491,15 +491,15 @@ int block_size=1024*1024*4; //copy by 4 MiB BDVK dir_info; dword folders; dword files; - dword bytes; - dword bytes_high; + dword sizelo; + dword sizehi; dword get(); dword calculate_loop(); }; :dword DIR_SIZE::get(dword way1) { - folders = files = bytes = bytes_high = 0; + folders = files = sizelo = sizehi = 0; if (!way1) return 0; calculate_loop(way1); } @@ -528,8 +528,8 @@ int block_size=1024*1024*4; //copy by 4 MiB else { GetFileInfo(cur_file, #dir_info); - bytes += dir_info.sizelo; - bytes_high += dir_info.sizehi; + sizelo += dir_info.sizelo; + sizehi += dir_info.sizehi; files++; } } diff --git a/programs/cmm/lib/kolibri.h b/programs/cmm/lib/kolibri.h index 7483d8fc24..4faa28fbf5 100644 --- a/programs/cmm/lib/kolibri.h +++ b/programs/cmm/lib/kolibri.h @@ -465,10 +465,10 @@ inline fastcall dword SetWindowLayerBehaviour(EDX, ESI) WriteText(x,y, fontType, color, str_offset); } -:void WriteNumber(dword x,y,byte fontType, dword color, count, number_or_offset) +:void WriteNumber(dword x,y,byte fontType, dword color, flags, number_or_offset) { EAX = 47; - EBX = count<<16; + EBX = flags; ECX = number_or_offset; EDX = x<<16+y; ESI = fontType<<24+color; diff --git a/programs/cmm/misc/mblocks.c b/programs/cmm/misc/mblocks.c index c60b5986a5..0f5afbc463 100644 --- a/programs/cmm/misc/mblocks.c +++ b/programs/cmm/misc/mblocks.c @@ -165,7 +165,7 @@ void Draw_Panel() void Draw_Count() { EDI = sc.work; //writing a number with bg - WriteNumber(WIN_W-32, PANEL_Y + 12, 0xD0, sc.work_text, 3, count); + WriteNumber(WIN_W-32, PANEL_Y + 12, 0xD0, sc.work_text, 3<<16, count); } diff --git a/programs/cmm/misc/pipet.c b/programs/cmm/misc/pipet.c index 158ec8f5dd..623a3693f3 100644 --- a/programs/cmm/misc/pipet.c +++ b/programs/cmm/misc/pipet.c @@ -103,9 +103,9 @@ void EventUpdateWindowContent() WriteTextWithBg(12,12, 0xD0, 0x000111, #picked_color_string, 0xFFFfff); - WriteNumber(12,33, 0xD0, 0xff0000, 3, rgb.r); - WriteNumber(44,33, 0xD0, 0x008000, 3, rgb.g); - WriteNumber(75,33, 0xD0, 0x0000ff, 3, rgb.b); + WriteNumber(12,33, 0xD0, 0xff0000, 3<<16, rgb.r); + WriteNumber(44,33, 0xD0, 0x008000, 3<<16, rgb.g); + WriteNumber(75,33, 0xD0, 0x0000ff, 3<<16, rgb.b); DrawBar(PICKED_X, PICKED_PADDING, PICKED_SIZE, PICKED_SIZE, picked_color); }