#include "mathed/InsetMathHull.h"
#include "mathed/MathMacroTemplate.h"
-#include "mathed/MathParser.h"
#include <boost/next_prior.hpp>
istringstream is(selstr);
Lexer lex;
lex.setStream(is);
- mathed_parser_warn_contents(false);
- formula->read(lex);
+ formula->readQuiet(lex);
if (formula->getType() == hullNone) {
// No valid formula, let's try with delims
is.str("$" + selstr + "$");
lex.setStream(is);
- formula->read(lex);
+ formula->readQuiet(lex);
if (formula->getType() == hullNone) {
// Still not valid, leave it as is
valid = false;
cur.insert(formula);
} else
cur.insert(formula);
- mathed_parser_warn_contents(true);
} else {
cur.insert(new MathMacroTemplate(sel));
}
cutSelection(cur, false, false);
cur.clearSelection();
- Font const old_font = cur.real_current_font;
docstring::const_iterator cit = cmd.argument().begin();
- docstring::const_iterator end = cmd.argument().end();
+ docstring::const_iterator const end = cmd.argument().end();
for (; cit != end; ++cit)
bv->translateAndInsert(*cit, this, cur);
{
LASSERT(cur.text() == this, /**/);
- Font const & font = cur.real_current_font;
- FontInfo const & fontinfo = font.fontInfo();
+ FontInfo const & fontinfo = cur.real_current_font.fontInfo();
bool enable = true;
InsetCode code = NO_CODE;
break;
case LFUN_LISTING_INSERT:
code = LISTINGS_CODE;
+ // not allowed in description items
+ enable = !inDescriptionItem(cur);
break;
case LFUN_FOOTNOTE_INSERT:
code = FOOT_CODE;
case LFUN_FLOAT_INSERT:
case LFUN_FLOAT_WIDE_INSERT:
code = FLOAT_CODE;
+ // not allowed in description items
+ enable = !inDescriptionItem(cur);
break;
case LFUN_WRAP_INSERT:
code = WRAP_CODE;
+ // not allowed in description items
+ enable = !inDescriptionItem(cur);
break;
case LFUN_FLOAT_LIST_INSERT:
code = FLOAT_LIST_CODE;
break;
case LFUN_CAPTION_INSERT:
code = CAPTION_CODE;
+ // not allowed in description items
+ enable = !inDescriptionItem(cur);
break;
case LFUN_NOTE_INSERT:
code = NOTE_CODE;
- // in commands (sections etc., only Notes are allowed)
+ // in commands (sections etc.) and description items,
+ // only Notes are allowed
enable = (cmd.argument().empty() || cmd.getArg(0) == "Note" ||
- !cur.paragraph().layout().isCommand());
+ (!cur.paragraph().layout().isCommand()
+ && !inDescriptionItem(cur)));
break;
case LFUN_FLEX_INSERT: {
code = FLEX_CODE;
break;
}
+ case LFUN_NEWPAGE_INSERT:
+ // not allowed in description items
+ enable = !inDescriptionItem(cur);
+ break;
+
case LFUN_WORD_DELETE_FORWARD:
case LFUN_WORD_DELETE_BACKWARD:
case LFUN_LINE_DELETE:
case LFUN_DATE_INSERT:
case LFUN_SELF_INSERT:
case LFUN_LINE_INSERT:
- case LFUN_NEWPAGE_INSERT:
case LFUN_MATH_DISPLAY:
case LFUN_MATH_MODE:
case LFUN_MATH_MACRO:
}
}
+
+// FIXME: an item inset would make things much easier.
+bool Text::inDescriptionItem(Cursor & cur) const
+{
+ Paragraph & par = cur.paragraph();
+ pos_type const pos = cur.pos();
+ pos_type const body_pos = par.beginOfBody();
+
+ if (par.layout().latextype != LATEX_LIST_ENVIRONMENT
+ && (par.layout().latextype != LATEX_ITEM_ENVIRONMENT
+ || par.layout().margintype != MARGIN_FIRST_DYNAMIC))
+ return false;
+
+ return (pos < body_pos
+ || (pos == body_pos
+ && (pos == 0 || par.getChar(pos - 1) != ' ')));
+}
+
} // namespace lyx