#include "support/convert.h"
#include "support/lyxtime.h"
-#include "mathed/math_hullinset.h"
-#include "mathed/math_macrotemplate.h"
+#include "mathed/InsetMathHull.h"
+#include "mathed/MathMacroTemplate.h"
#include <boost/current_function.hpp>
using lyx::cap::copySelection;
using lyx::cap::cutSelection;
-using lyx::cap::pasteParagraphList;
using lyx::cap::pasteSelection;
using lyx::cap::replaceSelection;
using lyx::support::isStrUnsignedInt;
using lyx::support::token;
-using lyx::frontend::Gui;
-using lyx::frontend::Clipboard;
-
using std::endl;
using std::string;
using std::istringstream;
if (sel.empty()) {
const int old_pos = cur.pos();
- cur.insert(new MathHullInset("simple"));
+ cur.insert(new InsetMathHull(hullSimple));
BOOST_ASSERT(old_pos == cur.pos());
cur.nextInset()->edit(cur, true);
// don't do that also for LFUN_MATH_MODE
if (sel.find("\\newcommand") == string::npos
&& sel.find("\\def") == string::npos)
{
- MathHullInset * formula = new MathHullInset;
+ InsetMathHull * formula = new InsetMathHull;
LyXLex lex(0, 0);
lex.setStream(is);
formula->read(cur.buffer(), lex);
- if (formula->getType() == "none")
+ if (formula->getType() == hullNone)
// Don't create pseudo formulas if
// delimiters are left out
- formula->mutate("simple");
+ formula->mutate(hullSimple);
cur.insert(formula);
} else
cur.insert(new MathMacroTemplate(is));
}
- cur.message(N_("Math editor mode"));
+ cur.message(lyx::from_utf8(N_("Math editor mode")));
}
} // namespace anon
if (edit)
inset->edit(cur, true);
- if (gotsel && pastesel)
+ if (gotsel && pastesel) {
cur.bv().owner()->dispatch(FuncRequest(LFUN_PASTE));
+ // reset first par to default
+ if (cur.lastpit() != 0 || cur.lastpos() != 0) {
+ LyXLayout_ptr const layout =
+ cur.buffer().params().getLyXTextClass().defaultLayout();
+ cur.text()->paragraphs().begin()->layout(layout);
+ }
+ }
return true;
}
case LFUN_CHAR_DELETE_BACKWARD:
if (!cur.selection()) {
- if (bv->owner()->getIntl().getTransManager().backspace()) {
+ if (bv->getIntl().getTransManager().backspace()) {
// Par boundary, full-screen update
if (cur.pos() == 0)
singleParUpdate = false;
} else if (tmp == "default") {
new_spacing = Spacing::Default;
} else {
- lyxerr << _("Unknown spacing argument: ")
+ lyxerr << lyx::to_utf8(_("Unknown spacing argument: "))
<< lyx::to_utf8(cmd.argument()) << endl;
}
if (cur_spacing != new_spacing || cur_value != new_value)
break;
}
- 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);
- }
- cur.clearSelection();
- cur.resetAnchor();
- needsUpdate = true;
+ case LFUN_INSET_DISSOLVE:
+ needsUpdate = dissolveInset(cur);
break;
- }
case LFUN_INSET_SETTINGS:
cur.inset().showInsetDialog(bv);
break;
case LFUN_SERVER_GET_XY:
- cur.message(convert<string>(cursorX(cur.top(), cur.boundary())) + ' '
- + convert<string>(cursorY(cur.top(), cur.boundary())));
+ cur.message(lyx::from_utf8(
+ convert<string>(cursorX(cur.top(), cur.boundary())) + ' '
+ + convert<string>(cursorY(cur.top(), cur.boundary()))));
break;
case LFUN_SERVER_SET_XY: {
case LFUN_SERVER_GET_FONT:
if (current_font.shape() == LyXFont::ITALIC_SHAPE)
- cur.message("E");
+ cur.message(lyx::from_utf8("E"));
else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE)
- cur.message("N");
+ cur.message(lyx::from_utf8("N"));
else
- cur.message("0");
+ cur.message(lyx::from_utf8("0"));
break;
case LFUN_SERVER_GET_LAYOUT:
- cur.message(cur.paragraph().layout()->name());
+ cur.message(lyx::from_utf8(cur.paragraph().layout()->name()));
break;
case LFUN_LAYOUT: {
}
if (!hasLayout) {
- cur.errorMessage(string(N_("Layout ")) + lyx::to_utf8(cmd.argument()) +
- N_(" not known"));
+ cur.errorMessage(lyx::from_utf8(N_("Layout ")) + cmd.argument() +
+ lyx::from_utf8(N_(" not known")));
break;
}
docstring::const_iterator end = cmd.argument().end();
for (; cit != end; ++cit)
#if 0
- bv->owner()->getIntl().getTransManager().
+ bv->getIntl().getTransManager().
translateAndInsert(*cit, this);
#else
insertChar(bv->cursor(), *cit);
case LFUN_MATH_MACRO:
if (cmd.argument().empty())
- cur.errorMessage(N_("Missing argument"));
+ cur.errorMessage(lyx::from_utf8(N_("Missing argument")));
else {
string s = lyx::to_utf8(cmd.argument());
string const s1 = token(s, ' ', 1);
case LFUN_MATH_MATRIX:
case LFUN_MATH_DELIM:
case LFUN_MATH_BIGDELIM: {
- cur.insert(new MathHullInset("simple"));
+ cur.insert(new InsetMathHull(hullSimple));
cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
cur.dispatch(cmd);
break;
bv->owner()->getLyXFunc().handleKeyFunc(cmd.action);
if (!cmd.argument().empty())
// FIXME: Are all these characters encoded in one byte in utf8?
- bv->owner()->getIntl().getTransManager()
+ bv->getIntl().getTransManager()
.translateAndInsert(cmd.argument()[0], this);
break;
enable = lyx::cap::numberOfSelections() > 0;
break;
- case LFUN_PARAGRAPH_MOVE_UP: {
+ case LFUN_PARAGRAPH_MOVE_UP:
enable = cur.pit() > 0 && !cur.selection();
break;
- }
- case LFUN_PARAGRAPH_MOVE_DOWN: {
+ case LFUN_PARAGRAPH_MOVE_DOWN:
enable = cur.pit() < cur.lastpit() && !cur.selection();
break;
- }
- case LFUN_INSET_DISSOLVE: {
- enable = !isMainText() && cur.inTexted();
+ case LFUN_INSET_DISSOLVE:
+ enable = !isMainText() && cur.inset().nargs() == 1;
break;
- }
case LFUN_WORD_DELETE_FORWARD:
case LFUN_WORD_DELETE_BACKWARD: