A support function for getting the current type of change at the cursor,
needed for deciding what to do on user input


Index: src/BufferView.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.C,v
retrieving revision 1.115
diff -u -r1.115 BufferView.C
--- src/BufferView.C    23 Jan 2003 16:23:35 -0000      1.115
+++ src/BufferView.C    7 Feb 2003 11:31:41 -0000
@@ -29,6 +29,7 @@
 #include "lyxlex.h"
 #include "lyxtext.h"
 #include "undo_funcs.h"
+#include "changes.h"
 
 #include "frontends/Alert.h"
 #include "frontends/Dialogs.h"
@@ -154,6 +155,12 @@
 }
 
 
+Change const BufferView::getCurrentChange()
+{
+       return pimpl_->getCurrentChange();
+}
+
+ 
 void BufferView::beforeChange(LyXText * text)
 {
        pimpl_->beforeChange(text);
Index: src/BufferView.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.h,v
retrieving revision 1.113
diff -u -r1.113 BufferView.h
--- src/BufferView.h    5 Jan 2003 22:38:41 -0000       1.113
+++ src/BufferView.h    7 Feb 2003 11:31:41 -0000
@@ -21,6 +21,7 @@
 
 #include <boost/utility.hpp>
 
+class Change;
 class LyXView;
 class LyXText;
 class TeXErrors;
@@ -107,6 +108,9 @@
        void restorePosition(unsigned int i);
        /// does the given bookmark have a saved position ?
        bool isSavedPosition(unsigned int i);
+ 
+       /// return the current change at the cursor
+       Change const getCurrentChange();
 
        /**
         * This holds the mapping between buffer paragraphs and screen rows.
Index: src/BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.322
diff -u -r1.322 BufferView_pimpl.C
--- src/BufferView_pimpl.C      23 Jan 2003 16:23:35 -0000      1.322
+++ src/BufferView_pimpl.C      7 Feb 2003 11:31:42 -0000
@@ -41,6 +41,8 @@
 #include "ParagraphParameters.h"
 #include "undo_funcs.h"
 #include "funcrequest.h"
+#include "iterators.h"
+#include "lyxfind.h"
 
 #include "insets/insetbib.h"
 #include "insets/insettext.h"
@@ -624,6 +626,21 @@
 }
 
 
+Change const BufferView::Pimpl::getCurrentChange()
+{
+       if (!bv_->buffer()->params.tracking_changes) 
+               return Change(Change::UNCHANGED);
+
+       LyXText * t(bv_->getLyXText());
+ 
+       if (!t->selection.set())
+               return Change(Change::UNCHANGED);
+ 
+       LyXCursor const & cur(t->selection.start);
+       return cur.par()->lookupChangeFull(cur.pos());
+}
+
+
 void BufferView::Pimpl::beforeChange(LyXText * text)
 {
        toggleSelection();
Index: src/BufferView_pimpl.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.h,v
retrieving revision 1.81
diff -u -r1.81 BufferView_pimpl.h
--- src/BufferView_pimpl.h      21 Oct 2002 00:15:48 -0000      1.81
+++ src/BufferView_pimpl.h      7 Feb 2003 11:31:42 -0000
@@ -23,6 +23,7 @@
 #pragma interface
 #endif
 
+class Change;
 class LyXView;
 class WorkArea;
 class LyXScreen;
@@ -74,6 +75,8 @@
        void cursorToggle();
        ///
        bool available() const;
+       /// get the change at the cursor position
+       Change const getCurrentChange();
        ///
        void beforeChange(LyXText *);
        ///
@@ -103,6 +106,9 @@
        ///
        bool dispatch(FuncRequest const & ev);
 private:
+       /// track changes for the document
+       void trackChanges();
+
        ///
        friend class BufferView;
 

Reply via email to