Output a space if pendingSpace() is true and it is actually needed

* 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
This commit is contained in:
Enrico Forestieri 2006-10-31 20:16:47 +00:00
parent a636a5a7f2
commit 6b1631a8c5

View 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;
}