enable direct input of #1...#9; some whitespace changes

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3332 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2002-01-11 10:26:13 +00:00
parent df3128954a
commit 08ae48d886
7 changed files with 64 additions and 45 deletions

View File

@ -508,6 +508,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
case LFUN_CARON: handleAccent(bv, "check"); break;
case LFUN_BREVE: handleAccent(bv, "breve"); break;
case LFUN_VECTOR: handleAccent(bv, "vec"); break;
case LFUN_UNDERBAR: handleAccent(bv, "underbar"); break;
// Math fonts
case LFUN_GREEK_TOGGLE: handleFont(bv, LM_TC_GREEK); break;

View File

@ -37,6 +37,7 @@
#include "math_factory.h"
#include "math_hullinset.h"
#include "math_iterator.h"
#include "math_macroarg.h"
#include "math_mathmlstream.h"
#include "math_parser.h"
#include "math_replace.h"
@ -851,6 +852,12 @@ bool MathCursor::inMacroMode() const
}
bool MathCursor::inMacroArgMode() const
{
return pos() > 0 && prevAtom()->getChar() == '#';
}
bool MathCursor::selection() const
{
return selection_;
@ -1306,30 +1313,28 @@ bool MathCursor::script(bool up)
bool MathCursor::interpret(char c)
{
// Removed super/subscript handling from here to ::script -MV
if (inMacroArgMode()) {
--pos();
plainErase();
if ('1' <= c && c <= '9')
insert(MathAtom(new MathMacroArgument(c - '0')));
else {
insert(MathAtom(new MathSpecialCharInset('#')));
interpret(c); // try again
}
return true;
}
// handle macroMode
if (inMacroMode()) {
string name = macroName();
if (name == "\\" && c == '#') {
insert(c, LM_TC_TEX);
return true;
}
if (name == "\\" && c == '\\') {
backspace();
interpret("\\backslash");
return true;
}
if (name == "\\#" && '1' <= c && c <= '9') {
insert(c, LM_TC_TEX);
macroModeClose();
return true;
}
if (isalpha(c)) {
insert(c, LM_TC_TEX);
return true;
@ -1373,6 +1378,11 @@ bool MathCursor::interpret(char c)
return pos() != size();
}
if (c == '#') {
insert(c, LM_TC_TEX);
return true;
}
/*
if (strchr("{}", c)) {
insert(c, LM_TC_TEX);
@ -1389,7 +1399,7 @@ bool MathCursor::interpret(char c)
return true;
}
if (strchr("#$%", c)) {
if (strchr("$%", c)) {
insert(MathAtom(new MathSpecialCharInset(c)));
lastcode_ = LM_TC_VAR;
return true;

View File

@ -124,8 +124,10 @@ public:
bool toggleLimits();
/// interpret name a name of a macro
void macroModeClose();
///
/// are we currently typing the name of a macro?
bool inMacroMode() const;
/// are we currently typing '#1' or '#2' or...?
bool inMacroArgMode() const;
// Local selection methods
///

View File

@ -24,7 +24,10 @@ MathInset * MathDecorationInset::clone() const
bool MathDecorationInset::upper() const
{
return name_ != "underline" && name_ != "underbrace";
return
name_ != "underbar" &&
name_ != "underline" &&
name_ != "underbrace";
}

View File

@ -135,6 +135,7 @@ key_type wordlist_array[] =
{"textstyle", LM_TK_STY, LM_ST_TEXT},
{"tilde", LM_TK_DECORATION, 0},
{"tt", LM_TK_OLDFONT, LM_TC_TT},
{"underbar", LM_TK_DECORATION, 0},
{"underbrace", LM_TK_DECORATION, 0},
{"underline", LM_TK_DECORATION, 0},
{"vdots", LM_TK_DOTS, 0},

View File

@ -70,6 +70,7 @@ void MathMacroArgument::normalize(NormalStream & os) const
void MathMacroArgument::substitute(MathMacro const & m)
{
cell(0) = m.cell(number_ - 1);
if (code_ != LM_TC_MIN)
for (MathArray::iterator it = cell(0).begin(); it != cell(0).end(); ++it)
it->nucleus()->handleFont(code_);
expanded_ = true;

View File

@ -455,6 +455,7 @@ named_deco_struct deco_table[] = {
// Decorations
{"widehat", angle, 3 },
{"widetilde", tilde, 0 },
{"underbar", hline, 0 },
{"underline", hline, 0 },
{"overline", hline, 0 },
{"underbrace", brace, 1 },