forked from KolibriOS/kolibrios
make history.h global
git-svn-id: svn://kolibrios.org@5977 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
0be26c4c22
commit
35b817fff3
@ -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()
|
||||
|
@ -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;
|
||||
}
|
@ -12,7 +12,6 @@ struct collection
|
||||
dword get();
|
||||
void drop();
|
||||
void increase_data_size();
|
||||
|
||||
};
|
||||
|
||||
void collection::increase_data_size() {
|
||||
|
38
programs/cmm/lib/patterns/history.h
Normal file
38
programs/cmm/lib/patterns/history.h
Normal file
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user