]> git.lyx.org Git - lyx.git/blobdiff - src/text3.C
revert recent change to development/FORMAT (don't change history)
[lyx.git] / src / text3.C
index f2c952590bc14d7669971e29ce576b47980f179e..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;
 
@@ -705,32 +709,39 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                break;
        }
 
-       case LFUN_INSET_SETTINGS:
-               cur.inset().showInsetDialog(bv);
-               break;
-
-       case LFUN_NEXT_INSET_TOGGLE: {
-               InsetBase * inset = cur.nextInset();
-               // this is the real function we want to invoke
-               cmd = FuncRequest(LFUN_INSET_TOGGLE);
-               cur.undispatched();
-               // if there is an inset at cursor, see whether it
-               // wants to toggle.
-               if (inset) {
-                       LCursor tmpcur = cur;
-                       tmpcur.pushLeft(*inset);
-                       inset->dispatch(tmpcur, cmd);
-                       if (tmpcur.result().dispatched()) {
-                               cur.clearSelection();
-                               cur.dispatched();
-                       }
+       case LFUN_INSET_DISSOLVE: {
+               recordUndoInset(cur);
+               cur.selHandle(false);
+               // save position
+               lyx::pos_type spos = cur.pos();
+               lyx::pit_type spit = cur.pit();
+               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);
                }
-               // if it did not work, try the underlying inset.
-               if (!cur.result().dispatched())
-                       cur.inset().dispatch(cur, cmd);
+               cur.clearSelection();
+               cur.resetAnchor();
+               needsUpdate = true;
                break;
        }
 
+       case LFUN_INSET_SETTINGS:
+               cur.inset().showInsetDialog(bv);
+               break;
+
        case LFUN_SPACE_INSERT:
                if (cur.paragraph().layout()->free_spacing)
                        insertChar(cur, ' ');
@@ -781,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();
@@ -1080,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);
@@ -1711,6 +1734,11 @@ bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
                break;
        }
 
+       case LFUN_INSET_DISSOLVE: {
+               enable = &cur.inset() && cur.inTexted();
+               break;
+       }
+
        case LFUN_WORD_DELETE_FORWARD:
        case LFUN_WORD_DELETE_BACKWARD:
        case LFUN_LINE_DELETE:
@@ -1749,7 +1777,6 @@ bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
        case LFUN_BREAK_PARAGRAPH_SKIP:
        case LFUN_PARAGRAPH_SPACING:
        case LFUN_INSET_INSERT:
-       case LFUN_NEXT_INSET_TOGGLE:
        case LFUN_WORD_UPCASE:
        case LFUN_WORD_LOWCASE:
        case LFUN_WORD_CAPITALIZE: