On Thu, Jul 11, 2002 at 05:53:56PM +0300, Dekel Tsur wrote:
> [example]

Ah... The patch has not yet been applied to 1.2.1cvs!

So it works for me but not for you.

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)
Index: math_braceinset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_braceinset.h,v
retrieving revision 1.6
diff -u -p -r1.6 math_braceinset.h
--- math_braceinset.h   21 Mar 2002 17:42:55 -0000      1.6
+++ math_braceinset.h   11 Jul 2002 15:27:46 -0000
@@ -21,6 +21,8 @@ public:
        MathInset * clone() const;
        ///
        MathBraceInset * asBraceInset() { return this; }
+       /// identifies things that add {...} when written
+       bool extraBraces() const { return true; }
        ///
        void draw(Painter &, int x, int y) const;
        ///
Index: math_inset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_inset.C,v
retrieving revision 1.81
diff -u -p -r1.81 math_inset.C
--- math_inset.C        8 Apr 2002 08:12:09 -0000       1.81
+++ math_inset.C        11 Jul 2002 15:27:46 -0000
@@ -26,6 +26,7 @@
 #include "math_scriptinset.h"
 #include "math_mathmlstream.h"
 #include "debug.h"
+#include "math_parser.h"
 
 
 using std::ostream;
@@ -234,4 +235,21 @@ void MathInset::mathmlize(MathMLStream &
 {
        NormalStream ns(os.os());
        normalize(ns);
+}
+
+
+string asString(MathArray const & ar)
+{
+       std::ostringstream os;
+       WriteStream ws(os);
+       ws << ar;
+       return os.str();
+}
+
+
+MathArray asArray(string const & str)
+{
+       MathArray ar;
+       mathed_parse_cell(ar, str);
+       return ar;
 }
Index: math_inset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_inset.h,v
retrieving revision 1.111
diff -u -p -r1.111 math_inset.h
--- math_inset.h        24 Apr 2002 17:07:42 -0000      1.111
+++ math_inset.h        11 Jul 2002 15:27:46 -0000
@@ -220,8 +220,8 @@ public:
        virtual MathTextCodes code() const { return LM_TC_MIN; }
        /// identifies things that can get \limits or \nolimits
        virtual bool takesLimits() const { return false; }
-       /// identifies complicated things that need braces if used as arg
-       virtual bool needsBraces() const { return true; }
+       /// identifies things that add {...} when written
+       virtual bool extraBraces() const { return false; }
 
        ///
        virtual void edit(BufferView *, int, int, unsigned int) {}
@@ -255,5 +255,8 @@ public:
 };
 
 std::ostream & operator<<(std::ostream &, MathInset const &);
+
+string asString(MathArray const & ar);
+MathArray asArray(string const & str);
 
 #endif
Index: math_parser.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_parser.C,v
retrieving revision 1.197.2.1
diff -u -p -r1.197.2.1 math_parser.C
--- math_parser.C       28 May 2002 22:52:57 -0000      1.197.2.1
+++ math_parser.C       11 Jul 2002 15:27:47 -0000
@@ -932,10 +932,6 @@ void Parser::parse_into(MathArray & arra
 {
        parse_into1(array, flags, code);
        // remove 'unnecessary' braces:
-       if (array.size() == 1 && array.back()->asBraceInset()) {
-               lyxerr << "extra braces removed\n";
-               array = array.back()->asBraceInset()->cell(0);
-       }
 }
 
 
@@ -1012,15 +1008,9 @@ void Parser::parse_into1(MathArray & arr
                else if (t.cat() == catBegin) {
                        MathArray ar;
                        parse_into(ar, FLAG_BRACE_LAST);
-#ifndef WITH_WARNINGS
-#warning this might be wrong in general!
-#endif
-                       // ignore braces around simple items
-                       if ((ar.size() == 1 && !ar.front()->needsBraces()
-       || (ar.size() == 2 && !ar.front()->needsBraces()
-                                           && ar.back()->asScriptInset()))
-       || (ar.size() == 0 && array.size() == 0))
-                       {
+                       // do not create a BraceInset if they were written by LyX
+                       // this helps to keep the annoyance of  "a choose b"  to a 
+minimum
+                       if (ar.size() == 1 && ar.front()->extraBraces()) {
                                array.push_back(ar);
                        } else {
                                array.push_back(MathAtom(new MathBraceInset));
@@ -1177,7 +1167,9 @@ void Parser::parse_into1(MathArray & arr
 */
 
                else if (t.cs() == "label") {
-                       curr_label_ = getArg('{', '}');
+                       MathArray ar;
+                       parse_into(ar, FLAG_ITEM, code);
+                       curr_label_ = asString(ar);
                }
 
                else if (t.cs() == "choose" || t.cs() == "over" || t.cs() == "atop") {
Index: math_sizeinset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_sizeinset.h,v
retrieving revision 1.14
diff -u -p -r1.14 math_sizeinset.h
--- math_sizeinset.h    21 Mar 2002 17:42:56 -0000      1.14
+++ math_sizeinset.h    11 Jul 2002 15:27:47 -0000
@@ -21,6 +21,8 @@ public:
        explicit MathSizeInset(latexkeys const * l);
        ///
        MathInset * clone() const;
+       /// identifies things that add {...} when written
+       bool extraBraces() const { return true; }
        ///
        void metrics(MathMetricsInfo const & st) const;
        ///

Reply via email to