Eolite/KFM2: 'Delete' feature rewritten (thanks IgorA for the report) - now always run in a separate process, other bugfixes

git-svn-id: svn://kolibrios.org@8861 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2021-06-15 18:22:58 +00:00
parent b436a2dc22
commit b3571d494b
5 changed files with 62 additions and 109 deletions

View File

@ -3,8 +3,9 @@
// 70.5 - get volume info and label
#define TITLE "Eolite File Manager 5 Beta"
#define ABOUT_TITLE "EOLITE 5 Beta"
#define ABOUT_TITLE "EOLITE 5 Beta2"
#define TITLE_EOLITE "Eolite File Manager 5 Beta2"
#define TITLE_KFM "Kolibri File Manager 2 Beta2";
#ifndef AUTOBUILD
#include "lang.h--"
@ -125,7 +126,7 @@ _ini ini;
char scroll_used=false;
dword about_stak=0,properties_stak=0,settings_stak=0,delete_stak=0;
dword about_stak=0,properties_stak=0,settings_stak=0;
proc_info Form;
int sc_slider_h;
@ -199,10 +200,8 @@ void handle_param()
properties_dialog();
ExitProcess();
case 'd':
strcpy(#file_path, p + 3);
itdir = dir_exists(#file_path);
DisplayOperationForm(DELETE_FLAG);
DeleteSingleElement();
strcpy(#path, p + 3);
DeleteThread();
ExitProcess();
case 'v':
cut_active = ESBYTE[p+2] - '0';
@ -244,7 +243,6 @@ void main()
ESBYTE[0] = NULL;
SystemDiscs.Get();
Open_Dir(#path,ONLY_OPEN);
strcpy(#inactive_path, #path);
llist_copy(#files_inactive, #files);
@ -297,7 +295,6 @@ void main()
if (getElementSelectedFlag(files.cur_y) == false) selected_count = 0; //on redraw selection would be flashed, see [L001]
EventShowListMenu();
}
//break;
}
if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+16) && (mouse.y>files.y-17) && (mouse.y<files.y)
@ -345,16 +342,12 @@ void main()
if (efm) && (mouse.y > files.y) && (mouse.down) {
if (mouse.x<Form.cwidth/2)
{
if (active_panel!=1)
{
if (active_panel!=1) {
active_panel = 1;
ChangeActivePanel();
}
}
else
{
if (active_panel!=2)
{
} else {
if (active_panel!=2) {
active_panel = 2;
ChangeActivePanel();
}
@ -436,16 +429,13 @@ void main()
if (new_element_active) || (del_active) || (dev_popin_active_on_panel)
{
if (dev_popin_active_on_panel) {
if (key_scancode == SCAN_CODE_ESC) EventClosePopinForm();
}
if (del_active) {
if (key_scancode == SCAN_CODE_ENTER) EventDelete();
if (key_scancode == SCAN_CODE_ESC) EventClosePopinForm();
}
if (new_element_active) {
if (key_scancode == SCAN_CODE_ENTER) NewElement();
if (key_scancode == SCAN_CODE_ESC) EventClosePopinForm();
EAX = key_editbox;
edit_box_key stdcall (#new_file_ed);
}
@ -481,18 +471,17 @@ void main()
case SCAN_CODE_1...SCAN_CODE_10:
key_scancode-=2;
if (key_scancode >= SystemDiscs.list.count) break;
if (!efm)
{
if (!efm) {
DrawRectangle(17,key_scancode*16+74,159,16, 0); //display click
pause(7);
}
SystemDiscs.Click(key_scancode);
break;
case SCAN_CODE_KEY_X:
EventCopy(CUT);
CopyFilesListToClipboard(CUT);
break;
case SCAN_CODE_KEY_C:
EventCopy(NOCUT);
CopyFilesListToClipboard(COPY);
break;
case SCAN_CODE_KEY_G:
EventOpenConsoleHere();
@ -567,15 +556,13 @@ void main()
case evReDraw:
draw_window();
if (CheckActiveProcess(Form.ID)) && (GetMenuClick()) break;
if (action_buf==OPERATION_END)
{
if (action_buf==OPERATION_END) {
EventRefresh();
action_buf=0;
}
break;
default:
if (Form.status_window>2) break;
EventRefreshDisksAndFolders();
if (Form.status_window<=2) EventRefreshDisksAndFolders();
}
if(cmd_free)
@ -583,7 +570,6 @@ void main()
if(cmd_free==2) about_stak=free(about_stak);
else if(cmd_free==3) properties_stak=free(properties_stak);
else if(cmd_free==4) settings_stak=free(settings_stak);
else if(cmd_free==6) delete_stak=free(delete_stak);
cmd_free = false;
}
}
@ -594,7 +580,7 @@ void draw_window()
incn x;
dword title;
if (show_status_bar.checked) status_bar_h = STATUS_BAR_H; else status_bar_h = 0;
if (efm) title = "Kolibri File Manager 2 - BETA"; else title = TITLE;
if (efm) title = TITLE_KFM; else title = TITLE_EOLITE;
DefineAndDrawWindow(Form.left+rand_n,Form.top+rand_n,Form.width,Form.height,0x73,NULL,title,0);
GetProcessInfo(#Form, SelfInfo);
if (Form.status_window>2) return;
@ -624,8 +610,8 @@ void draw_window()
ESDWORD[#toolbar_pal] = sc.work;
ESDWORD[#toolbar_pal+4] = MixColors(0, sc.work, 35);
PutPaletteImage(#toolbar, 246, 34, 0, 0, 8, #toolbar_pal);
for (i=0; i<3; i++) DefineHiddenButton(toolbar_buttons_x[i]+2,7,31-5,29-5,21+i);
for (i=3; i<6; i++) DefineHiddenButton(toolbar_buttons_x[i], 5,31, 29, 21+i);
for (i=0; i<3; i++) DefineHiddenButton(toolbar_buttons_x[i]+2,7,31-5,29-5,BACK_BTN+i);
for (i=3; i<6; i++) DefineHiddenButton(toolbar_buttons_x[i], 5,31, 29, BACK_BTN+i);
DrawBar(127, 8, 1, 25, sc.work_graph);
DrawBar(246,0, Form.cwidth - 246, 34, sc.work);
DrawDot(Form.cwidth-17,12);
@ -1193,7 +1179,7 @@ void FnProcess(byte N)
break;
case 5:
if (efm) {
EventCopy(false);
CopyFilesListToClipboard(COPY);
EventPaste(#inactive_path);
} else {
EventRefresh();
@ -1201,7 +1187,7 @@ void FnProcess(byte N)
break;
case 6:
if (efm) {
EventCopy(true);
CopyFilesListToClipboard(CUT);
EventPaste(#inactive_path);
}
break;
@ -1384,16 +1370,12 @@ void EventPaste(dword _into_path) {
}
void EventDelete()
char line_param[4096+5];
{
char line_param[4096+5];
CopyFilesListToClipboard(DELETE);
EventClosePopinForm();
if (!selected_count) {
sprintf(#line_param, "-d %s", #file_path);
RunProgram(#program_path, #line_param);
} else {
delete_stak = malloc(40000);
CreateThread(#DeleteSelectedElements,delete_stak+40000-4);
}
}
void EventClosePopinForm()
@ -1402,8 +1384,6 @@ void EventClosePopinForm()
new_element_active = 0;
dev_popin_active_on_panel = 0;
draw_window();
//DeleteButton(POPUP_BTN1);
//DeleteButton(POPUP_BTN2);
}
void EventShowProperties()
@ -1453,8 +1433,8 @@ void EventToolbarButtonClick(int _btid)
case BACK_BTN: EventHistoryGoBack(); break;
case FWRD_BTN: EventHistoryGoForward(); break;
case GOUP_BTN: Dir_Up(); break;
case COPY_BTN: EventCopy(CUT); break;
case CUT_BTN: EventCopy(NOCUT); break;
case COPY_BTN: CopyFilesListToClipboard(CUT); break;
case CUT_BTN: CopyFilesListToClipboard(COPY); break;
case PASTE_BTN:EventPaste(#path); break;
}
}

View File

@ -45,9 +45,9 @@ byte copy_to[4096];
byte copy_from[4096];
bool cut_active = false;
enum {NOCUT, CUT};
enum {COPY, CUT, DELETE};
void EventCopy(bool _cut_active)
void CopyFilesListToClipboard(bool _cut_active)
{
byte copy_t[4096];
dword buff_data;
@ -58,7 +58,7 @@ void EventCopy(bool _cut_active)
if (files.count<=0) return; //no files
cut_active = _cut_active;
if (cut_active!=DELETE) cut_active = _cut_active;
//if no element selected by "Insert" key, then we copy current element
if (!selected_count) {
@ -88,8 +88,6 @@ void EventCopy(bool _cut_active)
sprintf(copy_buf_offset,"%s/%s",#path,items.get(i)*304+buf+72);
copy_buf_offset += strlen(copy_buf_offset) + 1;
//setElementSelectedFlag(i, false);
if (cut_active) {
if (i>=files.first) && (i<files.first+files.visible)
PutShadow(files.x+4,i-files.first*files.item_h+files.y,16,files.item_h,1,-3);
@ -138,7 +136,6 @@ void PasteThread()
if (EAX!=0) goto _DIFFERENT_DRIVES;
path_offset += strlen(path_offset) + 1;
}
cut_active=false;
DialogExit();
}
@ -161,7 +158,7 @@ _DIFFERENT_DRIVES:
}
if (strstr(#copy_to, #copy_from))
{
notify("Copy directory into itself is a bad idea...");
notify("'Not possible to copy directory into itself.\nProcess terminated.' -E");
DialogExit();
}
@ -173,12 +170,11 @@ _DIFFERENT_DRIVES:
else if (cut_active)
{
strcpy(#file_path, #copy_from);
Del_File2(#copy_from, 0);
RecursiveDelete(#copy_from, false);
}
path_offset += strlen(path_offset) + 1;
}
cut_active=false;
DialogExit();
}
@ -190,7 +186,7 @@ _DIFFERENT_DRIVES:
//===================================================//
int del_error;
int Del_File2(dword way, sh_progr)
int RecursiveDelete(dword way, bool show_progress)
{
dword dirbuf, fcount, i, filename;
int error;
@ -205,11 +201,11 @@ int Del_File2(dword way, sh_progr)
sprintf(#del_from,"%s/%s",way,filename);
if ( TestBit(ESDWORD[filename-40], 4) )
{
Del_File2(#del_from, 1);
RecursiveDelete(#del_from, true);
}
else
{
if (sh_progr) Operation_Draw_Progress(filename);
if (show_progress) Operation_Draw_Progress(filename);
if (error = DeleteFile(#del_from)) del_error = error;
}
}
@ -217,51 +213,31 @@ int Del_File2(dword way, sh_progr)
if (error = DeleteFile(way)) del_error = error;
}
void DeleteSingleElement()
void DeleteThread()
{
DIR_SIZE delete_dir_size;
del_error = NULL;
if (itdir) {
copy_bar.max = delete_dir_size.get(#file_path);
} else {
copy_bar.max = 1;
}
Del_File2(#file_path, 1);
if (del_error) Write_Error(del_error);
DialogExit();
}
void DeleteSelectedElements()
{
byte del_from[4096];
int i;
int j;
int elements_count = 0;
dword buf;
dword path_offset;
DisplayOperationForm(DELETE_FLAG);
if (!selected_count) { DeleteSingleElement(); return; }
buf = Clipboard__GetSlotData(Clipboard__GetSlotCount()-1);
Clipboard__DeleteLastSlot();
if (DSDWORD[buf+4] != 3) return;
elements_count = ESINT[buf+8];
for (i=0; i<files.count; i++)
{
if (getElementSelectedFlag(i) == true) {
sprintf(#del_from,"%s/%s",#path,items.get(i)*304+buf+72);
copy_bar.max += GetFilesCount(#del_from);
}
path_offset = buf + 10;
for (j = 0; j < elements_count; j++) {
copy_bar.max += GetFilesCount(path_offset);
path_offset += strlen(path_offset) + 1;
}
del_error = 0;
for (i=0; i<files.count; i++)
{
if (getElementSelectedFlag(i) == true) {
sprintf(#del_from,"%s/%s", #path, items.get(i)*304+buf+72);
Del_File2(#del_from, 1);
path_offset = buf + 10;
for (j = 0; j < elements_count; j++) {
RecursiveDelete(path_offset, true);
path_offset += strlen(path_offset) + 1;
}
}
if (del_error) Write_Error(del_error);
cmd_free = 6;
DialogExit();
}

View File

@ -103,8 +103,8 @@ void EventMenuClick(dword _id)
if (active_menu == MENU_FILE) switch(_id) {
case 1: EventOpen(0); break;
case 2: ShowOpenWithDialog(); break;
case 3: EventCopy(NOCUT); break;
case 4: EventCopy(CUT); break;
case 3: CopyFilesListToClipboard(COPY); break;
case 4: CopyFilesListToClipboard(CUT); break;
case 5: EventPaste(#path); break;
case 6: FnProcess(2); break;
case 7: Del_Form(); break;
@ -112,8 +112,8 @@ void EventMenuClick(dword _id)
}
if (active_menu == MENU_DIR) switch(_id) {
case 1: EventOpen(0); break;
case 2: EventCopy(NOCUT); break;
case 3: EventCopy(CUT); break;
case 2: CopyFilesListToClipboard(COPY); break;
case 3: CopyFilesListToClipboard(CUT); break;
case 4: EventPaste(#path); break;
case 5: Del_Form(); break;
case 6: FnProcess(1); break;

View File

@ -42,7 +42,6 @@ void DisplayOperationForm(int operation_flag)
switch(CheckEvent())
{
case evButton:
notify(T_CANCEL_PASTE);
DialogExit();
break;

View File

@ -18,7 +18,6 @@
?define T_MOVE_WINDOW_TITLE "<EFBFBD>¥à¥¬¥é î..."
?define T_DELETE_WINDOW_TITLE "“¤ «ïî..."
?define T_ABORT_WINDOW_BUTTON "<EFBFBD>à¥à¢ âì"
?define T_CANCEL_PASTE "Š®¯¨à®¢ ­¨¥ ¯à¥ªà é¥­®. <20> ¯ª  ᪮¯¨à®¢ ­  ­¥ ¯®«­®áâìî."
?define T_SELECT_APP_TO_OPEN_WITH "‚ë¡¥à¨â¥ ¯à®£à ¬¬ã ¤«ï ®âªàëâ¨ï ä ©« "
?define DEL_MORE_FILES_1 "¢ë¡à ­­ë¥ í«¥¬¥­âë ("
?define DEL_MORE_FILES_2 " èâ.)?"
@ -48,7 +47,6 @@
?define T_MOVE_WINDOW_TITLE "Moving..."
?define T_DELETE_WINDOW_TITLE "Deleting..."
?define T_ABORT_WINDOW_BUTTON "Abort"
?define T_CANCEL_PASTE "Copy process terminated. Folder copied incompletely."
?define T_SELECT_APP_TO_OPEN_WITH "Select application to open file"
?define DEL_MORE_FILES_1 "selected items("
?define DEL_MORE_FILES_2 " pcs.)?"