]> git.lyx.org Git - lyx.git/blobdiff - src/text3.C
minimal effort implementation of:
[lyx.git] / src / text3.C
index 33eec5dbe2afa5aa01da2ad151390f0d30ba9b07..8a7069b689ae78cb925f8af9fab2a61be65ea6d2 100644 (file)
@@ -29,6 +29,7 @@
 #include "CutAndPaste.h"
 #include "debug.h"
 #include "dispatchresult.h"
+#include "errorlist.h"
 #include "factory.h"
 #include "funcrequest.h"
 #include "gettext.h"
@@ -63,6 +64,7 @@
 #include "support/lyxlib.h"
 #include "support/convert.h"
 #include "support/lyxtime.h"
+#include "support/unicode.h"
 
 #include "mathed/math_hullinset.h"
 #include "mathed/math_macrotemplate.h"
 #include <clocale>
 #include <sstream>
 
+using lyx::char_type;
 using lyx::pos_type;
 
 using lyx::cap::copySelection;
 using lyx::cap::cutSelection;
+using lyx::cap::pasteParagraphList;
 using lyx::cap::pasteSelection;
 using lyx::cap::replaceSelection;
 
@@ -706,39 +710,30 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
        }
 
        case LFUN_INSET_DISSOLVE: {
-               recordUndo(cur);
+               recordUndoInset(cur);
                cur.selHandle(false);
                // save position
                lyx::pos_type spos = cur.pos();
                lyx::pit_type spit = cur.pit();
-               bool content = false;
-               if (cur.lastpit() != 0 || cur.lastpos() != 0) {
-                       setCursor(cur, 0, 0);
-                       cur.resetAnchor();
-                       cur.pit() = cur.lastpit();
-                       cur.pos() = cur.lastpos();
-                       cur.setSelection();
-                       copySelection(cur);
-                       content = true;
-               }
-                       cur.popLeft();
-                       cur.resetAnchor();
-                       // store cursor offset
-                       if (spit == 0)
-                               spos += cur.pos();
-                       spit += cur.pit();
-                       cur.pos()++;
-                       cur.setSelection();
-               if (content) {
-                       lyx::cap::replaceSelection(cur);
-                       pasteSelection(cur, 0);
-                       cur.clearSelection();
+               ParagraphList plist;
+               if (cur.lastpit() != 0 || cur.lastpos() != 0) 
+                       plist = paragraphs();
+               cur.popLeft();
+               // store cursor offset
+               if (spit == 0)
+                       spos += cur.pos();
+               spit += cur.pit();
+               cur.paragraph().erase(cur.pos());
+               if (!plist.empty()) {
+                       Buffer * b = bv->buffer();
+                       pasteParagraphList(cur, plist, b->params().textclass, 
+                                          b->errorList("Paste"));
                        // restore position
                        cur.pit() = std::min(cur.lastpit(), spit);
                        cur.pos() = std::min(cur.lastpos(), spos);
-                       cur.resetAnchor();
-               } else
-                       cutSelection(cur, false, false);
+               }
+               cur.clearSelection();
+               cur.resetAnchor();
                needsUpdate = true;
                break;
        }
@@ -797,9 +792,12 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                cur.message(_("Paste"));
                lyx::cap::replaceSelection(cur);
                if (isStrUnsignedInt(cmd.argument))
-                       pasteSelection(cur, convert<unsigned int>(cmd.argument));
+                       pasteSelection(cur, bv->buffer()->errorList("Paste"),
+                       convert<unsigned int>(cmd.argument));
                else
-                       pasteSelection(cur, 0);
+                       pasteSelection(cur, bv->buffer()->errorList("Paste"),
+                       0);
+               bv->buffer()->errors("Paste");
                cur.clearSelection(); // bug 393
                bv->switchKeyMap();
                finishUndo();
@@ -1096,11 +1094,20 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                cur.clearSelection();
                LyXFont const old_font = real_current_font;
 
+#if 0
                string::const_iterator cit = cmd.argument.begin();
                string::const_iterator end = cmd.argument.end();
                for (; cit != end; ++cit)
                        bv->owner()->getIntl().getTransManager().
                                translateAndInsert(*cit, this);
+#else
+               std::vector<char> in(cmd.argument.begin(), cmd.argument.end());
+               std::vector<boost::uint32_t> const res = utf8_to_ucs4(in);
+               std::vector<boost::uint32_t>::const_iterator cit = res.begin();
+               std::vector<boost::uint32_t>::const_iterator end = res.end();
+               for (; cit != end; ++cit)
+                       insertChar(bv->cursor(), *cit);
+#endif
 
                cur.resetAnchor();
                moveCursor(cur, false);