]> git.lyx.org Git - lyx.git/blobdiff - src/Paragraph.cpp
adjust
[lyx.git] / src / Paragraph.cpp
index df3805d73315385215c05eb9b7fe6b46e125c4b1..9bd4e6e0b5943f52a1d7d130a7fbcd36f82b5f39 100644 (file)
@@ -597,7 +597,7 @@ bool Paragraph::Pimpl::simpleTeXBlanks(Encoding const & encoding,
        if (style.pass_thru)
                return false;
 
-       if (i < size() - 1) {
+       if (i + 1 < size()) {
                char_type next = getChar(i + 1);
                if (Encodings::isCombiningChar(next)) {
                        // This space has an accent, so we must always output it.
@@ -611,7 +611,7 @@ bool Paragraph::Pimpl::simpleTeXBlanks(Encoding const & encoding,
            && column > lyxrc.plaintext_linelen
            && i
            && getChar(i - 1) != ' '
-           && (i < size() - 1)
+           && (i + 1 < size())
            // same in FreeSpacing mode
            && !owner_->isFreeSpacing()
            // In typewriter mode, we want to avoid
@@ -641,15 +641,19 @@ int Paragraph::Pimpl::knownLangChars(odocstream & os,
                                     Encoding const & encoding,
                                     pos_type & i)
 {
-       // The latex command is "\textLANG{<spec>}" and we have to retain
-       // "\textLANG{<spec>" for the first char but only "<spec>" for all
-       // subsequent chars (this also works when we are passed untranslated
-       // unicode).
+       // When the character is marked by the proper language, we simply
+       // get its code point in some encoding, otherwise we get the
+       // translation specified in the unicodesymbols file, which is
+       // something like "\textLANG{<spec>}". So, we have to retain
+       // "\textLANG{<spec>" for the first char but only "<spec>" for
+       // all subsequent chars.
        docstring const latex1 = rtrim(encoding.latexChar(c), "}");
        int length = latex1.length();
        os << latex1;
-       while (i < size() - 1) {
+       while (i + 1 < size()) {
                char_type next = getChar(i + 1);
+               // Stop here if next character belongs to another
+               // language or there is a change tracking status.
                if (!Encodings::isKnownLangChar(next, preamble) ||
                    runningChange != lookupChange(i + 1))
                        break;
@@ -665,6 +669,7 @@ int Paragraph::Pimpl::knownLangChars(odocstream & os,
                        if (cit->pos() >= i + 1)
                                break;
                }
+               // Stop here if there is a font attribute change.
                if (found && cit != end && prev_font != cit->font())
                        break;
                docstring const latex = rtrim(encoding.latexChar(next), "}");
@@ -679,8 +684,8 @@ int Paragraph::Pimpl::knownLangChars(odocstream & os,
                }
                ++i;
        }
-       // When the proper language is set, we are passed the straight unicode,
-       // so we should not try to close the \textLANG command.
+       // When the proper language is set, we are simply passed a code
+       // point, so we should not try to close the \textLANG command.
        if (prefixIs(latex1, from_ascii("\\" + preamble))) {
                os << '}';
                ++length;
@@ -803,7 +808,7 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf,
 
                if ((inset->lyxCode() == GRAPHICS_CODE
                     || inset->lyxCode() == MATH_CODE
-                    || inset->lyxCode() == URL_CODE)
+                    || inset->lyxCode() == HYPERLINK_CODE)
                    && running_font.isRightToLeft()) {
                        if (running_font.language()->lang() == "farsi")
                                os << "\\beginL{}";
@@ -1006,7 +1011,7 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf,
 
                        if (pnr == phrases_nr && c != '\0') {
                                Encoding const & encoding = *(runparams.encoding);
-                               if (i < size() - 1) {
+                               if (i + 1 < size()) {
                                        char_type next = getChar(i + 1);
                                        if (Encodings::isCombiningChar(next)) {
                                                column += latexSurrogatePair(os, c, next, encoding) - 1;
@@ -2429,6 +2434,13 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
 }
 
 
+bool Paragraph::isHfill(pos_type pos) const
+{
+       return isInset(pos)
+               && getInset(pos)->lyxCode() == HFILL_CODE;
+}
+
+
 bool Paragraph::isNewline(pos_type pos) const
 {
        return isInset(pos)