Buffer: add a timestamp
This commit is contained in:
parent
14475e91cb
commit
5393e9e78b
|
@ -26,6 +26,7 @@ Buffer::Buffer(String name, Type type,
|
||||||
: m_name(std::move(name)), m_type(type),
|
: m_name(std::move(name)), m_type(type),
|
||||||
m_history(1), m_history_cursor(m_history.begin()),
|
m_history(1), m_history_cursor(m_history.begin()),
|
||||||
m_last_save_undo_index(0),
|
m_last_save_undo_index(0),
|
||||||
|
m_timestamp(0),
|
||||||
m_hook_manager(GlobalHookManager::instance()),
|
m_hook_manager(GlobalHookManager::instance()),
|
||||||
m_option_manager(GlobalOptionManager::instance())
|
m_option_manager(GlobalOptionManager::instance())
|
||||||
{
|
{
|
||||||
|
@ -233,6 +234,7 @@ void Buffer::check_invariant() const
|
||||||
|
|
||||||
void Buffer::do_insert(const BufferIterator& pos, const String& content)
|
void Buffer::do_insert(const BufferIterator& pos, const String& content)
|
||||||
{
|
{
|
||||||
|
++m_timestamp;
|
||||||
BufferSize offset = pos.offset();
|
BufferSize offset = pos.offset();
|
||||||
|
|
||||||
// all following lines advanced by length
|
// all following lines advanced by length
|
||||||
|
@ -307,6 +309,7 @@ void Buffer::do_insert(const BufferIterator& pos, const String& content)
|
||||||
|
|
||||||
void Buffer::do_erase(const BufferIterator& pos, BufferSize length)
|
void Buffer::do_erase(const BufferIterator& pos, BufferSize length)
|
||||||
{
|
{
|
||||||
|
++m_timestamp;
|
||||||
BufferIterator end = pos + length;
|
BufferIterator end = pos + length;
|
||||||
assert(end.is_valid());
|
assert(end.is_valid());
|
||||||
String prefix = m_lines[pos.line()].content.substr(0, pos.column());
|
String prefix = m_lines[pos.line()].content.substr(0, pos.column());
|
||||||
|
|
|
@ -114,6 +114,8 @@ public:
|
||||||
void insert(BufferIterator pos, const String& content);
|
void insert(BufferIterator pos, const String& content);
|
||||||
void erase(BufferIterator begin, BufferIterator end);
|
void erase(BufferIterator begin, BufferIterator end);
|
||||||
|
|
||||||
|
size_t timestamp() const { return m_timestamp; }
|
||||||
|
|
||||||
void begin_undo_group();
|
void begin_undo_group();
|
||||||
void end_undo_group();
|
void end_undo_group();
|
||||||
bool undo();
|
bool undo();
|
||||||
|
@ -201,6 +203,7 @@ private:
|
||||||
std::list<std::unique_ptr<Window>> m_windows;
|
std::list<std::unique_ptr<Window>> m_windows;
|
||||||
|
|
||||||
size_t m_last_save_undo_index;
|
size_t m_last_save_undo_index;
|
||||||
|
size_t m_timestamp;
|
||||||
|
|
||||||
std::vector<BufferChangeListener*> m_change_listeners;
|
std::vector<BufferChangeListener*> m_change_listeners;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user