namespace lyx {
namespace {
+
/// Inset identifier (above 0x10ffff, for ucs-4)
char_type const META_INSET = 0x200001;
+
}
class SpellCheckerState {
public:
- SpellCheckerState() {
+ SpellCheckerState()
+ {
needs_refresh_ = true;
current_change_number_ = 0;
}
return empty_;
}
- bool needsRefresh() const {
+ bool needsRefresh() const
+ {
return needs_refresh_;
}
- SpellChecker::ChangeNumber currentChangeNumber() const {
+ SpellChecker::ChangeNumber currentChangeNumber() const
+ {
return current_change_number_;
}
- void refreshRange(pos_type & first, pos_type & last) const {
+ void refreshRange(pos_type & first, pos_type & last) const
+ {
first = refresh_.first;
last = refresh_.last;
}
- void needsRefresh(pos_type pos) {
+ void needsRefresh(pos_type pos)
+ {
if (needs_refresh_ && pos != -1) {
if (pos < refresh_.first)
refresh_.first = pos;
needs_refresh_ = pos != -1;
}
- void needsCompleteRefresh(SpellChecker::ChangeNumber change_number) {
+ void needsCompleteRefresh(SpellChecker::ChangeNumber change_number)
+ {
needs_refresh_ = true;
refresh_.first = 0;
refresh_.last = -1;
current_change_number_ = change_number;
}
-
private:
typedef vector<SpellResultRange> Ranges;
typedef Ranges::const_iterator RangesIterator;
///
void latexSpecialChar(
otexstream & os,
+ BufferParams const & bparams,
OutputParams const & runparams,
Font const & running_font,
Change const & running_change,
Language * getSpellLanguage(pos_type const from) const;
Language * locateSpellRange(pos_type & from, pos_type & to,
- SkipPositions & skips) const;
+ SkipPositions & skips) const;
- bool hasSpellerChange() const {
+ bool hasSpellerChange() const
+ {
SpellChecker::ChangeNumber speller_change_number = 0;
if (theSpellChecker())
speller_change_number = theSpellChecker()->changeNumber();
speller_state_.setRange(fp, state);
}
- void requestSpellCheck(pos_type pos) {
+ void requestSpellCheck(pos_type pos)
+ {
if (pos == -1)
speller_state_.needsCompleteRefresh(speller_state_.currentChangeNumber());
else
speller_state_.needsRefresh(pos);
}
- void readySpellCheck() {
+ void readySpellCheck()
+ {
speller_state_.needsRefresh(-1);
}
// FIXME: change tracking
// Is this correct WRT change tracking?
Encoding const & encoding = *(runparams.encoding);
- docstring const latex1 = encoding.latexChar(next).first;
+ docstring latex1 = encoding.latexChar(next).first;
+ if (runparams.inIPA) {
+ string const tipashortcut = Encodings::TIPAShortcut(next);
+ if (!tipashortcut.empty()) {
+ latex1 = from_ascii(tipashortcut);
+ }
+ }
docstring const latex2 = encoding.latexChar(c).first;
if (docstring(1, next) == latex1) {
// the encoding supports the combination
odocstream::pos_type const len = os.os().tellp();
if (inset->forceLTR()
+ && !runparams.use_polyglossia
&& running_font.isRightToLeft()
// ERT is an exception, it should be output with no
// decorations at all
void Paragraph::Private::latexSpecialChar(otexstream & os,
+ BufferParams const & bparams,
OutputParams const & runparams,
Font const & running_font,
Change const & running_change,
pos_type end_pos,
unsigned int & column)
{
- char_type const c = text_[i];
+ // With polyglossia, brackets and stuff need not be reversed
+ // in RTL scripts (see bug #8251)
+ char_type const c = (runparams.use_polyglossia) ?
+ owner_->getUChar(bparams, i) : text_[i];
if (style.pass_thru || runparams.pass_thru) {
if (c != '\0') {
bool Paragraph::Private::latexSpecialT3(char_type const c, otexstream & os,
- pos_type /*i*/, unsigned int & /*column*/)
+ pos_type /*i*/, unsigned int & column)
{
switch (c) {
case '*':
case '[':
case ']':
- case '|':
case '\"':
os.put(c);
return true;
+ case '|':
+ os << "\\textvertline{}";
+ column += 14;
+ return true;
default:
return false;
}
char_type Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const
{
char_type c = d->text_[pos];
- if (!lyxrc.rtl_support)
+ if (!lyxrc.rtl_support || !getFontSettings(bparams, pos).isRightToLeft())
return c;
+ // FIXME: The arabic special casing is due to the difference of arabic
+ // round brackets input introduced in r18599. Check if this should be
+ // unified with Hebrew or at least if all bracket types should be
+ // handled the same (file format change in either case).
+ string const & lang = getFontSettings(bparams, pos).language()->lang();
+ bool const arabic = lang == "arabic_arabtex" || lang == "arabic_arabi"
+ || lang == "farsi";
char_type uc = c;
switch (c) {
case '(':
- uc = ')';
+ uc = arabic ? c : ')';
break;
case ')':
- uc = '(';
+ uc = arabic ? c : '(';
break;
case '[':
uc = ']';
uc = '<';
break;
}
- if (uc != c && getFontSettings(bparams, pos).isRightToLeft())
- return uc;
- return c;
+
+ return uc;
}
} else {
if (i >= start_pos && (end_pos == -1 || i < end_pos)) {
try {
- d->latexSpecialChar(os, rp, running_font, runningChange,
+ d->latexSpecialChar(os, bparams, rp, running_font, runningChange,
style, i, end_pos, column);
} catch (EncodingException & e) {
if (runparams.dryrun) {
retval += inset->xhtml(xs, np);
}
} else {
- char_type c = d->text_[i];
+ char_type c = getUChar(buf.params(), i);
if (style.pass_thru)
xs << c;
wl = WordLangTuple(word, lang);
- if (!word.size())
+ if (word.empty())
return result;
if (needsSpellCheck() || check_learned) {
void Paragraph::spellCheck() const
{
SpellChecker * speller = theSpellChecker();
- if (!speller || !size() ||!needsSpellCheck())
+ if (!speller || empty() ||!needsSpellCheck())
return;
pos_type start;
pos_type endpos;