* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
- * \author André Pönitz
+ * \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
+//#define AUTOCORRECT
+
#include "InsetMathNest.h"
#include "InsetMathArray.h"
#include "InsetMathSpace.h"
#include "InsetMathSymbol.h"
#include "InsetMathUnknown.h"
+#ifdef AUTOCORRECT
+#include "MathAutoCorrect.h"
+#endif
#include "MathCompletionList.h"
#include "MathData.h"
#include "MathFactory.h"
break;
//case LFUN_SERVER_GET_XY:
- // sprintf(dispatch_buffer, "%d %d",);
// break;
case LFUN_SERVER_SET_XY: {
break;
}
+ case LFUN_REGEXP_MODE: {
+ InsetMathHull * i = dynamic_cast<InsetMathHull *>(cur.inset().asInsetMath());
+ if (i && i->getType() == hullRegexp) {
+ cur.message(_("Already in regexp mode"));
+ break;
+ }
+ cur.macroModeClose();
+ docstring const save_selection = grabAndEraseSelection(cur);
+ selClearOrDel(cur);
+ cur.plainInsert(MathAtom(new InsetMathHull(hullRegexp)));
+ cur.posBackward();
+ cur.pushBackward(*cur.nextInset());
+ cur.niceInsert(save_selection);
+ cur.message(_("Regexp editor mode"));
+ break;
+ }
+
case LFUN_MATH_SIZE: {
FuncRequest fr = FuncRequest(LFUN_MATH_INSERT, cmd.argument());
doDispatch(cur, fr);
case LFUN_SPACE_INSERT:
cur.recordUndoSelection();
- cur.insert(MathAtom(new InsetMathSpace(from_ascii(","))));
+ cur.insert(MathAtom(new InsetMathSpace));
break;
case LFUN_MATH_SPACE:
cur.recordUndoSelection();
if (cmd.argument().empty())
- cur.insert(MathAtom(new InsetMathSpace(from_ascii(","))));
- else
- cur.insert(MathAtom(new InsetMathSpace(cmd.argument())));
+ cur.insert(MathAtom(new InsetMathSpace));
+ else {
+ string const name = cmd.getArg(0);
+ string const len = cmd.getArg(1);
+ cur.insert(MathAtom(new InsetMathSpace(name, len)));
+ }
break;
case LFUN_ERT_INSERT:
if (name == "ref") {
InsetMathRef tmp(name);
data = tmp.createDialogStr(to_utf8(name));
+ } else if (name == "mathspace") {
+ InsetMathSpace tmp;
+ data = tmp.createDialogStr();
}
cur.bv().showDialog(to_utf8(name), data);
break;
// getStatus is not called with a valid reference and the
// dialog would not be applyable.
string const name = cmd.getArg(0);
- flag.setEnabled(name == "ref");
+ flag.setEnabled(name == "ref" || name == "mathspace");
break;
}
}
-bool InsetMathNest::interpretChar(Cursor & cur, char_type c)
+bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
{
//lyxerr << "interpret 2: '" << c << "'" << endl;
docstring save_selection;
MathWordList const & mwl = mathedWordList();
bool star_macro = c == '*'
&& (mwl.find(name.substr(1) + "*") != mwl.end()
- || cur.buffer().getMacro(name.substr(1) + "*", cur, true));
+ || cur.buffer()->getMacro(name.substr(1) + "*", cur, true));
if (isAlphaASCII(c) || star_macro) {
cur.activeMacro()->setName(name + docstring(1, c));
return true;
// This is annoying as one has to press <space> far too often.
// Disable it.
-#if 0
+#ifdef AUTOCORRECT
// leave autocorrect mode if necessary
- if (autocorrect() && c == ' ') {
- autocorrect() = false;
+ if (cur.autocorrect() && c == ' ') {
+ cur.autocorrect() = false;
return true;
}
#endif
}
+#ifdef AUTOCORRECT
// try auto-correction
- //if (autocorrect() && hasPrevAtom() && math_autocorrect(prevAtom(), c))
- // return true;
+ if (cur.autocorrect() && cur.pos() != 0 && math_autocorrect(cur.prevAtom(), c))
+ return true;
+#endif
// no special circumstances, so insert the character without any fuss
cur.insert(c);
{
// fill it with macros from the buffer
MacroNameSet macros;
- cur.buffer().listMacroNames(macros);
+ cur.buffer()->listMacroNames(macros);
MacroNameSet::const_iterator it;
for (it = macros.begin(); it != macros.end(); ++it) {
- if (cur.buffer().getMacro(*it, cur, false))
+ if (cur.buffer()->getMacro(*it, cur, false))
locals.push_back("\\" + *it);
}
sort(locals.begin(), locals.end());