+2003-04-02 John Levon <levon@movementarian.org>
+
+ * lyxtext.h:
+ * text.C:
+ * Makefile.am:
+ * text_funcs.h:
+ * text_funcs.C: make transposeChars a free function
+
+ * lyxrow_funcs.C: remove wrong comment
+
2003-04-01 Lars Gullik Bjønnes <larsbj@gullik.net>
* lyxtext.h: adjust
text.C \
text2.C \
text3.C \
+ text_funcs.C \
+ text_funcs.h \
toc.C \
toc.h \
trans.C \
}
-// It seems that this is only used in LyXText, it
-// perhaps this function should be moved into LyXText. (Lgb)
pos_type lastPos(LyXText const & lt, RowList::iterator rit)
{
if (rit->par()->empty())
};
/// Change the case of the word at cursor position.
void changeCase(TextCase action);
- ///
- void transposeChars();
///
void toggleInset();
}
-void LyXText::transposeChars()
-{
- Paragraph * tmppar = cursor.par();
-
- setUndo(bv(), Undo::FINISH, tmppar, tmppar->next());
-
- pos_type tmppos = cursor.pos();
-
- // First decide if it is possible to transpose at all
-
- if (tmppos == 0 || tmppos == tmppar->size())
- return;
-
- if (isDeletedText(*tmppar, tmppos - 1)
- || isDeletedText(*tmppar, tmppos))
- return;
-
- unsigned char c1 = tmppar->getChar(tmppos);
- unsigned char c2 = tmppar->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);
- pos_type const ipos(erased ? tmppos - 1 : tmppos + 1);
-
- tmppar->insertChar(ipos, c1);
- tmppar->insertChar(ipos + 1, c2);
-
- checkParagraph(tmppar, tmppos);
-}
-
-
void LyXText::Delete()
{
// this is a very easy implementation
#include "insets/insetcommand.h"
#include "insets/insetnewline.h"
#include "undo_funcs.h"
+#include "text_funcs.h"
#include <ctime>
#include <clocale>
case LFUN_TRANSPOSE_CHARS:
update();
- transposeChars();
+ transposeChars(*this, cursor);
if (inset_owner)
bv->updateInset(inset_owner);
update();
--- /dev/null
+/**
+ * \file text_funcs.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS
+ *
+ * This file contains some utility functions for actually mutating
+ * the text contents of a document
+ */
+
+#include <config.h>
+
+#include "lyxtext.h"
+#include "paragraph.h"
+#include "lyxcursor.h"
+#include "undo_funcs.h"
+
+using lyx::pos_type;
+
+void transposeChars(LyXText & text, LyXCursor const & cursor)
+{
+ Paragraph * tmppar = cursor.par();
+
+ setUndo(text.bv(), Undo::FINISH, tmppar, tmppar->next());
+
+ pos_type tmppos = cursor.pos();
+
+ // First decide if it is possible to transpose at all
+
+ if (tmppos == 0 || tmppos == tmppar->size())
+ return;
+
+ if (isDeletedText(*tmppar, tmppos - 1)
+ || isDeletedText(*tmppar, tmppos))
+ return;
+
+ unsigned char c1 = tmppar->getChar(tmppos);
+ unsigned char c2 = tmppar->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);
+ pos_type const ipos(erased ? tmppos - 1 : tmppos + 1);
+
+ tmppar->insertChar(ipos, c1);
+ tmppar->insertChar(ipos + 1, c2);
+
+ text.checkParagraph(tmppar, tmppos);
+}
--- /dev/null
+/**
+ * \file text_funcs.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS
+ *
+ * This file contains some utility functions for actually mutating
+ * the text contents of a document
+ */
+
+#ifndef TEXT_FUNCS_H
+#define TEXT_FUNCS_H
+
+#include <config.h>
+
+class LyXText;
+class LyXCursor;
+
+void transposeChars(LyXText & text, LyXCursor const & cursor);
+
+#endif // TEXT_FUNCS_H