#include "InsetMathSpace.h"
#include "InsetMathSymbol.h"
#include "InsetMathUnknown.h"
+#include "MathAutoCorrect.h"
#include "MathCompletionList.h"
#include "MathData.h"
#include "MathFactory.h"
}
// Now that we know exactly what we want to do, let's do it!
cur.selHandle(select);
- cur.autocorrect() = false;
cur.clearTargetX();
cur.macroModeClose();
// try moving forward or backwards as necessary...
break;
//case LFUN_SERVER_GET_XY:
- // sprintf(dispatch_buffer, "%d %d",);
// break;
case LFUN_SERVER_SET_XY: {
break;
}
+ case LFUN_MATH_FONT_STYLE: {
+ FuncRequest fr = FuncRequest(LFUN_MATH_INSERT, '\\' + cmd.argument());
+ doDispatch(cur, fr);
+ 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;
flag.setEnabled(currentMode() != TEXT_MODE);
break;
- case LFUN_MATH_INSERT: {
+ case LFUN_MATH_FONT_STYLE: {
bool const textarg =
- arg == "\\textbf" || arg == "\\textsf" ||
- arg == "\\textrm" || arg == "\\textmd" ||
- arg == "\\textit" || arg == "\\textsc" ||
- arg == "\\textsl" || arg == "\\textup" ||
- arg == "\\texttt" || arg == "\\textbb" ||
- arg == "\\textnormal";
+ arg == "textbf" || arg == "textsf" ||
+ arg == "textrm" || arg == "textmd" ||
+ arg == "textit" || arg == "textsc" ||
+ arg == "textsl" || arg == "textup" ||
+ arg == "texttt" || arg == "textbb" ||
+ arg == "textnormal";
flag.setEnabled(currentMode() != TEXT_MODE || textarg);
break;
}
+ case LFUN_MATH_INSERT:
+ flag.setEnabled(currentMode() != TEXT_MODE);
+ break;
+
case LFUN_MATH_MATRIX:
flag.setEnabled(currentMode() == MATH_MODE);
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;
}
return true;
}
- // This is annoying as one has to press <space> far too often.
- // Disable it.
-#if 0
- // leave autocorrect mode if necessary
- if (autocorrect() && c == ' ') {
- autocorrect() = false;
- return true;
- }
-#endif
+ // leave autocorrect mode if necessary
+ if (lyxrc.autocorrection_math && c == ' ' && cur.autocorrect()) {
+ cur.autocorrect() = false;
+ cur.message(_("Autocorrect Off ('!' to enter)"));
+ return true;
+ }
+ if (lyxrc.autocorrection_math && c == '!' && !cur.autocorrect()) {
+ cur.autocorrect() = true;
+ cur.message(_("Autocorrect On (<space> to exit)"));
+ return true;
+ }
// just clear selection on pressing the space bar
if (cur.selection() && c == ' ') {
// try auto-correction
- //if (autocorrect() && hasPrevAtom() && math_autocorrect(prevAtom(), c))
- // return true;
+ if (lyxrc.autocorrection_math && cur.autocorrect() && cur.pos() != 0
+ && math_autocorrect(cur.prevAtom(), c))
+ return true;
// no special circumstances, so insert the character without any fuss
cur.insert(c);
- cur.autocorrect() = true;
+ if (lyxrc.autocorrection_math) {
+ if (!cur.autocorrect())
+ cur.message(_("Autocorrect Off ('!' to enter)"));
+ else
+ cur.message(_("Autocorrect On (<space> to exit)"));
+ }
return true;
}
globals.push_back(from_ascii("\\color"));
globals.push_back(from_ascii("\\normalcolor"));
globals.push_back(from_ascii("\\textcolor"));
+ globals.push_back(from_ascii("\\cfrac"));
globals.push_back(from_ascii("\\dfrac"));
globals.push_back(from_ascii("\\tfrac"));
globals.push_back(from_ascii("\\dbinom"));