]> git.lyx.org Git - features.git/commitdiff
Output a space if pendingSpace() is true and it is actually needed
authorEnrico Forestieri <forenr@lyx.org>
Tue, 31 Oct 2006 20:16:47 +0000 (20:16 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Tue, 31 Oct 2006 20:16:47 +0000 (20:16 +0000)
* src/mathed/MathStream.C
(isAlpha): new, test whether a lyx::char_type is an ascii letter.
(operator<<): output a space if pendingSpace() is true and what follows
begins with an ascii letter. Also update the number of lines written.

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

src/mathed/MathStream.C

index a1bdc8efe90d82da82e975a561fbf2c84875caca..e51819dc713b42dba90c0b5808f44d26942d49ef 100644 (file)
@@ -25,6 +25,12 @@ bool isAlpha(char c)
        return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
 }
 
+
+bool isAlpha(lyx::char_type c)
+{
+       return c < 0x80 && isAlpha(static_cast<char>(c));
+}
+
 }
 
 
@@ -93,7 +99,19 @@ NormalStream & operator<<(NormalStream & ns, int i)
 
 WriteStream & operator<<(WriteStream & ws, docstring const & s)
 {
+       if (ws.pendingSpace() && s.length() > 0) {
+               if (isAlpha(s[0]))
+                       ws.os() << ' ';
+               ws.pendingSpace(false);
+       }
        ws.os() << s;
+       int lf = 0;
+       docstring::const_iterator dit = s.begin();
+       docstring::const_iterator end = s.end();
+       for (; dit != end; ++dit)
+               if ((*dit) == '\n')
+                       ++lf;
+       ws.addlines(lf);
        return ws;
 }