cosmetics

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2511 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2001-08-14 09:35:44 +00:00
parent 8766c98cfe
commit 4310ee2793
5 changed files with 30 additions and 50 deletions

View File

@ -160,6 +160,7 @@ void InsetFormula::metrics() const
par_->metrics(display() ? LM_ST_DISPLAY : LM_ST_TEXT); par_->metrics(display() ? LM_ST_DISPLAY : LM_ST_TEXT);
} }
vector<string> const InsetFormula::getLabelList() const vector<string> const InsetFormula::getLabelList() const
{ {
return par_->getLabelList(); return par_->getLabelList();

View File

@ -177,7 +177,9 @@ void InsetFormulaBase::edit(BufferView * bv, int x, int /*y*/, unsigned int)
lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl; lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl;
metrics(); metrics();
//bv->updateInset(this, false); // if that is removed, we won't get the magenta box when entering an
// inset for the first time
bv->updateInset(this, false);
if (x == 0) if (x == 0)
mathcursor->first(); mathcursor->first();
else else

View File

@ -399,15 +399,12 @@ void MathCursor::insert(char c, MathTextCodes t)
if (t != LM_TC_VAR) if (t != LM_TC_VAR)
lastcode_ = t; lastcode_ = t;
if (imacro_ && !(MathIsAlphaFont(t) || t == LM_TC_VAR)) if (imacro_ && t != LM_TC_TEX)
macroModeClose(); macroModeClose();
if (imacro_) { if (imacro_) {
if (MathIsAlphaFont(t) || t == LM_TC_VAR) { imacro_->setName(imacro_->name() + c);
// was MacroModeinsert(c); return;
imacro_->setName(imacro_->name() + c);
return;
}
} }
array().insert(pos(), new MathCharInset(c, t)); array().insert(pos(), new MathCharInset(c, t));

View File

@ -16,12 +16,6 @@ using std::endl;
using std::max; using std::max;
bool MathIsAlphaFont(MathTextCodes x)
{
return LM_TC_VAR <= x && x <= LM_TC_TEXTRM;
}
/// ///
class Matrix { class Matrix {
public: public:
@ -457,35 +451,43 @@ math_deco_struct math_deco_table[] = {
struct math_deco_compare { struct math_deco_compare {
/// for use by sort and lower_bound /// for use by sort and lower_bound
inline int operator()(math_deco_struct const & a, math_deco_struct const & b) const
int operator()(math_deco_struct const & a, {
math_deco_struct const & b) const {
return a.code < b.code; return a.code < b.code;
} }
}; };
int const math_deco_table_size = int const math_deco_table_size =
sizeof(math_deco_table) /sizeof(math_deco_struct); sizeof(math_deco_table) / sizeof(math_deco_struct);
class init_deco_table { // sort the table on startup
public: struct init_deco_table {
init_deco_table() { init_deco_table() {
if (!init) { std::sort(math_deco_table,
sort(math_deco_table,
math_deco_table + math_deco_table_size, math_deco_table + math_deco_table_size,
math_deco_compare()); math_deco_compare());
init_deco_table::init = true;
}
} }
private:
static bool init;
}; };
static init_deco_table dummy;
math_deco_struct const * search_deco(int code)
{
static const math_deco_struct search_elem = { code, 0, 0 };
math_deco_struct const * res =
lower_bound(math_deco_table,
math_deco_table + math_deco_table_size,
search_elem, math_deco_compare());
if (res != math_deco_table + math_deco_table_size &&
res->code == code)
return res;
return 0;
}
bool init_deco_table::init = false;
static init_deco_table idt;
} // namespace anon } // namespace anon
@ -529,8 +531,6 @@ int mathed_char_descent(MathTextCodes type, MathStyles size, unsigned char c)
return lyxfont::descent(c, font); return lyxfont::descent(c, font);
} }
int mathed_char_width(MathTextCodes type, MathStyles size, unsigned char c) int mathed_char_width(MathTextCodes type, MathStyles size, unsigned char c)
{ {
LyXFont const font = WhichFont(type, size); LyXFont const font = WhichFont(type, size);
@ -560,31 +560,12 @@ int mathed_string_height(MathTextCodes type, MathStyles size, string const & s,
return asc + des; return asc + des;
} }
int mathed_string_width(MathTextCodes type, MathStyles size, string const & s) int mathed_string_width(MathTextCodes type, MathStyles size, string const & s)
{ {
return lyxfont::width(s, WhichFont(type, size)); return lyxfont::width(s, WhichFont(type, size));
} }
namespace {
math_deco_struct const * search_deco(int code)
{
math_deco_struct search_elem = { code, 0, 0 };
math_deco_struct const * res =
lower_bound(math_deco_table,
math_deco_table + math_deco_table_size,
search_elem, math_deco_compare());
if (res != math_deco_table + math_deco_table_size &&
res->code == code)
return res;
return 0;
}
}
void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, void mathed_draw_deco(Painter & pain, int x, int y, int w, int h,
latexkeys const * l) latexkeys const * l)
{ {
@ -674,6 +655,7 @@ bool isBinaryOp(char c)
return true; return true;
} }
// In a near future maybe we use a better fonts renderer // In a near future maybe we use a better fonts renderer
void drawStr(Painter & pain, MathTextCodes type, MathStyles siz, void drawStr(Painter & pain, MathTextCodes type, MathStyles siz,
int x, int y, string const & s) int x, int y, string const & s)

View File

@ -32,8 +32,6 @@ int mathed_string_width(MathTextCodes type, MathStyles size, string const & s);
int mathed_string_ascent(MathTextCodes type, MathStyles size, string const & s); int mathed_string_ascent(MathTextCodes type, MathStyles size, string const & s);
int mathed_string_descent(MathTextCodes type, MathStyles size, string const & s); int mathed_string_descent(MathTextCodes type, MathStyles size, string const & s);
bool MathIsAlphaFont(MathTextCodes x);
void drawStr(Painter & pain, MathTextCodes type, MathStyles siz, void drawStr(Painter & pain, MathTextCodes type, MathStyles siz,
int x, int y, string const & s); int x, int y, string const & s);
void drawChar(Painter & pain, MathTextCodes type, MathStyles siz, void drawChar(Painter & pain, MathTextCodes type, MathStyles siz,