otexstream & os,
pos_type i,
unsigned int & column);
- ///
- bool latexSpecialPhrase(
- otexstream & os,
- pos_type & i,
- pos_type end_pos,
- unsigned int & column,
- OutputParams const & runparams);
///
void validate(LaTeXFeatures & features) const;
bool onlyText(Buffer const & buf, Font const & outerfont,
pos_type initial) const;
- /// match a string against a particular point in the paragraph
- bool isTextAt(string const & str, pos_type pos) const;
-
/// a vector of speller skip positions
typedef vector<FontSpan> SkipPositions;
typedef SkipPositions::const_iterator SkipPositionsIterator;
};
-namespace {
-
-struct special_phrase {
- string phrase;
- docstring macro;
- bool builtin;
-};
-
-special_phrase const special_phrases[] = {
- { "LyX", from_ascii("\\LyX{}"), false },
- { "TeX", from_ascii("\\TeX{}"), true },
- { "LaTeX2e", from_ascii("\\LaTeXe{}"), true },
- { "LaTeX", from_ascii("\\LaTeX{}"), true },
-};
-
-size_t const phrases_nr = sizeof(special_phrases)/sizeof(special_phrase);
-
-} // namespace anon
-
-
Paragraph::Private::Private(Paragraph * owner, Layout const & layout)
: owner_(owner), inset_owner_(0), id_(-1), begin_of_body_(0), layout_(&layout)
{
}
-bool Paragraph::Private::isTextAt(string const & str, pos_type pos) const
-{
- pos_type const len = str.length();
-
- // is the paragraph large enough?
- if (pos + len > int(text_.size()))
- return false;
-
- // does the wanted text start at point?
- for (string::size_type i = 0; i < str.length(); ++i) {
- // Caution: direct comparison of characters works only
- // because str is pure ASCII.
- if (str[i] != text_[pos + i])
- return false;
- }
-
- return fontlist_.hasChangeInRange(pos, len);
-}
-
-
void Paragraph::Private::latexInset(BufferParams const & bparams,
otexstream & os,
OutputParams & runparams,
char_type const c = (runparams.use_polyglossia) ?
owner_->getUChar(bparams, i) : text_[i];
- if (style.pass_thru || runparams.pass_thru) {
+ if (style.pass_thru || runparams.pass_thru
+ || contains(style.pass_thru_chars, c)
+ || contains(runparams.pass_thru_chars, c)) {
if (c != '\0') {
Encoding const * const enc = runparams.encoding;
if (enc && !enc->encodable(c))
return;
// If T1 font encoding is used, use the special
// characters it provides.
- // NOTE: some languages reset the font encoding
- // internally
+ // NOTE: Some languages reset the font encoding internally.
+ // If we are using such a language, we do not output
+ // special T1 chars.
if (!runparams.inIPA && !running_font.language()->internalFontEncoding()
- && lyxrc.fontenc == "T1" && latexSpecialT1(c, os, i, column))
+ && bparams.font_encoding() == "T1" && latexSpecialT1(c, os, i, column))
return;
// Otherwise, we use what LaTeX provides us.
break;
default:
- // LyX, LaTeX etc.
- if (latexSpecialPhrase(os, i, end_pos, column, runparams))
- return;
-
if (c == '\0')
return;
}
-/// \param end_pos
-/// If [start_pos, end_pos) does not include entirely the special phrase, then
-/// do not apply the macro transformation.
-bool Paragraph::Private::latexSpecialPhrase(otexstream & os, pos_type & i, pos_type end_pos,
- unsigned int & column, OutputParams const & runparams)
-{
- // FIXME: if we have "LaTeX" with a font
- // change in the middle (before the 'T', then
- // the "TeX" part is still special cased.
- // Really we should only operate this on
- // "words" for some definition of word
-
- for (size_t pnr = 0; pnr < phrases_nr; ++pnr) {
- if (!isTextAt(special_phrases[pnr].phrase, i)
- || (end_pos != -1 && i + int(special_phrases[pnr].phrase.size()) > end_pos))
- continue;
- if (runparams.moving_arg)
- os << "\\protect";
- os << special_phrases[pnr].macro;
- i += special_phrases[pnr].phrase.length() - 1;
- column += special_phrases[pnr].macro.length() - 1;
- return true;
- }
- return false;
-}
-
-
void Paragraph::Private::validate(LaTeXFeatures & features) const
{
if (layout_->inpreamble && inset_owner_) {
// then the contents
for (pos_type i = 0; i < int(text_.size()) ; ++i) {
- for (size_t pnr = 0; pnr < phrases_nr; ++pnr) {
- if (!special_phrases[pnr].builtin
- && isTextAt(special_phrases[pnr].phrase, i)) {
- features.require(special_phrases[pnr].phrase);
- break;
- }
- }
BufferEncodings::validate(text_[i], features);
}
}
{
int column = 0;
- if (params_.noindent() && !layout_->pass_thru
- && (layout_->toggle_indent != ITOGGLE_NEVER)) {
+ bool canindent =
+ (bparams.paragraph_separation == BufferParams::ParagraphIndentSeparation) ?
+ (layout_->toggle_indent != ITOGGLE_NEVER) :
+ (layout_->toggle_indent == ITOGGLE_ALWAYS);
+
+ if (canindent && params_.noindent() && !layout_->pass_thru) {
os << "\\noindent ";
column += 10;
}