}
break;
- case LFUN_MATH:
- mathDispatch(bv_, ev.argument);
- break;
-
case LFUN_MATH_MACRO:
- mathDispatchMathMacro(bv_, ev.argument);
- break;
-
case LFUN_MATH_DELIM:
- mathDispatchMathDelim(bv_, ev.argument);
- break;
-
case LFUN_INSERT_MATRIX:
- mathDispatchInsertMatrix(bv_, ev.argument);
- break;
-
case LFUN_INSERT_MATH:
- mathDispatchInsertMath(bv_, ev.argument);
- break;
-
case LFUN_MATH_IMPORT_SELECTION: // Imports LaTeX from the X selection
- mathDispatchMathImportSelection(bv_, ev.argument);
- break;
-
case LFUN_MATH_DISPLAY: // Open or create a displayed math inset
- mathDispatchMathDisplay(bv_, ev.argument);
- break;
-
case LFUN_MATH_MODE: // Open or create an inlined math inset
- mathDispatchMathMode(bv_, ev.argument);
- break;
-
case LFUN_GREEK: // Insert a single greek letter
- mathDispatchGreek(bv_, ev.argument);
+ mathDispatch(FuncRequest(bv_, ev.action, ev.argument));
break;
case LFUN_CITATION_INSERT:
+
+ * lyxfunc.C:
+ BufferView_pimpl.C: streamlining mathed <-> outer world interaction
+
+ * commandtags.h:
+ LyXAction.C: remove unused LFUN_MATH
+
+
2002-08-15 Lars Gullik Bjønnes <larsbj@gullik.net>
* paragraph.[Ch]: add some NO_NEXT ifdefs.
{ LFUN_MARK_OFF, "mark-off", "", ReadOnly },
{ LFUN_MARK_ON, "mark-on", "", ReadOnly },
{ LFUN_SETMARK, "mark-toggle", "", ReadOnly },
- { LFUN_MATH, "math", "", Noop },
{ LFUN_MATH_DELIM, "math-delim", "", Noop },
{ LFUN_MATH_DISPLAY, "math-display", "", Noop },
{ LFUN_GREEK, "math-greek", N_("Math Greek"), Noop },
LFUN_INSERT_MATH,
LFUN_INSERT_MATRIX,
LFUN_GREEK, // 110
- LFUN_MATH, // Andre' 2002-06-14
LFUN_MATH_LIMITS,
LFUN_GREEK_TOGGLE,
LFUN_MATH_DELIM, // Alejandro 180696
void MenuInsertLabel(BufferView * bv, string const & arg)
{
- string label(arg);
+ string label = arg;
bv->owner()->prohibitInput();
if (label.empty()) {
Paragraph * par = bv->getLyXText()->cursor.par();
disable = !IsFileReadable(buf->getLogName().second);
break;
case LFUN_MATH_VALIGN:
- if (mathcursor && mathcursor->formula()->hullType() != "simple") {
+ if (mathcursor) {
char align = mathcursor->valign();
if (align == '\0') {
disable = true;
break;
case LFUN_MATH_HALIGN:
- if (mathcursor && mathcursor->formula()->hullType() != "simple") {
+ if (mathcursor) {
char align = mathcursor->halign();
if (align == '\0') {
disable = true;
break;
case LFUN_MATH_MUTATE:
- if (tli && (tli->lyxCode() == Inset::MATH_CODE))
- flag.setOnOff(mathcursor->formula()->hullType() == ev.argument);
+ if (mathcursor)
+ //flag.setOnOff(mathcursor->formula()->hullType() == ev.argument);
+ flag.setOnOff(false);
else
disable = true;
break;
case LFUN_MATH_ROW_DELETE:
case LFUN_MATH_COLUMN_INSERT:
case LFUN_MATH_COLUMN_DELETE:
- disable = !mathcursor || !mathcursor->halign() ||
- mathcursor->formula()->hullType() == "simple";
+ disable = !mathcursor || !mathcursor->halign();
break;
default:
pi.pain.image(x, y - a, w, h,
*(preview_->pimage()->image(*this, *bv)));
} else {
- //pi.base.style = display() ? LM_ST_DISPLAY : LM_ST_TEXT;
pi.base.style = LM_ST_TEXT;
pi.base.font = font;
pi.base.font.setColor(LColor::math);
}
-UpdatableInset::RESULT
-InsetFormula::localDispatch(FuncRequest const & ev)
-{
- RESULT result = DISPATCHED;
- BufferView * bv = ev.view();
-
- switch (ev.action) {
-
- case LFUN_MATH_MUTATE:
- {
- bv->lockedInsetStoreUndo(Undo::EDIT);
- int x;
- int y;
- mathcursor->getPos(x, y);
- mutate(ev.argument);
- mathcursor->setPos(x, y);
- mathcursor->normalize();
- updateLocal(bv, true);
- break;
- }
-
-
- case LFUN_MATH_DISPLAY:
- {
- int x = 0;
- int y = 0;
- mathcursor->getPos(x, y);
- if (hullType() == "simple")
- mutate("equation");
- else
- mutate("simple");
- mathcursor->setPos(x, y);
- mathcursor->normalize();
- updateLocal(bv, true);
- break;
- }
-
- case LFUN_PASTESELECTION:
- {
- string const clip = bv->getClipboard();
- if (!clip.empty())
- mathed_parse_normal(par_, clip);
- break;
- }
-
- default:
- result = InsetFormulaBase::localDispatch(ev);
- }
-
- return result;
-}
-
-
-bool InsetFormula::display() const
-{
- return hullType() != "simple" && hullType() != "none";
-}
-
-
Inset::Code InsetFormula::lyxCode() const
{
return Inset::MATH_CODE;
bool InsetFormula::insetAllowed(Inset::Code code) const
{
return
- (code == Inset::LABEL_CODE && display())
+ (code == Inset::LABEL_CODE)
|| code == Inset::REF_CODE
|| code == Inset::ERT_CODE;
}
}
-string InsetFormula::hullType() const
-{
- return par()->getType();
-}
-
-
+/*
void InsetFormula::mutate(string const & type)
{
par_.nucleus()->mutate(type);
}
+*/
//
#include <boost/scoped_ptr.hpp>
-class MathHullInset;
-
///
class InsetFormula : public InsetFormulaBase {
public:
///
bool insetAllowed(Inset::Code code) const;
///
- virtual RESULT localDispatch(FuncRequest const &);
- ///
std::vector<string> const getLabelList() const;
///
- string hullType() const;
- ///
MathAtom const & par() const { return par_; }
///
MathAtom & par() { return par_; }
///
void addPreview(grfx::PreviewLoader &) const;
///
- void mutate(string const & type);
+ //void mutate(string const & type);
private:
- /// Is this a displayed environment?
- bool display() const;
/// available in AMS only?
bool ams() const;
switch (ev.action) {
+ case LFUN_MATH_MUTATE:
+ case LFUN_MATH_DISPLAY:
case LFUN_MATH_HALIGN:
case LFUN_MATH_VALIGN:
case LFUN_MATH_ROW_INSERT:
break;
}
+/*
+ case LFUN_PASTESELECTION: {
+ string const clip = bv->getClipboard();
+ if (!clip.empty())
+ mathed_parse_normal(par_, clip);
+ break;
+ }
+*/
+
case LFUN_PASTE:
if (was_macro)
mathcursor->macroModeClose();
}
+bool InsetFormulaBase::display() const
+{
+ return par()->asHullInset() && par()->asHullInset()->display();
+}
+
+
/////////////////////////////////////////////////////////////////////
-void mathDispatchCreation(BufferView * bv, string const & arg, bool display)
+void mathDispatchCreation(FuncRequest const & cmd, bool display)
{
- if (!bv->available())
- return;
-
+ BufferView * bv = cmd.view();
// use selection if available..
//string sel;
//if (action == LFUN_MATH_IMPORT_SELECTION)
if (sel.empty()) {
InsetFormula * f = new InsetFormula(bv);
if (openNewInset(bv, f)) {
- f->mutate("simple");
+ bv->theLockingInset()->
+ localDispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple"));
// don't do that also for LFUN_MATH_MODE unless you want end up with
// always changing to mathrm when opening an inlined inset
// -- I really hate "LyXfunc overloading"...
if (display)
f->localDispatch(FuncRequest(bv, LFUN_MATH_DISPLAY));
- f->localDispatch(FuncRequest(bv, LFUN_INSERT_MATH, arg));
+ f->localDispatch(FuncRequest(bv, LFUN_INSERT_MATH, cmd.argument));
}
} else {
// create a macro if we see "\\newcommand" somewhere, and an ordinary
}
-void mathDispatchMathDisplay(BufferView * bv, string const & arg)
-{
- mathDispatchCreation(bv, arg, true);
-}
-
-
-void mathDispatchMathMode(BufferView * bv, string const & arg)
-{
- mathDispatchCreation(bv, arg, false);
-}
-
-
-void mathDispatchMathImportSelection(BufferView * bv, string const & arg)
-{
- mathDispatchCreation(bv, arg, true);
-}
-
-
-void mathDispatchMathMacro(BufferView * bv, string const & arg)
-{
- if (!bv->available())
- return;
- if (arg.empty())
- bv->owner()->getLyXFunc().setErrorMessage(N_("Missing argument"));
- else {
- string s = arg;
- string const s1 = token(s, ' ', 1);
- int const na = s1.empty() ? 0 : lyx::atoi(s1);
- openNewInset(bv, new InsetFormulaMacro(token(s, ' ', 0), na));
- }
-}
-
-
-void mathDispatchMathDelim(BufferView * bv, string const & arg)
+void mathDispatch(FuncRequest const & cmd)
{
+ BufferView * bv = cmd.view();
if (!bv->available())
return;
- InsetFormula * f = new InsetFormula(bv);
- if (openNewInset(bv, f)) {
- f->mutate("simple");
- bv->theLockingInset()->localDispatch(FuncRequest(bv, LFUN_MATH_DELIM, arg));
- }
-}
-
-void mathDispatchInsertMatrix(BufferView * bv, string const & arg)
-{
- if (!bv->available())
- return;
- InsetFormula * f = new InsetFormula(bv);
- if (openNewInset(bv, f)) {
- f->mutate("simple");
- bv->theLockingInset()->localDispatch(FuncRequest(bv, LFUN_INSERT_MATRIX, arg));
- }
-}
+ switch (cmd.action) {
+ case LFUN_MATH_DISPLAY:
+ mathDispatchCreation(cmd, true);
+ break;
-void mathDispatchInsertMath(BufferView * bv, string const & arg)
-{
- if (!bv->available())
- return;
- InsetFormula * f = new InsetFormula(bv);
- if (openNewInset(bv, f)) {
- f->mutate("simple");
- bv->theLockingInset()->localDispatch(FuncRequest(bv, LFUN_INSERT_MATH, arg));
- }
-}
+ case LFUN_MATH_MODE:
+ mathDispatchCreation(cmd, false);
+ break;
+ case LFUN_MATH_IMPORT_SELECTION:
+ mathDispatchCreation(cmd, false);
+ break;
-void mathDispatchGreek(BufferView * bv, string const & arg)
-{
- if (!bv->available())
- return;
- InsetFormula * f = new InsetFormula(bv);
- if (openNewInset(bv, f)) {
- f->mutate("simple");
- bv->theLockingInset()->localDispatch(FuncRequest(bv, LFUN_GREEK, arg));
- bv->unlockInset(f);
+ case LFUN_MATH_MACRO:
+ if (cmd.argument.empty())
+ bv->owner()->getLyXFunc().setErrorMessage(N_("Missing argument"));
+ else {
+ string s = cmd.argument;
+ string const s1 = token(s, ' ', 1);
+ int const na = s1.empty() ? 0 : lyx::atoi(s1);
+ openNewInset(bv, new InsetFormulaMacro(token(s, ' ', 0), na));
+ }
+ break;
+
+ case LFUN_GREEK:
+ case LFUN_INSERT_MATH:
+ case LFUN_INSERT_MATRIX:
+ case LFUN_MATH_DELIM: {
+ InsetFormula * f = new InsetFormula(bv);
+ if (openNewInset(bv, f)) {
+ bv->theLockingInset()->
+ localDispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple"));
+ bv->theLockingInset()->localDispatch(cmd);
+ }
+ break;
+ }
+ default:
+ break;
}
}
-
-
-void mathDispatch(BufferView *, kb_action, string const &)
-{}
-
-
-void mathDispatch(BufferView *, string const &)
-{}
virtual int width(BufferView *, LyXFont const &) const = 0;
///
virtual void draw(BufferView *,LyXFont const &, int, float &, bool) const = 0;
- ///
- virtual string hullType() const { return "none"; }
/// lowest x coordinate
virtual int xlow() const;
/// highest x coordinate
/// To allow transparent use of math editing functions
virtual RESULT localDispatch(FuncRequest const &);
+ /// To allow transparent use of math editing functions
+ //virtual void status(FuncRequest const &);
///
virtual std::vector<string> const getLabelList() const;
virtual void revealCodes(BufferView *) const;
///
virtual Inset::EDITABLE editable() const { return HIGHLY_EDITABLE; }
+ ///
+ bool display() const;
private:
/// unimplemented
// We don't really mess want around with mathed stuff outside mathed.
// So do it here.
-//
-void mathDispatchCreation(BufferView *, string const &, bool);
-//
-void mathDispatchMathDisplay(BufferView *, string const &);
-//
-void mathDispatchMathMode(BufferView *, string const &);
-//
-void mathDispatchMathMacro(BufferView *, string const &);
-//
-void mathDispatchMathDelim(BufferView *, string const &);
-//
-void mathDispatchInsertMath(BufferView *, string const &);
-//
-void mathDispatchInsertMatrix(BufferView *, string const &);
-//
-void mathDispatchGreek(BufferView *, string const &);
-//
-void mathDispatchMathImportSelection(BufferView *, string const &);
-//
-void mathDispatch(BufferView *, FuncRequest const &);
-//
-void mathDispatch(BufferView *, string const &);
+void mathDispatch(FuncRequest const &);
#endif
doExtern(cmd, idx, pos);
return DISPATCHED_POP;
+ case LFUN_MATH_MUTATE: {
+ row_type r = row(idx);
+ col_type c = col(idx);
+ mutate(cmd.argument);
+ idx = r * ncols() + c;
+ if (idx >= nargs())
+ idx = nargs() - 1;
+ if (pos > cell(idx).size())
+ pos = cell(idx).size();
+ return DISPATCHED_POP;
+ }
+
+ case LFUN_MATH_DISPLAY: {
+ mutate(type_ == "simple" ? "equation" : "simple");
+ idx = 0;
+ pos = cell(idx).size();
+ return DISPATCHED_POP;
+ }
+
default:
return MathGridInset::dispatch(cmd, idx, pos);