summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2012-08-15 17:07:53 +0200
committerMaxime Coste <frrrwww@gmail.com>2012-08-15 17:07:53 +0200
commit5393e9e78b673bcfeb75ee4e2262aaae294e73ee (patch)
tree2f85c785e959f7d8602ecf39559e8e0ec107e893 /src
parent14475e91cbc47a6dbff15cb6393d0da99f404a1f (diff)
Buffer: add a timestamp
Diffstat (limited to 'src')
-rw-r--r--src/buffer.cc3
-rw-r--r--src/buffer.hh3
2 files changed, 6 insertions, 0 deletions
diff --git a/src/buffer.cc b/src/buffer.cc
index 7c643dd5..8cec62d2 100644
--- a/src/buffer.cc
+++ b/src/buffer.cc
@@ -26,6 +26,7 @@ Buffer::Buffer(String name, Type type,
: m_name(std::move(name)), m_type(type),
m_history(1), m_history_cursor(m_history.begin()),
m_last_save_undo_index(0),
+ m_timestamp(0),
m_hook_manager(GlobalHookManager::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)
{
+ ++m_timestamp;
BufferSize offset = pos.offset();
// 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)
{
+ ++m_timestamp;
BufferIterator end = pos + length;
assert(end.is_valid());
String prefix = m_lines[pos.line()].content.substr(0, pos.column());
diff --git a/src/buffer.hh b/src/buffer.hh
index cc20a607..b048dbe5 100644
--- a/src/buffer.hh
+++ b/src/buffer.hh
@@ -114,6 +114,8 @@ public:
void insert(BufferIterator pos, const String& content);
void erase(BufferIterator begin, BufferIterator end);
+ size_t timestamp() const { return m_timestamp; }
+
void begin_undo_group();
void end_undo_group();
bool undo();
@@ -201,6 +203,7 @@ private:
std::list<std::unique_ptr<Window>> m_windows;
size_t m_last_save_undo_index;
+ size_t m_timestamp;
std::vector<BufferChangeListener*> m_change_listeners;