2024-02-22 21:29:25 +01:00
|
|
|
#include "elna/history.hpp"
|
|
|
|
|
|
|
|
namespace elna
|
|
|
|
{
|
|
|
|
editor_history::editor_history()
|
|
|
|
: commands{}, current_pointer(commands.cend())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void editor_history::push(const std::string& entry)
|
|
|
|
{
|
2024-02-25 15:16:19 +01:00
|
|
|
commands.push_back(entry);
|
|
|
|
current_pointer = commands.cend();
|
2024-02-22 21:29:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void editor_history::clear()
|
|
|
|
{
|
|
|
|
commands.clear();
|
|
|
|
current_pointer = commands.cend();
|
|
|
|
}
|
|
|
|
|
|
|
|
editor_history::const_iterator editor_history::prev() noexcept
|
|
|
|
{
|
|
|
|
if (this->current_pointer != cbegin())
|
|
|
|
{
|
|
|
|
this->current_pointer = std::prev(this->current_pointer);
|
|
|
|
}
|
|
|
|
return this->current_pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
editor_history::const_iterator editor_history::next() noexcept
|
|
|
|
{
|
|
|
|
if (this->current_pointer != cend())
|
|
|
|
{
|
|
|
|
this->current_pointer = std::next(this->current_pointer);
|
|
|
|
}
|
|
|
|
return this->current_pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
editor_history::const_iterator editor_history::cbegin() const noexcept
|
|
|
|
{
|
|
|
|
return this->commands.cbegin();
|
|
|
|
}
|
|
|
|
|
|
|
|
editor_history::const_iterator editor_history::cend() const noexcept
|
|
|
|
{
|
|
|
|
return this->commands.cend();
|
|
|
|
}
|
2024-02-25 15:16:19 +01:00
|
|
|
|
|
|
|
editor_history::const_iterator editor_history::current() const noexcept
|
|
|
|
{
|
|
|
|
return this->current_pointer;
|
|
|
|
}
|
2024-02-22 21:29:25 +01:00
|
|
|
}
|