]> git.lyx.org Git - features.git/blobdiff - src/texstream.cpp
Revert "Always remove selection after cursor up/down"
[features.git] / src / texstream.cpp
index 10033a9255da7e5c4b63d39157d698992b2ee446..891367ce44bbdeeeb46a37d578fe63e23d59f51b 100644 (file)
@@ -68,8 +68,8 @@ void otexstream::put(char_type const & c)
                protectspace_ = false;
        }
        if (terminate_command_) {
-               if ((c == ' ' || c == '\0') && !isprotected)
-                       // A space follows. Terminate with brackets.
+               if ((c == ' ' || c == '\0' || c == '\n') && !isprotected)
+                       // A space or line break follows. Terminate with brackets.
                        os() << "{}";
                else if (c != '\\' && c != '{' && c != '}')
                        // Non-terminating character follows. Terminate with space.
@@ -90,7 +90,7 @@ size_t otexstringstream::length()
 
 TexString otexstringstream::release()
 {
-       TexString ts(ods_.str(), move(texrow()));
+       TexString ts(ods_.str(), std::move(texrow()));
        // reset this
        texrow() = TexRow();
        ods_.clear();
@@ -107,6 +107,8 @@ TerminateCommand termcmd;
 otexstream & operator<<(otexstream & ots, BreakLine)
 {
        if (ots.canBreakLine()) {
+               if (ots.terminateCommand())
+                       ots << "{}";
                ots.otexrowstream::put('\n');
                ots.lastChar('\n');
        }
@@ -120,6 +122,8 @@ otexstream & operator<<(otexstream & ots, SafeBreakLine)
 {
        otexrowstream & otrs = ots;
        if (ots.canBreakLine()) {
+           if (ots.terminateCommand())
+                       otrs << "{}";
                otrs << "%\n";
                ots.lastChar('\n');
        }
@@ -160,8 +164,8 @@ otexstream & operator<<(otexstream & ots, odocstream_manip pf)
 otexrowstream & operator<<(otexrowstream & ots, TexString ts)
 {
        ts.validate();
-       ots.os() << move(ts.str);
-       ots.texrow().append(move(ts.texrow));
+       ots.os() << std::move(ts.str);
+       ots.texrow().append(std::move(ts.texrow));
        return ots;
 }
 
@@ -175,7 +179,7 @@ otexstream & operator<<(otexstream & ots, TexString ts)
 
        otexrowstream & otrs = ots;
        bool isprotected = false;
-       char const c = ts.str[0];
+       char_type const c = ts.str[0];
        if (ots.protectSpace()) {
                if (!ots.canBreakLine() && c == ' ') {
                        otrs << "{}";
@@ -184,8 +188,8 @@ otexstream & operator<<(otexstream & ots, TexString ts)
                ots.protectSpace(false);
        }
        if (ots.terminateCommand()) {
-               if ((c == ' ' || c == '\0') && !isprotected)
-                       // A space follows. Terminate with brackets.
+               if ((c == ' ' || c == '\0' || c == '\n') && !isprotected)
+                       // A space or line break follows. Terminate with brackets.
                        otrs << "{}";
                else if (c != '\\' && c != '{' && c != '}')
                        // Non-terminating character follows. Terminate with space.
@@ -197,7 +201,7 @@ otexstream & operator<<(otexstream & ots, TexString ts)
                ots.canBreakLine(ts.str[len - 2] != '\n');
        ots.lastChar(ts.str[len - 1]);
 
-       otrs << move(ts);
+       otrs << std::move(ts);
        return ots;
 }
 
@@ -219,7 +223,7 @@ otexstream & operator<<(otexstream & ots, docstring const & s)
                return ots;
        otexrowstream & otrs = ots;
        bool isprotected = false;
-       char const c = s[0];
+       char_type const c = s[0];
        if (ots.protectSpace()) {
                if (!ots.canBreakLine() && c == ' ') {
                        otrs << "{}";
@@ -228,8 +232,8 @@ otexstream & operator<<(otexstream & ots, docstring const & s)
                ots.protectSpace(false);
        }
        if (ots.terminateCommand()) {
-               if ((c == ' ' || c == '\0') && !isprotected)
-                       // A space follows. Terminate with brackets.
+               if ((c == ' ' || c == '\0' || c == '\n') && !isprotected)
+                       // A space or line break follows. Terminate with brackets.
                        otrs << "{}";
                else if (c != '\\' && c != '{' && c != '}')
                        // Non-terminating character follows. Terminate with space.
@@ -326,7 +330,7 @@ template otexrowstream & operator<< <unsigned int>(otexrowstream &,
 template otexrowstream & operator<< <unsigned long>(otexrowstream &,
                                                                                                        unsigned long);
 
-#ifdef LYX_USE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
 template otexrowstream & operator<< <unsigned long long>(otexrowstream &,
                                                          unsigned long long);
 #endif
@@ -347,8 +351,8 @@ template otexstream & operator<< <double>(otexstream &, double);
 template otexstream & operator<< <int>(otexstream &, int);
 template otexstream & operator<< <unsigned int>(otexstream &, unsigned int);
 template otexstream & operator<< <unsigned long>(otexstream &, unsigned long);
-#ifdef LYX_USE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
 template otexstream & operator<< <unsigned long long>(otexstream &, unsigned long long);
 #endif
 
-}
+} // namespace lyx