Skip to content
Snippets Groups Projects
Commit 16de34e5 authored by Leandro Melo's avatar Leandro Melo
Browse files

No need to set format when text is normal.

parent 1ce3eb38
No related branches found
No related tags found
No related merge requests found
...@@ -300,35 +300,36 @@ void Highlighter::applyFormat(int offset, ...@@ -300,35 +300,36 @@ void Highlighter::applyFormat(int offset,
try { try {
itemData = definition->itemData(itemDataName); itemData = definition->itemData(itemDataName);
} catch (const HighlighterException &) { } catch (const HighlighterException &) {
// Although the formatting is skipped this case does not break the highlighter. In fact, // There are broken files which Kate can cope with. For instance the Printf context in
// currently there are broken xml definition files which Kate can cope with. For instance, // java.xml points to an inexistent Printf item data. These are taken as normal text.
// the Printf context in java.xml points to an inexistent Printf item data.
return; return;
} }
QTextCharFormat format = m_genericFormats.value(itemData->style()); if (itemData->style() != ItemData::kDsNormal) {
QTextCharFormat format = m_genericFormats.value(itemData->style());
if (itemData->isCustomized()) {
// Please notice that the following are applied every time for item datas which have if (itemData->isCustomized()) {
// customizations. The configureFormats method could be used to provide a "one time" // Please notice that the following are applied every time for item datas which have
// configuration, but it would probably require to traverse all item datas from all // customizations. The configureFormats method could be used to provide a "one time"
// definitions available/loaded (either to set the values or for some "notifying" // configuration, but it would probably require to traverse all item datas from all
// strategy). This is because the highlighter does not really know on which definition(s) // definitions available/loaded (either to set the values or for some "notifying"
// it is working. Since not many item datas specify customizations I think this approach // strategy). This is because the highlighter does not really know on which
// would fit better. If there are other ideas... // definition(s) it is working. Since not many item datas specify customizations I
if (itemData->color().isValid()) // think this approach would fit better. If there are other ideas...
format.setForeground(itemData->color()); if (itemData->color().isValid())
if (itemData->isItalicSpecified()) format.setForeground(itemData->color());
format.setFontItalic(itemData->isItalic()); if (itemData->isItalicSpecified())
if (itemData->isBoldSpecified()) format.setFontItalic(itemData->isItalic());
format.setFontWeight(toFontWeight(itemData->isBold())); if (itemData->isBoldSpecified())
if (itemData->isUnderlinedSpecified()) format.setFontWeight(toFontWeight(itemData->isBold()));
format.setFontUnderline(itemData->isUnderlined()); if (itemData->isUnderlinedSpecified())
if (itemData->isStrikedOutSpecified()) format.setFontUnderline(itemData->isUnderlined());
format.setFontStrikeOut(itemData->isStrikedOut()); if (itemData->isStrikedOutSpecified())
} format.setFontStrikeOut(itemData->isStrikedOut());
}
setFormat(offset, count, format); setFormat(offset, count, format);
}
} }
void Highlighter::applyVisualWhitespaceFormat(const QString &text) void Highlighter::applyVisualWhitespaceFormat(const QString &text)
...@@ -443,8 +444,6 @@ void Highlighter::configureFormats(const TextEditor::FontSettings & fs) ...@@ -443,8 +444,6 @@ void Highlighter::configureFormats(const TextEditor::FontSettings & fs)
m_visualWhitespaceFormat = fs.toTextCharFormat( m_visualWhitespaceFormat = fs.toTextCharFormat(
QLatin1String(TextEditor::Constants::C_VISUAL_WHITESPACE)); QLatin1String(TextEditor::Constants::C_VISUAL_WHITESPACE));
m_genericFormats[ItemData::kDsNormal] = fs.toTextCharFormat(
QLatin1String(TextEditor::Constants::C_TEXT));
m_genericFormats[ItemData::kDsKeyword] = fs.toTextCharFormat( m_genericFormats[ItemData::kDsKeyword] = fs.toTextCharFormat(
QLatin1String(TextEditor::Constants::C_KEYWORD)); QLatin1String(TextEditor::Constants::C_KEYWORD));
m_genericFormats[ItemData::kDsDataType] = fs.toTextCharFormat( m_genericFormats[ItemData::kDsDataType] = fs.toTextCharFormat(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment