summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
4c7d66b)
* src/cursor.C
(LCursor::plainInsert): Move special \bigl stuff from here to
MathNestInset::interpret
(LCursor::macroModeClose): try to intepret the current macro before
it is simply inserted
* src/mathed/math_nestinset.C
(MathNestInset::doDispatch): try to intepret the argument of
LFUN_SELFINSERT also if it is longer than one character
* src/mathed/math_nestinset.[Ch]
(MathNestInset::interpret): new, moved from LCursor::plainInsert
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13786
a592a061-630c-0410-9148-
cb99ea01b6c8
#include "insets/insettabular.h"
#include "insets/insettext.h"
#include "insets/insettabular.h"
#include "insets/insettext.h"
-#include "mathed/math_biginset.h"
#include "mathed/math_data.h"
#include "mathed/math_inset.h"
#include "mathed/math_scriptinset.h"
#include "mathed/math_data.h"
#include "mathed/math_inset.h"
#include "mathed/math_scriptinset.h"
void LCursor::plainInsert(MathAtom const & t)
{
void LCursor::plainInsert(MathAtom const & t)
{
- // Create a MathBigInset from cell()[pos() - 1] and t if possible
- if (!empty() && pos() > 0 && cell()[pos() - 1]->asUnknownInset()) {
- string const name = asString(t);
- if (MathBigInset::isBigInsetDelim(name)) {
- string prev = asString(cell()[pos() - 1]);
- if (prev[0] == '\\') {
- prev = prev.substr(1);
- latexkeys const * l = in_word_set(prev);
- if (l && l->inset == "big") {
- cell()[pos() - 1] =
- MathAtom(new MathBigInset(prev, name));
- return;
- }
- }
- }
- }
cell().insert(pos(), t);
++pos();
}
cell().insert(pos(), t);
++pos();
}
if (macro && macro->getInsetName() == name)
lyxerr << "can't enter recursive macro" << endl;
if (macro && macro->getInsetName() == name)
lyxerr << "can't enter recursive macro" << endl;
+ MathNestInset * const in = inset().asMathInset()->asNestInset();
+ if (in && in->interpret(*this, s))
+ return true;
plainInsert(createMathInset(name));
return true;
}
plainInsert(createMathInset(name));
return true;
}
case LFUN_SELFINSERT:
if (cmd.argument.size() != 1) {
recordUndo(cur);
case LFUN_SELFINSERT:
if (cmd.argument.size() != 1) {
recordUndo(cur);
- cur.insert(cmd.argument);
+ if (!interpret(cur, cmd.argument))
+ cur.insert(cmd.argument);
break;
}
// Don't record undo steps if we are in macro mode and
break;
}
// Don't record undo steps if we are in macro mode and
}
// One character big delimiters. The others are handled in
}
// One character big delimiters. The others are handled in
- // LCursor::plainInsert.
+ // the other interpret() method.
latexkeys const * l = in_word_set(name.substr(1));
if (name[0] == '\\' && l && l->inset == "big") {
string delim;
latexkeys const * l = in_word_set(name.substr(1));
if (name[0] == '\\' && l && l->inset == "big") {
string delim;
- if (c == '{' || c == '}' || c == '&' || c == '$' || c == '#' || c == '%'
- || c == '_' || c == '^') {
+ if (c == '{' || c == '}' || c == '&' || c == '$' || c == '#' ||
+ c == '%' || c == '_' || c == '^') {
cur.niceInsert(createMathInset(string(1, c)));
return true;
}
cur.niceInsert(createMathInset(string(1, c)));
return true;
}
+bool MathNestInset::interpret(LCursor & cur, string const & str)
+{
+ // Create a MathBigInset from cur.cell()[cur.pos() - 1] and t if
+ // possible
+ if (!cur.empty() && cur.pos() > 0 &&
+ cur.cell()[cur.pos() - 1]->asUnknownInset()) {
+ if (MathBigInset::isBigInsetDelim(str)) {
+ string prev = asString(cur.cell()[cur.pos() - 1]);
+ if (prev[0] == '\\') {
+ prev = prev.substr(1);
+ latexkeys const * l = in_word_set(prev);
+ if (l && l->inset == "big") {
+ cur.cell()[cur.pos() - 1] =
+ MathAtom(new MathBigInset(prev, str));
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+
bool MathNestInset::script(LCursor & cur, bool up, string const &
save_selection)
{
bool MathNestInset::script(LCursor & cur, bool up, string const &
save_selection)
{
///
void handleFont2(LCursor & cur, std::string const & arg);
///
void handleFont2(LCursor & cur, std::string const & arg);
+ /// interpret \p c and insert the result at the current position of
+ /// of \p cur. Return whether the cursor should stay in the formula.
bool interpret(LCursor & cur, char c);
///
bool script(LCursor & cur, bool,
std::string const & save_selection = std::string());
bool interpret(LCursor & cur, char c);
///
bool script(LCursor & cur, bool,
std::string const & save_selection = std::string());
+public:
+ /// interpret \p str and insert the result at the current position of
+ /// \p cur if it is something known. Return whether \p cur was
+ /// inserted.
+ bool interpret(LCursor & cur, std::string const & str);
private:
/// lfun handler
private:
/// lfun handler