2015-12-17 01:08:01 +03:00
|
|
|
#include "..\lib\collection.h"
|
|
|
|
|
2016-01-01 19:51:53 +03:00
|
|
|
struct _history {
|
2015-12-17 01:08:01 +03:00
|
|
|
collection items;
|
|
|
|
int active;
|
2020-04-10 19:19:52 +03:00
|
|
|
void clear();
|
2015-12-17 01:48:58 +03:00
|
|
|
int add();
|
|
|
|
int back();
|
|
|
|
int forward();
|
2015-12-17 01:08:01 +03:00
|
|
|
dword current();
|
2020-03-29 13:57:14 +03:00
|
|
|
};
|
2015-12-17 01:08:01 +03:00
|
|
|
|
2016-01-01 19:51:53 +03:00
|
|
|
int _history::add(dword in)
|
2015-12-17 01:08:01 +03:00
|
|
|
{
|
|
|
|
if (!strcmp(in, items.get(active-1))) return 0;
|
|
|
|
items.count = active;
|
|
|
|
items.add(in);
|
|
|
|
active++;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-01-01 19:51:53 +03:00
|
|
|
int _history::back()
|
2015-12-17 01:08:01 +03:00
|
|
|
{
|
|
|
|
if (active==1) return 0;
|
|
|
|
active--;
|
2015-12-17 01:48:58 +03:00
|
|
|
return 1;
|
2015-12-17 01:08:01 +03:00
|
|
|
}
|
|
|
|
|
2016-01-01 19:51:53 +03:00
|
|
|
int _history::forward()
|
2015-12-17 01:08:01 +03:00
|
|
|
{
|
|
|
|
if (active==items.count) return 0;
|
|
|
|
active++;
|
2015-12-17 01:48:58 +03:00
|
|
|
return 1;
|
2015-12-17 01:08:01 +03:00
|
|
|
}
|
|
|
|
|
2016-01-01 19:51:53 +03:00
|
|
|
dword _history::current()
|
2015-12-17 01:08:01 +03:00
|
|
|
{
|
|
|
|
return items.get(active-1);
|
2020-04-10 19:19:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
:void _history::clear()
|
|
|
|
{
|
|
|
|
items.drop();
|
|
|
|
active=0;
|
|
|
|
}
|