return;
}
pos_type endpos = last;
- owner_->locateWord(first, endpos, WHOLE_WORD);
+ owner_->locateWord(first, endpos, WHOLE_WORD, true);
if (endpos < last) {
endpos = last;
- owner_->locateWord(last, endpos, WHOLE_WORD);
+ owner_->locateWord(last, endpos, WHOLE_WORD, true);
}
last = endpos;
}
}
-void Paragraph::addChangesToBuffer(Buffer const & buf) const
-{
- d->changes_.updateBuffer(buf);
-}
-
-
-bool Paragraph::isChangeUpdateRequired() const
-{
- return d->changes_.isUpdateRequired();
-}
-
-
bool Paragraph::isDeleted(pos_type start, pos_type end) const
{
LASSERT(start >= 0 && start <= size(), return false);
}
+bool Paragraph::isChanged() const
+{
+ return d->changes_.isChanged();
+}
+
+
bool Paragraph::isMergedOnEndOfParDeletion(bool trackChanges) const
{
// keep the logic here in sync with the logic of eraseChars()
return change.inserted() && change.currentAuthor();
}
+Change Paragraph::parEndChange() const
+{
+ return d->changes_.lookup(size());
+}
+
void Paragraph::setChange(Change const & change)
{
// see comment in setChange(Change const &) above
if (!change.deleted() && pos < size())
- if (Inset * inset = getInset(pos))
- inset->setChange(change);
+ if (Inset * inset = getInset(pos))
+ inset->setChange(change);
}
bool close = false;
odocstream::pos_type const len = os.os().tellp();
- if (inset->forceLTR()
+ if (inset->forceLTR(runparams)
&& running_font.isRightToLeft()
// ERT is an exception, it should be output with no
// decorations at all
char_type c = d->text_[pos];
// Return unchanged character in LTR languages
- // or if we use poylglossia/bidi.
- if (rp.use_polyglossia || !getFontSettings(bparams, pos).isRightToLeft())
+ // or if we use poylglossia/bidi (XeTeX).
+ if (rp.useBidiPackage()
+ || !getFontSettings(bparams, pos).isRightToLeft())
return c;
// Without polyglossia/bidi, we need to account for some special cases.
char_type uc = c;
// 1. In the following languages, parentheses need to be reversed.
- bool const reverseparens = lang == "hebrew";
+ // Also with polyglodia/luabidi
+ bool const reverseparens = (lang == "hebrew" || rp.use_polyglossia);
// 2. In the following languages, brackets don't need to be reversed.
bool const reversebrackets = lang != "arabic_arabtex"
}
-LyXAlignment Paragraph::getAlign() const
+LyXAlignment Paragraph::getAlign(BufferParams const & bparams) const
{
if (d->params_.align() == LYX_ALIGN_LAYOUT)
- return d->layout_->align;
+ return getDefaultAlign(bparams);
else
return d->params_.align();
}
+LyXAlignment Paragraph::getDefaultAlign(BufferParams const & bparams) const
+{
+ LyXAlignment res = layout().align;
+ if (isRTL(bparams)) {
+ // Swap sides
+ if (res == LYX_ALIGN_LEFT)
+ res = LYX_ALIGN_RIGHT;
+ else if (res == LYX_ALIGN_RIGHT)
+ res = LYX_ALIGN_LEFT;
+ }
+ return res;
+}
+
+
docstring const & Paragraph::labelString() const
{
return d->params_.labelString();
InsetCode code = ownerCode();
bool const lastpar = runparams.isLastPar;
// RTL in classic (PDF)LaTeX (without the Bidi package)
+ // Luabibdi (used by LuaTeX) behaves like classic
bool const rtl_classic = owner_->getParLanguage(bparams)->rightToLeft()
- && !runparams.use_polyglossia;
+ && !runparams.useBidiPackage();
switch (curAlign) {
case LYX_ALIGN_NONE:
InsetCode code = ownerCode();
bool const lastpar = runparams.isLastPar;
// RTL in classic (PDF)LaTeX (without the Bidi package)
+ // Luabibdi (used by LuaTeX) behaves like classic
bool const rtl_classic = owner_->getParLanguage(bparams)->rightToLeft()
- && !runparams.use_polyglossia;
+ && !runparams.useBidiPackage();
switch (curAlign) {
case LYX_ALIGN_NONE:
Change const & change = runparams.inDeletedInset
? runparams.changeOfDeletedInset : lookupChange(i);
+ char_type const c = d->text_[i];
+
// Check whether a display math inset follows
- if (d->text_[i] == META_INSET
+ if (c == META_INSET
&& i >= start_pos && (end_pos == -1 || i < end_pos)) {
+ if (isDeleted(i))
+ runparams.ctObject = getInset(i)->CtObject(runparams);
+
InsetMath const * im = getInset(i)->asInsetMath();
if (im && im->asHullInset()
&& im->asHullInset()->outerDisplay()) {
basefont, needPar);
open_font = false;
}
- basefont = getLayoutFont(bparams, outerfont);
+ basefont = (body_pos > i) ? getLabelFont(bparams, outerfont)
+ : getLayoutFont(bparams, outerfont);
running_font = basefont;
column += Changes::latexMarkChange(os, bparams,
Change(Change::INSERTED), change, rp);
basefont, basefont, needPar);
open_font = false;
}
- basefont = getLayoutFont(bparams, outerfont);
+ basefont = (body_pos > i) ? getLabelFont(bparams, outerfont)
+ : getLayoutFont(bparams, outerfont);
running_font = basefont;
column += Changes::latexMarkChange(os, bparams, runningChange,
change, runparams);
open_font = false;
}
- string const running_lang = runparams.use_polyglossia ?
- running_font.language()->polyglossia() : running_font.language()->babel();
- // close babel's font environment before opening CJK.
- string const lang_end_command = runparams.use_polyglossia ?
- "\\end{$$lang}" : lyxrc.language_command_end;
- bool const using_begin_end = runparams.use_polyglossia ||
- !lang_end_command.empty();
- if (!running_lang.empty() &&
- (!using_begin_end || running_lang == openLanguageName()) &&
- current_font.language()->encoding()->package() == Encoding::CJK) {
- string end_tag = subst(lang_end_command,
- "$$lang",
- running_lang);
- os << from_ascii(end_tag);
- column += end_tag.length();
- if (using_begin_end)
- popLanguageName();
+ // if necessary, close language environment before opening CJK
+ string const running_lang = running_font.language()->babel();
+ string const lang_end_command = lyxrc.language_command_end;
+ if (!lang_end_command.empty() && !bparams.useNonTeXFonts
+ && !running_lang.empty()
+ && running_lang == openLanguageName()
+ && current_font.language()->encoding()->package() == Encoding::CJK) {
+ string end_tag = subst(lang_end_command, "$$lang", running_lang);
+ os << from_ascii(end_tag);
+ column += end_tag.length();
+ popLanguageName();
}
// Switch file encoding if necessary (and allowed)
}
}
- char_type const c = d->text_[i];
-
// A display math inset inside an ulem command will be output
// as a box of width \linewidth, so we have to either disable
// indentation if the inset starts a paragraph, or start a new
current_font.language() != running_font.language()) &&
i != body_pos - 1)
{
+ bool const in_ct_deletion = (bparams.output_changes
+ && runningChange == change
+ && change.type == Change::DELETED
+ && !os.afterParbreak());
+ if (in_ct_deletion) {
+ // We have to close and then reopen \lyxdeleted,
+ // as strikeout needs to be on lowest level.
+ bool needPar = false;
+ OutputParams rp = runparams;
+ column += running_font.latexWriteEndChanges(
+ os, bparams, rp, basefont,
+ basefont, needPar);
+ os << '}';
+ column += 1;
+ }
odocstringstream ods;
column += current_font.latexWriteStartChanges(ods, bparams,
runparams, basefont,
<< from_ascii("{}");
else
os << fontchange;
+ if (in_ct_deletion) {
+ // We have to close and then reopen \lyxdeleted,
+ // as strikeout needs to be on lowest level.
+ OutputParams rp = runparams;
+ column += Changes::latexMarkChange(os, bparams,
+ Change(Change::UNCHANGED), change, rp);
+ }
}
// FIXME: think about end_pos implementation...
runningChange, style, i, column);
if (incremented)
--parInline;
+
+ if (runparams.ctObject == OutputParams::CT_DISPLAYOBJECT
+ || runparams.ctObject == OutputParams::CT_UDISPLAYOBJECT) {
+ // Close \lyx*deleted and force its
+ // reopening (if needed)
+ os << '}';
+ column++;
+ runningChange = Change(Change::UNCHANGED);
+ runparams.ctObject = OutputParams::CT_NORMAL;
+ }
}
} else if (i >= start_pos && (end_pos == -1 || i < end_pos)) {
if (!bparams.useNonTeXFonts)
}
}
try {
- d->latexSpecialChar(os, bparams, rp, running_font,
+ d->latexSpecialChar(os, bparams, rp, running_font,
alien_script, style, i, end_pos, column);
} catch (EncodingException & e) {
if (runparams.dryrun) {
runparams.post_macro = rp.post_macro;
}
- // Close wrapper for alien script
+ // Close wrapper for alien script
if (!alien_script.empty()) {
os << "}";
alien_script.clear();
- }
+ }
// If we have an open font definition, we have to close it
if (open_font) {
FontShape curr_fs = INHERIT_SHAPE;
FontFamily curr_fam = INHERIT_FAMILY;
- FontSize curr_size = FONT_SIZE_INHERIT;
+ FontSize curr_size = INHERIT_SIZE;
string const default_family =
buf.masterBuffer()->params().fonts_default_family;
if (old_size != curr_size) {
if (size_flag) {
switch (old_size) {
- case FONT_SIZE_TINY:
+ case TINY_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_TINY));
break;
- case FONT_SIZE_SCRIPT:
+ case SCRIPT_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_SCRIPT));
break;
- case FONT_SIZE_FOOTNOTE:
+ case FOOTNOTE_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_FOOTNOTE));
break;
- case FONT_SIZE_SMALL:
+ case SMALL_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_SMALL));
break;
- case FONT_SIZE_LARGE:
+ case LARGE_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_LARGE));
break;
- case FONT_SIZE_LARGER:
+ case LARGER_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_LARGER));
break;
- case FONT_SIZE_LARGEST:
+ case LARGEST_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_LARGEST));
break;
- case FONT_SIZE_HUGE:
+ case HUGE_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_HUGE));
break;
- case FONT_SIZE_HUGER:
+ case HUGER_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_HUGER));
break;
- case FONT_SIZE_INCREASE:
+ case INCREASE_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_INCREASE));
break;
- case FONT_SIZE_DECREASE:
+ case DECREASE_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_DECREASE));
break;
- case FONT_SIZE_INHERIT:
- case FONT_SIZE_NORMAL:
+ case INHERIT_SIZE:
+ case NORMAL_SIZE:
break;
default:
// the other tags are for internal use
size_flag = false;
}
switch (curr_size) {
- case FONT_SIZE_TINY:
+ case TINY_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_TINY));
size_flag = true;
break;
- case FONT_SIZE_SCRIPT:
+ case SCRIPT_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_SCRIPT));
size_flag = true;
break;
- case FONT_SIZE_FOOTNOTE:
+ case FOOTNOTE_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_FOOTNOTE));
size_flag = true;
break;
- case FONT_SIZE_SMALL:
+ case SMALL_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_SMALL));
size_flag = true;
break;
- case FONT_SIZE_LARGE:
+ case LARGE_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_LARGE));
size_flag = true;
break;
- case FONT_SIZE_LARGER:
+ case LARGER_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_LARGER));
size_flag = true;
break;
- case FONT_SIZE_LARGEST:
+ case LARGEST_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_LARGEST));
size_flag = true;
break;
- case FONT_SIZE_HUGE:
+ case HUGE_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_HUGE));
size_flag = true;
break;
- case FONT_SIZE_HUGER:
+ case HUGER_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_HUGER));
size_flag = true;
break;
- case FONT_SIZE_INCREASE:
+ case INCREASE_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_INCREASE));
size_flag = true;
break;
- case FONT_SIZE_DECREASE:
+ case DECREASE_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_DECREASE));
size_flag = true;
break;
- case FONT_SIZE_NORMAL:
- case FONT_SIZE_INHERIT:
+ case NORMAL_SIZE:
+ case INHERIT_SIZE:
break;
default:
// the other tags are for internal use
}
-bool Paragraph::isWordSeparator(pos_type pos) const
+bool Paragraph::isWordSeparator(pos_type pos, bool const ignore_deleted) const
{
if (pos == size())
return true;
+ if (ignore_deleted && isDeleted(pos))
+ return false;
if (Inset const * inset = getInset(pos))
return !inset->isLetter();
// if we have a hard hyphen (no en- or emdash) or apostrophe
void Paragraph::locateWord(pos_type & from, pos_type & to,
- word_location const loc) const
+ word_location const loc, bool const ignore_deleted) const
{
switch (loc) {
case WHOLE_WORD_STRICT:
if (from == 0 || from == size()
- || isWordSeparator(from)
- || isWordSeparator(from - 1)) {
+ || isWordSeparator(from, ignore_deleted)
+ || isWordSeparator(from - 1, ignore_deleted)) {
to = from;
return;
}
case WHOLE_WORD:
// If we are already at the beginning of a word, do nothing
- if (!from || isWordSeparator(from - 1))
+ if (!from || isWordSeparator(from - 1, ignore_deleted))
break;
// fall through
case PREVIOUS_WORD:
// always move the cursor to the beginning of previous word
- while (from && !isWordSeparator(from - 1))
+ while (from && !isWordSeparator(from - 1, ignore_deleted))
--from;
break;
case NEXT_WORD:
break;
}
to = from;
- while (to < size() && !isWordSeparator(to))
+ while (to < size() && !isWordSeparator(to, ignore_deleted))
++to;
}
if (!d->layout_->spellcheck || !inInset().allowSpellCheck())
return result;
- locateWord(from, to, WHOLE_WORD);
+ locateWord(from, to, WHOLE_WORD, true);
if (from == to || from >= size())
return result;