further \mbox tweaking

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4333 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2002-06-04 09:45:41 +00:00
parent 8d9f14a22b
commit aa1b4aa789
7 changed files with 43 additions and 43 deletions

View File

@ -591,15 +591,12 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
break;
case LFUN_MATH_MODE:
#if 1
handleFont(bv, arg, "textrm");
#endif
#if 0
mathcursor->niceInsert(MathAtom(new MathHullInset(LM_OT_SIMPLE)));
updateLocal(bv, true);
#endif
if (mathcursor->inMathMode()) {
handleFont(bv, arg, "textrm");
} else {
mathcursor->niceInsert(MathAtom(new MathHullInset(LM_OT_SIMPLE)));
updateLocal(bv, true);
}
//bv->owner()->message(_("math text mode toggled"));
break;

View File

@ -1406,6 +1406,12 @@ bool MathCursor::script(bool up)
}
bool MathCursor::inMathMode() const
{
return !par()->asBoxInset();
}
bool MathCursor::interpret(char c)
{
//lyxerr << "interpret 2: '" << c << "'\n";
@ -1470,13 +1476,13 @@ bool MathCursor::interpret(char c)
selClearOrDel();
if (/*lastcode_ == LM_TC_TEXTRM ||*/ par()->asBoxInset()) {
if (!inMathMode()) {
// suppress direct insertion of two spaces in a row
// the still allows typing '<space>a<space>' and deleting the 'a', but
// it is better than nothing...
if (c == ' ' && hasPrevAtom() && prevAtom()->getChar() == ' ')
return true;
insert(c); // LM_TC_TEXTRM;
insert(c);
return true;
}

View File

@ -130,6 +130,8 @@ public:
MathUnknownInset * inMacroMode() const;
/// are we currently typing '#1' or '#2' or...?
bool inMacroArgMode() const;
/// are we in an mbox?
bool inMathMode() const;
// Local selection methods
///

View File

@ -164,12 +164,12 @@ key_type wordlist_array[] =
{"sup", "funclim", 0},
{"tan", "func", 0},
{"tanh", "func", 0},
{"textbf", "font", 0},
{"textit", "font", 0},
{"textmd", "font", 0},
{"textrm", "font", 0},
{"textsl", "font", 0},
{"textup", "font", 0},
{"textbf", "font", 1},
{"textit", "font", 1},
{"textmd", "font", 1},
{"textrm", "font", 1},
{"textsl", "font", 1},
{"textup", "font", 1},
{"textstyle", "style", LM_ST_TEXT},
{"tilde", "decoration", 0},
{"tt", "oldfont", 0},

View File

@ -159,6 +159,7 @@ int MathHullInset::defaultColSpace(col_type col)
void MathHullInset::metrics(MathMetricsInfo & mi) const
{
MathFontSetChanger dummy(mi.base, "mathnormal");
// let the cells adjust themselves
MathGridInset::metrics(mi);
@ -169,7 +170,7 @@ void MathHullInset::metrics(MathMetricsInfo & mi) const
}
if (numberedType()) {
//augmentFont(mi_.base.font, "mathbf");
MathFontSetChanger dummy(mi.base, "mathbf");
int l = 0;
for (row_type row = 0; row < nrows(); ++row)
l = max(l, mathed_string_width(mi.base.font, nicelabel(row)));
@ -189,6 +190,7 @@ void MathHullInset::metrics(MathMetricsInfo & mi) const
void MathHullInset::draw(MathPainterInfo & pi, int x, int y) const
{
MathFontSetChanger dummy(pi.base, "mathnormal");
MathGridInset::draw(pi, x, y);
if (numberedType()) {

View File

@ -128,7 +128,7 @@ enum {
FLAG_RIGHT = 1 << 2, // next \\right ends the parsing process
FLAG_END = 1 << 3, // next \\end ends the parsing process
FLAG_BRACK_END = 1 << 4, // next closing bracket ends the parsing process
FLAG_BOX = 1 << 5, // we are in a box
FLAG_TEXTMODE = 1 << 5, // we are in a box
FLAG_ITEM = 1 << 6, // read a (possibly braced token)
FLAG_BLOCK = 1 << 7, // next block ends the parsing process
FLAG_BLOCK2 = 1 << 8, // next block2 ends the parsing process
@ -775,20 +775,21 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
// cat codes
//
if (t.cat() == catMath) {
dump();
if (flags & FLAG_TEXTMODE) {
// we are inside some text mode thingy, so opening new math is allowed
MathAtom at(new MathHullInset(LM_OT_SIMPLE));
parse_into2(at, FLAG_SIMPLE, false);
cell->push_back(at);
} else {
lyxerr << "something strange in the parser\n";
break;
}
if (flags & FLAG_SIMPLE) {
// this is the end of the formula
return;
}
if (flags & FLAG_BOX) {
// we are inside an mbox, so opening new math is allowed
push_back(t);
cell->push_back(MathAtom(new MathHullInset(LM_OT_SIMPLE)));
parse_normal(cell->back());
} else {
lyxerr << "somthing strange in the parser\n";
break;
}
}
else if (t.cat() == catLetter)
@ -1048,18 +1049,10 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
if (l) {
if (l->inset == "font") {
lyxerr << "starting font " << t.cs() << "\n";
//CatCode catSpaceSave = theCatcode[' '];
//if (l->id == LM_TC_TEXTRM) {
// // temporarily change catcode
// theCatcode[' '] = catLetter;
//}
MathAtom p = createMathInset(t.cs());
parse_into(p->cell(0), FLAG_ITEM);
bool textmode = (t.cs()[0] == 't');
parse_into(p->cell(0), FLAG_ITEM | (textmode ? FLAG_TEXTMODE : 0));
cell->push_back(p);
// undo catcode changes
//theCatcode[' '] = catSpaceSave;
//lyxerr << "ending font\n";
}
@ -1072,7 +1065,7 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
else if (l->inset == "box") {
MathAtom p = createMathInset(t.cs());
parse_into(p->cell(0), FLAG_ITEM | FLAG_BOX);
parse_into(p->cell(0), FLAG_ITEM | FLAG_TEXTMODE);
cell->push_back(p);
}

View File

@ -570,7 +570,7 @@ fontinfo fontinfos[] = {
{"eufrak", LyXFont::EUFRAK_FAMILY, def_series, def_shape, LColor::math},
{"mathbf", def_family, LyXFont::BOLD_SERIES, def_shape, LColor::math},
{"mathcal",LyXFont::CMSY_FAMILY, def_series, def_shape, LColor::math},
{"mathnormal", def_family,def_series, def_shape, LColor::math},
{"mathnormal", def_family,def_series, LyXFont::ITALIC_SHAPE, LColor::math},
{"mathrm", LyXFont::ROMAN_FAMILY, def_series, def_shape, LColor::math},
{"mathsf", LyXFont::SANS_FAMILY, def_series, def_shape, LColor::math},
{"msa", LyXFont::MSA_FAMILY, def_series, def_shape, LColor::math},
@ -578,8 +578,8 @@ fontinfo fontinfos[] = {
{"textbf", def_family, LyXFont::BOLD_SERIES, def_shape, LColor::black},
{"textit", def_family, def_series, LyXFont::ITALIC_SHAPE, LColor::black},
{"textmd", def_family, LyXFont::MEDIUM_SERIES, def_shape, LColor::black},
{"textnormal", def_family, def_series, def_shape, LColor::black},
{"textrm", LyXFont::ROMAN_FAMILY, def_series, def_shape, LColor::black},
{"textnormal", def_family, def_series, LyXFont::UP_SHAPE, LColor::black},
{"textrm", LyXFont::ROMAN_FAMILY, def_series,LyXFont::UP_SHAPE,LColor::black},
{"textsc", def_family, def_series, LyXFont::SMALLCAPS_SHAPE, LColor::black},
{"textsf", LyXFont::SANS_FAMILY, def_series, def_shape, LColor::black},
{"textsl", def_family, def_series, LyXFont::SLANTED_SHAPE, LColor::black},