Eolite is in beta again because this is a general code refactoring and clean to get proper two-panes implementation and potentially multitabs support

git-svn-id: svn://kolibrios.org@8947 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2021-06-26 17:36:34 +00:00
parent 05b495ef7e
commit 4a974f6b39
6 changed files with 133 additions and 146 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 RC5" #define ABOUT_TITLE "EOLITE 5 Beta8"
#define TITLE_EOLITE "Eolite File Manager 5 RC5" #define TITLE_EOLITE "Eolite File Manager 5 Beta8"
#define TITLE_KFM "Kolibri File Manager 2 RC5"; #define TITLE_KFM "Kolibri File Manager 2 Beta8";
#define MEMSIZE 1024 * 250 #define MEMSIZE 1024 * 250
#include "../lib/clipboard.h" #include "../lib/clipboard.h"
@ -28,36 +28,7 @@
#include "imgs/images.h" #include "imgs/images.h"
//Button IDs #include "include/const.h"
enum {
PATH_BTN = 10,
POPUP_BTN1 = 201,
POPUP_BTN2 = 202,
KFM_DEV_DROPDOWN_1 = 205,
KFM_DEV_DROPDOWN_2 = 207,
BREADCRUMB_ID = 300,
BACK_BTN = 400,
FWRD_BTN,
GOUP_BTN,
COPY_BTN,
CUT_BTN,
PASTE_BTN,
KFM_FUNC_ID = 450
};
//NewElement options
enum {
CREATE_FILE=1,
CREATE_FOLDER,
RENAME_ITEM
};
//OpenDir options
enum {
WITH_REDRAW,
ONLY_OPEN
};
_history history; _history history;
@ -84,52 +55,54 @@ bool efm = false;
int toolbar_buttons_x[7]={9,46,85,134,167,203}; int toolbar_buttons_x[7]={9,46,85,134,167,203};
bool active_about = false;
bool active_settings = false;
bool _not_draw = false;
bool dir_at_fat16 = NULL; bool dir_at_fat16 = NULL;
bool disk_popin_active_on_panel=0;
dword about_thread_id; dword about_thread_id;
dword settings_window; dword settings_window;
bool active_about = false;
bool active_settings = false;
byte del_active=0; byte del_active=0;
byte new_element_active=0; byte new_element_active=0;
llist files, files_active, files_inactive; llist files, files_active, files_inactive;
byte list_full_redraw; bool list_full_redraw;
dword buf; //Folder data
collection_int items=0; dword buf;
int selected_count; collection_int items=0;
int count_dir; int selected_count;
int folder_count;
//dword path;
char path[4096];
byte path[4096]; //Sselected element data
byte file_path[4096]; byte file_path[4096];
byte file_name[256]; byte file_name[256];
byte new_element_name[256]; byte new_element_name[256];
byte temp[4096]; byte temp[4096];
bool itdir; bool itdir;
//Window data
proc_info Form;
int sc_slider_h;
bool scroll_used=false;
char sort_type=2;
bool sort_desc=false;
int status_bar_h;
int icon_size = 18;
int active_panel=0;
int disk_popin_active_on_panel=0;
#define PANES_COUNT 2
unsigned char location[PANES_COUNT];
char active_path[4096], inactive_path[4096]; char active_path[4096], inactive_path[4096];
dword eolite_ini_path[4096];
_ini ini;
char scroll_used=false;
dword about_stak=0,properties_stak=0,settings_stak=0; dword about_stak=0,properties_stak=0,settings_stak=0;
byte cmd_free=0;
proc_info Form;
int sc_slider_h;
int action_buf;
int rand_n;
char sort_type=2;
bool sort_desc=false;
int active_panel=0;
libimg_image icons16_default; libimg_image icons16_default;
libimg_image icons16_selected; libimg_image icons16_selected;
@ -137,15 +110,10 @@ libimg_image icons16_selected;
libimg_image icons32_default; libimg_image icons32_default;
libimg_image icons32_selected; libimg_image icons32_selected;
int status_bar_h;
int icon_size = 18;
edit_box new_file_ed = {200,213,180,0xFFFFFF,0x94AECE,0xFFFFFF,0xFFFFFF,0x10000000, edit_box new_file_ed = {200,213,180,0xFFFFFF,0x94AECE,0xFFFFFF,0xFFFFFF,0x10000000,
248,#new_element_name,0,ed_focus+ed_always_focus,6,0}; 248,#new_element_name,0,ed_focus+ed_always_focus,6,0};
PathShow_data FileShow = {0, 56,215, 8, 100, 1, 0, 0x0, 0xFFFfff, #file_name, #temp, 0}; PathShow_data FileShow = {0, 56,215, 8, 100, 1, 0, 0x0, 0xFFFfff, #file_name, #temp, 0};
byte cmd_free=0;
#include "include\translations.h"
#include "include\gui.h" #include "include\gui.h"
#include "include\settings.h" #include "include\settings.h"
@ -159,18 +127,12 @@ byte cmd_free=0;
#include "include\properties.h" #include "include\properties.h"
#include "include\breadcrumbs.h" #include "include\breadcrumbs.h"
void load_libraries()
{
load_dll(boxlib, #box_lib_init,0);
load_dll(libini, #lib_init,1);
load_dll(libimg, #libimg_init,1);
}
void handle_param() void handle_param()
{ {
//-p <path> : just show file/folder properties dialog //-p <path> : just show file/folder properties dialog
//-d <path> : delete file/folder //-d <path> : delete file/folder
//-v : paste files/folder from clipboard //-v : paste files/folder from clipboard
int i;
dword p = #param; dword p = #param;
if (param[0]=='\\') && (param[1]=='E') && (param[2]=='F') && (param[3]=='M') { if (param[0]=='\\') && (param[1]=='E') && (param[2]=='F') && (param[3]=='M') {
efm = true; efm = true;
@ -180,6 +142,12 @@ void handle_param()
LoadIniSettings(); LoadIniSettings();
for (i=0; i<PANES_COUNT; i++) {
location[i] = malloc(4096);
strcpy(location[i], #path_start);
}
//path = location[0];
if (ESBYTE[p]=='\0') return; if (ESBYTE[p]=='\0') return;
if (ESBYTE[p]=='-') switch (ESBYTE[p+1]) if (ESBYTE[p]=='-') switch (ESBYTE[p+1])
@ -225,13 +193,12 @@ void main()
dword id; dword id;
int old_cur_y; int old_cur_y;
load_libraries(); load_dll(boxlib, #box_lib_init,0);
load_dll(libini, #lib_init,1);
load_dll(libimg, #libimg_init,1);
SetAppColors(); SetAppColors();
ESBYTE[0] = NULL;
handle_param(); handle_param();
rand_n = random(80);
ESBYTE[0] = NULL; ESBYTE[0] = NULL;
@ -240,7 +207,7 @@ void main()
strcpy(#inactive_path, #path); strcpy(#inactive_path, #path);
llist_copy(#files_inactive, #files); llist_copy(#files_inactive, #files);
SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
loop() switch(@WaitEventTimeout(80)) loop() switch(@WaitEventTimeout(100))
{ {
case evMouse: case evMouse:
if (del_active) || (disk_popin_active_on_panel) || (Form.status_window&ROLLED_UP) break; if (del_active) || (disk_popin_active_on_panel) || (Form.status_window&ROLLED_UP) break;
@ -318,8 +285,8 @@ void main()
//Scrooll //Scrooll
if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+18) && (mouse.y>files.y) 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();} && (mouse.y<files.y+files.h-18) && (mouse.lkm) && (!scroll_used) {scroll_used=true; DrawScroll(scroll_used);}
if (scroll_used) && (!mouse.key&MOUSE_LEFT) { scroll_used=false; Scroll(); } if (scroll_used) && (!mouse.key&MOUSE_LEFT) { scroll_used=false; DrawScroll(scroll_used); }
if (scroll_used) if (scroll_used)
{ {
@ -488,7 +455,7 @@ void main()
EventOpenNewEolite(); EventOpenNewEolite();
break; break;
case SCAN_CODE_KEY_R: case SCAN_CODE_KEY_R:
EventRefreshDisksAndFolders(); EventManualFolderRefresh();
break; break;
case SCAN_CODE_ENTER: case SCAN_CODE_ENTER:
if (!itdir) ShowOpenWithDialog(); if (!itdir) ShowOpenWithDialog();
@ -546,15 +513,9 @@ void main()
case evReDraw: case evReDraw:
draw_window(); draw_window();
if (CheckActiveProcess(Form.ID)) && (GetMenuClick()) break; if (CheckActiveProcess(Form.ID)) && (GetMenuClick()) break;
if (action_buf==OPERATION_END) {
EventRefresh();
action_buf=0;
}
break; break;
default: default:
if (Form.status_window<=2) EventRefreshDisksAndFolders(); if (!Form.status_window&ROLLED_UP) EventRefreshDisksAndFolders();
//sprintf(#param, "/tmp0/1/%i", random(99999)); //for testing purpose
//CreateFile(0, 0, #param);
} }
if(cmd_free) if(cmd_free)
@ -571,6 +532,9 @@ void draw_window()
dword i=0; dword i=0;
incn x; incn x;
dword title; dword title;
static int rand_n;
if (rand_n) rand_n = random(80);
if (show_status_bar.checked) { if (show_status_bar.checked) {
#define STBAR_EOLITE_H 16; #define STBAR_EOLITE_H 16;
#define STBAR_KFM_H 21+16; #define STBAR_KFM_H 21+16;
@ -677,7 +641,7 @@ void DrawStatusBar()
if (!show_status_bar.checked) return; if (!show_status_bar.checked) return;
if (files.count>0) && (streq(items.get(0)*304+buf+72,"..")) go_up_folder_exists=1; if (files.count>0) && (streq(items.get(0)*304+buf+72,"..")) go_up_folder_exists=1;
DrawBar(0, Form.cheight - status_bar_h, Form.cwidth, status_bar_h, sc.work); DrawBar(0, Form.cheight - status_bar_h, Form.cwidth, status_bar_h, sc.work);
sprintf(#status_bar_str, T_STATUS_EVEMENTS, count_dir-go_up_folder_exists, files.count-count_dir); sprintf(#status_bar_str, T_STATUS_EVEMENTS, folder_count-go_up_folder_exists, files.count-folder_count);
WriteText(6,Form.cheight - 13,0x80,sc.work_text,#status_bar_str); WriteText(6,Form.cheight - 13,0x80,sc.work_text,#status_bar_str);
if (selected_count) { if (selected_count) {
sprintf(#status_bar_str, T_STATUS_SELECTED, selected_count); sprintf(#status_bar_str, T_STATUS_SELECTED, selected_count);
@ -772,7 +736,7 @@ void List_ReDraw()
if (colored_lines.checked) separator_color = col.list_bg; else separator_color = col.list_vert_line; if (colored_lines.checked) separator_color = col.list_bg; else separator_color = col.list_vert_line;
DrawBar(files.x+files.w-141,all_lines_h + files.y,1,files.h - all_lines_h, separator_color); DrawBar(files.x+files.w-141,all_lines_h + files.y,1,files.h - all_lines_h, separator_color);
DrawBar(files.x+files.w-68,all_lines_h + files.y,1,files.h - all_lines_h, separator_color); DrawBar(files.x+files.w-68,all_lines_h + files.y,1,files.h - all_lines_h, separator_color);
Scroll(); DrawScroll(scroll_used);
if (del_active) Del_Form(); if (del_active) Del_Form();
if (new_element_active) && (col.selec != 0xCCCccc) NewElement_Form(new_element_active, #new_element_name); if (new_element_active) && (col.selec != 0xCCCccc) NewElement_Form(new_element_active, #new_element_name);
@ -891,9 +855,6 @@ void Open_Dir(dword dir_path, redraw){
} }
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(!_not_draw) DrawPathBar();
history.add(#path); history.add(#path);
SystemDiscs.Draw(); SystemDiscs.Draw();
files.visible = files.h / files.item_h; files.visible = files.h / files.item_h;
@ -902,13 +863,11 @@ void Open_Dir(dword dir_path, redraw){
dir_at_fat16 = true; else dir_at_fat16 = false; dir_at_fat16 = true; else dir_at_fat16 = false;
Sorting(); Sorting();
list_full_redraw = true; list_full_redraw = true;
if (redraw!=ONLY_OPEN)&&(!_not_draw) {DrawStatusBar(); List_ReDraw();}
SetCurDir(dir_path); SetCurDir(dir_path);
} DrawPathBar();
if (files.count==-1) && (redraw!=ONLY_OPEN) if (redraw!=ONLY_OPEN) {
{ List_ReDraw();
files.KeyHome(); DrawStatusBar();
if(!_not_draw) { list_full_redraw=true; DrawStatusBar(); List_ReDraw(); }
} }
} }
@ -923,7 +882,7 @@ inline Sorting()
if (!strcmp(#path,"/")) //do not sort root folder if (!strcmp(#path,"/")) //do not sort root folder
{ {
for(d=1;d<files.count;d++;) items.set(d, d); for(d=1;d<files.count;d++;) items.set(d, d);
count_dir = d; folder_count = d;
return; return;
} }
for (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;) //files | folders for (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;) //files | folders
@ -937,7 +896,7 @@ inline Sorting()
f++; f++;
} }
} }
count_dir = d; folder_count = d;
//sorting: files first, then folders //sorting: files first, then folders
Sort_by_Name(0,d-1); Sort_by_Name(0,d-1);
if (sort_type==1) Sort_by_Name(d,files.count-1); if (sort_type==1) Sort_by_Name(d,files.count-1);
@ -1169,7 +1128,7 @@ void FnProcess(byte N)
CopyFilesListToClipboard(COPY); CopyFilesListToClipboard(COPY);
EventPaste(#inactive_path); EventPaste(#inactive_path);
} else { } else {
EventRefreshDisksAndFolders(); EventManualFolderRefresh();
} }
break; break;
case 6: case 6:
@ -1202,19 +1161,6 @@ void FnProcess(byte N)
} }
} }
void EventRefresh()
{
if (efm)
{
DrawFilePanels();
} else {
Tip(56, T_DEVICES, 55, "-");
Open_Dir(#path,WITH_REDRAW);
pause(10);
DrawDeviceAndActionsLeftPanel();
}
}
void SetActivePanel(int _active) void SetActivePanel(int _active)
{ {
if (active_panel != _active) { if (active_panel != _active) {
@ -1266,15 +1212,26 @@ int GetRealFileCountInFolder(dword folder_path)
void EventRefreshDisksAndFolders() void EventRefreshDisksAndFolders()
{ {
if(GetRealFileCountInFolder("/")+dir_exists("/kolibrios") != SystemDiscs.dev_num) { if(efm) {
SystemDiscs.Get(); if (GetRealFileCountInFolder(#inactive_path) != files_inactive.count) {
EventRefresh(); DrawFilePanels();
return;
}
} else { } else {
if(GetRealFileCountInFolder(#path) != files.count) EventRefresh(); if (GetRealFileCountInFolder("/")+dir_exists("/kolibrios") != SystemDiscs.dev_num) {
else if(efm) && (GetRealFileCountInFolder(#inactive_path) != files_inactive.count) { SystemDiscs.Get();
EventRefresh(); DrawDeviceAndActionsLeftPanel();
} }
} }
if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
}
void EventManualFolderRefresh()
{
Tip(56, T_DEVICES, 55, "-");
pause(10);
EventRefreshDisksAndFolders();
DrawDeviceAndActionsLeftPanel();
} }
void EventSort(dword id) void EventSort(dword id)

View File

@ -37,7 +37,7 @@ char *kfm_func = {
"“¤ «¨âì", "“¤ «¨âì",
"” ©«", "” ©«",
" <20> áâனª¨" " <20> áâனª¨"
} };
#else #else
?define T_FILE "File" ?define T_FILE "File"
?define T_TYPE "Type" ?define T_TYPE "Type"
@ -78,6 +78,36 @@ char *kfm_func = {
"Delete", "Delete",
"File", "File",
" Settings" " Settings"
} };
#endif #endif
//Button IDs
enum {
PATH_BTN = 10,
POPUP_BTN1 = 201,
POPUP_BTN2 = 202,
KFM_DEV_DROPDOWN_1 = 205,
KFM_DEV_DROPDOWN_2 = 207,
BREADCRUMB_ID = 300,
BACK_BTN = 400,
FWRD_BTN,
GOUP_BTN,
COPY_BTN,
CUT_BTN,
PASTE_BTN,
KFM_FUNC_ID = 450
};
//NewElement options
enum {
CREATE_FILE=1,
CREATE_FOLDER,
RENAME_ITEM
};
//OpenDir options
enum {
WITH_REDRAW,
ONLY_OPEN
};

View File

@ -1,5 +1,5 @@
void Scroll() { void DrawScroll(bool _scroll_used) {
dword i; dword i;
dword sc_x = files.x + files.w; dword sc_x = files.x + files.w;
@ -23,8 +23,10 @@ void Scroll() {
//slider //slider
DrawRectangle(sc_x,sc_slider_y,16,sc_slider_h,sc.work_graph); DrawRectangle(sc_x,sc_slider_y,16,sc_slider_h,sc.work_graph);
DrawRectangle3D(sc_x+1,sc_slider_y+1,14,sc_slider_h-2, sc.work_light , sc.work_dark); DrawRectangle3D(sc_x+1,sc_slider_y+1,14,sc_slider_h-2, sc.work_light , sc.work_dark);
if (!scroll_used) for (i=0; i<13; i++) DrawBar(sc_x + 2 + i, sc_slider_y+2, 1, sc_slider_h-3, col.work_gradient[13-i]); for (i=0; i<13; i++) {
if (scroll_used) for (i=0; i<13; i++) DrawBar(sc_x + 2 + i, sc_slider_y+2, 1, sc_slider_h-3, col.work_gradient[i]); if (!_scroll_used) EDX = col.work_gradient[13-i]; else EDX = col.work_gradient[i];
DrawBar(sc_x + 2 + i, sc_slider_y+2, 1, sc_slider_h-3, EDX);
}
sc_center = sc_slider_h / 2 + sc_slider_y; sc_center = sc_slider_h / 2 + sc_slider_y;

View File

@ -14,7 +14,6 @@ enum {
COPY_FLAG, COPY_FLAG,
MOVE_FLAG, MOVE_FLAG,
DELETE_FLAG, DELETE_FLAG,
OPERATION_END
}; };
void DisplayOperationForm(int operation_flag) void DisplayOperationForm(int operation_flag)
@ -57,7 +56,6 @@ void DisplayOperationForm(int operation_flag)
} }
void DialogExit() { void DialogExit() {
action_buf = OPERATION_END;
ActivateWindow(GetProcessSlot(Form.ID)); ActivateWindow(GetProcessSlot(Form.ID));
ExitProcess(); ExitProcess();
} }

View File

@ -131,10 +131,7 @@ void SetProperties(int mode)
} }
cmd_free=3; cmd_free=3;
_not_draw = true; Open_Dir(#path,ONLY_OPEN);
Open_Dir(#path,WITH_REDRAW);
_not_draw = false;
EventRedrawWindow(Form.left,Form.top);
ExitProcess(); ExitProcess();
} }

View File

@ -27,6 +27,9 @@
?define START_PATH " Start path: " ?define START_PATH " Start path: "
#endif #endif
dword eolite_ini_path[4096];
_ini ini;
char path_start[4096]; char path_start[4096];
edit_box path_start_ed = {290,50,57,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,4098, edit_box path_start_ed = {290,50,57,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,4098,
#path_start,0, 100000000000010b,0,0}; #path_start,0, 100000000000010b,0,0};