diff --git a/programs/cmm/eolite/Eolite.c b/programs/cmm/eolite/Eolite.c index 1b92fb2246..19886e2f34 100644 --- a/programs/cmm/eolite/Eolite.c +++ b/programs/cmm/eolite/Eolite.c @@ -19,6 +19,8 @@ //obj #include "..\lib\obj\libini.h" #include "..\lib\obj\box_lib.h" +//patterns +#include "..\lib\patterns\history.h" byte CMD_ENABLE_SAVE_IMG = false; @@ -104,7 +106,6 @@ char *fd_path_eolite_ini_path; #include "include\sorting.h" #include "include\icons.h" #include "include\left_panel.h" -#include "include\history.h" #include "include\menu.h" #include "include\about.h" #include "include\properties.h" @@ -170,8 +171,9 @@ void main() { if (dif_x > 150) { - if (FoldersHistory.forward()) + if (History.forward()) { + strcpy(#path, History.current()); files.KeyHome(); Open_Dir(#path,WITH_REDRAW); } @@ -323,8 +325,9 @@ void main() GoBack(); break; case 22: //Forward - if (FoldersHistory.forward()) + if (History.forward()) { + strcpy(#path, History.current()); files.KeyHome(); Open_Dir(#path,WITH_REDRAW); } @@ -735,7 +738,7 @@ void Open_Dir(dword dir_path, redraw){ if (ESBYTE[dir_path+1]!='\0') chrcat(dir_path, '/'); if (errornum) { - FoldersHistory.add(); + History.add(#path); GoBack(); Write_Error(errornum); return; @@ -753,7 +756,7 @@ void Open_Dir(dword dir_path, redraw){ PathShow_prepare stdcall(#PathShow); PathShow_draw stdcall(#PathShow); } - FoldersHistory.add(); + History.add(#path); files.visible = files.h / files.item_h; if (files.count < files.visible) files.visible = files.count; if (redraw!=ONLY_SHOW) Sorting(); @@ -1001,7 +1004,10 @@ inline fastcall void GoBack() char cur_folder[4096]; strcpy(#cur_folder, #path); cur_folder[strlen(#cur_folder)-1]=0x00; //delete last '/' - if (FoldersHistory.back()) SelectFileByName(#cur_folder+strrchr(#cur_folder,'/')); + if (History.back()) { + strcpy(#path, History.current()); + SelectFileByName(#cur_folder+strrchr(#cur_folder,'/')); + } } void ShowOpenWithDialog() diff --git a/programs/cmm/eolite/include/history.h b/programs/cmm/eolite/include/history.h deleted file mode 100644 index 17a8836e04..0000000000 --- a/programs/cmm/eolite/include/history.h +++ /dev/null @@ -1,35 +0,0 @@ - -struct _FoldersHistory { - collection history; - int history_current; - int add(); - int back(); - int forward(); -} FoldersHistory; - -int _FoldersHistory::add() -{ - if (!strcmp(#path, history.get(history_current-1))) return 0; - history.count = history_current; - history.add(#path); - history_current++; - return 1; -} - -int _FoldersHistory::back() -{ - if (history_current==1) return 0; - history_current--; - strcpy(#path, history.get(history_current-1)); - debugln(#path); - return 1; -} - -int _FoldersHistory::forward() -{ - if (history_current==history.count) return 0; - history_current++; - strcpy(#path, history.get(history_current-1)); - debugln(#path); - return 1; -} \ No newline at end of file diff --git a/programs/cmm/lib/collection.h b/programs/cmm/lib/collection.h index f12a394e1d..2ce4cdec54 100644 --- a/programs/cmm/lib/collection.h +++ b/programs/cmm/lib/collection.h @@ -12,7 +12,6 @@ struct collection dword get(); void drop(); void increase_data_size(); - }; void collection::increase_data_size() { diff --git a/programs/cmm/lib/patterns/history.h b/programs/cmm/lib/patterns/history.h new file mode 100644 index 0000000000..23691176f1 --- /dev/null +++ b/programs/cmm/lib/patterns/history.h @@ -0,0 +1,38 @@ +#include "..\lib\collection.h" + +struct _History { + collection items; + int active; + dword add(); + dword back(); + dword forward(); + dword current(); +} History; + +dword _History::add(dword in) +{ + if (!strcmp(in, items.get(active-1))) return 0; + items.count = active; + items.add(in); + active++; + return 1; +} + +dword _History::back() +{ + if (active==1) return 0; + active--; + return items.get(active-1); +} + +dword _History::forward() +{ + if (active==items.count) return 0; + active++; + return items.get(active-1); +} + +dword _History::current() +{ + return items.get(active-1); +} \ No newline at end of file