/* * This sets the folding indent: * 0 for the first line of the diff header. * 1 for all the following lines of the diff header and all @@ lines. * 2 for everything else */ void DiffHighlighter::highlightBlock(const QString &text) { Q_D(DiffHighlighter); if (text.isEmpty()) return; const int length = text.length(); const Internal::DiffFormats format = d->analyzeLine(text); switch (format) { case Internal::DiffTextFormat: break; case Internal::DiffInFormat: { // Mark trailing whitespace. const int trimmedLen = trimmedLength(text); setFormat(0, trimmedLen, formatForCategory(format)); if (trimmedLen != length) setFormat(trimmedLen, length - trimmedLen, d->m_addedTrailingWhiteSpaceFormat); } break; default: setFormat(0, length, formatForCategory(format)); break; } // codefolding: TextEditor::TextBlockUserData *data = TextEditor::TextDocumentLayout::userData(currentBlock()); QTC_ASSERT(data, return; );
/* * This sets the folding indent: * 0 for the first line of the diff header. * 1 for all the following lines of the diff header and all @@ lines. * 2 for everything else */ void DiffAndLogHighlighter::highlightBlock(const QString &text) { if (text.isEmpty()) return; const int length = text.length(); const TextEditor::TextStyle format = d->analyzeLine(text); if (format == TextEditor::C_ADDED_LINE) { // Mark trailing whitespace. const int trimmedLen = trimmedLength(text); setFormatWithSpaces(text, 0, trimmedLen, formatForCategory(format)); if (trimmedLen != length) setFormat(trimmedLen, length - trimmedLen, d->m_addedTrailingWhiteSpaceFormat); } else if (format != TextEditor::C_TEXT) { setFormatWithSpaces(text, 0, length, formatForCategory(format)); } else { formatSpaces(text); } // codefolding: TextEditor::TextBlockUserData *data = TextEditor::TextDocumentLayout::userData(currentBlock()); QTC_ASSERT(data, return; );