X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FMathStream.cpp;h=b8a8019d3665dbe0ad51f802e68442f3f7849246;hb=34fc56c9bca45ea0c7b8f455f770b5bd10a711bb;hp=b0a842f209fdfe140be456ec97ebecde3b057438;hpb=9abb7db46800e554f57e865a3e768602ffd9d6f1;p=lyx.git diff --git a/src/mathed/MathStream.cpp b/src/mathed/MathStream.cpp index b0a842f209..b8a8019d36 100644 --- a/src/mathed/MathStream.cpp +++ b/src/mathed/MathStream.cpp @@ -3,7 +3,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author André Pönitz + * \author André Pönitz * * Full author contact details are available in file CREDITS. */ @@ -12,7 +12,6 @@ #include "MathStream.h" -#include "InsetMath.h" #include "MathData.h" #include "MathExtern.h" @@ -20,6 +19,7 @@ #include "support/docstring.h" #include +#include #include using namespace std; @@ -85,7 +85,12 @@ NormalStream & operator<<(NormalStream & ns, int i) WriteStream & operator<<(WriteStream & ws, docstring const & s) { - if (ws.pendingSpace() && s.length() > 0) { + if (ws.pendingBrace()) { + ws.os() << '}'; + ws.pendingBrace(false); + ws.pendingSpace(false); + ws.textMode(true); + } else if (ws.pendingSpace() && s.length() > 0) { if (isAlphaASCII(s[0])) ws.os() << ' '; ws.pendingSpace(false); @@ -102,21 +107,26 @@ WriteStream & operator<<(WriteStream & ws, docstring const & s) } -WriteStream::WriteStream(odocstream & os, bool fragile, bool latex) +WriteStream::WriteStream(odocstream & os, bool fragile, bool latex, bool dryrun, + Encoding const * encoding) : os_(os), fragile_(fragile), firstitem_(false), latex_(latex), - pendingspace_(false), line_(0) + dryrun_(dryrun), pendingspace_(false), pendingbrace_(false), + textmode_(false), locked_(0), line_(0), encoding_(encoding) {} WriteStream::WriteStream(odocstream & os) : os_(os), fragile_(false), firstitem_(false), latex_(false), - pendingspace_(false), line_(0) + dryrun_(false), pendingspace_(false), pendingbrace_(false), + textmode_(false), locked_(0), line_(0), encoding_(0) {} WriteStream::~WriteStream() { - if (pendingspace_) + if (pendingbrace_) + os_ << '}'; + else if (pendingspace_) os_ << ' '; } @@ -133,6 +143,24 @@ void WriteStream::pendingSpace(bool how) } +void WriteStream::pendingBrace(bool brace) +{ + pendingbrace_ = brace; +} + + +void WriteStream::textMode(bool textmode) +{ + textmode_ = textmode; +} + + +void WriteStream::lockedMode(bool locked) +{ + locked_ = locked; +} + + WriteStream & operator<<(WriteStream & ws, MathAtom const & at) { at->write(ws); @@ -149,7 +177,12 @@ WriteStream & operator<<(WriteStream & ws, MathData const & ar) WriteStream & operator<<(WriteStream & ws, char const * s) { - if (ws.pendingSpace() && strlen(s) > 0) { + if (ws.pendingBrace()) { + ws.os() << '}'; + ws.pendingBrace(false); + ws.pendingSpace(false); + ws.textMode(true); + } else if (ws.pendingSpace() && strlen(s) > 0) { if (isAlphaASCII(s[0])) ws.os() << ' '; ws.pendingSpace(false); @@ -162,7 +195,12 @@ WriteStream & operator<<(WriteStream & ws, char const * s) WriteStream & operator<<(WriteStream & ws, char c) { - if (ws.pendingSpace()) { + if (ws.pendingBrace()) { + ws.os() << '}'; + ws.pendingBrace(false); + ws.pendingSpace(false); + ws.textMode(true); + } else if (ws.pendingSpace()) { if (isAlphaASCII(c)) ws.os() << ' '; ws.pendingSpace(false); @@ -176,6 +214,11 @@ WriteStream & operator<<(WriteStream & ws, char c) WriteStream & operator<<(WriteStream & ws, int i) { + if (ws.pendingBrace()) { + ws.os() << '}'; + ws.pendingBrace(false); + ws.textMode(true); + } ws.os() << i; return ws; } @@ -183,6 +226,11 @@ WriteStream & operator<<(WriteStream & ws, int i) WriteStream & operator<<(WriteStream & ws, unsigned int i) { + if (ws.pendingBrace()) { + ws.os() << '}'; + ws.pendingBrace(false); + ws.textMode(true); + } ws.os() << i; return ws; }