Eolite 3.33: improve code related to disk management, fix issues with too many disks in two-panels mode
git-svn-id: svn://kolibrios.org@6034 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
590faca990
commit
3f00e8b196
@ -80,7 +80,7 @@ int rand_n;
|
||||
byte CMD_REFRESH;
|
||||
|
||||
//struct t_settings {
|
||||
byte sort_num=2,
|
||||
int sort_num=2,
|
||||
show_dev_name=true,
|
||||
real_files_names_case=false,
|
||||
info_after_copy=false,
|
||||
@ -127,7 +127,7 @@ void main()
|
||||
fd_path_eolite_ini_path = "/fd/1/File Managers/Eolite.ini";
|
||||
|
||||
LoadIniSettings();
|
||||
GetSystemDiscs();
|
||||
SystemDiscs.Get();
|
||||
SetAppColors();
|
||||
if (param)
|
||||
{
|
||||
@ -352,7 +352,7 @@ void main()
|
||||
FnProcess(id-50);
|
||||
break;
|
||||
case 100...120:
|
||||
ClickOnDisk(id-100);
|
||||
SystemDiscs.Click(id-100);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -387,14 +387,14 @@ void main()
|
||||
{
|
||||
case 059...068:
|
||||
key_scancode -= 59;
|
||||
if (key_scancode<disk_list.count)
|
||||
if (key_scancode < SystemDiscs.list.count)
|
||||
{
|
||||
if (!two_panels)
|
||||
{
|
||||
DrawRectangle(17,key_scancode*16+74,159,16, 0); //display click
|
||||
pause(7);
|
||||
}
|
||||
ClickOnDisk(key_scancode);
|
||||
SystemDiscs.Click(key_scancode);
|
||||
}
|
||||
break;
|
||||
case 45: //Ctrl+X
|
||||
@ -581,6 +581,7 @@ void DrawList()
|
||||
|
||||
void DrawFilePanels()
|
||||
{
|
||||
int files_y;
|
||||
if (!two_panels)
|
||||
{
|
||||
DrawDeviceAndActionsLeftPanel();
|
||||
@ -593,31 +594,33 @@ void DrawFilePanels()
|
||||
llist_copy(#files, #files_inactive);
|
||||
strcpy(#path, #inactive_path);
|
||||
col_selec = 0xCCCccc;
|
||||
SystemDiscs.Draw();
|
||||
files_y = files.y;
|
||||
|
||||
if (active_panel==1)
|
||||
{
|
||||
llist_copy(#files, #files_inactive);
|
||||
strcpy(#path, #inactive_path);
|
||||
col_selec = 0xCCCccc;
|
||||
files.SetSizes(Form.cwidth/2, 57+22, Form.cwidth/2 -17, Form.cheight-59-22, files.item_h);
|
||||
files.SetSizes(Form.cwidth/2, files_y, Form.cwidth/2 -17, Form.cheight-files_y, files.item_h);
|
||||
DrawList();
|
||||
Open_Dir(#path,WITH_REDRAW);
|
||||
llist_copy(#files, #files_active);
|
||||
strcpy(#path, #active_path);
|
||||
col_selec = 0x94AECE;
|
||||
files.SetSizes(2, 57+22, Form.cwidth/2-2-17, Form.cheight-59-22, files.item_h);
|
||||
files.SetSizes(2, files_y, Form.cwidth/2-2-17, Form.cheight-files_y, files.item_h);
|
||||
DrawList();
|
||||
Open_Dir(#path,WITH_REDRAW);
|
||||
}
|
||||
if (active_panel==2)
|
||||
{
|
||||
files.SetSizes(2, 57+22, Form.cwidth/2-2-17, Form.cheight-59-22, files.item_h);
|
||||
files.SetSizes(2, files_y, Form.cwidth/2-2-17, Form.cheight-files_y, files.item_h);
|
||||
DrawList();
|
||||
Open_Dir(#path,WITH_REDRAW);
|
||||
llist_copy(#files, #files_active);
|
||||
strcpy(#path, #active_path);
|
||||
col_selec = 0x94AECE;
|
||||
files.SetSizes(Form.cwidth/2, 57+22, Form.cwidth/2 -17, Form.cheight-59-22, files.item_h);
|
||||
files.SetSizes(Form.cwidth/2, files_y, Form.cwidth/2 -17, Form.cheight-files_y, files.item_h);
|
||||
DrawList();
|
||||
Open_Dir(#path,WITH_REDRAW);
|
||||
}
|
||||
@ -762,12 +765,12 @@ void Open_Dir(dword dir_path, redraw){
|
||||
PathShow_draw stdcall(#PathShow);
|
||||
}
|
||||
history.add(#path);
|
||||
SystemDiscs.Draw();
|
||||
files.visible = files.h / files.item_h;
|
||||
if (files.count < files.visible) files.visible = files.count;
|
||||
if (redraw!=ONLY_SHOW) Sorting();
|
||||
list_full_redraw = true;
|
||||
if (redraw!=ONLY_OPEN)&&(!_not_draw) List_ReDraw();
|
||||
DrawSystemDiscs();
|
||||
}
|
||||
if (files.count==-1) && (redraw!=ONLY_OPEN)
|
||||
{
|
||||
@ -1145,7 +1148,7 @@ void FnProcess(byte N)
|
||||
Tip(56, T_DEVICES, 55, "-");
|
||||
Open_Dir(#path,WITH_REDRAW);
|
||||
pause(10);
|
||||
GetSystemDiscs();
|
||||
SystemDiscs.Get();
|
||||
Open_Dir(#path,WITH_REDRAW);
|
||||
DrawDeviceAndActionsLeftPanel();
|
||||
}
|
||||
|
@ -18,24 +18,6 @@
|
||||
?define T_SATA "SATA ¤¨áª "
|
||||
?define T_USB "USB ¤¨áª "
|
||||
?define T_RAM "RAM ¤¨áª "
|
||||
#elif LANG_EST
|
||||
?define T_DEVICES "Seadmed"
|
||||
?define T_ACTIONS "Toimingud"
|
||||
char *actions[] = {
|
||||
57, "Uus fail", "F7",
|
||||
56, "Uus kataloog", "F6",
|
||||
60, "Seaded", "F10",
|
||||
0,0,0
|
||||
};
|
||||
?define T_PROG "Programs "
|
||||
?define T_SYS "System "
|
||||
?define T_UNC "Unknown "
|
||||
?define T_CD "CD-ROM "
|
||||
?define T_FD "Floppy disk "
|
||||
?define T_HD "Hard disk "
|
||||
?define T_SATA "SATA disk"
|
||||
?define T_USB "USB disk"
|
||||
?define T_RAM "RAM disk"
|
||||
#else
|
||||
?define T_DEVICES "Devices"
|
||||
?define T_ACTIONS "Actions"
|
||||
@ -56,29 +38,66 @@
|
||||
?define T_RAM "RAM disk"
|
||||
#endif
|
||||
|
||||
|
||||
void Tip(int y, dword caption, id, arrow)
|
||||
struct _SystemDiscs
|
||||
{
|
||||
int i;
|
||||
DrawBar(17,y,160,1,0xEFEDEE);
|
||||
DrawFilledBar(17, y+1, 160, 16);
|
||||
WriteText(25,y+5,0x80,system.color.work_text,caption);
|
||||
if (id) DefineButton(159,y+1,16,16,id+BT_HIDE+BT_NOFRAME,0); //arrow button
|
||||
WriteText(165,y+5,0x80,system.color.work_text,arrow); //arrow
|
||||
DrawBar(17,y+17,160,1,system.color.work_graph);
|
||||
collection list;
|
||||
void Get();
|
||||
void Draw();
|
||||
void Click();
|
||||
} SystemDiscs;
|
||||
|
||||
|
||||
void GetDiskIconAndName(char disk_first_letter, dword dev_icon, disc_name)
|
||||
{
|
||||
switch(disk_first_letter)
|
||||
{
|
||||
case 'k':
|
||||
ESBYTE[dev_icon]=0;
|
||||
strcpy(disc_name, T_PROG);
|
||||
break;
|
||||
case 'r':
|
||||
ESBYTE[dev_icon]=0;
|
||||
strcpy(disc_name, T_SYS);
|
||||
break;
|
||||
case 'c':
|
||||
ESBYTE[dev_icon]=1;
|
||||
strcpy(disc_name, T_CD);
|
||||
break;
|
||||
case 'f':
|
||||
ESBYTE[dev_icon]=2;
|
||||
strcpy(disc_name, T_FD);
|
||||
break;
|
||||
case 'h':
|
||||
case 'b':
|
||||
ESBYTE[dev_icon]=3;
|
||||
strcpy(disc_name, T_HD);
|
||||
break;
|
||||
case 's':
|
||||
ESBYTE[dev_icon]=3;
|
||||
strcpy(disc_name, T_SATA);
|
||||
break;
|
||||
case 'u':
|
||||
ESBYTE[dev_icon]=5;
|
||||
strcpy(disc_name, T_USB);
|
||||
break;
|
||||
case 't':
|
||||
ESBYTE[dev_icon]=4;
|
||||
strcpy(disc_name, T_RAM);
|
||||
break;
|
||||
default:
|
||||
ESBYTE[dev_icon]=3;
|
||||
strcpy(disc_name, T_UNC);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
collection disk_list;
|
||||
|
||||
void GetSystemDiscs()
|
||||
void _SystemDiscs::Get()
|
||||
{
|
||||
char dev_name[10], sys_discs[10];
|
||||
int i1, j1, dev_num, dev_disc_num;
|
||||
dword temp_file_count, tempbuf;
|
||||
dword devbuf;
|
||||
|
||||
disk_list.drop();
|
||||
list.drop();
|
||||
devbuf = malloc(10000);
|
||||
ReadDir(19, devbuf, "/");
|
||||
dev_num = EBX;
|
||||
@ -90,12 +109,12 @@ void GetSystemDiscs()
|
||||
for (j1=0; j1<dev_disc_num; j1++;)
|
||||
{
|
||||
sprintf(#sys_discs,"%s%s/",#dev_name,j1*304+ buf+72);
|
||||
disk_list.add(#sys_discs);
|
||||
list.add(#sys_discs);
|
||||
}
|
||||
if (!strcmp(#sys_discs, "/rd/1/"))
|
||||
{
|
||||
GetDir(#tempbuf, #temp_file_count, "/kolibrios/", DIRS_ONLYREAL);
|
||||
if (temp_file_count) disk_list.add("/kolibrios/");
|
||||
if (temp_file_count) list.add("/kolibrios/");
|
||||
free(tempbuf);
|
||||
}
|
||||
else if (!strcmp(#sys_discs, "/fd/1/")) CMD_ENABLE_SAVE_IMG = true;
|
||||
@ -103,101 +122,95 @@ void GetSystemDiscs()
|
||||
free(devbuf);
|
||||
}
|
||||
|
||||
|
||||
void DrawSystemDiscs()
|
||||
void _SystemDiscs::Draw()
|
||||
{
|
||||
char dev_name[15], disc_name[100], i, dev_icon, is_active, name_len;
|
||||
int pos_y, pos_x=2;
|
||||
int draw_y, draw_x, draw_h;
|
||||
|
||||
for (i=0; i<30; i++) DeleteButton(100+i);
|
||||
for (i=0;i<disk_list.count;i++)
|
||||
|
||||
if ( two_panels) { draw_y = 41; draw_x = 2; draw_h = 21; }
|
||||
if (!two_panels) { draw_y = 74; draw_x = 17; draw_h = 16; }
|
||||
|
||||
for (i=0;i<list.count;i++)
|
||||
{
|
||||
strcpy(#dev_name, disk_list.get(i));
|
||||
strcpy(#dev_name, list.get(i));
|
||||
dev_name[strlen(#dev_name)-1]=NULL;
|
||||
switch(dev_name[1])
|
||||
{
|
||||
case 'k':
|
||||
dev_icon=0;
|
||||
strcpy(#disc_name, T_PROG);
|
||||
break;
|
||||
case 'r':
|
||||
dev_icon=0;
|
||||
strcpy(#disc_name, T_SYS);
|
||||
break;
|
||||
case 'c':
|
||||
dev_icon=1;
|
||||
strcpy(#disc_name, T_CD);
|
||||
break;
|
||||
case 'f':
|
||||
dev_icon=2;
|
||||
strcpy(#disc_name, T_FD);
|
||||
break;
|
||||
case 'h':
|
||||
case 'b':
|
||||
dev_icon=3;
|
||||
strcpy(#disc_name, T_HD);
|
||||
break;
|
||||
case 's':
|
||||
dev_icon=3;
|
||||
strcpy(#disc_name, T_SATA);
|
||||
break;
|
||||
case 'u':
|
||||
dev_icon=5;
|
||||
strcpy(#disc_name, T_USB);
|
||||
break;
|
||||
case 't':
|
||||
dev_icon=4;
|
||||
strcpy(#disc_name, T_RAM);
|
||||
break;
|
||||
default:
|
||||
dev_icon=3;
|
||||
strcpy(#disc_name, T_UNC);
|
||||
}
|
||||
GetDiskIconAndName(dev_name[1], #dev_icon, #disc_name);
|
||||
if (strstr(#path, #dev_name)) is_active=true; else is_active=false;
|
||||
if (!two_panels)
|
||||
if (two_panels)
|
||||
{
|
||||
pos_y = i*16+74;
|
||||
DrawBar(17,pos_y,6,17,0xFFFFFF);
|
||||
DrawBar(17+6+18,pos_y,160-6-18,17,0xFFFFFF);
|
||||
DefineButton(17,pos_y,159,16,100+i+BT_HIDE,0xFFFFFF);
|
||||
if (show_dev_name)
|
||||
{
|
||||
strcat(#disc_name, #dev_name);
|
||||
if (is_active) WriteText(46+1,pos_y+5,0x80,0x555555,#disc_name);
|
||||
WriteText(46,pos_y+5,0x80,0,#disc_name);
|
||||
name_len = strlen(#dev_name)-1*8;
|
||||
DrawBar(draw_x, draw_y, name_len + 31, draw_h, 0xFFFFFF);
|
||||
DefineButton(draw_x+2, draw_y, name_len + 27, draw_h-1, 100+i+BT_HIDE,0xFFFFFF);
|
||||
_PutImage(draw_x + 5, draw_y+2, 18,17, is_active*6+dev_icon*17*18*3+#devices);
|
||||
WriteText(draw_x + 24, draw_y+3, 10110000b, 0, #dev_name+1);
|
||||
draw_x += name_len + 31;
|
||||
if (draw_x>=Form.width-35) && (Form.width) {
|
||||
DrawBar(draw_x, draw_y, Form.cwidth - draw_x - 2, draw_h, 0xFFFFFF);
|
||||
draw_x = 2;
|
||||
draw_y += draw_h;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_active) WriteText(46+1,pos_y+5,0x80,0x555555,#dev_name);
|
||||
WriteText(46,pos_y+5,0x80,0,#dev_name);
|
||||
}
|
||||
_PutImage(23,pos_y, 18,17, is_active*6+dev_icon*17*18*3+#devices);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos_y = 43;
|
||||
name_len = strlen(#dev_name)-1*8;
|
||||
DrawBar(pos_x, pos_y, name_len + 31, 17, 0xFFFFFF);
|
||||
DefineButton(pos_x+2, pos_y, name_len + 27, 16, 100+i+BT_HIDE,0xFFFFFF);
|
||||
_PutImage(pos_x + 5, pos_y, 18,17, is_active*6+dev_icon*17*18*3+#devices);
|
||||
WriteText(pos_x + 24, pos_y+1, 10110000b, 0, #dev_name+1);
|
||||
pos_x += name_len + 31;
|
||||
DrawBar(draw_x,draw_y,6,draw_h+1,0xFFFFFF);
|
||||
DrawBar(draw_x+6+18,draw_y,160-6-18,draw_h+1,0xFFFFFF);
|
||||
DefineButton(draw_x,draw_y,159,16,100+i+BT_HIDE,0xFFFFFF);
|
||||
if (show_dev_name)
|
||||
{
|
||||
strcat(#disc_name, #dev_name);
|
||||
if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#disc_name);
|
||||
WriteText(draw_x+29,draw_y+5,0x80,0,#disc_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#dev_name);
|
||||
WriteText(draw_x+29,draw_y+5,0x80,0,#dev_name);
|
||||
}
|
||||
_PutImage(draw_x+6,draw_y, 18,17, is_active*6+dev_icon*17*18*3+#devices);
|
||||
draw_y += draw_h;
|
||||
}
|
||||
}
|
||||
if (two_panels)
|
||||
{
|
||||
DrawBar(pos_x, pos_y, Form.cwidth - pos_x - 2, 17, 0xFFFFFF);
|
||||
DrawBar(2, pos_y-2, Form.cwidth - 4, 2, 0xFFFFFF);
|
||||
DrawBar(2, pos_y+17, Form.cwidth - 4, 2, 0xFFFFFF);
|
||||
DefineButton(Form.cwidth - 23, pos_y, 17,16, 60+BT_HIDE, 0xCCCccc);
|
||||
_PutImage(Form.cwidth - 21, pos_y+2, 14,13, 2*14*13*3+#factions);
|
||||
DrawBar(draw_x, draw_y, Form.cwidth - draw_x - 2, draw_h, 0xFFFFFF);
|
||||
DefineButton(Form.cwidth - 23, draw_y+2, 17,16, 60+BT_HIDE, 0xCCCccc);
|
||||
_PutImage(Form.cwidth - 21, draw_y+4, 14,13, 2*14*13*3+#factions);
|
||||
files.y = draw_y + draw_h + 17;
|
||||
}
|
||||
}
|
||||
|
||||
void _SystemDiscs::Click(int n)
|
||||
{
|
||||
strcpy(#path, list.get(n));
|
||||
files.KeyHome();
|
||||
Open_Dir(#path,WITH_REDRAW);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DrawDeviceAndActionsLeftPanel()
|
||||
{
|
||||
Tip(56, T_DEVICES, 55, "=");
|
||||
SystemDiscs.Draw();
|
||||
ActionsDraw();
|
||||
DrawLeftPanelBg();
|
||||
}
|
||||
|
||||
void Tip(int y, dword caption, id, arrow)
|
||||
{
|
||||
DrawBar(17,y,160,1,0xEFEDEE);
|
||||
DrawFilledBar(17, y+1, 160, 16);
|
||||
WriteText(25,y+5,0x80,system.color.work_text,caption);
|
||||
if (id) DefineButton(159,y+1,16,16,id+BT_HIDE+BT_NOFRAME,0); //arrow button
|
||||
WriteText(165,y+5,0x80,system.color.work_text,arrow); //arrow
|
||||
DrawBar(17,y+17,160,1,system.color.work_graph);
|
||||
}
|
||||
|
||||
void ActionsDraw()
|
||||
{
|
||||
int actions_y=disk_list.count*16+108, lineh=16;
|
||||
int actions_y= SystemDiscs.list.count*16+108, lineh=16;
|
||||
Tip(actions_y-18, T_ACTIONS, 77, ""); //çàãîëîâîê
|
||||
for (i=0; actions[i*3]!=0; i++, actions_y+=lineh)
|
||||
{
|
||||
@ -209,10 +222,9 @@ void ActionsDraw()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DrawLeftPanelBg()
|
||||
{
|
||||
int actions_y=disk_list.count*16;
|
||||
int actions_y = SystemDiscs.list.count*16;
|
||||
int start_y = actions_y+156;
|
||||
int onTop1;
|
||||
DrawBar(2,41,190,15,col_lpanel); //ñèíèé ïðÿìîóãîëüíèê - íàä äåâàéñàìè
|
||||
@ -233,21 +245,4 @@ void DrawLeftPanelBg()
|
||||
}
|
||||
PutShadow(17,start_y,160,1,1,3);
|
||||
PutShadow(18,start_y+1,158,1,1,1);
|
||||
}
|
||||
|
||||
|
||||
void DrawDeviceAndActionsLeftPanel()
|
||||
{
|
||||
Tip(56, T_DEVICES, 55, "=");
|
||||
DrawSystemDiscs();
|
||||
ActionsDraw();
|
||||
DrawLeftPanelBg();
|
||||
}
|
||||
|
||||
|
||||
void ClickOnDisk(int n)
|
||||
{
|
||||
strcpy(#path, disk_list.get(n));
|
||||
files.KeyHome();
|
||||
Open_Dir(#path,WITH_REDRAW);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
#define TITLE "Eolite File Manager v3.31"
|
||||
#define ABOUT_TITLE "Eolite 3.31"
|
||||
#define TITLE "Eolite File Manager v3.33"
|
||||
#define ABOUT_TITLE "Eolite 3.33"
|
||||
|
||||
#ifdef LANG_RUS
|
||||
?define T_FILE "” ©«"
|
||||
|
Loading…
Reference in New Issue
Block a user