#include "CutAndPaste.h"
#include "debug.h"
#include "dispatchresult.h"
+#include "errorlist.h"
#include "factory.h"
#include "funcrequest.h"
#include "gettext.h"
#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;
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, ' ');
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();
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);
break;
}
- case LFUN_INSET_DIALOG_SHOW: {
- InsetBase * inset = cur.nextInset();
- if (inset) {
- FuncRequest fr(LFUN_INSET_DIALOG_SHOW);
- inset->dispatch(cur, fr);
- }
- break;
- }
-
case LFUN_ESCAPE:
if (cur.selection()) {
cur.selection() = false;
code = InsetBase::SPACE_CODE;
break;
-#ifdef WITH_WARNINGS
-#warning This LFUN is not used anymore and should be nuked (JMarc 29/10/2005)
-#endif
-#if 0
- case LFUN_INSET_DIALOG_SHOW: {
- InsetBase * inset = cur.nextInset();
- enable = inset;
- if (inset) {
- code = inset->lyxCode();
- if (!(code == InsetBase::INCLUDE_CODE
- || code == InsetBase::BIBTEX_CODE
- || code == InsetBase::FLOAT_LIST_CODE
- || code == InsetBase::TOC_CODE))
- enable = false;
- }
- break;
- }
-#endif
-
case LFUN_INSET_MODIFY:
// We need to disable this, because we may get called for a
// tabular cell via
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:
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: