menu: fix keys

lib/strings.h: fix strstri()
Eolite: 
- fix sorting
- paste in a new process
- delete and properties in a new process for a single item 

git-svn-id: svn://kolibrios.org@7878 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2020-05-06 15:53:34 +00:00
parent c82fc5ccb8
commit 249e0b8ea6
16 changed files with 467 additions and 371 deletions

View File

@ -107,7 +107,7 @@ _ini ini;
char scroll_used=false;
dword about_stak,properties_stak,settings_stak,copy_stak,delete_stak;
dword about_stak=0,properties_stak=0,settings_stak=0,delete_stak=0;
proc_info Form;
int sc_slider_h;
@ -138,12 +138,11 @@ byte cmd_free=0;
#include "include\gui.h"
#include "include\settings.h"
#include "include\progress_dialog.h"
#include "include\copy.h"
#include "include\copy_and_delete.h"
#include "include\sorting.h"
#include "include\icons.h"
#include "include\left_panel.h"
#include "include\menu.h"
#include "include\delete.h"
#include "include\about.h"
#include "include\properties.h"
#include "include\breadcrumbs.h"
@ -156,6 +155,33 @@ void load_libraries()
load_dll(libimg, #libimg_init,1);
}
void handle_param()
{
//-p : just show file/folder properties dialog
//-v : paste thread
//-d : delete thread
if (param) && (param[0]=='-') switch (param[1])
{
case 'p':
strcpy(#file_path, #param + 3);
strcpy(#file_name, #param + strrchr(#param, '/'));
itdir = dir_exists(#file_path);
properties_dialog();
return;
case 'v':
cut_active = param[2] - '0';
strcpy(#path, #param + 4);
PasteThread();
return;
case 'd':
strcpy(#file_path, #param + 3);
itdir = dir_exists(#file_path);
DisplayOperationForm(DELETE_FLAG);
DeleteSingleElement();
return;
}
}
void main()
{
dword id;
@ -169,14 +195,7 @@ void main()
LoadIniSettings();
SystemDiscs.Get();
//-p just show file/folder properties dialog
if (param) && (param[0]=='-') && (param[1]=='p')
{
strcpy(#file_path, #param + 3);
strcpy(#file_name, #param + strrchr(#param, '/'));
properties_dialog();
ExitProcess();
}
handle_param();
ESBYTE[0] = NULL;
@ -300,12 +319,9 @@ void main()
id=GetButtonID();
if (new_element_active) || (del_active) {
if(POPUP_BTN1==id) || (POPUP_BTN2==id) {
if (del_active) Del_File(id-POPUP_BTN2);
if (new_element_active) NewElement(id-POPUP_BTN2);
DeleteButton(POPUP_BTN1);
DeleteButton(POPUP_BTN2);
}
if (POPUP_BTN1==id) && (del_active) EventDelete();
if (POPUP_BTN1==id) && (new_element_active) NewElement();
if (POPUP_BTN2==id) EventClosePopinForm();
break;
}
@ -329,13 +345,13 @@ void main()
Dir_Up();
break;
case 24:
Copy(#file_path, CUT);
EventCopy(CUT);
break;
case 25:
Copy(#file_path, NOCUT);
EventCopy(NOCUT);
break;
case 26:
Paste();
EventPaste();
break;
case 31...33:
EventSort(id-30);
@ -368,13 +384,13 @@ void main()
{
if (del_active)
{
if (key_scancode == SCAN_CODE_ENTER) Del_File(true);
if (key_scancode == SCAN_CODE_ESC) Del_File(false);
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(true);
if (key_scancode == SCAN_CODE_ESC) NewElement(false);
if (key_scancode == SCAN_CODE_ENTER) NewElement();
if (key_scancode == SCAN_CODE_ESC) EventClosePopinForm();
EAX = key_editbox;
edit_box_key stdcall (#new_file_ed);
}
@ -405,16 +421,16 @@ void main()
SystemDiscs.Click(key_scancode);
break;
case SCAN_CODE_KEY_X:
Copy(#file_path, CUT);
EventCopy(CUT);
break;
case SCAN_CODE_KEY_C:
Copy(#file_path, NOCUT);
EventCopy(NOCUT);
break;
case SCAN_CODE_KEY_G:
EventOpenConsoleHere();
break;
case SCAN_CODE_KEY_V:
Paste();
EventPaste();
break;
case SCAN_CODE_KEY_D: //set image as bg
strlcpy(#temp, "\\S__",4);
@ -485,7 +501,6 @@ void main()
if (action_buf==OPERATION_END)
{
FnProcess(5);
if (copy_stak) SelectFileByName(#copy_to+strrchr(#copy_to,'/'));
action_buf=0;
}
break;
@ -499,7 +514,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==5) copy_stak=free(copy_stak);
else if(cmd_free==6) delete_stak=free(delete_stak);
cmd_free = false;
}
@ -953,85 +967,81 @@ void ShowOpenWithDialog()
RunProgram("/sys/@open", #open_param);
}
void NewElement(byte newf)
void NewElement()
{
BDVK element_info;
byte del_rezult, copy_rezult, info_result;
if (newf)
sprintf(#temp,"%s/%s",#path,new_file_ed.text);
info_result = GetFileInfo(#temp, #element_info);
switch(new_element_active)
{
sprintf(#temp,"%s/%s",#path,new_file_ed.text);
info_result = GetFileInfo(#temp, #element_info);
switch(new_element_active)
{
case CREATE_FILE:
if (info_result==5)
case CREATE_FILE:
if (info_result==5)
{
CreateFile(0, 0, #temp);
if (EAX)
{
CreateFile(0, 0, #temp);
if (EAX)
if (EAX==5) notify(NOT_CREATE_FILE);
else Write_Error(EAX);
}
}
else
{
notify(FS_ITEM_ALREADY_EXISTS);
}
break;
case CREATE_FOLDER:
if (info_result==5)
{
CreateDir(#temp);
if (EAX)
{
if (EAX==5) notify(NOT_CREATE_FOLDER);
else Write_Error(EAX);
}
}
else
{
notify(FS_ITEM_ALREADY_EXISTS);
}
break;
case RENAME_ITEM:
if (info_result==5)
{
if (itdir)
{
//rename only empty folders
if (del_rezult = DeleteFile(#file_path))
{
if (EAX==5) notify(NOT_CREATE_FILE);
else Write_Error(EAX);
Write_Error(del_rezult);
return;
}
if (CreateDir(#temp)) CreateDir(#file_path);
Open_Dir(#path,WITH_REDRAW);
SelectFileByName(new_file_ed.text);
}
else
{
notify(FS_ITEM_ALREADY_EXISTS);
}
break;
case CREATE_FOLDER:
if (info_result==5)
{
CreateDir(#temp);
if (EAX)
if (copy_rezult = CopyFile(#file_path,#temp))
{
if (EAX==5) notify(NOT_CREATE_FOLDER);
else Write_Error(EAX);
}
}
else
{
notify(FS_ITEM_ALREADY_EXISTS);
}
break;
case RENAME_ITEM:
if (info_result==5)
{
if (itdir)
{
//rename only empty folders
if (del_rezult = DeleteFile(#file_path))
{
Write_Error(del_rezult);
return;
}
if (CreateDir(#temp)) CreateDir(#file_path);
Open_Dir(#path,WITH_REDRAW);
SelectFileByName(new_file_ed.text);
Write_Error(copy_rezult);
}
else
{
if (copy_rezult = CopyFile(#file_path,#temp))
{
Write_Error(copy_rezult);
}
else
{
DeleteFile(#file_path);
SelectFileByName(new_file_ed.text);
}
DeleteFile(#file_path);
SelectFileByName(new_file_ed.text);
}
}
else
{
notify(FS_ITEM_ALREADY_EXISTS);
}
}
new_element_active = 0;
Open_Dir(#path,WITH_REDRAW);
SelectFileByName(new_file_ed.text);
}
else
{
notify(FS_ITEM_ALREADY_EXISTS);
}
}
new_element_active = 0;
Open_Dir(#path,WITH_REDRAW);
SelectFileByName(new_file_ed.text);
EventClosePopinForm();
}
void NewElement_Form(byte crt, dword strng)
@ -1093,8 +1103,7 @@ void FnProcess(byte N)
NewElement_Form(CREATE_FILE, T_NEW_FILE);
break;
case 8:
properties_stak = malloc(8096);
CreateThread(#properties_dialog, properties_stak+8092);
EventShowProperties();
break;
case 10: //F10
if (!active_settings)
@ -1253,4 +1262,45 @@ void ProceedMouseGestures()
}
}
void EventPaste() {
char paste_line[4096+6];
sprintf(#paste_line, "-v%i %s", cut_active, #path);
RunProgram(#program_path, #paste_line);
EventClosePopinForm();
}
void EventDelete()
char line_param[4096+5];
{
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()
{
del_active=0;
new_element_active = 0;
draw_window();
DeleteButton(POPUP_BTN1);
DeleteButton(POPUP_BTN2);
}
void EventShowProperties()
char line_param[4096+5];
{
if (!selected_count) {
sprintf(#line_param, "-p %s", #file_path);
RunProgram(#program_path, #line_param);
} else {
properties_stak = malloc(8096);
CreateThread(#properties_dialog, properties_stak+8092);
}
}
stop:

View File

@ -1,141 +0,0 @@
byte copy_to[4096];
byte copy_from[4096];
byte cut_active=0;
enum {NOCUT, CUT};
void setElementSelectedFlag(dword n, int state) {
dword selected_offset = file_mas[n]*304 + buf+32 + 7;
ESBYTE[selected_offset] = state;
if (n==0) && (strncmp(file_mas[n]*304+buf+72,"..",2)==0) {
ESBYTE[selected_offset] = false; //do not selec ".." directory
return;
}
if (state==true) selected_count++;
if (state==false) selected_count--;
if (selected_count<0) selected_count=0;
}
int getElementSelectedFlag(dword n) {
dword selected_offset = file_mas[n]*304 + buf+32 + 7;
return ESBYTE[selected_offset];
}
void Copy(dword pcth, char cut)
{
byte copy_t[4096];
dword buff_data;
dword path_len = 0;
dword size_buf = 0;
dword copy_buf_offset = 0;
dword i;
if (files.count<=0) return; //no files
//if no element selected by "Insert" key, then we copy current element
if (!selected_count)
setElementSelectedFlag(files.cur_y, true);
if (!selected_count) return;
size_buf = 4;
for (i=0; i<files.count; i++)
{
if (getElementSelectedFlag(i) == true) {
sprintf(#copy_t,"%s/%s",#path,file_mas[i]*304+buf+72);
path_len = strlen(#copy_t);
size_buf += path_len + 1;
}
}
size_buf += 20;
buff_data = malloc(size_buf);
ESDWORD[buff_data] = size_buf;
ESDWORD[buff_data+4] = SLOT_DATA_TYPE_RAW;
ESINT[buff_data+8] = selected_count;
copy_buf_offset = buff_data + 10;
for (i=0; i<files.count; i++)
{
if (getElementSelectedFlag(i) == true) {
sprintf(copy_buf_offset,"%s/%s",#path,file_mas[i]*304+buf+72);
copy_buf_offset += strlen(copy_buf_offset) + 1;
}
}
if (selected_count==1) setElementSelectedFlag(files.cur_y, false);
Clipboard__SetSlotData(size_buf, buff_data);
cut_active = cut;
free(buff_data);
}
void Paste() {
copy_stak = free(copy_stak);
copy_stak = malloc(64000);
CreateThread(#PasteThread,copy_stak+64000-4);
}
void PasteThread()
{
char copy_rezult;
int j;
int paste_elements_count = 0;
dword buf;
dword path_offset;
dword file_count_paste = 0;
_dir_size paste_dir_size;
BDVK file_info_count;
copy_bar.value = 0;
buf = Clipboard__GetSlotData(Clipboard__GetSlotCount()-1);
if (DSDWORD[buf+4] != 3) return;
paste_elements_count = ESINT[buf+8];
path_offset = buf + 10;
//calculate copy files count for progress bar
for (j = 0; j < paste_elements_count; j++) {
GetFileInfo(path_offset, #file_info_count);
if ( file_info_count.isfolder ) {
paste_dir_size.get(path_offset);
file_count_paste += paste_dir_size.files;
}
else file_count_paste++;
path_offset += strlen(path_offset) + 1;
}
copy_bar.max = file_count_paste;
if (cut_active) operation_flag = MOVE_FLAG;
else operation_flag = COPY_FLAG;
path_offset = buf + 10;
DisplayOperationForm();
for (j = 0; j < paste_elements_count; j++) {
strcpy(#copy_from, path_offset);
if (!copy_from) DialogExit();
sprintf(#copy_to, "%s/%s", #path, #copy_from+strrchr(#copy_from,'/'));
if (!strcmp(#copy_from,#copy_to))
{
sprintf(#copy_to, "%s/NEW_%s", #path, #copy_from+strrchr(#copy_from,'/'));
}
if (strstr(#copy_to, #copy_from))
{
notify("Copy directory into itself is a bad idea...");
DialogExit();
}
if (copy_rezult = copyf(#copy_from,#copy_to))
{
Write_Error(copy_rezult);
if (copy_rezult==8) DialogExit(); //not enough space
}
else if (cut_active)
{
strcpy(#file_path, #copy_from);
Del_File2(#copy_from, 0);
}
path_offset += strlen(path_offset) + 1;
}
cut_active=false;
if (info_after_copy.checked) notify(INFO_AFTER_COPY);
DialogExit();
}

View File

@ -0,0 +1,237 @@
//===================================================//
// //
// MASS ACTIONS //
// //
//===================================================//
void setElementSelectedFlag(dword n, int state) {
dword selected_offset = file_mas[n]*304 + buf+32 + 7;
ESBYTE[selected_offset] = state;
if (n==0) && (strncmp(file_mas[n]*304+buf+72,"..",2)==0) {
ESBYTE[selected_offset] = false; //do not selec ".." directory
return;
}
if (state==true) selected_count++;
if (state==false) selected_count--;
if (selected_count<0) selected_count=0;
}
int getElementSelectedFlag(dword n) {
dword selected_offset = file_mas[n]*304 + buf+32 + 7;
return ESBYTE[selected_offset];
}
dword GetFilesCount(dword _in_path)
{
int j;
BDVK file_info_count;
DIR_SIZE paste_dir_size;
GetFileInfo(_in_path, #file_info_count);
if ( file_info_count.isfolder ) {
return paste_dir_size.get(_in_path);
} else {
return 1;
}
}
//===================================================//
// //
// COPY AND PASTE //
// //
//===================================================//
byte copy_to[4096];
byte copy_from[4096];
bool cut_active = false;
enum {NOCUT, CUT};
void EventCopy(bool _cut_active)
{
byte copy_t[4096];
dword buff_data;
dword path_len = 0;
dword size_buf = 0;
dword copy_buf_offset = 0;
dword i;
if (files.count<=0) return; //no files
cut_active = _cut_active;
//if no element selected by "Insert" key, then we copy current element
if (!selected_count) {
setElementSelectedFlag(files.cur_y, true);
}
if (!selected_count) return;
size_buf = 4;
for (i=0; i<files.count; i++)
{
if (getElementSelectedFlag(i) == true) {
sprintf(#copy_t,"%s/%s",#path,file_mas[i]*304+buf+72);
path_len = strlen(#copy_t);
size_buf += path_len + 1;
}
}
size_buf += 20;
buff_data = malloc(size_buf);
ESDWORD[buff_data] = size_buf;
ESDWORD[buff_data+4] = SLOT_DATA_TYPE_RAW;
ESINT[buff_data+8] = selected_count;
copy_buf_offset = buff_data + 10;
for (i=0; i<files.count; i++)
{
if (getElementSelectedFlag(i) == true) {
sprintf(copy_buf_offset,"%s/%s",#path,file_mas[i]*304+buf+72);
copy_buf_offset += strlen(copy_buf_offset) + 1;
}
}
if (selected_count==1) setElementSelectedFlag(files.cur_y, false);
Clipboard__SetSlotData(size_buf, buff_data);
free(buff_data);
}
void PasteThread()
{
char copy_rezult;
int j;
int paste_elements_count = 0;
dword buf;
dword path_offset;
buf = Clipboard__GetSlotData(Clipboard__GetSlotCount()-1);
if (DSDWORD[buf+4] != 3) return;
paste_elements_count = ESINT[buf+8];
path_offset = buf + 10;
if (cut_active) {
DisplayOperationForm(MOVE_FLAG);
} else {
DisplayOperationForm(COPY_FLAG);
}
for (j = 0; j < paste_elements_count; j++) {
copy_bar.max += GetFilesCount(path_offset);
path_offset += strlen(path_offset) + 1;
}
path_offset = buf + 10;
for (j = 0; j < paste_elements_count; j++) {
strcpy(#copy_from, path_offset);
if (!copy_from) DialogExit();
sprintf(#copy_to, "%s/%s", #path, #copy_from+strrchr(#copy_from,'/'));
if (!strcmp(#copy_from,#copy_to))
{
sprintf(#copy_to, "%s/NEW_%s", #path, #copy_from+strrchr(#copy_from,'/'));
}
if (strstr(#copy_to, #copy_from))
{
notify("Copy directory into itself is a bad idea...");
DialogExit();
}
if (copy_rezult = copyf(#copy_from,#copy_to))
{
Write_Error(copy_rezult);
if (copy_rezult==8) DialogExit(); //not enough space
}
else if (cut_active)
{
strcpy(#file_path, #copy_from);
Del_File2(#copy_from, 0);
}
path_offset += strlen(path_offset) + 1;
}
cut_active=false;
if (info_after_copy.checked) notify(INFO_AFTER_COPY);
DialogExit();
}
//===================================================//
// //
// DELETE //
// //
//===================================================//
int del_error;
int Del_File2(dword way, sh_progr)
{
dword dirbuf, fcount, i, filename;
int error;
char del_from[4096];
if (dir_exists(way))
{
if (error = GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL)) del_error = error;
for (i=0; i<fcount; i++)
{
//if (CheckEvent()==evReDraw) draw_window();
filename = i*304+dirbuf+72;
sprintf(#del_from,"%s/%s",way,filename);
if ( TestBit(ESDWORD[filename-40], 4) )
{
Del_File2(#del_from, 1);
}
else
{
if (sh_progr) Operation_Draw_Progress(filename);
if (error = DeleteFile(#del_from)) del_error = error;
}
}
}
if (error = DeleteFile(way)) del_error = error;
}
void DeleteSingleElement()
{
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;
DisplayOperationForm(DELETE_FLAG);
if (!selected_count) { DeleteSingleElement(); return; }
for (i=0; i<files.count; i++)
{
if (getElementSelectedFlag(i) == true) {
sprintf(#del_from,"%s/%s",#path,file_mas[i]*304+buf+72);
copy_bar.max += GetFilesCount(#del_from);
}
}
del_error = 0;
for (i=0; i<files.count; i++)
{
if (getElementSelectedFlag(i) == true) {
sprintf(#del_from,"%s/%s", #path, file_mas[i]*304+buf+72);
Del_File2(#del_from, 1);
}
}
if (del_error) Write_Error(del_error);
cmd_free = 6;
DialogExit();
}

View File

@ -1,95 +0,0 @@
int del_error;
int Del_File2(dword way, sh_progr)
{
dword dirbuf, fcount, i, filename;
int error;
char del_from[4096];
if (dir_exists(way))
{
if (error = GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL)) del_error = error;
for (i=0; i<fcount; i++)
{
if (CheckEvent()==evReDraw) draw_window();
filename = i*304+dirbuf+72;
sprintf(#del_from,"%s/%s",way,filename);
if ( TestBit(ESDWORD[filename-40], 4) )
{
Del_File2(#del_from, 1);
}
else
{
if (sh_progr) Operation_Draw_Progress(filename);
if (error = DeleteFile(#del_from)) del_error = error;
}
}
}
if (error = DeleteFile(way)) del_error = error;
}
void Del_File_Thread()
{
byte del_from[4096];
int tst, count, i;
BDVK file_info_count;
_dir_size delete_dir_size;
dword file_count_delete = 0;
copy_bar.value = 0;
operation_flag = DELETE_FLAG;
if (selected_count)
{
for (i=0; i<files.count; i++)
{
if (getElementSelectedFlag(i) == true) {
sprintf(#del_from,"%s/%s",#path,file_mas[i]*304+buf+72);
GetFileInfo(#del_from, #file_info_count);
if ( file_info_count.isfolder ) {
delete_dir_size.get(#del_from);
file_count_delete += delete_dir_size.files;
}
else file_count_delete++;
}
}
}
else
{
if (itdir) {
delete_dir_size.get(#file_path);
file_count_delete += delete_dir_size.files;
}
else file_count_delete++;
}
copy_bar.max = file_count_delete;
del_error = 0;
DisplayOperationForm();
if (selected_count)
{
for (i=0; i<files.count; i++)
{
if (getElementSelectedFlag(i) == true) {
sprintf(#del_from,"%s/%s",#path,file_mas[i]*304+buf+72);
Del_File2(#del_from, 1);
}
}
}
else
{
Del_File2(#file_path, 1);
}
if (del_error) Write_Error(del_error);
cmd_free = 6;
DialogExit();
}
void Del_File(byte dodel) {
del_active=0;
if (dodel)
{
delete_stak = malloc(40000);
CreateThread(#Del_File_Thread,delete_stak+40000-4);
}
else draw_window();
}

View File

@ -95,23 +95,23 @@ bool active_menu = false;
void EventMenuClick(dword _id)
{
if (active_menu == MENU_NO_FILE) switch(_id) {
case 1: Paste(); break;
case 1: EventPaste(); break;
}
if (active_menu == MENU_FILE) switch(_id) {
case 1: Open(0); break;
case 2: ShowOpenWithDialog(); break;
case 3: Copy(#file_path, NOCUT); break;
case 4: Copy(#file_path, CUT); break;
case 5: Paste(); break;
case 3: EventCopy(NOCUT); break;
case 4: EventCopy(CUT); break;
case 5: EventPaste(); break;
case 6: FnProcess(2); break;
case 7: Del_Form(); break;
case 8: FnProcess(8); break;
}
if (active_menu == MENU_DIR) switch(_id) {
case 1: Open(0); break;
case 2: Copy(#file_path, NOCUT); break;
case 3: Copy(#file_path, CUT); break;
case 4: Paste(); break;
case 2: EventCopy(NOCUT); break;
case 3: EventCopy(CUT); break;
case 4: EventPaste(); break;
case 5: Del_Form(); break;
case 6: FnProcess(8); break;
}

View File

@ -8,30 +8,35 @@
proc_info Dialog_Form;
progress_bar copy_bar = {0,PR_LEFT,PR_TOP,PR_W,PR_H,0,0,1,0xFFFFFF,0x00FF00,0x555555};
//sensor copying = {PR_LEFT,PR_TOP,WIN_DIALOG_W-PR_LEFT-PR_LEFT,19};
int operation_flag;
enum {
REDRAW_FLAG,
COPY_FLAG,
MOVE_FLAG,
DELETE_FLAG,
OPERATION_END
};
void DisplayOperationForm()
void DisplayOperationForm(int operation_flag)
{
dword title;
if (operation_flag==COPY_FLAG) {
title = T_COPY_WINDOW_TITLE;
copy_bar.progress_color = 0x00FF00;
copy_bar.value = 0;
copy_bar.max = 0;
}
else if (operation_flag==MOVE_FLAG) {
title = T_MOVE_WINDOW_TITLE;
copy_bar.progress_color = 0x00FF00;
copy_bar.value = 0;
copy_bar.max = 0;
}
else if (operation_flag==DELETE_FLAG) {
title = T_DELETE_WINDOW_TITLE;
copy_bar.progress_color = 0xF17A65;
copy_bar.value = 0;
copy_bar.max = 0;
}
copy_bar.frame_color = sc.work_graph;
switch(CheckEvent())
@ -42,13 +47,13 @@ void DisplayOperationForm()
break;
case evReDraw:
DefineAndDrawWindow(Form.left+Form.width-200,Form.top+90,WIN_DIALOG_W+9,skin_height+WIN_DIALOG_H,0x34,sc.work,title,0);
DefineAndDrawWindow(Form.left+Form.width-200, Form.top+90, WIN_DIALOG_W+9,
skin_height+WIN_DIALOG_H, 0x34, sc.work, title, 0);
GetProcessInfo(#Dialog_Form, SelfInfo);
DrawCaptButton(WIN_DIALOG_W-PR_LEFT-101, PR_TOP+PR_H+6, 100,26, 2,
sc.button, sc.button_text, T_ABORT_WINDOW_BUTTON);
DrawRectangle3D(PR_LEFT-1, PR_TOP-1, PR_W+1, PR_H+1, sc.work_dark, sc.work_light);
//copying.draw_wrapper();
}
}
@ -64,15 +69,12 @@ void Operation_Draw_Progress(dword filename) {
copy_bar.value++;
return;
}
DisplayOperationForm();
DisplayOperationForm(REDRAW_FLAG);
DrawBar(PR_LEFT, PR_TOP-20, WIN_DIALOG_W-PR_LEFT, 15, sc.work);
WriteText(PR_LEFT, PR_TOP-20, 0x90, sc.work_text, filename);
progressbar_draw stdcall (#copy_bar);
progressbar_progress stdcall (#copy_bar);
//copy_bar.value++;
//pause(1);
//copying.draw_progress(copy_bar.value*copying.w/copy_bar.max, copy_bar.value, copy_bar.max-copy_bar.value, "");
WriteTextWithBg(PR_LEFT, PR_TOP+PR_H+5, 0xD0, sc.work_text,
sprintf(#param, "%i/%i", copy_bar.value, copy_bar.max), sc.work);

View File

@ -51,7 +51,8 @@ BDVK file_info_dirsize;
bool apply_question_active;
_dir_size more_files_count;
DIR_SIZE more_files_count;
DIR_SIZE dir_size;
checkbox ch_read_only = { PR_T_ONLY_READ, NULL };
checkbox ch_hidden = { PR_T_HIDDEN, NULL };

View File

@ -16,8 +16,9 @@ void Sort_by_Name(int a, b) //
int j;
int isn = a;
if (a >= b) return;
for (j = a; j <= b; j++)
if (strcmp(file_mas[j]*304 + buf+72, file_mas[b]*304 + buf+72)<=0) { file_mas[isn] >< file_mas[j]; isn++;}
for (j = a; j <= b; j++) {
if (strcmpi(file_mas[j]*304 + buf+72, file_mas[b]*304 + buf+72)<=0) { file_mas[isn] >< file_mas[j]; isn++;}
}
Sort_by_Name(a, isn-2);
Sort_by_Name(isn, b);
}
@ -44,11 +45,9 @@ void Sort_by_Type(int a, b) //
n=strcmp(ext1, ext2);
if (n<0) { file_mas[isn] >< file_mas[j]; isn++;}
if (!n) && (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);
}

View File

@ -1,5 +1,5 @@
#define TITLE "Eolite File Manager 4.24b"
#define ABOUT_TITLE "EOLITE 4.24b"
#define TITLE "Eolite File Manager 4.28"
#define ABOUT_TITLE "EOLITE 4.28"
#ifdef LANG_RUS
?define T_FILE "” ©«"

View File

@ -15,9 +15,15 @@ void test1()
collection s;
{
s.add("Hello");
s.add("World!");
s.add("World");
debugln(s.get(0)); //-> Hello
debugln(s.get(1)); //-> World
s.delete_last();
debugln(s.get(0)); //-> Hello
debugln(s.get(1)); //-> 0
s.add("Kolibri");
debugln(s.get(0)); //-> Hello
debugln(s.get(1)); //-> Kolibri
s.drop();
}

View File

@ -20,6 +20,8 @@ struct collection
dword get_pos_by_name();
void drop();
void increase_data_size();
dword get_last();
bool delete_last();
};
:void collection::increase_data_size() {
@ -40,7 +42,10 @@ struct collection
}
:int collection::addn(dword in, len) {
if (count >= 4000) return 0;
if (count >= 4000) {
debugln("collection: more than 4000 elements!");
return 0;
}
if (element_offset[count]+len+2 > data_size) {
increase_data_size();
addn(in, len);
@ -57,6 +62,10 @@ struct collection
return data_start + element_offset[pos];
}
:dword collection::get_last() {
return get(count-1);
}
:dword collection::get_pos_by_name(dword name) {
dword i;
for (i=0; i<count; i++) {
@ -73,6 +82,9 @@ struct collection
count = 0;
}
:bool collection::delete_last() {
count--;
}
/*========================================================
= =

View File

@ -15,7 +15,7 @@
if (!from1) || (!in1)
{
notify("Error: too few copyf() params!");
return;
return -1;
}
if (error = GetFileInfo(from1, #CopyFile_atr1))
{

View File

@ -6,6 +6,10 @@
#include "../lib/date.h"
#endif
#ifndef INCLUDE_COLLECTION_H
#include "../lib/collection.h"
#endif
//===================================================//
// //
// Basic System Functions //
@ -235,14 +239,14 @@ enum
DIRS_ONLYREAL
};
:int GetDir(dword dir_buf, file_count, path, doptions)
dword buf, fcount, error;
char readbuf[32];
{
dword buf, fcount, error;
buf = malloc(32);
error = ReadDir(0, buf, path);
error = ReadDir(0, #readbuf, path);
if (!error)
{
fcount = ESDWORD[buf+8];
buf = realloc(buf, fcount+1*304+32);
fcount = ESDWORD[#readbuf+8];
buf = malloc(fcount+1*304+32);
ReadDir(fcount, buf, path);
//fcount=EBX;
@ -261,7 +265,7 @@ enum
}
else
{
ESDWORD[dir_buf] = free(buf);
ESDWORD[dir_buf] = 0;
ESDWORD[file_count] = 0;
}
return error;
@ -421,26 +425,28 @@ int block_size=1024*1024*4; //copy by 4 MiB
// //
//===================================================//
:struct _dir_size
:struct DIR_SIZE
{
BDVK dir_info;
dword folders;
dword files;
dword bytes;
void get();
void calculate_loop();
} dir_size;
dword get();
dword calculate_loop();
};
:void _dir_size::get(dword way)
:dword DIR_SIZE::get(dword way1)
{
folders = files = bytes = 0;
if (way) calculate_loop(way);
if (!way1) return 0;
calculate_loop(way1);
}
:void _dir_size::calculate_loop(dword way)
:dword DIR_SIZE::calculate_loop(dword way)
{
dword dirbuf, fcount, i, filename;
dword cur_file;
if (!way) return 0;
if (dir_exists(way))
{
cur_file = malloc(4096);
@ -467,6 +473,8 @@ int block_size=1024*1024*4; //copy by 4 MiB
free(cur_file);
free(dirbuf);
}
return files;
}
#endif

View File

@ -491,7 +491,7 @@ LS3:
}
}
inline dword strcmpi(dword cmp1, cmp2)
inline signed int strcmpi(dword cmp1, cmp2)
{
char si, ue;
@ -501,7 +501,7 @@ inline dword strcmpi(dword cmp1, cmp2)
ue = DSBYTE[cmp2];
if (si>='A') && (si<='Z') si +=32;
if (ue>='A') && (ue<='Z') ue +=32;
if (si != ue) return -1;
if (si != ue) return si-ue;
cmp1++;
cmp2++;
if ((DSBYTE[cmp1]=='\0') && (DSBYTE[cmp2]=='\0')) return 0;

View File

@ -147,6 +147,13 @@ void main()
}
}
void CorrectLastItem()
{
if (menu1.cur_y > menu1.count - GetSeparatorsCount() - 1) {
menu1.cur_y = menu1.count - GetSeparatorsCount() - 1;
}
}
void ProcessKeys()
{
switch(key_scancode)
@ -164,7 +171,16 @@ void ProcessKeys()
break;
case SCAN_CODE_UP:
if (!menu1.KeyUp()) menu1.KeyEnd();
if (!menu1.KeyUp()) {
menu1.KeyEnd();
CorrectLastItem();
}
draw_list();
break;
case SCAN_CODE_END:
menu1.KeyEnd();
CorrectLastItem();
draw_list();
break;

View File

@ -21,6 +21,7 @@ dword tmp_size[10];
void General__Main()
{
DIR_SIZE dir_size;
dword cpu_frequency;
incn y;
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON);