2014-01-23 20:54:32 +01:00
|
|
|
#ifndef line_change_watcher_hh_INCLUDED
|
|
|
|
#define line_change_watcher_hh_INCLUDED
|
|
|
|
|
2014-05-11 14:20:13 +02:00
|
|
|
#include "units.hh"
|
|
|
|
#include "utils.hh"
|
2014-01-23 20:54:32 +01:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2014-05-11 14:20:13 +02:00
|
|
|
class Buffer;
|
|
|
|
|
2014-01-23 20:54:32 +01:00
|
|
|
struct LineModification
|
|
|
|
{
|
|
|
|
LineCount old_line; // line position in the old buffer
|
|
|
|
LineCount new_line; // new line position
|
|
|
|
LineCount num_removed; // number of lines removed after this one
|
|
|
|
LineCount num_added; // number of lines added after this one
|
|
|
|
|
|
|
|
LineCount diff() const { return new_line - old_line + num_added - num_removed; }
|
|
|
|
};
|
|
|
|
|
2014-05-11 14:20:13 +02:00
|
|
|
class LineChangeWatcher
|
2014-01-23 20:54:32 +01:00
|
|
|
{
|
|
|
|
public:
|
2014-05-11 14:20:13 +02:00
|
|
|
LineChangeWatcher (const Buffer& buffer);
|
2014-01-23 20:54:32 +01:00
|
|
|
|
|
|
|
std::vector<LineModification> compute_modifications();
|
2014-05-11 14:20:13 +02:00
|
|
|
|
|
|
|
const Buffer& buffer() const { return *m_buffer; }
|
2014-01-23 20:54:32 +01:00
|
|
|
private:
|
2014-05-11 14:20:13 +02:00
|
|
|
safe_ptr<const Buffer> m_buffer;
|
|
|
|
size_t m_timestamp;
|
2014-01-23 20:54:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // line_change_watcher_hh_INCLUDED
|