2014-05-26 21:59:08 +02:00
|
|
|
#ifndef line_change_watcher_hh_INCLUDED
|
|
|
|
#define line_change_watcher_hh_INCLUDED
|
|
|
|
|
2018-10-21 03:10:21 +02:00
|
|
|
#include "array_view.hh"
|
2014-05-26 21:59:08 +02:00
|
|
|
#include "units.hh"
|
|
|
|
#include "utils.hh"
|
2018-10-21 03:10:21 +02:00
|
|
|
#include "range.hh"
|
2015-01-12 14:58:41 +01:00
|
|
|
#include "vector.hh"
|
2014-12-23 14:34:21 +01:00
|
|
|
|
2014-05-26 21:59:08 +02:00
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
|
|
|
class Buffer;
|
|
|
|
|
|
|
|
struct LineModification
|
|
|
|
{
|
|
|
|
LineCount old_line; // line position in the old buffer
|
|
|
|
LineCount new_line; // new line position
|
2015-02-01 00:50:24 +01:00
|
|
|
LineCount num_removed; // number of lines removed (including this one)
|
|
|
|
LineCount num_added; // number of lines added (including this one)
|
2014-05-26 21:59:08 +02:00
|
|
|
|
|
|
|
LineCount diff() const { return new_line - old_line + num_added - num_removed; }
|
|
|
|
};
|
|
|
|
|
2015-01-12 14:58:41 +01:00
|
|
|
Vector<LineModification> compute_line_modifications(const Buffer& buffer, size_t timestamp);
|
2014-05-26 21:59:08 +02:00
|
|
|
|
2018-10-21 03:10:21 +02:00
|
|
|
using LineRange = Range<LineCount>;
|
|
|
|
|
|
|
|
struct LineRangeSet : private Vector<LineRange, MemoryDomain::Highlight>
|
|
|
|
{
|
|
|
|
using Base = Vector<LineRange, MemoryDomain::Highlight>;
|
|
|
|
using Base::operator[];
|
|
|
|
using Base::begin;
|
|
|
|
using Base::end;
|
|
|
|
|
|
|
|
ConstArrayView<LineRange> view() const { return {data(), data() + size()}; }
|
|
|
|
|
|
|
|
void reset(LineRange range) { Base::operator=({range}); }
|
|
|
|
|
|
|
|
void update(ConstArrayView<LineModification> modifs);
|
2019-09-01 05:03:01 +02:00
|
|
|
void add_range(LineRange range, FunctionRef<void (LineRange)> on_new_range);
|
2018-10-21 03:10:21 +02:00
|
|
|
void remove_range(LineRange range);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-05-26 21:59:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // line_change_watcher_hh_INCLUDED
|