]> git.lyx.org Git - features.git/commitdiff
whitespace
authorGeorg Baum <baum@lyx.org>
Sun, 15 Mar 2015 17:20:01 +0000 (18:20 +0100)
committerGeorg Baum <baum@lyx.org>
Wed, 18 Mar 2015 20:33:10 +0000 (21:33 +0100)
src/Buffer.cpp
src/mathed/MathData.cpp

index 54da9b24ea394bc0f7dbfa3f5b685bc4d00565a6..f9da416dfb7774b0157e4e54589c2a307ed1b399 100644 (file)
@@ -367,7 +367,7 @@ private:
 static FileName createBufferTmpDir()
 {
        // FIXME This would be the ideal application for a TempDir class (like
-       //       TempFile but for directories) 
+       //       TempFile but for directories)
        string counter;
        {
                static int count;
@@ -3335,7 +3335,7 @@ void Buffer::Impl::updateMacros(DocIterator & it, DocIterator & scope)
                                continue;
 
                        // register macro
-                       // FIXME (Abdel), I don't understandt why we pass 'it' here
+                       // FIXME (Abdel), I don't understand why we pass 'it' here
                        // instead of 'macroTemplate' defined above... is this correct?
                        macros[macroTemplate.name()][it] =
                                Impl::ScopeMacro(scope, MacroData(const_cast<Buffer *>(owner_), it));
@@ -4453,9 +4453,9 @@ void Buffer::updateBuffer(UpdateScope scope, UpdateType utype) const
                if (master != this) {
                        bufToUpdate.insert(this);
                        master->updateBuffer(UpdateMaster, utype);
-                       // If the master buffer has no gui associated with it, then the TocModel is 
-                       // not updated during the updateBuffer call and TocModel::toc_ is invalid 
-                       // (bug 5699). The same happens if the master buffer is open in a different 
+                       // If the master buffer has no gui associated with it, then the TocModel is
+                       // not updated during the updateBuffer call and TocModel::toc_ is invalid
+                       // (bug 5699). The same happens if the master buffer is open in a different
                        // window. This test catches both possibilities.
                        // See: http://marc.info/?l=lyx-devel&m=138590578911716&w=2
                        // There remains a problem here: If there is another child open in yet a third
index fe73aa8965305a40d6400b497b564d3d9cb9e8a7..1b79f0cb9a72588b20712826d1dea6f0d77af543 100644 (file)
@@ -273,16 +273,16 @@ void MathData::metrics(MetricsInfo & mi, Dimension & dim) const
                dim += d;
                if (i == n - 1)
                        kerning_ = at->kerning(mi.base.bv);
-               
+
                // HACK to draw completion suggestion inline
                if (inlineCompletionData != this
                    || size_t(inlineCompletionPos.pos()) != i + 1)
                        continue;
-               
+
                docstring const & completion = mi.base.bv->inlineCompletion();
                if (completion.length() == 0)
                        continue;
-               
+
                FontInfo font = mi.base.font;
                augmentFont(font, from_ascii("mathnormal"));
                dim.wid += mathed_string_width(font, completion);
@@ -324,7 +324,7 @@ void MathData::draw(PainterInfo & pi, int x, int y) const
                at->drawSelection(pi, x, y);
                at->draw(pi, x, y);
                x += coords.dim(at.nucleus()).wid;
-               
+
                // Is the inline completion here?
                if (inlineCompletionData != this
                    || size_t(inlineCompletionPos.pos()) != i + 1)
@@ -334,20 +334,20 @@ void MathData::draw(PainterInfo & pi, int x, int y) const
                        continue;
                FontInfo f = pi.base.font;
                augmentFont(f, from_ascii("mathnormal"));
-               
+
                // draw the unique and the non-unique completion part
                // Note: this is not time-critical as it is
                // only done once per screen.
                size_t uniqueTo = bv.inlineCompletionUniqueChars();
                docstring s1 = completion.substr(0, uniqueTo);
                docstring s2 = completion.substr(uniqueTo);
-               
+
                if (!s1.empty()) {
                        f.setColor(Color_inlinecompletion);
                        pi.pain.text(x, y, s1, f);
                        x += mathed_string_width(f, s1);
                }
-               
+
                if (!s2.empty()) {
                        f.setColor(Color_nonunique_inlinecompletion);
                        pi.pain.text(x, y, s2, f);
@@ -444,7 +444,7 @@ void MathData::updateMacros(Cursor * cur, MacroContext const & mc,
                macroInset = operator[](i).nucleus()->asMacro();
 
                // Cursor in \label?
-               if (newDisplayMode != MathMacro::DISPLAY_UNFOLDED 
+               if (newDisplayMode != MathMacro::DISPLAY_UNFOLDED
                    && oldDisplayMode == MathMacro::DISPLAY_UNFOLDED) {
                        // put cursor in front of macro
                        if (cur) {
@@ -459,33 +459,33 @@ void MathData::updateMacros(Cursor * cur, MacroContext const & mc,
                macroInset->setDisplayMode(newDisplayMode);
 
                // arity changed?
-               if (newDisplayMode == MathMacro::DISPLAY_NORMAL 
+               if (newDisplayMode == MathMacro::DISPLAY_NORMAL
                    && (macroInset->arity() != macroNumArgs
                        || macroInset->optionals() != macroOptionals)) {
                        // is it a virgin macro which was never attached to parameters?
                        bool fromInitToNormalMode
-                       = (oldDisplayMode == MathMacro::DISPLAY_INIT 
+                       = (oldDisplayMode == MathMacro::DISPLAY_INIT
                           || oldDisplayMode == MathMacro::DISPLAY_INTERACTIVE_INIT)
                          && newDisplayMode == MathMacro::DISPLAY_NORMAL;
-                       
+
                        // if the macro was entered interactively (i.e. not by paste or during
                        // loading), it should not be greedy, but the cursor should
                        // automatically jump into the macro when behind
                        bool interactive = (oldDisplayMode == MathMacro::DISPLAY_INTERACTIVE_INIT);
-                       
+
                        // attach parameters
                        attachMacroParameters(cur, i, macroNumArgs, macroOptionals,
                                fromInitToNormalMode, interactive, appetite);
-                       
+
                        if (cur) {
                                // FIXME: proper anchor handling, this removes the selection
                                cur->updateInsets(&cur->bottom().inset());
-                               cur->clearSelection();  
+                               cur->clearSelection();
                        }
                }
 
                // Give macro the chance to adapt to new situation.
-               // The macroInset could be invalid now because it was put into a script 
+               // The macroInset could be invalid now because it was put into a script
                // inset and therefore "deep" copied. So get it again from the MathData.
                InsetMath * inset = operator[](i).nucleus();
                if (inset->asScriptInset())
@@ -499,7 +499,7 @@ void MathData::updateMacros(Cursor * cur, MacroContext const & mc,
 void MathData::detachMacroParameters(DocIterator * cur, const size_type macroPos)
 {
        MathMacro * macroInset = operator[](macroPos).nucleus()->asMacro();
-       
+
        // detach all arguments
        vector<MathData> detachedArgs;
        if (macroPos + 1 == size())
@@ -507,7 +507,7 @@ void MathData::detachMacroParameters(DocIterator * cur, const size_type macroPos
                macroInset->detachArguments(detachedArgs, true);
        else
                macroInset->detachArguments(detachedArgs, false);
-       
+
        // find cursor slice
        int curMacroSlice = -1;
        if (cur)
@@ -521,33 +521,33 @@ void MathData::detachMacroParameters(DocIterator * cur, const size_type macroPos
                cur->cutOff(curMacroSlice, argSlices);
                cur->pop_back();
        }
-       
-       // only [] after the last non-empty argument can be dropped later 
+
+       // only [] after the last non-empty argument can be dropped later
        size_t lastNonEmptyOptional = 0;
        for (size_t l = 0; l < detachedArgs.size() && l < macroInset->optionals(); ++l) {
                if (!detachedArgs[l].empty())
                        lastNonEmptyOptional = l;
        }
-       
+
        // optional arguments to be put back?
        pos_type p = macroPos + 1;
        size_t j = 0;
        for (; j < detachedArgs.size() && j < macroInset->optionals(); ++j) {
                // another non-empty parameter follows?
                bool canDropEmptyOptional = j >= lastNonEmptyOptional;
-               
+
                // then we can drop empty optional parameters
                if (detachedArgs[j].empty() && canDropEmptyOptional) {
                        if (curMacroIdx == j)
                                (*cur)[curMacroSlice - 1].pos() = macroPos + 1;
                        continue;
                }
-               
+
                // Otherwise we don't drop an empty optional, put it back normally
                MathData optarg;
                asArray(from_ascii("[]"), optarg);
                MathData & arg = detachedArgs[j];
-               
+
                // look for "]", i.e. put a brace around?
                InsetMathBrace * brace = 0;
                for (size_t q = 0; q < arg.size(); ++q) {
@@ -557,22 +557,22 @@ void MathData::detachMacroParameters(DocIterator * cur, const size_type macroPos
                                break;
                        }
                }
-               
+
                // put arg between []
                if (brace) {
                        brace->cell(0) = arg;
                        optarg.insert(1, MathAtom(brace));
                } else
                        optarg.insert(1, arg);
-               
+
                // insert it into the array
                insert(p, optarg);
                p += optarg.size();
-               
+
                // cursor in macro?
                if (curMacroSlice == -1)
                        continue;
-               
+
                // cursor in optional argument of macro?
                if (curMacroIdx == j) {
                        if (brace) {
@@ -585,21 +585,21 @@ void MathData::detachMacroParameters(DocIterator * cur, const size_type macroPos
                        // cursor right of macro
                        (*cur)[curMacroSlice - 1].pos() += optarg.size();
        }
-       
+
        // put them back into the MathData
        for (; j < detachedArgs.size(); ++j, ++p) {
                MathData const & arg = detachedArgs[j];
-               if (arg.size() == 1 
+               if (arg.size() == 1
                    && !arg[0]->asScriptInset()
                    && !(arg[0]->asMacro() && arg[0]->asMacro()->arity() > 0))
                        insert(p, arg[0]);
                else
                        insert(p, MathAtom(new InsetMathBrace(arg)));
-               
+
                // cursor in macro?
                if (curMacroSlice == -1)
                        continue;
-               
+
                // cursor in j-th argument of macro?
                if (curMacroIdx == j) {
                        if (operator[](p).nucleus()->asBraceInset()) {
@@ -613,20 +613,20 @@ void MathData::detachMacroParameters(DocIterator * cur, const size_type macroPos
                } else if ((*cur)[curMacroSlice - 1].pos() >= int(p))
                        ++(*cur)[curMacroSlice - 1].pos();
        }
-       
+
        if (cur)
                cur->updateInsets(&cur->bottom().inset());
 }
 
 
-void MathData::attachMacroParameters(Cursor * cur, 
+void MathData::attachMacroParameters(Cursor * cur,
        const size_type macroPos, const size_type macroNumArgs,
        const int macroOptionals, const bool fromInitToNormalMode,
        const bool interactiveInit, const size_t appetite)
 {
        MathMacro * macroInset = operator[](macroPos).nucleus()->asMacro();
 
-       // start at atom behind the macro again, maybe with some new arguments 
+       // start at atom behind the macro again, maybe with some new arguments
        // from the detach phase above, to add them back into the macro inset
        size_t p = macroPos + 1;
        vector<MathData> detachedArgs;
@@ -672,7 +672,7 @@ void MathData::attachMacroParameters(Cursor * cur,
 
                // get pointer to "deep" copied macro inset
                scriptInset = operator[](macroPos).nucleus()->asScriptInset();
-               macroInset = scriptInset->nuc()[0].nucleus()->asMacro();        
+               macroInset = scriptInset->nuc()[0].nucleus()->asMacro();
        }
 
        // remove them from the MathData
@@ -701,20 +701,20 @@ void MathData::attachMacroParameters(Cursor * cur,
 }
 
 
-void MathData::collectOptionalParameters(Cursor * cur, 
-       const size_type numOptionalParams, vector<MathData> & params, 
+void MathData::collectOptionalParameters(Cursor * cur,
+       const size_type numOptionalParams, vector<MathData> & params,
        size_t & pos, MathAtom & scriptToPutAround,
        const pos_type macroPos, const int thisPos, const int thisSlice)
 {
        Buffer * buf = cur ? cur->buffer() : 0;
        // insert optional arguments?
-       while (params.size() < numOptionalParams 
+       while (params.size() < numOptionalParams
               && pos < size()
               && !scriptToPutAround.nucleus()) {
                // is a [] block following which could be an optional parameter?
                if (operator[](pos)->getChar() != '[')
                        break;
-               
+
                // found possible optional argument, look for "]"
                size_t right = pos + 1;
                for (; right < size(); ++right) {
@@ -723,7 +723,7 @@ void MathData::collectOptionalParameters(Cursor * cur,
                        if (cell->getChar() == ']')
                                // found right end
                                break;
-                       
+
                        // maybe "]" with a script around?
                        InsetMathScript * script = cell.nucleus()->asScriptInset();
                        if (!script)
@@ -736,16 +736,16 @@ void MathData::collectOptionalParameters(Cursor * cur,
                                break;
                        }
                }
-               
+
                // found?
                if (right >= size()) {
                        // no ] found, so it's not an optional argument
                        break;
                }
-               
+
                // add everything between [ and ] as optional argument
                MathData optarg(buf, begin() + pos + 1, begin() + right);
-               
+
                // a brace?
                bool brace = false;
                if (optarg.size() == 1 && optarg[0]->asBraceInset()) {
@@ -753,7 +753,7 @@ void MathData::collectOptionalParameters(Cursor * cur,
                        params.push_back(optarg[0]->asBraceInset()->cell(0));
                } else
                        params.push_back(optarg);
-               
+
                // place cursor in optional argument of macro
                if (thisSlice != -1
                    && thisPos >= int(pos) && thisPos <= int(right)) {
@@ -773,37 +773,37 @@ void MathData::collectOptionalParameters(Cursor * cur,
 
        // fill up empty optional parameters
        while (params.size() < numOptionalParams)
-               params.push_back(MathData());   
+               params.push_back(MathData());
 }
 
 
-void MathData::collectParameters(Cursor * cur, 
-       const size_type numParams, vector<MathData> & params, 
+void MathData::collectParameters(Cursor * cur,
+       const size_type numParams, vector<MathData> & params,
        size_t & pos, MathAtom & scriptToPutAround,
        const pos_type macroPos, const int thisPos, const int thisSlice,
-       const size_t appetite) 
+       const size_t appetite)
 {
        size_t startSize = params.size();
-       
+
        // insert normal arguments
        while (params.size() < numParams
               && params.size() - startSize < appetite
               && pos < size()
               && !scriptToPutAround.nucleus()) {
                MathAtom & cell = operator[](pos);
-               
+
                // fix cursor
                vector<CursorSlice> argSlices;
                int argPos = 0;
                if (thisSlice != -1 && thisPos == int(pos))
-                       cur->cutOff(thisSlice, argSlices);              
-               
+                       cur->cutOff(thisSlice, argSlices);
+
                // which kind of parameter is it? In {}? With index x^n?
                InsetMathBrace const * brace = cell->asBraceInset();
                if (brace) {
                        // found brace, convert into argument
                        params.push_back(brace->cell(0));
-                       
+
                        // cursor inside of the brace or just in front of?
                        if (thisPos == int(pos) && !argSlices.empty()) {
                                argPos = argSlices[0].pos();
@@ -818,10 +818,10 @@ void MathData::collectParameters(Cursor * cur,
                                params.push_back(script->nuc()[0]->asBraceInset()->cell(0));
                        else
                                params.push_back(script->nuc());
-                       
+
                        // script will be put around below
                        scriptToPutAround = cell;
-                       
+
                        // this should only happen after loading, so make cursor handling simple
                        if (thisPos >= int(macroPos) && thisPos <= int(macroPos + numParams)) {
                                argSlices.clear();
@@ -834,16 +834,16 @@ void MathData::collectParameters(Cursor * cur,
                        array.insert(0, cell);
                        params.push_back(array);
                }
-               
+
                // put cursor in argument again
                if (thisSlice != - 1 && thisPos == int(pos)) {
                        cur->append(params.size() - 1, argPos);
                        cur->append(argSlices);
                        (*cur)[thisSlice].pos() = macroPos;
                }
-               
+
                ++pos;
-       }       
+       }
 }