]> git.lyx.org Git - features.git/commitdiff
Handle properly script insets which nucleus has more than one
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 23 Aug 2006 10:57:49 +0000 (10:57 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 23 Aug 2006 10:57:49 +0000 (10:57 +0000)
element (like {a'}^{2}). (froward port from 14802)

* src/mathed/math_nestinset.C (script): when creating a script
inset, handle specially previous atom if it is a MathBraceInset
(this is used in interactive input).

* src/mathed/math_parser.C (parse1): when creating a script inset,
handle specially previous atom if it is a MathBraceInset (this is
used in parsing phase).

* src/mathed/math_scriptinset.C (write): put nucleus into braces
if it contains more than one element or is itself a script inset.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14819 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/math_nestinset.C
src/mathed/math_parser.C
src/mathed/math_scriptinset.C

index fd0cef3b48e6de038044caa1ba6e27cc931f68d8..a747ee742a7bd98324dc4f519d289d5cd9e3649f 100644 (file)
@@ -1368,6 +1368,12 @@ bool MathNestInset::script(LCursor & cur, bool up, string const &
                }
                --cur.pos();
                MathScriptInset * inset = cur.nextAtom().nucleus()->asScriptInset();
+               // special handling of {}-bases
+               // is this always correct?
+               if (inset->nuc().size() == 1 
+                   && inset->nuc().back()->asBraceInset())
+                       inset->nuc() = inset->nuc().back()->asNestInset()->cell(0);
+               
                cur.push(*inset);
                cur.idx() = 1;
                cur.pos() = 0;
index 6aea310a37bc79f210f0d323ff6bd1f082c30d2e..6d4584c674c48df16a3df9f9e4344ce63121016d 100644 (file)
@@ -813,10 +813,9 @@ void Parser::parse1(MathGridInset & grid, unsigned flags,
                        MathScriptInset * p = cell->back().nucleus()->asScriptInset();
                        // special handling of {}-bases
                        // is this always correct?
-                       // It appears that this is wrong (Dekel)
-                       //if (p->nuc().size() == 1 && p->nuc().back()->asNestInset() &&
-                       //    p->nuc().back()->extraBraces())
-                       //      p->nuc() = p->nuc().back()->asNestInset()->cell(0);
+                       if (p->nuc().size() == 1 
+                           && p->nuc().back()->asBraceInset())
+                               p->nuc() = p->nuc().back()->asNestInset()->cell(0);
                        parse(p->cell(p->idxOfScript(up)), FLAG_ITEM, mode);
                        if (limits) {
                                p->limits(limits);
index 2983a56120dc852a98dbbc18e8ef2ab20ef0b30f..6032f248e197aec8802835bf3fd77e3ea55b0a99 100644 (file)
@@ -420,7 +420,11 @@ bool MathScriptInset::idxUpDown(LCursor & cur, bool up) const
 void MathScriptInset::write(WriteStream & os) const
 {
        if (nuc().size()) {
-               os << nuc();
+               if (nuc().size() == 1 
+                   && ! nuc().begin()->nucleus()->asScriptInset())
+                       os << nuc();
+               else
+                       os << '{' << nuc() << '}';
                //if (nuc().back()->takesLimits()) {
                        if (limits_ == -1)
                                os << "\\nolimits ";