]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
* do not lookup the same macro all the time
[lyx.git] / src / Cursor.cpp
index 74a0cd2e4937317ac98b204cffc7ef0693109afe..95d44b747b95473dbaf14ccbea266976dcdc348e 100644 (file)
@@ -28,7 +28,7 @@
 #include "LyXFunc.h" // only for setMessage()
 #include "LyXRC.h"
 #include "Row.h"
-#include "LyXText.h"
+#include "Text.h"
 #include "Paragraph.h"
 #include "paragraph_funcs.h"
 #include "ParIterator.h"
@@ -245,6 +245,17 @@ namespace {
                return true;
        }
 
+       docstring parbreak(Paragraph const & par)
+       {
+               odocstringstream ods;
+               ods << '\n';
+               // only add blank line if we're not in an ERT or Listings inset
+               if (par.ownerCode() != Inset::ERT_CODE 
+                   && par.ownerCode() != Inset::LISTINGS_CODE)
+                       ods << '\n';
+               return ods.str();
+       }
+
 } // namespace anon
 
 
@@ -1178,12 +1189,14 @@ docstring Cursor::selectionAsString(bool label) const
 
                // First paragraph in selection
                docstring result = pars[startpit].
-                       asString(buffer, startpos, pars[startpit].size(), label) + "\n\n";
+                       asString(buffer, startpos, pars[startpit].size(), label)
+                                + parbreak(pars[startpit]);
 
                // The paragraphs in between (if any)
                for (pit_type pit = startpit + 1; pit != endpit; ++pit) {
                        Paragraph const & par = pars[pit];
-                       result += par.asString(buffer, 0, par.size(), label) + "\n\n";
+                       result += par.asString(buffer, 0, par.size(), label)
+                                 + parbreak(pars[pit]);
                }
 
                // Last paragraph in selection
@@ -1233,7 +1246,7 @@ Encoding const * Cursor::getEncoding() const
                if (operator[](s).text())
                        break;
        CursorSlice const & sl = operator[](s);
-       LyXText const & text = *sl.text();
+       Text const & text = *sl.text();
        Font font = text.getPar(sl.pit()).getFont(
                bv().buffer()->params(), sl.pos(), outerFont(sl.pit(), text.paragraphs()));
        return font.language()->encoding();
@@ -1274,7 +1287,7 @@ Font Cursor::getFont() const
                if (operator[](s).text())
                        break;
        CursorSlice const & sl = operator[](s);
-       LyXText const & text = *sl.text();
+       Text const & text = *sl.text();
        Font font = text.getPar(sl.pit()).getFont(
                bv().buffer()->params(),
                sl.pos(),
@@ -1327,10 +1340,4 @@ void Cursor::fixIfBroken()
 }
 
 
-bool Cursor::isRTL() const
-{
-       return top().paragraph().isRightToLeftPar(bv().buffer()->params());
-}
-
-
 } // namespace lyx