From 0adc14a11d05de37f43602d34fca90a417f0f114 Mon Sep 17 00:00:00 2001 From: Dekel Tsur Date: Mon, 15 Jan 2001 19:59:54 +0000 Subject: [PATCH] Various fixes. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_1_6@1339 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 10 ++++++++++ src/mathed/math_draw.C | 3 +-- src/paragraph.C | 6 ++++++ src/support/lstrings.C | 8 ++++++++ src/support/lstrings.h | 3 +++ src/text.C | 12 ++++++++---- 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9767fc8797..f0f4e461ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2001-01-13 Dekel Tsur + + * src/paragraph.C (SimpleTeXOnePar) Put \protect before paragraph + alignment commands (when needed). + + * src/text.C (InsertChar): Add ':' to number separator chars. + Use contains instead of strchr. + + * src/mathed/math_draw.C (Metrics): Use the correct GetString. + 2001-01-11 Lars Gullik Bjønnes * release 1.1.6. tagged as lyx-1_1_6 in CVS (in branch diff --git a/src/mathed/math_draw.C b/src/mathed/math_draw.C index d677e1d1ca..620bf06b52 100644 --- a/src/mathed/math_draw.C +++ b/src/mathed/math_draw.C @@ -142,7 +142,6 @@ MathParInset::Metrics() { byte cx; byte cxp = 0; - string s; int ls; int asc = df_asc; int des = 0; @@ -163,7 +162,7 @@ MathParInset::Metrics() while (data.OK()) { cx = data.GetChar(); if (cx >= ' ') { - s = reinterpret_cast(data.GetString(ls)); + string s = data.GetString(); mathed_string_height(data.FCode(), size, s, asc, des); if (asc > ascent) ascent = asc; if (des > descent) descent = des; diff --git a/src/paragraph.C b/src/paragraph.C index 68c85766bc..4178582b70 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -2563,6 +2563,8 @@ bool LyXParagraph::SimpleTeXOnePar(Buffer const * buf, case LYX_ALIGN_SPECIAL: break; case LYX_ALIGN_LEFT: + if (moving_arg) + os << "\\protect"; if (getParLanguage(bparams)->babel() != "hebrew") { os << "\\raggedright "; column+= 13; @@ -2572,6 +2574,8 @@ bool LyXParagraph::SimpleTeXOnePar(Buffer const * buf, } break; case LYX_ALIGN_RIGHT: + if (moving_arg) + os << "\\protect"; if (getParLanguage(bparams)->babel() != "hebrew") { os << "\\raggedleft "; column+= 12; @@ -2581,6 +2585,8 @@ bool LyXParagraph::SimpleTeXOnePar(Buffer const * buf, } break; case LYX_ALIGN_CENTER: + if (moving_arg) + os << "\\protect"; os << "\\centering "; column+= 11; break; diff --git a/src/support/lstrings.C b/src/support/lstrings.C index 6be5d94b12..1449e429ee 100644 --- a/src/support/lstrings.C +++ b/src/support/lstrings.C @@ -344,6 +344,14 @@ bool contains(string const & a, string const & b) } +bool contains(string const & a, char b) +{ + if (a.empty()) + return false; + return a.find(b) != string::npos; +} + + bool contains(char const * a, char const * b) { Assert(a && b); diff --git a/src/support/lstrings.h b/src/support/lstrings.h index bffbc0d865..3f47c4820b 100644 --- a/src/support/lstrings.h +++ b/src/support/lstrings.h @@ -125,6 +125,9 @@ bool contains(string const & a, char const * b); /// bool contains(string const & a, string const & b); +/// +bool contains(string const & a, char b); + /// bool contains(char const * a, char const * b); diff --git a/src/text.C b/src/text.C index e0c054484d..9420e59534 100644 --- a/src/text.C +++ b/src/text.C @@ -1911,9 +1911,13 @@ void LyXText::InsertChar(BufferView * bview, char c) if (lyxrc.auto_number) { + static string const number_operators = "+-/*"; + static string const number_unary_operators = "+-"; + static string const number_seperators = ".,:"; + if (current_font.number() == LyXFont::ON) { - if (!isdigit(c) && !strchr("+-/*", c) && - !(strchr(".,",c) && + if (!isdigit(c) && !contains(number_operators, c) && + !(contains(number_seperators, c) && cursor.pos() >= 1 && cursor.pos() < cursor.par()->size() && GetFont(bview->buffer(), @@ -1930,7 +1934,7 @@ void LyXText::InsertChar(BufferView * bview, char c) if (cursor.pos() > 0) { char const c = cursor.par()->GetChar(cursor.pos() - 1); - if (strchr("+-",c) && + if (contains(number_unary_operators, c) && (cursor.pos() == 1 || cursor.par()->IsSeparator(cursor.pos() - 2) || cursor.par()->IsNewline(cursor.pos() - 2) ) @@ -1939,7 +1943,7 @@ void LyXText::InsertChar(BufferView * bview, char c) cursor.par(), cursor.pos() - 1, current_font); - } else if (strchr(".,", c) && + } else if (contains(number_seperators, c) && cursor.pos() >= 2 && GetFont(bview->buffer(), cursor.par(),