Changeset View
Changeset View
Standalone View
Standalone View
src/syntax/katehighlight.cpp
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | |||||
76 | { | 76 | { | ||
77 | /** | 77 | /** | ||
78 | * get name and section, always works | 78 | * get name and section, always works | ||
79 | */ | 79 | */ | ||
80 | iName = def.name(); | 80 | iName = def.name(); | ||
81 | iSection = def.translatedSection(); | 81 | iSection = def.translatedSection(); | ||
82 | 82 | | |||
83 | /** | 83 | /** | ||
84 | * get all included definitions, e.g. PHP for HTML highlighting | ||||
85 | */ | ||||
86 | auto definitions = def.includedDefinitions(); | ||||
87 | | ||||
88 | /** | ||||
84 | * handle the "no highlighting" case | 89 | * handle the "no highlighting" case | ||
90 | * it's possible to not have any defintions with malformed file | ||||
85 | */ | 91 | */ | ||
86 | if (!def.isValid()) { | 92 | if (!def.isValid() || (definitions.isEmpty() && def.formats().isEmpty())) { | ||
87 | // dummy properties + formats | 93 | // dummy properties + formats | ||
88 | m_properties.resize(1); | 94 | m_properties.resize(1); | ||
89 | m_propertiesForFormat.push_back(&m_properties[0]); | 95 | m_propertiesForFormat.push_back(&m_properties[0]); | ||
90 | m_formats.resize(1); | 96 | m_formats.resize(1); | ||
91 | m_formatsIdToIndex.insert(std::make_pair(m_formats[0].id(), 0)); | 97 | m_formatsIdToIndex.insert(std::make_pair(m_formats[0].id(), 0)); | ||
92 | 98 | | |||
93 | // be done, all below is just for the real highlighting variants | 99 | // be done, all below is just for the real highlighting variants | ||
94 | return; | 100 | return; | ||
Show All 11 Lines | |||||
106 | m_foldingIndentationSensitive = def.indentationBasedFoldingEnabled(); | 112 | m_foldingIndentationSensitive = def.indentationBasedFoldingEnabled(); | ||
107 | 113 | | |||
108 | /** | 114 | /** | ||
109 | * tell the AbstractHighlighter the definition it shall use | 115 | * tell the AbstractHighlighter the definition it shall use | ||
110 | */ | 116 | */ | ||
111 | setDefinition(def); | 117 | setDefinition(def); | ||
112 | 118 | | |||
113 | /** | 119 | /** | ||
114 | * get all included definitions, e.g. PHP for HTML highlighting | | |||
115 | */ | | |||
116 | auto definitions = definition().includedDefinitions(); | | |||
117 | | ||||
118 | /** | | |||
119 | * first: handle only really included definitions | 120 | * first: handle only really included definitions | ||
120 | */ | 121 | */ | ||
121 | for (const auto &includedDefinition : definitions) | 122 | for (const auto &includedDefinition : definitions) | ||
122 | embeddedHighlightingModes.push_back(includedDefinition.name()); | 123 | embeddedHighlightingModes.push_back(includedDefinition.name()); | ||
123 | 124 | | |||
124 | /** | 125 | /** | ||
125 | * now: handle all, including this definition itself | 126 | * now: handle all, including this definition itself | ||
126 | * create the format => attributes mapping | 127 | * create the format => attributes mapping | ||
▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Line(s) | 176 | { | |||
246 | } | 247 | } | ||
247 | 248 | | |||
248 | } | 249 | } | ||
249 | 250 | | |||
250 | void KateHighlighting::applyFormat(int offset, int length, const KSyntaxHighlighting::Format &format) | 251 | void KateHighlighting::applyFormat(int offset, int length, const KSyntaxHighlighting::Format &format) | ||
251 | { | 252 | { | ||
252 | // WE ATM assume ascending offset order | 253 | // WE ATM assume ascending offset order | ||
253 | Q_ASSERT(m_textLineToHighlight); | 254 | Q_ASSERT(m_textLineToHighlight); | ||
254 | Q_ASSERT(format.isValid()); | 255 | if (!format.isValid()) { | ||
256 | return; | ||||
257 | } | ||||
255 | 258 | | |||
256 | // get internal attribute, must exist | 259 | // get internal attribute, must exist | ||
257 | const auto it = m_formatsIdToIndex.find(format.id()); | 260 | const auto it = m_formatsIdToIndex.find(format.id()); | ||
258 | Q_ASSERT(it != m_formatsIdToIndex.end()); | 261 | Q_ASSERT(it != m_formatsIdToIndex.end()); | ||
259 | 262 | | |||
260 | // remember highlighting info in our textline | 263 | // remember highlighting info in our textline | ||
261 | m_textLineToHighlight->addAttribute(Kate::TextLineData::Attribute(offset, length, it->second)); | 264 | m_textLineToHighlight->addAttribute(Kate::TextLineData::Attribute(offset, length, it->second)); | ||
262 | } | 265 | } | ||
▲ Show 20 Lines • Show All 403 Lines • Show Last 20 Lines |