forked from KolibriOS/kolibrios
910558ed00
git-svn-id: svn://kolibrios.org@3295 a494cfbc-eb01-0410-851d-a64ba20cac60
828 lines
23 KiB
Plaintext
828 lines
23 KiB
Plaintext
//Leency & Veliant -=- KolibriOS Team -=- 2012
|
|
//GNU GPL licence.
|
|
|
|
//êîïèðîâàòü ÷åðåç ïîòîê
|
|
//IF (strcmp(#path+strlen(#path)-1,"/")<>0) copystr("/",#path+strlen(#path)); //åñëè íåò, + "/" ïåðåíåñòèâ îïåíäèð
|
|
//èêîíêà äåéñòâèòåëüíî íóæíà äðóãàÿ äëÿ íåèçâåñíûõ óñòðîéñòâ è ïàïîê â áóäóþùåì.
|
|
|
|
#include "lib\kolibri.h"
|
|
#include "lib\memory.h"
|
|
#include "lib\edit_box_lib.h"
|
|
#include "lib\file_system.h"
|
|
#include "imgs\toolbar.txt"
|
|
#include "imgs\left_p.txt"
|
|
|
|
int BUTTON_HEIGHT=18;
|
|
|
|
//for OpenDir
|
|
#define ONLY_SHOW 0
|
|
#define WITH_REDRAW 1
|
|
#define ONLY_OPEN 2
|
|
|
|
//ïåðåìåííûå
|
|
#define title "Eolite File Manager v1.56"
|
|
dword col_work = 0xE4DFE1;
|
|
dword col_border = 0x819FC5;
|
|
dword col_padding = 0xC8C9C9;
|
|
dword col_selec = 0x94AECE;
|
|
dword col_lpanel = 0x00699C;
|
|
|
|
|
|
/*
|
|
int
|
|
f_count,
|
|
f_first,
|
|
f_current;
|
|
*/
|
|
|
|
int f_visible,
|
|
count,
|
|
za_kadrom,
|
|
curbtn;
|
|
|
|
|
|
byte cut_active,
|
|
rename_active,
|
|
del_active;
|
|
byte show_actions=1,
|
|
show_dev_name=1,
|
|
sort_num=2,
|
|
isdir;
|
|
unsigned char
|
|
path[4096],
|
|
edit_path[4096],
|
|
file_path[4096],
|
|
file_name[4096],
|
|
copy_file[4096],
|
|
temp[4096];
|
|
int scroll_size;
|
|
|
|
|
|
|
|
int toolbar_buttons_x[7]={9,46,85,134,167,203};
|
|
char tmp_disk_del_param[3]="d0\0";
|
|
|
|
dword file_mas[6898];
|
|
int j, i, mouse_dd;
|
|
int scroll_used;
|
|
|
|
struct path_string {
|
|
char Item[4096];
|
|
};
|
|
|
|
|
|
dword stak[100]; //îêíî About
|
|
|
|
edit_box edit1= {250,247,13,0xffffff,0x94AECE,0xD3DDEB,0xffffff,0,248,#edit_path,#mouse_dd,64,6,6};
|
|
edit_box edit2= {250,213,80,0xFFFFCC,0x94AECE,0xFFFFCC,0xffffff,0,248,#file_name,#mouse_dd,64,6,6};
|
|
|
|
proc_info Form;
|
|
dword buf, off; //äëÿ òåêñòà è áóôåðà
|
|
|
|
#include "include\some_code.h"
|
|
#include "include\about_dialog.h"
|
|
#include "include\sorting.h"
|
|
#include "include\icons_f.h"
|
|
#include "include\ini.h"
|
|
#include "include\left_panel.h"
|
|
#include "include\history.h"
|
|
|
|
void main()
|
|
{
|
|
word key, id;
|
|
mouse m;
|
|
|
|
load_editbox_lib();
|
|
GetSystemDiscs();
|
|
GetIni(1);
|
|
|
|
edit1.shift_color=col_selec;
|
|
edit2.shift_color=col_selec;
|
|
|
|
if (param)
|
|
{
|
|
copystr(#param, #path);
|
|
if (strcmp(#path+strlen(#path)-1,"/")<>0) copystr("/",#path+strlen(#path)); //åñëè íåò, + "/"
|
|
}
|
|
else
|
|
copystr("/rd/1/", #path);
|
|
|
|
Open_Dir(#path,ONLY_OPEN);
|
|
loop() switch(WaitEvent())
|
|
{
|
|
case evMouse:
|
|
IF (del_active) break;
|
|
|
|
id=GetSlot(Form.ID);
|
|
IF (id<>GetActiveProcess()) break; //åñëè îêíî íå àêòèâíî íà ñîáûòèÿ ìûøè íå ðåàãèðóåì
|
|
|
|
IF (!rename_active) edit_box_mouse stdcall(#edit1); ELSE edit_box_mouse stdcall(#edit2);
|
|
|
|
m.get();
|
|
|
|
if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>40) && (m.y<57)
|
|
{
|
|
IF (m.lkm==1) DrawRegion_3D(onLeft(26,0),41,14,14,0xC7C7C7,0xFFFFFF);
|
|
WHILE (m.lkm==1) && (za_kadrom>0)
|
|
{
|
|
Pause(10);
|
|
za_kadrom--;
|
|
List_ReDraw();
|
|
m.get();
|
|
}
|
|
DrawRegion_3D(onLeft(26,0),41,14,14,0xFFFFFF,0xC7C7C7);
|
|
}
|
|
|
|
if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>onTop(22,0)+1) && (m.y<onTop(22,0)+16)
|
|
{
|
|
IF (m.lkm==1) DrawRegion_3D(onLeft(26,0),onTop(21,0),14,14,0xC7C7C7,0xFFFFFF);
|
|
while (m.lkm==1) && (za_kadrom<count-f_visible)
|
|
{
|
|
Pause(10);
|
|
za_kadrom++;
|
|
List_ReDraw();
|
|
m.get();
|
|
}
|
|
DrawRegion_3D(onLeft(26,0),onTop(21,0),14,14,0xFFFFFF,0xC7C7C7);
|
|
}
|
|
|
|
//êîë¸ñèêî ìûøè
|
|
IF (m.vert==65535) && (za_kadrom>0)
|
|
{
|
|
if (za_kadrom>0) za_kadrom--;
|
|
if (curbtn<f_visible-1) curbtn++;
|
|
List_ReDraw();
|
|
if (za_kadrom>0) za_kadrom--;
|
|
if (curbtn<f_visible-1) curbtn++;
|
|
List_ReDraw();
|
|
}
|
|
IF (m.vert==1) && (za_kadrom<count-f_visible)
|
|
{
|
|
if (za_kadrom<count-f_visible) za_kadrom++;
|
|
if (curbtn>0) curbtn--;
|
|
List_ReDraw();
|
|
if (za_kadrom<count-f_visible) za_kadrom++;
|
|
if (curbtn>0) curbtn--;
|
|
List_ReDraw();
|
|
}
|
|
//ñêðîëë
|
|
if (!m.lkm) && (scroll_used) { scroll_used=NULL; TVScroll(); }
|
|
if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>56) && (m.y<Form.height) && (m.lkm) && (!scroll_used) {scroll_used=1;TVScroll();}
|
|
|
|
if (scroll_used)
|
|
{
|
|
IF (scroll_size/2+57>m.y) || (m.y<0) || (m.y>4000) m.y=scroll_size/2+57; //åñëè êóðñîð íàä îêíîì
|
|
id=za_kadrom; //ñîõðàíÿåì ñòàðîå êîëè÷åñòâî
|
|
j= scroll_size/2;
|
|
za_kadrom = m.y -j -57 * count;
|
|
za_kadrom /= onTop(22,57);
|
|
IF (f_visible+za_kadrom>count) za_kadrom=count-f_visible;
|
|
IF (id<>za_kadrom) List_ReDraw(); //÷òîá ëèøíèé ðàç íå ïåðåðèñîâûâàòü
|
|
}
|
|
break;
|
|
//Button pressed-----------------------------------------------------------------------------
|
|
case evButton:
|
|
id=GetButtonID();
|
|
IF (id==1) ExitProcess();
|
|
|
|
IF (del_active)
|
|
{
|
|
IF (id==301) || (id==302) Del_File(302-id);
|
|
break;
|
|
}
|
|
switch(id)
|
|
{
|
|
case 21: //Back
|
|
GoBack();
|
|
break;
|
|
case 22: //Forward
|
|
if (HistoryPath(GO_FORWARD))
|
|
{
|
|
za_kadrom=curbtn=NULL; //ââåðõ ñïèñêà
|
|
Open_Dir(#path,WITH_REDRAW);
|
|
}
|
|
break;
|
|
case 23: //up!
|
|
Dir_Up();
|
|
break;
|
|
case 24: //cut
|
|
key=24;
|
|
case 25: //copy
|
|
goto CTRLC_MARK;
|
|
case 26: //paste
|
|
Paste();
|
|
break;
|
|
case 27: //goto edit_path
|
|
Goto_edit_path();
|
|
break;
|
|
case 31...33: //sort
|
|
IF(sort_num==1) DrawFilledBar(onLeft(192,168)/2+210,42,6,10);
|
|
IF(sort_num==2) DrawFilledBar(onLeft(115,0),42,6,10);
|
|
IF(sort_num==3) DrawFilledBar(onLeft(44,0),42,6,10);
|
|
sort_num=id-30;
|
|
Open_Dir(#path,1);
|
|
break;
|
|
case 30: //about
|
|
CreateThread(#about_dialog,#stak);
|
|
break;
|
|
case 77:
|
|
IF (show_actions==1) show_actions=0; ELSE show_actions=1;
|
|
DrawLeftPanel();
|
|
break;
|
|
case 78: //rescan devices
|
|
Tip(56, "Devices", 78, "-");
|
|
Pause(10);
|
|
GetSystemDiscs();
|
|
Open_Dir(#path,WITH_REDRAW);
|
|
DrawLeftPanel();
|
|
break;
|
|
case 80: //rename
|
|
goto REN_MARK;
|
|
case 81: //Delete file
|
|
Del_Form();
|
|
break;
|
|
case 82: //create folder
|
|
NEW_FOLDER_MARK:
|
|
copystr(#path, #temp);
|
|
copystr("New folder", #temp+strlen(#temp));
|
|
CreateFolder(#temp);
|
|
IF (!EAX){
|
|
SelectFile("New folder");
|
|
goto REN_MARK;
|
|
}
|
|
ELSE
|
|
{
|
|
Write_Error(EAX);
|
|
ShowMessage("Folder can not be created.");
|
|
}
|
|
break;
|
|
case 100...120:
|
|
DEVICE_MARK:
|
|
DrawRegion_3D(17,id-100*16+74,159,16, 0, 0); //âûäåëåíèå
|
|
copystr(#disk_list[id-100].Item, #path);
|
|
za_kadrom=curbtn=0;
|
|
Open_Dir(#path,1);
|
|
Pause(5);
|
|
DrawRegion_3D(17,id-100*16+74,159,16, 0xFFFFFF, 0xFFFFFF);
|
|
break;
|
|
case 130...160:
|
|
tmp_disk_del_param[1]=disk_list[id-130].Item[4];
|
|
RunProgram("/sys/tmpdisk", #tmp_disk_del_param);
|
|
Pause(10);
|
|
GetSystemDiscs();
|
|
Open_Dir(#path,WITH_REDRAW);
|
|
DrawLeftPanel();
|
|
break;
|
|
default:
|
|
if (id<200) break; //êíîïêè èç ñïèñêà ôàéëîâ
|
|
if (curbtn!=id-201) {FileList_ReDraw(id-201-curbtn); break;}
|
|
else
|
|
OPEN_MARK:
|
|
if (!isdir) GetIni(0); else
|
|
if (!strcmp(#file_name,"..")) Dir_Up();
|
|
else
|
|
{
|
|
OPEN_DEV:
|
|
copystr(#file_path, #path);
|
|
IF (strcmp(#path+strlen(#path)-1,"/")<>0) copystr("/",#path+strlen(#path)); //åñëè íåò, + "/"
|
|
za_kadrom=curbtn=0;
|
|
Open_Dir(#path,1);
|
|
}
|
|
}
|
|
break;
|
|
//Key pressed-----------------------------------------------------------------------------
|
|
case evKey:
|
|
key = GetKey();
|
|
if (Form.status_window>2) break;
|
|
IF (del_active)
|
|
{
|
|
IF (key==013) Del_File(true);
|
|
IF (key==027) Del_File(false);
|
|
break;
|
|
}
|
|
IF (edit1.flags<>64) && (edit1.flags<>0) && (key<>13)
|
|
{
|
|
EAX=key<<8;
|
|
edit_box_key stdcall (#edit1);
|
|
break;
|
|
}
|
|
IF (edit2.flags<>64) && (key<>13) && (key<>27)
|
|
{
|
|
EAX=key<<8;
|
|
edit_box_key stdcall (#edit2);
|
|
break;
|
|
}
|
|
switch (key)
|
|
{
|
|
case 209...217:
|
|
id=key-110;
|
|
IF (id-100>=disc_num) break;
|
|
GOTO DEVICE_MARK;
|
|
case 8: //Íàçàä
|
|
//GoBack();
|
|
Dir_Up();
|
|
break;
|
|
case 004: //Ctrl+D ðèñ íà ðàá ñòîë ðàñòÿíóòü
|
|
copystr("\\S__", #temp);
|
|
copystr(#file_path, #temp+strlen(#temp));
|
|
RunProgram("/sys/media/kiv", #temp);
|
|
break;
|
|
case 014: //Ctrl+N íîâîå îêíî
|
|
IF (Form.left==98) MoveSize(Form.left-20,Form.top-20,OLD,OLD);
|
|
RunProgram("/sys/File Managers/Eolite", #path);
|
|
break;
|
|
case 024: //Ctrl+X
|
|
case 003: //Ctrl+C
|
|
CTRLC_MARK:
|
|
IF (isdir) break; //ïàïêè ïîêà ÷òî êîïèðîâàòü íå óìååì
|
|
copystr(#file_path,#copy_file); //âû÷èñëÿåì êàêîé ôàéë êîïèðîâàòü
|
|
IF (key==24) cut_active=1; ELSE cut_active=0;
|
|
break;
|
|
case 022: //Ctrl+V
|
|
Paste();
|
|
break;
|
|
case 027: //Esc
|
|
IF (rename_active==1) ReName(false);
|
|
break;
|
|
case 013: //Enter
|
|
IF (rename_active==1) {ReName(true); break;}
|
|
IF (strcmp(#path,#edit_path)<>0) Goto_edit_path();
|
|
ELSE GOTO OPEN_MARK;
|
|
break;
|
|
case 55: //F6 - new folder
|
|
goto NEW_FOLDER_MARK;
|
|
case 56: //IF (rename_active==1) break;//up
|
|
case 178: //up
|
|
FileList_ReDraw(-1);
|
|
break;
|
|
case 177: //down
|
|
FileList_ReDraw(1);
|
|
break;
|
|
case 180: //home
|
|
za_kadrom=0;
|
|
curbtn=0;
|
|
List_ReDraw();
|
|
break;
|
|
case 181: //end
|
|
za_kadrom=count-f_visible;
|
|
curbtn=f_visible-1;
|
|
List_ReDraw();
|
|
break;
|
|
case 183: //Page Down
|
|
FileList_ReDraw(f_visible-1);
|
|
break;
|
|
case 184: //Page Up
|
|
FileList_ReDraw(-f_visible+1);
|
|
break;
|
|
case 051: //Íàæàòà F2
|
|
REN_MARK:
|
|
if (!count) break;
|
|
DeleteButton(curbtn+201); //ýòî ÷òîá ìîæíî áûëî âûäåëÿòü ìûøüþ
|
|
edit2.flags=66; //äåëàåì êîìïîíåíò àêòèâíûì
|
|
edit2.width=onLeft(24,217);
|
|
edit2.top=curbtn*BUTTON_HEIGHT+59;
|
|
edit2.size=edit2.pos=strlen(#file_name);
|
|
edit_box_draw stdcall (#edit2);
|
|
DrawBar(213,curbtn*BUTTON_HEIGHT+58,edit2.width+1,1,0xFFFFCC); //ïîëîñà æåëòàÿ ñâåðõó äëÿ îäèíàêîâîñòè
|
|
rename_active=1;
|
|
break;
|
|
case 052: //Íàæàòà F3
|
|
IF (!isdir) RunProgram("/sys/tinypad", #file_path);
|
|
break;
|
|
case 053: //Íàæàòà F4
|
|
IF (!isdir) RunProgram("/sys/develop/heed", #file_path);
|
|
break;
|
|
case 054: //F5
|
|
Open_Dir(#path,1);
|
|
break;
|
|
case 182: //delete file
|
|
Del_Form();
|
|
break;
|
|
default:
|
|
for (i=curbtn+za_kadrom+1; i<count; i++)
|
|
{
|
|
copystr(file_mas[i]*304+buf+72,#temp);
|
|
IF (temp[0]==key) || (temp[0]==key-32)
|
|
{
|
|
FileList_ReDraw(i-curbtn-za_kadrom);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case evReDraw:
|
|
draw_window();
|
|
}
|
|
}
|
|
|
|
|
|
inline fastcall void draw_window()
|
|
{
|
|
int min_size_y = disc_num*16+195;
|
|
|
|
if (GetScreenHeight()<480)
|
|
DefineAndDrawWindow(20,0,582,GetScreenHeight()-30,0x73,col_work,title);
|
|
else
|
|
DefineAndDrawWindow(98,90,582,482,0x73,col_work,title);
|
|
GetProcessInfo(#Form, SelfInfo);
|
|
if (Form.status_window>2) return;
|
|
if (Form.height<min_size_y) MoveSize(OLD,OLD,OLD,min_size_y);
|
|
if (Form.width<480) MoveSize(OLD,OLD,480,OLD);
|
|
|
|
//toolbar buttons
|
|
PutPaletteImage(#toolbar,246,34,0,0,#toolbar_pal);
|
|
for (j=0; j<3; j++) DefineButton(toolbar_buttons_x[j]+2,5+2,31-5,29-5,21+j+BT_HIDE,col_work);
|
|
for (j=3; j<6; j++) DefineButton(toolbar_buttons_x[j],5,31,29,21+j+BT_HIDE,col_work);
|
|
//ïîëîñà àäðåñà
|
|
edit1.width=Form.width-314;
|
|
DrawBar(246,0,onLeft(246,60),12, col_work); //ôîí íàä ïîëîñîé àäðåñà
|
|
DrawBar(246,29,onLeft(246,60),5,col_work); //ôîí ïîä ïîëîñîé àäðåñà
|
|
DrawRegion_3D(246,12,onLeft(66,246),16,col_border,col_border); //îáîäîê
|
|
DefineButton(onLeft(34,0),6,27,28,30+BT_HIDE+BT_NOFRAME,col_work); //about
|
|
DefineButton(onLeft(65,0),13,16,14,27+BT_HIDE,col_work); //êíîïêà ïåðåõîäà
|
|
PutPaletteImage(#goto_about,56,34,Form.width-65,0,#goto_about_pal);
|
|
//ïðÿìîóãîëüíèêè âíóòðè
|
|
DrawRegion_3D(1,40,Form.cwidth-3,onTop(46,0),col_border,col_border); //ñèíèé îáîäîê
|
|
DrawRegion_3D(0,39,Form.cwidth-1,onTop(44,0),col_palette[4],col_palette[4]); //ôîí
|
|
for (i=0; i<5; i++) DrawBar(0, 34+i, Form.cwidth, 1, col_palette[8-i]);
|
|
DrawLeftPanel();
|
|
//SortButtons
|
|
DrawFlatButton(192,40,onLeft(192,168),16,31,col_work,"File");
|
|
DrawFlatButton(onLeft(168,0),40,73,16,32,col_work,"Type");
|
|
DrawFlatButton(onLeft(95,0),40,68,16,33,col_work,"Size");
|
|
//Ïåðåðèñîâûâàåì ñïèñîê
|
|
Open_Dir(#path,ONLY_SHOW);
|
|
//ïðîêðóòêà
|
|
DrawBar(onLeft(27,0),57,1,onTop(22,57),col_border); //ëèíèÿ ñëåâà îò ïðîêðóòêè
|
|
DrawFlatButton(onLeft(27,0),40,16,16,0,col_work,"\x18"); //ïðîêðóòêà ââåðõ
|
|
DrawFlatButton(onLeft(27,0),onTop(22,0),16,16,0,col_work,"\x19");//ïðîêðóòêà âíèç
|
|
if (del_active) Del_Form();
|
|
}
|
|
|
|
|
|
void KEdit()
|
|
{
|
|
edit1.size=edit1.pos=strlen(#edit_path);
|
|
edit1.offset=0;
|
|
edit_box_draw stdcall (#edit1);
|
|
}
|
|
|
|
|
|
void FileList_ReDraw(int curbtn_)
|
|
{
|
|
if (curbtn_<=0) //ââåðõ
|
|
{
|
|
IF (za_kadrom==0) && (curbtn<=0) return;
|
|
IF (-curbtn_-1<curbtn)
|
|
{
|
|
Line_ReDraw(0xFFFFFF, curbtn); //áåëàÿ ïîëîñà
|
|
curbtn+=curbtn_;
|
|
Line_ReDraw(col_selec, curbtn); //âûäåëåíèå
|
|
return;
|
|
}
|
|
ELSE
|
|
{
|
|
IF (-curbtn_<za_kadrom) za_kadrom+=curbtn_; ELSE za_kadrom=0;
|
|
curbtn=0;
|
|
List_ReDraw();
|
|
return;
|
|
}
|
|
}
|
|
else //âíèç
|
|
{
|
|
IF (za_kadrom==count-f_visible) && (curbtn==f_visible-1) return;
|
|
IF (f_visible-curbtn>curbtn_)
|
|
{
|
|
Line_ReDraw(0xFFFFFF, curbtn); //áåëàÿ ïîëîñà
|
|
curbtn+=curbtn_;
|
|
Line_ReDraw(col_selec, curbtn); //âûäåëåíèå
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
IF(za_kadrom+curbtn+curbtn_>=count)
|
|
{
|
|
za_kadrom=count-f_visible;
|
|
curbtn=curbtn_-za_kadrom+curbtn;
|
|
}
|
|
ELSE
|
|
{
|
|
za_kadrom+=curbtn_+curbtn-f_visible+1;
|
|
curbtn=f_visible-1;
|
|
}
|
|
|
|
IF (curbtn<0) || (curbtn>f_visible)
|
|
{
|
|
curbtn=f_visible-1;
|
|
}
|
|
List_ReDraw();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
void List_ReDraw()
|
|
{
|
|
int paint_x=f_visible*BUTTON_HEIGHT+57;
|
|
IF (count-za_kadrom<f_visible) || (curbtn>f_visible-1) //åñëè ìû â êîíöå ñïèñêà ôàéëîâ ðàçâåðí¸ì îêíî ïîÿâÿòüñÿ ïóñòÿå áåëûå êíîïêè
|
|
{ za_kadrom=count-f_visible; curbtn=f_visible-1; } //ýòî åñëè âûäåëåíèå ïîñëå ñõëîïûâàíèÿ îêíà çà êàäðîì
|
|
|
|
FOR (j=0; j<f_visible; j++) IF (curbtn<>j) Line_ReDraw(0xFFFFFF, j); ELSE Line_ReDraw(col_selec, curbtn);
|
|
DrawBar(192,paint_x,onLeft(27,192),onTop(paint_x,6),0xFFFFFF); //çàëèâêà áåëûì äîêîíöà
|
|
DrawBar(onLeft(168,0),paint_x,1,onTop(paint_x,6),col_work); //ïîëîñà ñåðàÿ âåðòèêàëüíàÿ 1
|
|
DrawBar(onLeft(95,0),paint_x,1,onTop(paint_x,6),col_work); //ïîëîñà ñåðàÿ âåðòèêàëüíàÿ 2
|
|
TVScroll();
|
|
}
|
|
|
|
|
|
void Line_ReDraw(dword color, filenum){
|
|
dword text_col=0, name_len,
|
|
y=filenum*BUTTON_HEIGHT+57; //ïîëîæåíèå òåêñòà ïî Y
|
|
IF (rename_active==1) ReName(false);
|
|
DefineButton(192,y,onLeft(28,192),BUTTON_HEIGHT,201+filenum+BT_HIDE+BT_NOFRAME,color); //êíîïà
|
|
//äà, ÿ íå ñïîðþ ÷òî èçâðàò, íî çàòî ïåðåðèñîâêè íå âèäíî
|
|
DrawBar(192,y,3,BUTTON_HEIGHT,color);
|
|
DrawBar(192+19,y,onLeft(46,192),BUTTON_HEIGHT,color); DrawBar(195,y+17,16,1,color);
|
|
if (BUTTON_HEIGHT>18) DrawBar(195,y+18,16,BUTTON_HEIGHT-18,color);
|
|
if (BUTTON_HEIGHT>15) DrawBar(195,y,16,BUTTON_HEIGHT-15,color);
|
|
|
|
off=file_mas[filenum+za_kadrom]*304 + buf+72;
|
|
|
|
if (!TestBit(ESDWORD[off-40], 4)) //ýòî ÔÀÉË èëè ïàïêà?
|
|
{
|
|
copystr(off,#temp);
|
|
Put_icon(#temp+strchr(#temp,'.'), BUTTON_HEIGHT/2-7+y, color);
|
|
WriteText(7-strlen(ConvertSize(ESDWORD[off-8]))*6+onLeft(75,0),BUTTON_HEIGHT-6/2+y,0x80,0,ConvertSize(ESDWORD[off-8]),0); //size
|
|
}
|
|
else
|
|
if (!strcmp("..",off))
|
|
Put_icon("..", BUTTON_HEIGHT/2-7+y, color);
|
|
else
|
|
Put_icon("<DIR>", BUTTON_HEIGHT/2-7+y, color);
|
|
|
|
if (TestBit(ESDWORD[off-40],1)) || (TestBit(ESDWORD[off-40],2)) text_col=0xA6A6B7; //ôàéë ñêðûòûé èëè ñèñòåìíûé?
|
|
|
|
if (color<>0xFFFfff)
|
|
{
|
|
isdir=TestBit(ESDWORD[off-40], 4);
|
|
|
|
copystr(off,#file_name);
|
|
copystr(#path,#file_path);
|
|
copystr(#file_name,#file_path+strlen(#file_path)); //ïîëíûé ïóòü ê ôàéëó
|
|
IF (text_col==0xA6A6B7) text_col=0xFFFFFF;
|
|
}
|
|
name_len = onLeft(215,165)/6;
|
|
IF (strlen(off)<name_len) name_len = strlen(off); //äëèííà íàçâàíèÿ ôàéëà
|
|
WriteText(215,BUTTON_HEIGHT-6/2+y,0,text_col,off,name_len); //èìÿ ôàéëà
|
|
DrawBar(onLeft(168,0),y,1,BUTTON_HEIGHT,col_work); //ïîëîñà ñåðàÿ âåðòèêàëüíàÿ 1
|
|
DrawBar(onLeft(95,0),y,1,BUTTON_HEIGHT,col_work); //ïîëîñà ñåðàÿ âåðòèêàëüíàÿ 2
|
|
}
|
|
|
|
|
|
void Open_Dir(dword temp_, redraw){
|
|
int errornum, max_count;
|
|
char path_[4096],
|
|
somelen=strlen(temp_)-1;
|
|
|
|
if (redraw<>ONLY_SHOW)
|
|
{
|
|
copystr(temp_, #path_);
|
|
if (somelen) path_[somelen]=NULL;
|
|
|
|
if (buf) free(buf);
|
|
buf = malloc(32);
|
|
errornum=ReadDir(0, buf, #path_);
|
|
if (errornum<>0) //îøèáêà ïðè ÷òåíèè ïàïêè
|
|
{
|
|
HistoryPath(ADD_NEW_PATH);
|
|
GoBack();
|
|
Write_Error(errornum);
|
|
return;
|
|
}
|
|
count = ESDWORD[buf+8];
|
|
buf = realloc(count * 304 + 32, buf); //ïî÷åìó 32?
|
|
ReadDir(count, buf, #path_);
|
|
count=EBX;
|
|
max_count = sizeof(file_mas)/sizeof(dword)-1;
|
|
if (count>max_count) count=max_count; //1 íà óäà÷ó ;)
|
|
|
|
}
|
|
if (count<>-1)
|
|
{
|
|
//debug("successfully \n");
|
|
copystr(temp_,#edit_path);
|
|
KEdit();
|
|
HistoryPath(ADD_NEW_PATH);
|
|
IF (!strcmp(".",buf+72)) {count--; memmov(buf,buf+304,count*304);} //ôèëüòðóåì ýëåìåíò "."
|
|
FOR (j=0;j<f_visible;j++) DeleteButton(201+j); //óäàëÿåì ñòàðûå
|
|
f_visible=onTop(6,57)/BUTTON_HEIGHT;
|
|
IF (count<f_visible) f_visible=count;
|
|
//ñòðåëî÷êà ñîðòèðîâêè
|
|
IF (sort_num==1) WriteText(Form.width+60/2,45,0x80,0x4E78AC,"\x19",0);
|
|
IF (sort_num==2) WriteText(Form.width-115,45,0x80,0x4E78AC,"\x19",0);
|
|
IF (sort_num==3) WriteText(Form.width-44,45,0x80,0x4E78AC,"\x19",0);
|
|
IF (redraw<>ONLY_SHOW) Sorting(); //äëÿ áîëüøèõ ïàïîê ïðè ðåïåèíòå îêíà
|
|
IF (redraw<>ONLY_OPEN) List_ReDraw();
|
|
}
|
|
IF (count==-1) && (redraw<>ONLY_OPEN) {f_visible=count=0; List_ReDraw();}
|
|
}
|
|
|
|
|
|
|
|
inline Sorting()
|
|
{
|
|
dword k=0, l=1;
|
|
int i;
|
|
if (!strcmp(#path,"/")) //íå ñîðòèðîâàòü ïàïêè è íå ìåíÿòü ðåãèñòð â "/"
|
|
{
|
|
FOR(k=1;k<count;k++;) file_mas[k]=k;
|
|
return;
|
|
}
|
|
FOR (j=count-1, off=count-1*304+buf+32; j>=0; j--, off-=304;) //ïàïêè ââåðõ, ôàéëû âíèç
|
|
{
|
|
TitleCase(off+40);
|
|
if (TestBit(ESDWORD[off],4)) //ïàïêà?
|
|
{
|
|
file_mas[k]=j;
|
|
k++;
|
|
}
|
|
else
|
|
{
|
|
file_mas[count-l]=j;
|
|
l++;
|
|
}
|
|
}
|
|
//Ñîáñòâåííî ñîðòèðîâêà: âíà÷àëå ïàïêè, ïîòîì ôàéëû
|
|
Sort_by_Name(0,k-1);
|
|
IF (sort_num==1) Sort_by_Name(k,count-1);
|
|
IF (sort_num==2) Sort_by_Type(k,count-1);
|
|
IF (sort_num==3) Sort_by_Size(k,count-1);
|
|
//åñëè ïàïêà ".." íå ïåðâàÿ, ñòàâèì å¸ òóäà
|
|
IF (k>0) && (strcmp(file_mas[0]*304+buf+72,"..")<>0) FOR(k--; k>0; k--;) IF (!strcmp(file_mas[k]*304+buf+72,"..")) file_mas[k]><file_mas[0];
|
|
}
|
|
|
|
|
|
void Del_Form()
|
|
{
|
|
int dform_x=Form.width/2-13;
|
|
//òèïà îêíî
|
|
if (!count) return;
|
|
FOR (i=5;i<11;i++) DeleteButton(201+i); //óäàëÿåì êíîïêè ïîä ôîðìîé
|
|
DrawFlatButton(dform_x,160,200,80,0,col_work, ""); //ôîðìà
|
|
WriteText(dform_x+19,175,0x80,0,"Do you really want to delete",0);
|
|
IF (strlen(#file_name)<28)
|
|
{
|
|
WriteText(strlen(#file_name)*6+dform_x+20,190,0x80,0,"?",0);
|
|
WriteText(dform_x+20,190,0x80,0,#file_name,0); //ïèøåì èìÿ
|
|
}
|
|
ELSE
|
|
{
|
|
WriteText(164+dform_x,190,0x80,0,"...?",0);
|
|
WriteText(dform_x+20,190,0,0,#file_name,24); //ïèøåì èìÿ
|
|
}
|
|
//êíîïî÷êè
|
|
DrawFlatButton(dform_x+20,208,70,20,301,0xFFB6B5,"Yes");
|
|
DrawFlatButton(dform_x+111,208,70,20,302,0xC6DFC6,"No");
|
|
del_active=1;
|
|
}
|
|
|
|
|
|
void Del_File(byte dodel)
|
|
{
|
|
int del_file_rez;
|
|
IF (dodel==true)
|
|
{
|
|
del_file_rez=DeleleFile(#file_path);
|
|
IF (del_file_rez<>0)
|
|
{
|
|
Write_Error(del_file_rez);
|
|
IF ( isdir) ShowMessage("Error. Folder isn't empty.");
|
|
IF (!isdir) ShowMessage("Error. Filesystem read-only.");
|
|
}
|
|
}
|
|
del_active=0;
|
|
DeleteButton(301); DeleteButton(302); //óäàëÿåì êíîïî÷êè Yes/No
|
|
Open_Dir(#path,1);
|
|
}
|
|
|
|
void Paste()
|
|
{
|
|
char new_copy_path[4096];
|
|
int copy_rezult;
|
|
|
|
IF (!copy_file) return; //îòìåíà, åøè åù¸ íè÷¸ íå ñêîïèðîâàëè
|
|
copystr(#path,#new_copy_path);
|
|
copystr(#copy_file+strchr(#copy_file,'/'),#new_copy_path+strlen(#new_copy_path));
|
|
if (!strcmp(#copy_file,#new_copy_path)) //åñëè ìû êîïèðóåì è âñòàâëÿåì â îäíîé è òîé æå ïàïêå
|
|
{
|
|
copystr(#path,#new_copy_path);
|
|
copystr("new_",#new_copy_path+strlen(#new_copy_path));
|
|
copystr(#copy_file+strchr(#copy_file,'/'),#new_copy_path+strlen(#new_copy_path));
|
|
}
|
|
copy_rezult=CopyFile(#copy_file,#new_copy_path);
|
|
IF (copy_rezult<>0) //îøèáêà
|
|
{
|
|
Write_Error(copy_rezult);
|
|
DrawFlatButton(Form.width/2-13,160,200,80,0,0xFFB6B5, "Error. You can't paste here.");
|
|
Pause(150);
|
|
}
|
|
IF (cut_active) //åñëè ìû âûáðàëè âûðåçàòü
|
|
{
|
|
copystr(#copy_file,#file_path);
|
|
Del_File(true);
|
|
copy_file=NULL;
|
|
cut_active=false;
|
|
}
|
|
SelectFile(#new_copy_path+strchr(#new_copy_path,'/'));
|
|
}
|
|
|
|
|
|
void ReName(byte rename)
|
|
{
|
|
int del_file_rez;
|
|
char edit_name[256];
|
|
rename_active=0;
|
|
edit2.flags=64;
|
|
DefineButton(192,curbtn*BUTTON_HEIGHT+57,onLeft(27,192),BUTTON_HEIGHT,curbtn+201+BT_HIDE+BT_NOFRAME,0xFFFFFF);
|
|
if (rename==true)
|
|
{
|
|
copystr(#path,#temp);
|
|
copystr(#file_name,#edit_name); //ñîõðàíÿåì íîâîå èìÿ ôàéëà, äëÿ òîãî, ÷òîáû åãî ïîòîì âûäåëèòü
|
|
copystr(#file_name,#temp+strlen(#temp));
|
|
if (strcmp(#file_path,#temp)<>0) && (file_name)
|
|
IF (isdir)
|
|
{
|
|
del_file_rez=DeleleFile(#file_path);
|
|
IF (del_file_rez<>0)
|
|
{
|
|
Write_Error(del_file_rez);
|
|
ShowMessage("Error. Folder isn't empty.");
|
|
return;
|
|
}
|
|
ELSE CreateFolder(#temp);
|
|
Open_Dir(#path,1);
|
|
}
|
|
ELSE
|
|
{
|
|
CopyFile(#file_path,#temp);
|
|
Del_File(true);
|
|
}
|
|
SelectFile(#edit_name);
|
|
}
|
|
Line_ReDraw(col_selec,curbtn);
|
|
}
|
|
|
|
|
|
|
|
void Goto_edit_path()
|
|
{
|
|
IF (!strcmp(#path,#edit_path)) return; //ïðîâåðêà íå â ýòîé ëè ìû ïàïêå
|
|
IF (strcmp(#edit_path+strlen(#edit_path)-1,"/")<>0) copystr("/",#edit_path+strlen(#edit_path)); //åñëè íåò, + "/"
|
|
Open_Dir(#edit_path,ONLY_OPEN); //ïðîâåðÿåì åñëè ôàéëû â ïàïêå, òàê ìû óçíà¸ì ñóùåñòâóåò ëè îíà
|
|
IF (count<1)
|
|
KEdit(); //ïðîñòî î÷èùàåì ïîëîñó àäðåñà
|
|
ELSE
|
|
{
|
|
za_kadrom=curbtn=0; //íàâåðõ ñïèñêà
|
|
copystr(#edit_path,#path);
|
|
}
|
|
Open_Dir(#path,1);
|
|
}
|
|
|
|
void SelectFile(dword that_file)
|
|
{
|
|
za_kadrom=curbtn=0; //ââåðõ ñïèñêà
|
|
Open_Dir(#path,ONLY_OPEN);
|
|
TitleCase(that_file);
|
|
for (i=count-1; i>=0; i--;)
|
|
if (!strcmp(file_mas[i]*304+buf+72,that_file)) break;
|
|
FileList_ReDraw(i);
|
|
List_ReDraw();
|
|
}
|
|
|
|
|
|
void Dir_Up()
|
|
{
|
|
char cur_folder[4096];
|
|
if (path[1]==NULL) return;
|
|
i=strlen(#path)-1;
|
|
path[i]=0x00;
|
|
do i--; while (path[i]<>'/');
|
|
copystr(#path+i+1,#cur_folder);
|
|
path[i+1]=0x00;
|
|
SelectFile(#cur_folder);
|
|
}
|
|
|
|
|
|
inline fastcall void GoBack() //âíà÷àëå óäàëÿåì òåêóùèé ïóòü, à ïîòîì êîïèðóåì òî, ÷òî îñòàëîñü
|
|
{
|
|
char cur_folder[4096];
|
|
copystr(GetCurrentFolder(), #cur_folder);
|
|
if (HistoryPath(GO_BACK)) SelectFile(#cur_folder);
|
|
}
|
|
|
|
|
|
stop:
|