Eolite: file selection by Space, fix panes blinking in KFM2, better Open_Dir()

git-svn-id: svn://kolibrios.org@8872 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2021-06-17 21:29:58 +00:00
parent ba2ee17f68
commit 210cb2b3ce
3 changed files with 92 additions and 90 deletions

View File

@ -3,9 +3,9 @@
// 70.5 - get volume info and label // 70.5 - get volume info and label
#define ABOUT_TITLE "EOLITE 5 Beta4" #define ABOUT_TITLE "EOLITE 5 Beta5"
#define TITLE_EOLITE "Eolite File Manager 5 Beta4" #define TITLE_EOLITE "Eolite File Manager 5 Beta5"
#define TITLE_KFM "Kolibri File Manager 2 Beta4"; #define TITLE_KFM "Kolibri File Manager 2 Beta5";
#ifndef AUTOBUILD #ifndef AUTOBUILD
#include "lang.h--" #include "lang.h--"
@ -59,7 +59,6 @@ enum {
//OpenDir options //OpenDir options
enum { enum {
ONLY_SHOW,
WITH_REDRAW, WITH_REDRAW,
ONLY_OPEN ONLY_OPEN
}; };
@ -94,7 +93,7 @@ bool active_settings = false;
bool _not_draw = false; bool _not_draw = false;
bool dir_at_fat16 = NULL; bool dir_at_fat16 = NULL;
bool dev_popin_active_on_panel=0; bool disk_popin_active_on_panel=0;
dword about_thread_id; dword about_thread_id;
dword settings_window; dword settings_window;
@ -249,7 +248,7 @@ void main()
loop() switch(@WaitEventTimeout(80)) loop() switch(@WaitEventTimeout(80))
{ {
case evMouse: case evMouse:
if (del_active) || (dev_popin_active_on_panel) || (Form.status_window>2) break; if (del_active) || (disk_popin_active_on_panel) || (Form.status_window>2) break;
if (new_element_active) if (new_element_active)
{ {
edit_box_mouse stdcall(#new_file_ed); edit_box_mouse stdcall(#new_file_ed);
@ -323,7 +322,8 @@ void main()
} }
//Scrooll //Scrooll
if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+18) && (mouse.y>files.y) && (mouse.y<files.y+files.h-18) && (mouse.lkm) && (!scroll_used) {scroll_used=true; Scroll();} if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+18) && (mouse.y>files.y)
&& (mouse.y<files.y+files.h-18) && (mouse.lkm) && (!scroll_used) {scroll_used=true; Scroll();}
if (scroll_used) && (!mouse.key&MOUSE_LEFT) { scroll_used=false; Scroll(); } if (scroll_used) && (!mouse.key&MOUSE_LEFT) { scroll_used=false; Scroll(); }
if (scroll_used) if (scroll_used)
@ -339,17 +339,10 @@ void main()
} }
if (efm) && (mouse.y > files.y) && (mouse.down) { if (efm) && (mouse.y > files.y) && (mouse.down) {
if (mouse.x<Form.cwidth/2) if (mouse.x<Form.cwidth/2) {
{ if (active_panel!=1) ChangeActivePanel();
if (active_panel!=1) {
active_panel = 1;
ChangeActivePanel();
}
} else { } else {
if (active_panel!=2) { if (active_panel!=2) ChangeActivePanel();
active_panel = 2;
ChangeActivePanel();
}
} }
} }
break; break;
@ -357,11 +350,17 @@ void main()
case evButton: case evButton:
id = GetButtonID(); id = GetButtonID();
if (new_element_active) || (del_active) || (dev_popin_active_on_panel) { if (id==CLOSE_BTN) {
KillProcess(about_thread_id);
SaveIniSettings();
ExitProcess();
}
if (new_element_active) || (del_active) || (disk_popin_active_on_panel) {
if (POPUP_BTN1==id) && (del_active) EventDelete(); if (POPUP_BTN1==id) && (del_active) EventDelete();
if (POPUP_BTN1==id) && (new_element_active) NewElement(); if (POPUP_BTN1==id) && (new_element_active) NewElement();
if (POPUP_BTN2==id) EventClosePopinForm(); if (POPUP_BTN2==id) EventClosePopinForm();
if (dev_popin_active_on_panel) { if (disk_popin_active_on_panel) {
if (id>=100) && (id<=120) EventDriveClick(id); if (id>=100) && (id<=120) EventDriveClick(id);
else EventClosePopinForm(); else EventClosePopinForm();
} }
@ -370,38 +369,24 @@ void main()
switch(id) switch(id)
{ {
case CLOSE_BTN:
KillProcess(about_thread_id);
SaveIniSettings();
ExitProcess();
case PATH_BTN: case PATH_BTN:
notify(COPY_PATH_STR); notify(COPY_PATH_STR);
Clipboard__CopyText(#path); Clipboard__CopyText(#path);
break; break;
case KFM_DEV_DROPDOWN_1: case KFM_DEV_DROPDOWN_1:
case KFM_DEV_DROPDOWN_1+1: case KFM_DEV_DROPDOWN_1+1:
dev_popin_active_on_panel = 1; EventOpenDiskPopin(1);
DefineHiddenButton(0,0,5000,3000,9999+BT_NOFRAME);
SystemDiscs.DrawOptions(Form.cwidth/2-DDW, 8+DEV_H_HOR+3);
break; break;
case KFM_DEV_DROPDOWN_2: case KFM_DEV_DROPDOWN_2:
case KFM_DEV_DROPDOWN_2+1: case KFM_DEV_DROPDOWN_2+1:
dev_popin_active_on_panel = 2; EventOpenDiskPopin(2);
DefineHiddenButton(0,0,5000,3000,9999+BT_NOFRAME);
SystemDiscs.DrawOptions(Form.cwidth-DDW-2, 8+DEV_H_HOR+3);
break; break;
case BACK_BTN...PASTE_BTN: case BACK_BTN...PASTE_BTN:
if (active_panel==2) { if (active_panel==2) ChangeActivePanel();
active_panel = 1;
ChangeActivePanel();
}
EventToolbarButtonClick(id); EventToolbarButtonClick(id);
break; break;
case BACK_BTN+100...PASTE_BTN+100: case BACK_BTN+100...PASTE_BTN+100:
if (active_panel==1) { if (active_panel==1) ChangeActivePanel();
active_panel = 2;
ChangeActivePanel();
}
EventToolbarButtonClick(id-100); EventToolbarButtonClick(id-100);
break; break;
case 31...33: case 31...33:
@ -431,7 +416,7 @@ void main()
if (Form.status_window>2) break; if (Form.status_window>2) break;
if (new_element_active) || (del_active) || (dev_popin_active_on_panel) if (new_element_active) || (del_active) || (disk_popin_active_on_panel)
{ {
if (key_scancode == SCAN_CODE_ESC) EventClosePopinForm(); if (key_scancode == SCAN_CODE_ESC) EventClosePopinForm();
@ -446,6 +431,11 @@ void main()
break; break;
} }
if (key_modifier&KEY_LALT) || (key_modifier&KEY_RALT) {
if (key_scancode == SCAN_CODE_F1) EventOpenDiskPopin(1);
if (key_scancode == SCAN_CODE_F2) EventOpenDiskPopin(2);
break;
}
if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) { if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
if (key_scancode == SCAN_CODE_ENTER) { if (key_scancode == SCAN_CODE_ENTER) {
@ -501,9 +491,6 @@ void main()
case SCAN_CODE_KEY_N: case SCAN_CODE_KEY_N:
EventOpenNewEolite(); EventOpenNewEolite();
break; break;
case SCAN_CODE_KEY_M:
Open_Dir(#inactive_path,WITH_REDRAW);
break;
case SCAN_CODE_KEY_R: case SCAN_CODE_KEY_R:
EventRefresh(); EventRefresh();
break; break;
@ -531,9 +518,7 @@ void main()
break; break;
case SCAN_CODE_TAB: case SCAN_CODE_TAB:
if (!efm) break; if (!efm) break;
if (active_panel==1) active_panel=2; else active_panel=1;
ChangeActivePanel(); ChangeActivePanel();
DrawFilePanels();
break; break;
case SCAN_CODE_MENU: case SCAN_CODE_MENU:
mouse.x = files.x+15; mouse.x = files.x+15;
@ -543,6 +528,11 @@ void main()
case SCAN_CODE_DEL: case SCAN_CODE_DEL:
Del_Form(); Del_Form();
break; break;
case SCAN_CODE_SPACE:
EventChooseFile(files.cur_y);
DrawStatusBar();
Line_ReDraw(col.selec, files.cur_y);
break;
case SCAN_CODE_INS: case SCAN_CODE_INS:
EventChooseFile(files.cur_y); EventChooseFile(files.cur_y);
files.KeyDown(); files.KeyDown();
@ -567,6 +557,8 @@ void main()
break; break;
default: default:
if (Form.status_window<=2) EventRefreshDisksAndFolders(); if (Form.status_window<=2) EventRefreshDisksAndFolders();
//sprintf(#param, "/tmp0/1/%i", random(99999)); //for testing purpose
//CreateFile(0, 0, #param);
} }
if(cmd_free) if(cmd_free)
@ -583,7 +575,11 @@ void draw_window()
dword i=0; dword i=0;
incn x; incn x;
dword title; dword title;
if (show_status_bar.checked) status_bar_h = STATUS_BAR_H; else status_bar_h = 0; if (show_status_bar.checked) {
status_bar_h = STATUS_BAR_H;
} else {
status_bar_h = 0;
}
if (efm) title = TITLE_KFM; else title = TITLE_EOLITE; 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); DefineAndDrawWindow(Form.left+rand_n,Form.top+rand_n,Form.width,Form.height,0x73,NULL,title,0);
GetProcessInfo(#Form, SelfInfo); GetProcessInfo(#Form, SelfInfo);
@ -633,10 +629,10 @@ void draw_window()
DrawStatusBar(); DrawStatusBar();
if (!selected_count) Open_Dir(#path,ONLY_OPEN); //if there are no selected files -> refresh folder [L001] if (!selected_count) Open_Dir(#path,ONLY_OPEN); //if there are no selected files -> refresh folder [L001]
DrawFilePanels(); DrawFilePanels();
dev_popin_active_on_panel = 0; disk_popin_active_on_panel = 0;
} }
void DrawList() void DrawButtonsAroundList()
{ {
word sorting_arrow_x; word sorting_arrow_x;
dword sorting_arrow_t = "\x19"; dword sorting_arrow_t = "\x19";
@ -686,50 +682,44 @@ void DrawFilePanels()
{ {
DrawDeviceAndActionsLeftPanel(); DrawDeviceAndActionsLeftPanel();
files.SetSizes(192, 57, Form.cwidth - 210, Form.cheight - 59 - status_bar_h, files.item_h); files.SetSizes(192, 57, Form.cwidth - 210, Form.cheight - 59 - status_bar_h, files.item_h);
DrawList(); DrawButtonsAroundList();
Open_Dir(#path,ONLY_SHOW); List_ReDraw();
} }
else else
{ {
//SystemDiscs.Get();
llist_copy(#files, #files_inactive); llist_copy(#files, #files_inactive);
strcpy(#path, #inactive_path); strcpy(#path, #inactive_path);
col.selec = col.selec_inactive;
SystemDiscs.Draw();
files_y = files.y; files_y = files.y;
h2 = Form.cheight-files_y-2 - status_bar_h; h2 = Form.cheight-files_y-2 - status_bar_h;
col.selec = col.selec_inactive; //this is a bad code: need to use some var to set inactive panel for DrawButtonsAroundList();
if (active_panel==1) if (active_panel==1)
{ {
llist_copy(#files, #files_inactive);
strcpy(#path, #inactive_path);
col.selec = col.selec_inactive; //this is a bad code: need to use some var to set inactive panel for DrawList();
files.SetSizes(Form.cwidth/2, files_y, w2-17, h2, files.item_h); files.SetSizes(Form.cwidth/2, files_y, w2-17, h2, files.item_h);
DrawList(); DrawButtonsAroundList();
Open_Dir(#path,WITH_REDRAW); Open_Dir(#path,WITH_REDRAW);
llist_copy(#files, #files_active); llist_copy(#files, #files_active);
strcpy(#path, #active_path); strcpy(#path, #active_path);
col.selec = col.selec_active; col.selec = col.selec_active;
files.SetSizes(2, files_y, Form.cwidth/2-2-17, h2, files.item_h); files.SetSizes(2, files_y, Form.cwidth/2-2-17, h2, files.item_h);
DrawList(); DrawButtonsAroundList();
Open_Dir(#path,WITH_REDRAW); Open_Dir(#path,WITH_REDRAW);
} }
if (active_panel==2) if (active_panel==2)
{ {
files.SetSizes(2, files_y, Form.cwidth/2-2-17, h2, files.item_h); files.SetSizes(2, files_y, Form.cwidth/2-2-17, h2, files.item_h);
DrawList(); DrawButtonsAroundList();
Open_Dir(#path,WITH_REDRAW); Open_Dir(#path,WITH_REDRAW);
llist_copy(#files, #files_active); llist_copy(#files, #files_active);
strcpy(#path, #active_path); strcpy(#path, #active_path);
col.selec = col.selec_active; col.selec = col.selec_active;
files.SetSizes(Form.cwidth/2, files_y, w2 -17, h2, files.item_h); files.SetSizes(Form.cwidth/2, files_y, w2 -17, h2, files.item_h);
DrawList(); DrawButtonsAroundList();
Open_Dir(#path,WITH_REDRAW); Open_Dir(#path,WITH_REDRAW);
} }
} }
} }
void List_ReDraw() void List_ReDraw()
{ {
int all_lines_h; int all_lines_h;
@ -738,6 +728,7 @@ void List_ReDraw()
dword separator_color; dword separator_color;
files.CheckDoesValuesOkey(); //prevent some shit files.CheckDoesValuesOkey(); //prevent some shit
if (files.count < files.visible) files.visible = files.count;
if (list_full_redraw) || (old_first != files.first) if (list_full_redraw) || (old_first != files.first)
{ {
@ -889,8 +880,7 @@ void Line_ReDraw(dword bgcol, filenum){
void Open_Dir(dword dir_path, redraw){ void Open_Dir(dword dir_path, redraw){
int errornum; int errornum;
if (redraw!=ONLY_SHOW)
{
selected_count = 0; selected_count = 0;
if (buf) free(buf); if (buf) free(buf);
errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT); errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT);
@ -902,7 +892,7 @@ void Open_Dir(dword dir_path, redraw){
return; return;
} }
if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0; if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0;
}
if (files.count!=-1) if (files.count!=-1)
{ {
if(!_not_draw) DrawPathBar(); if(!_not_draw) DrawPathBar();
@ -912,7 +902,7 @@ void Open_Dir(dword dir_path, redraw){
if (files.count < files.visible) files.visible = files.count; if (files.count < files.visible) files.visible = files.count;
if (!strncmp(dir_path, "/rd/1/",5)) || (!strncmp(dir_path, "/sys/",4)) if (!strncmp(dir_path, "/rd/1/",5)) || (!strncmp(dir_path, "/sys/",4))
dir_at_fat16 = true; else dir_at_fat16 = false; dir_at_fat16 = true; else dir_at_fat16 = false;
if (redraw!=ONLY_SHOW) Sorting(); Sorting();
list_full_redraw = true; list_full_redraw = true;
if (redraw!=ONLY_OPEN)&&(!_not_draw) {DrawStatusBar(); List_ReDraw();} if (redraw!=ONLY_OPEN)&&(!_not_draw) {DrawStatusBar(); List_ReDraw();}
SetCurDir(dir_path); SetCurDir(dir_path);
@ -1234,6 +1224,7 @@ void EventRefresh()
void ChangeActivePanel() void ChangeActivePanel()
{ {
if (active_panel==1) active_panel=2; else active_panel=1;
llist_copy(#files_active, #files_inactive); llist_copy(#files_active, #files_inactive);
llist_copy(#files_inactive, #files); llist_copy(#files_inactive, #files);
strcpy(#active_path, #inactive_path); strcpy(#active_path, #inactive_path);
@ -1287,13 +1278,10 @@ void EventRefreshDisksAndFolders()
{ {
if(GetRealFileCountInFolder(#inactive_path) != files_inactive.count) { if(GetRealFileCountInFolder(#inactive_path) != files_inactive.count) {
ChangeActivePanel(); ChangeActivePanel();
Open_Dir(#path,WITH_REDRAW);
ChangeActivePanel(); ChangeActivePanel();
} }
if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
} else {
if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
} }
if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
} }
void EventSort(dword id) void EventSort(dword id)
@ -1302,7 +1290,7 @@ void EventSort(dword id)
if (sort_type == id) sort_desc ^= 1; if (sort_type == id) sort_desc ^= 1;
else sort_type = id; else sort_type = id;
strcpy(#selected_filename, #file_name); strcpy(#selected_filename, #file_name);
DrawList(); DrawButtonsAroundList();
Open_Dir(#path,WITH_REDRAW); Open_Dir(#path,WITH_REDRAW);
SelectFileByName(#selected_filename); SelectFileByName(#selected_filename);
} }
@ -1383,7 +1371,7 @@ void EventClosePopinForm()
{ {
del_active = 0; del_active = 0;
new_element_active = 0; new_element_active = 0;
dev_popin_active_on_panel = 0; disk_popin_active_on_panel = 0;
draw_window(); draw_window();
} }
@ -1442,8 +1430,7 @@ void EventToolbarButtonClick(int _btid)
void EventDriveClick(int __id) void EventDriveClick(int __id)
{ {
if (dev_popin_active_on_panel != active_panel) { if (disk_popin_active_on_panel != active_panel) {
if (active_panel == 1) active_panel=2; else active_panel=1;
ChangeActivePanel(); ChangeActivePanel();
} }
@ -1453,4 +1440,16 @@ void EventDriveClick(int __id)
} }
} }
void EventOpenDiskPopin(int panel_n)
{
DefineHiddenButton(0,0,5000,3000,9999+BT_NOFRAME);
disk_popin_active_on_panel = panel_n;
SystemDiscs.Get();
if (disk_popin_active_on_panel==1) {
SystemDiscs.DrawOptions(Form.cwidth/2-DDW, 8+DEV_H_HOR+3);
} else {
SystemDiscs.DrawOptions(Form.cwidth-DDW-2, 8+DEV_H_HOR+3);
}
}
stop: stop:

View File

@ -4,13 +4,16 @@ void DrawPathBar()
{ {
if (efm) { if (efm) {
return; return;
} PathShow.start_x = 10;
PathShow.start_y = Form.cheight - status_bar_h;
} else {
PathShow.start_x = 250;
PathShow.start_y = 17;
if (show_breadcrumb.checked) { if (show_breadcrumb.checked) {
DrawBreadCrumbs(); DrawBreadCrumbs();
return; return;
} }
}
PathShow.start_x = -efm*22 + 250;
PathShow.area_size_x = Form.cwidth-300; PathShow.area_size_x = Form.cwidth-300;
DrawBar(PathShow.start_x-3, PathShow.start_y-6, PathShow.area_size_x+3, 19, col.odd_line); DrawBar(PathShow.start_x-3, PathShow.start_y-6, PathShow.area_size_x+3, 19, col.odd_line);

View File

@ -98,7 +98,7 @@ void _SystemDiscs::Get()
bool kolibrios_exists=false; bool kolibrios_exists=false;
char dev_name[10], sys_discs[10]; char dev_name[10], sys_discs[10];
int i1, j1, dev_num_i, dev_disc_num; int i1, j1, dev_num_i, dev_disc_num;
dword devbuf; dword devbuf, diskbuf;
list.drop(); list.drop();
devbuf = malloc(10000); devbuf = malloc(10000);
@ -107,11 +107,10 @@ void _SystemDiscs::Get()
for (i1=0; i1<dev_num_i; i1++) for (i1=0; i1<dev_num_i; i1++)
{ {
sprintf(#dev_name,"/%s",i1*304+ devbuf+72); sprintf(#dev_name,"/%s",i1*304+ devbuf+72);
Open_Dir(#dev_name, ONLY_OPEN); GetDir(#diskbuf, #dev_disc_num, #dev_name, DIRS_NOROOT);
dev_disc_num = files.count;
for (j1=0; j1<dev_disc_num; j1++;) for (j1=0; j1<dev_disc_num; j1++;)
{ {
sprintf(#sys_discs,"%s/%s",#dev_name,j1*304+ buf+72); sprintf(#sys_discs,"%s/%s",#dev_name,j1*304+ diskbuf+72);
if (sys_discs[1]=='c') || (dir_exists(#sys_discs)) list.add(#sys_discs); if (sys_discs[1]=='c') || (dir_exists(#sys_discs)) list.add(#sys_discs);
} }
if (!strcmp(#sys_discs, "/rd/1")) if (!strcmp(#sys_discs, "/rd/1"))
@ -124,6 +123,7 @@ void _SystemDiscs::Get()
} }
} }
free(devbuf); free(devbuf);
free(diskbuf);
} }
#define DDW 120 #define DDW 120