interpret a typed \#1 as math-macro-arg 0

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2744 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2001-09-12 14:31:18 +00:00
parent e7209bd562
commit c740d233cc
3 changed files with 14 additions and 3 deletions

View File

@ -1283,18 +1283,23 @@ void MathCursor::interpret(string const & s)
if (lastcode_ == LM_TC_TEX) {
if (macroName().empty()) {
if (strchr("#$%{}", c)) {
if (strchr("$%{}", c)) {
insert(new MathCharInset(c, LM_TC_TEX));
lastcode_ = LM_TC_VAR;
return;
}
insert(c, LM_TC_TEX);
if (!isalpha(c)) {
if (!isalpha(c) && c != '#') {
macroModeClose();
lastcode_ = LM_TC_VAR;
}
} else {
if (isalpha(c))
if ('1' <= c && c <= '9' && macroName() == "#") {
insert(c, LM_TC_TEX);
macroModeClose();
lastcode_ = LM_TC_VAR;
}
else if (isalpha(c))
insert(c, LM_TC_TEX);
else {
macroModeClose();

View File

@ -10,6 +10,7 @@
#include "math_kerninset.h"
#include "math_macro.h"
#include "math_macrotable.h"
#include "math_macroarg.h"
#include "math_notinset.h"
#include "math_rootinset.h"
#include "math_spaceinset.h"
@ -66,6 +67,9 @@ MathInset * createMathInset(latexkeys const * l)
MathInset * createMathInset(string const & s)
{
//cerr << "creating inset with name: '" << s << "'\n";
if (s.size() == 2 && s[0] == '#' && s[1] >= '1' && s[1] <= '9')
return new MathMacroArgument(s[1] - '0');
latexkeys const * l = in_word_set(s);
if (l)
return createMathInset(l);

View File

@ -27,6 +27,8 @@ public:
void writeNormal(std::ostream &) const;
///
void substitute(MathMacro const & macro);
///
bool isActive() const { return false; }
private:
/// A number between 1 and 9