]> git.lyx.org Git - lyx.git/blobdiff - src/text_funcs.C
"Inter-word Space"
[lyx.git] / src / text_funcs.C
index 74c8dfd0ef4ba679a444719a7a7f5f0d4d6ea15a..a5f4daf6fe913ec3e67a1a7047507de2664559f9 100644 (file)
@@ -9,7 +9,7 @@
  * Full author contact details are available in file CREDITS
  *
  * This file contains some utility functions for actually mutating
- * the text contents of a document 
+ * the text contents of a document
  */
 
 #include <config.h>
 #include "lyxcursor.h"
 #include "undo_funcs.h"
 
+#include <boost/next_prior.hpp>
+
 using lyx::pos_type;
 
 void transposeChars(LyXText & text, LyXCursor const & cursor)
 {
-       Paragraph * tmppar = cursor.par();
+       ParagraphList::iterator tmppit = cursor.par();
 
-       setUndo(text.bv(), Undo::FINISH, tmppar, tmppar->next());
+       setUndo(text.bv(), Undo::FINISH, tmppit);
 
        pos_type tmppos = cursor.pos();
 
        // First decide if it is possible to transpose at all
 
-       if (tmppos == 0 || tmppos == tmppar->size())
+       if (tmppos == 0 || tmppos == tmppit->size())
                return;
 
-       if (isDeletedText(*tmppar, tmppos - 1)
-               || isDeletedText(*tmppar, tmppos))
+       if (isDeletedText(*tmppit, tmppos - 1)
+               || isDeletedText(*tmppit, tmppos))
                return;
 
-       unsigned char c1 = tmppar->getChar(tmppos);
-       unsigned char c2 = tmppar->getChar(tmppos - 1);
+       unsigned char c1 = tmppit->getChar(tmppos);
+       unsigned char c2 = tmppit->getChar(tmppos - 1);
 
        // We should have an implementation that handles insets
        // as well, but that will have to come later. (Lgb)
        if (c1 == Paragraph::META_INSET || c2 == Paragraph::META_INSET)
                return;
 
-       bool const erased = tmppar->erase(tmppos - 1, tmppos + 1);
+       bool const erased = tmppit->erase(tmppos - 1, tmppos + 1);
        pos_type const ipos(erased ? tmppos - 1 : tmppos + 1);
 
-       tmppar->insertChar(ipos, c1);
-       tmppar->insertChar(ipos + 1, c2);
+       tmppit->insertChar(ipos, c1);
+       tmppit->insertChar(ipos + 1, c2);
 
-       text.checkParagraph(tmppar, tmppos);
+       text.checkParagraph(tmppit, tmppos);
 }