X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fchanges.h;h=967a9a6c8d7bc6308827ba632a311068b3c778b4;hb=cd4033aef3a3f1efdb5a676b8bab3d367f53a830;hp=8ea506ffd60e64b3904e7fb5216014b836af7b98;hpb=26b0abe7dc2a49b9827c1617e880f5dba7c063ec;p=lyx.git diff --git a/src/changes.h b/src/changes.h index 8ea506ffd6..967a9a6c8d 100644 --- a/src/changes.h +++ b/src/changes.h @@ -33,9 +33,12 @@ public: DELETED // deleted text }; - explicit Change(Type t, int a = 0, time_type ct = 0) + explicit Change(Type t, int a = 0, time_type ct = current_time()) : type(t), author(a), changetime(ct) {} + /// is the change similar to the given change such that both can be merged? + bool isSimilarTo(Change const & change); + Type type; int author; @@ -50,27 +53,35 @@ class Changes { public: /// set the pos to the given change void set(Change const & change, pos_type pos); - /// set the range to the given change + /// set the range (excluding end) to the given change void set(Change const & change, pos_type start, pos_type end); - /// return the change at the given position - Change const lookup(pos_type pos) const; + /// erase the entry at pos and adjust all range bounds past it + /// (assumes that a character was deleted at pos) + void erase(lyx::pos_type pos); + + /// insert a new entry at pos and adjust all range bounds past it + /// (assumes that a character was inserted at pos) + void insert(Change const & change, lyx::pos_type pos); + + /// + + /// return the change at the given pos + Change const & lookup(pos_type pos) const; - /// return true if there is a change in the given range + /// return true if there is a change in the given range (excluding end) bool isChanged(pos_type start, pos_type end) const; - /// remove the given entry. This implies that a character was - /// deleted at pos, and will adjust all range bounds past it - void erase(pos_type pos); + /// - /// output latex to mark a transition between two changetypes + /// output latex to mark a transition between two change types /// returns length of text outputted - static int latexMarkChange(odocstream & os, Change::Type old, - Change::Type change, bool const & output); + static int latexMarkChange(odocstream & os, Change::Type oldChangeType, + Change::Type changeType, bool const & output); /// output .lyx file format for transitions between changes static void lyxMarkChange(std::ostream & os, int & column, - time_type curtime, Change const & old, Change const & change); + Change const & old, Change const & change); private: class Range { @@ -78,11 +89,15 @@ private: Range(pos_type s, pos_type e) : start(s), end(e) {} - // does this range contain r ? - bool contains(Range const & r) const; + // does this range contain r ? (inlined as the result of profiling) + bool contains(Range const & r) const { + return r.start >= start && r.end <= end; + } - // does this range contain pos ? - bool contains(pos_type pos) const; + // does this range contain pos ? (inlined as the result of profiling) + bool contains(pos_type pos) const { + return pos >= start && pos < end; + } // do the ranges intersect ? bool intersects(Range const & r) const; @@ -103,7 +118,7 @@ private: Range range; }; - /// merge neighbouring ranges, assuming that they are abutting + /// merge equal changes with adjoining ranges void merge(); typedef std::vector ChangeTable;