Kate
katehighlight.cpp
Go to the documentation of this file.
155 KateHlContext *KateHighlighting::generateContextStack (Kate::TextLineData::ContextStack &contextStack,
183 contextStack.resize ((modification.pops >= contextStack.size()) ? 0 : (contextStack.size() - modification.pops));
197 contextStack.resize ((modification.pops >= contextStack.size()) ? 0 : (contextStack.size() - modification.pops));
255 // kDebug(13010) << "Dynamic context: using context #" << value << " (for model " << model << " with args " << *args << ")";
272 qDeleteAll(m_contexts.begin()+base_startctx, m_contexts.end()); // delete dynamic contexts (after base_startctx)
315 context = generateContextStack(ctx, contextNum(0)->lineEndContext, previousLine); //get stack ID to use
320 //kDebug(13010) << "\t\tctxNum = " << ctxNum << " contextList[ctxNum] = " << contextList[ctxNum]; // ellis
327 previousLine = ctx.size()-1; //position of the last context ID of th previous line within the stack
333 context = generateContextStack(ctx, context->lineEndContext, previousLine); //get stack ID to use
444 if ( item->lookAhead && ( item->ctx.pops < 2 && item->ctx.newContext == ( ctx.isEmpty() ? 0 : ctx.last() ) ) )
497 textLine->addAttribute (Kate::TextLineData::Attribute (offset, offset2-offset, attribute, item->region2));
594 if (m_foldingIndentationSensitive && (tabWidth > 0) && !textLine->markedAsFoldingStartAttribute ()) {
619 void KateHighlighting::getKateExtendedAttributeList (const QString &schema, QList<KateExtendedAttribute::Ptr> &list, KConfig* cfg)
668 void KateHighlighting::getKateExtendedAttributeListCopy( const QString &schema, QList< KateExtendedAttribute::Ptr >& list, KConfig* cfg )
686 void KateHighlighting::setKateExtendedAttributeList(const QString &schema, QList<KateExtendedAttribute::Ptr> &list, KConfig *cfg, bool writeDefaultsToo)
704 settings<<(p->hasProperty(QTextFormat::ForegroundBrush)?QString::number(p->foreground().color().rgb(),16):(writeDefaultsToo?QString::number(a->foreground().color().rgb(),16):""));
705 settings<<(p->hasProperty(KTextEditor::Attribute::SelectedForeground)?QString::number(p->selectedForeground().color().rgb(),16):(writeDefaultsToo?QString::number(a->selectedForeground().color().rgb(),16):""));
706 settings<<(p->hasProperty(QTextFormat::FontWeight)?(p->fontBold()?"1":"0"):(writeDefaultsToo?(a->fontBold()?"1":"0"):""));
707 settings<<(p->hasProperty(QTextFormat::FontItalic)?(p->fontItalic()?"1":"0"):(writeDefaultsToo?(a->fontItalic()?"1":"0"):""));
708 settings<<(p->hasProperty(QTextFormat::FontStrikeOut)?(p->fontStrikeOut()?"1":"0"):(writeDefaultsToo?(a->fontStrikeOut()?"1":"0"):""));
709 settings<<(p->hasProperty(QTextFormat::FontUnderline)?(p->fontUnderline()?"1":"0"):(writeDefaultsToo?(a->fontUnderline()?"1":"0"):""));
710 settings<<(p->hasProperty(QTextFormat::BackgroundBrush)?QString::number(p->background().color().rgb(),16):((writeDefaultsToo && a->hasProperty(QTextFormat::BackgroundBrush))?QString::number(a->background().color().rgb(),16):""));
711 settings<<(p->hasProperty(KTextEditor::Attribute::SelectedBackground)?QString::number(p->selectedBackground().color().rgb(),16):((writeDefaultsToo&& a->hasProperty(KTextEditor::Attribute::SelectedBackground))?QString::number(a->selectedBackground().color().rgb(),16):""));
712 settings<<(p->hasProperty(QTextFormat::FontFamily)?(p->fontFamily()):(writeDefaultsToo?a->fontFamily():QString()));
738 void KateHighlighting::addCharacterEncoding( const QString& key, const QString& encoding, const QChar& c )
817 list.append(KateExtendedAttribute::Ptr(new KateExtendedAttribute(i18n("Normal Text"), KTextEditor::HighlightInterface::dsNormal)));
827 KateSyntaxContextData *data = KateHlManager::self()->syntax->getGroupInfo("highlighting","itemData");
841 QString selBgColor = KateHlManager::self()->syntax->groupData(data,QString("selBackgroundColor"));
842 QString spellChecking = KateHlManager::self()->syntax->groupData(data,QString("spellChecking"));
847 KateExtendedAttribute::indexForStyleName(KateHlManager::self()->syntax->groupData(data,QString("defStyleNum")))));
851 newData->setForeground(colors.adaptToScheme(QColor(color), KateDefaultColors::ForegroundColor));
853 newData->setSelectedForeground(colors.adaptToScheme(QColor(selColor), KateDefaultColors::ForegroundColor));
860 newData->setBackground(colors.adaptToScheme(QColor(bgColor), KateDefaultColors::BackgroundColor));
862 newData->setSelectedBackground(colors.adaptToScheme(QColor(selBgColor), KateDefaultColors::BackgroundColor));
885 int KateHighlighting::lookupAttrName(const QString& name, QList<KateExtendedAttribute::Ptr> &iDl)
925 QString beginRegionStr=KateHlManager::self()->syntax->groupItemData(data,QString("beginRegion"));
966 QString tmpAttr=KateHlManager::self()->syntax->groupItemData(data,QString("attribute")).simplified();
1006 const QString & insensitive_str = KateHlManager::self()->syntax->groupItemData(data,QString("insensitive"));
1010 bool minimal = IS_TRUE( KateHlManager::self()->syntax->groupItemData(data,QString("minimal")) );
1012 // dominik: look ahead and do not change offset. so we can change contexts w/o changing offset1.
1013 bool lookAhead = IS_TRUE( KateHlManager::self()->syntax->groupItemData(data,QString("lookAhead")) );
1017 bool firstNonSpace = IS_TRUE(KateHlManager::self()->syntax->groupItemData(data,QString("firstNonSpace")) );
1039 else if (dataname=="DetectChar") tmpItem=(new KateHlCharDetect(attr,context,regionId,regionId2,chr));
1040 else if (dataname=="Detect2Chars") tmpItem=(new KateHl2CharDetect(attr,context,regionId,regionId2,chr,chr1));
1041 else if (dataname=="RangeDetect") tmpItem=(new KateHlRangeDetect(attr,context,regionId,regionId2, chr, chr1));
1042 else if (dataname=="LineContinue") tmpItem=(new KateHlLineContinue(attr, context, regionId, regionId2, chr));
1043 else if (dataname=="StringDetect") tmpItem=(new KateHlStringDetect(attr,context,regionId,regionId2,stringdata,insensitive));
1044 else if (dataname=="WordDetect") tmpItem=(new KateHlWordDetect(attr,context,regionId,regionId2,stringdata,insensitive));
1045 else if (dataname=="AnyChar") tmpItem=(new KateHlAnyChar(attr,context,regionId,regionId2,stringdata));
1046 else if (dataname=="RegExpr") tmpItem=(new KateHlRegExpr(attr,context,regionId,regionId2,stringdata, insensitive, minimal));
1051 else if (dataname=="HlCStringChar") tmpItem= (new KateHlCStringChar(attr,context,regionId,regionId2));
1052 else if (dataname=="DetectSpaces") tmpItem= (new KateHlDetectSpaces(attr,context,regionId,regionId2));
1053 else if (dataname=="DetectIdentifier") tmpItem= (new KateHlDetectIdentifier(attr,context,regionId,regionId2));
1086 if(attr < attributeList.length() && attributeList[attr]->hasProperty(KateExtendedAttribute::Spellchecking)) {
1132 return (m_additionalData[ hlKeyForAttrib( attrib ) ]->wordWrapDeliminator.indexOf(c) != -1) && (sq.indexOf(c) == -1);
1153 ( ( !m_additionalData[k]->multiLineCommentStart.isEmpty() && !m_additionalData[k]->multiLineCommentEnd.isEmpty() ) ||
1231 KateSyntaxContextData *data=KateHlManager::self()->syntax->getGroupInfo("general","emptyLine");
1244 bool regexprcase=(KateHlManager::self()->syntax->groupData(data,"casesensitive").toUpper().compare("TRUE")==0);
1281 casesensitive = IS_TRUE( KateHlManager::self()->syntax->groupItemData(data,QString("casesensitive")) );
1284 weakDeliminator=(KateHlManager::self()->syntax->groupItemData(data,QString("weakDeliminator")));
1299 QString addDelim = (KateHlManager::self()->syntax->groupItemData(data,QString("additionalDeliminator")));
1348 wordWrapDeliminator = (KateHlManager::self()->syntax->groupItemData(data,QString("wordWrapDeliminator")));
1371 KateSyntaxContextData *data = KateHlManager::self()->syntax->getConfig("general","indentation");
1397 m_foldingIndentationSensitive = IS_TRUE( KateHlManager::self()->syntax->groupItemData(data, QString("indentationsensitive")) );
1409 kDebug(13010)<<"############################ use indent for fold are: "<<m_foldingIndentationSensitive;
1416 KateSyntaxContextData *data=KateHlManager::self()->syntax->getGroupInfo("spellchecking","encoding");
1451 QString policy = KateHlManager::self()->syntax->groupItemData(data,"encodingReplacementPolicy");
1482 KateSyntaxContextData *data=KateHlManager::self()->syntax->getGroupInfo("highlighting","context");
1494 errorsAndWarnings += i18n("<b>%1</b>: Deprecated syntax. Context %2 has no symbolic name<br />", buildIdentifier, id-ctx0);
1508 KateHlContextModification KateHighlighting::getContextModificationFromString(QStringList *ContextNameList, QString tmpLineEndContext, /*NO CONST*/ QString &unres)
1597 if (noHl) // if this a highlighting for "normal texts" only, tere is no need for a context list creation
1648 kWarning(13010)<<"Unknown highlighting description referenced:" << it.key() << "in" << identifier;
1678 kDebug(13010)<<"Unresolved contexts, which need attention: "<<unresolvedContextReferences.count();
1771 (*it)->incCtx=getContextModificationFromString(&ContextNameList,(*it)->incCtxN,dummy).newContext;
1774 kDebug(13010)<<"Resolved "<<(*it)->incCtxN<< " to "<<(*it)->incCtx.newContext<<" for include rule";
1797 if (index < 0 || index >= list->count()) return; //invalid iterator, shouldn't happen, but better have a rule prepared ;)
1830 kWarning() << "infinite recursion in IncludeRules in language file for " << iName << "in context" << list->at(index1)->incCtxN;
1939 KateSyntaxContextData * data = KateHlManager::self()->syntax->getGroupInfo("highlighting", "context");
1949 QString tmpAttr=KateHlManager::self()->syntax->groupData(data,QString("attribute")).simplified();
1957 QString tmpLineEndContext=KateHlManager::self()->syntax->groupData(data,QString("lineEndContext")).simplified();
1962 QString tmpNIBF = KateHlManager::self()->syntax->groupData(data, QString("noIndentationBasedFolding") );
1971 QString tmpFtc = KateHlManager::self()->syntax->groupData( data, QString("fallthroughContext") );
1985 QString emptyLineContext = KateHlManager::self()->syntax->groupData( data, QString("lineEmptyContext") );
1988 emptyLineContextModification = getContextModificationFromString(&ContextNameList, emptyLineContext, dummy);
2016 if ( tag == "IncludeRules" ) //if the new item is an Include rule, we have to take special care
2019 QString incAttrib = KateHlManager::self()->syntax->groupItemData( data, QString("includeAttrib"));
2037 KateHlIncludeRule *ir=new KateHlIncludeRule(i,m_contexts[i]->items.count(),incCtxN,includeAttrib);
2055 includeRules.append(new KateHlIncludeRule(i,m_contexts[i]->items.count(),incCtx, includeAttrib));
2069 KateHlManager::self()->syntax->groupKateExtendedAttribute( data, QString("context")),dummy); // the index is *required*
2077 kDebug(13010)<<"Context "<<ctxId<<"not defined. You can not include the rules of an undefined context";
2095 c->subItems[c->subItems.size()-1] = createKateHlItem(datasub,iDl,&RegionList,&ContextNameList);
2162 KTextEditor::Attribute::Ptr newAttribute( new KTextEditor::Attribute(*defaultStyleList.at(itemData->defaultStyleIndex())) );
2191 KTextEditor::Attribute::Ptr newAttribute( new KTextEditor::Attribute(*defaultStyleList.at(itemData->defaultStyleIndex())) );
Definition: katehighlight.h:103
bool hasNext() const
void clear()
This class can be used to efficiently search for occurrences of strings in a given string...
Definition: prefixstore.h:41
QColor adaptToScheme(const QColor &color, ColorType type) const
Definition: katedefaultcolors.cpp:119
void freeGroupInfo(KateSyntaxContextData *data)
Definition: katesyntaxdocument.cpp:196
short attribute(int pos) const
Gets the attribute at the given position use KRenderer::attributes to get the KTextAttribute for this...
Definition: katetextline.h:376
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
QScriptValue i18n(QScriptContext *context, QScriptEngine *engine)
i18n("text", arguments [optional])
Definition: katescripthelpers.cpp:186
iterator insert(const Key &key, const T &value)
bool canComment(int startAttr, int endAttr) const
Definition: katehighlight.cpp:1149
QString toUpper() const
short toShort(bool *ok, int base) const
bool contains(const Key &key) const
int indentDepth(int tabWidth) const
Returns the indentation depth with each tab expanded into tabWidth characters.
Definition: katetextline.cpp:81
KateSyntaxContextData * getSubItems(KateSyntaxContextData *data)
Definition: katesyntaxdocument.cpp:201
void append(const T &value)
iterator begin()
void append(const T &t)
QScriptValue i18nc(QScriptContext *context, QScriptEngine *engine)
i18nc("context", "text", arguments [optional])
Definition: katescripthelpers.cpp:210
int length() const
int pops
number of contexts to pop from the stack before pushing a new context on it
Definition: katehighlight.h:100
Definition: katehighlighthelpers.h:28
KateHighlighting(const KateSyntaxModeListItem *def)
Definition: katehighlight.cpp:83
Definition: katehighlighthelpers.h:163
KSharedPtr< KateExtendedAttribute > Ptr
Definition: kateextendedattribute.h:38
QString getCommentStart(int attrib=0) const
Definition: katehighlight.cpp:1157
const_iterator constBegin() const
const T & at(int i) const
void use()
Increase the usage count, and trigger initialization if needed.
Definition: katehighlight.cpp:748
T & last()
QString simplified() const
Definition: katehighlighthelpers.h:244
iterator erase(iterator pos)
const_iterator constFind(const Key &key) const
void addAttribute(const Attribute &attribute)
Add attribute to this line.
Definition: katetextline.cpp:185
bool isEmptyLine(const Kate::TextLineData *textline) const
Definition: katehighlight.cpp:2209
bool canBreakAt(QChar c, int attrib=0) const
Definition: katehighlight.cpp:1129
QString & remove(int position, int n)
void clear()
QString hlKeyForAttrib(int attrib) const
map attribute to its highlighting file.
Definition: katehighlight.cpp:1106
QLinkedList< QRegExp > emptyLines(int attribute=0) const
Definition: katehighlight.cpp:1135
QString getCommentEnd(int attrib=0) const
Definition: katehighlight.cpp:1162
int size() const
virtual void capturedTexts(QStringList &)
Definition: katehighlighthelpers.h:42
Definition: katehighlighthelpers.h:228
const KatePrefixStore & getCharacterEncodingsPrefixStore(int attrib) const
Definition: katehighlight.cpp:723
void clear()
describe a modification of the context stack
Definition: katehighlight.h:61
Definition: katehighlighthelpers.h:72
QList< Key > keys() const
CSLPos getCommentSingleLinePosition(int attrib=0) const
Definition: katehighlight.cpp:1172
bool attributeRequiresSpellchecking(int attr)
Definition: katehighlight.cpp:1083
void clear()
int newContext
new context to push on the stack if this is < 0, push nothing on the stack
Definition: katehighlight.h:94
KateHlContextModification lineEndContext
Definition: katehighlighthelpers.h:85
QWidget * activeWindow()
Definition: katehighlighthelpers.h:172
QString number(int n, int base)
int count(const T &value) const
void append(const T &value)
bool isSpace() const
signed char commentRegion(int attr) const
Definition: katehighlight.cpp:1144
void clear()
int getEncodedCharactersInsertionPolicy(int attrib) const
Definition: katehighlight.cpp:733
void resize(int size)
KateHlContextModification emptyLineContextModification
Definition: katehighlighthelpers.h:99
bool empty() const
bool isEmpty() const
const QHash< QString, QChar > & characterEncodings(int attrib=0) const
Definition: katehighlight.cpp:1177
bool noIndentationBasedFolding
Definition: katehighlighthelpers.h:96
void markAsFoldingStartIndentation()
Mark as folding start line of an indentation based folding.
Definition: katetextline.h:257
Definition: katehighlighthelpers.h:284
KateHlContext * clone(const QStringList *args)
Definition: katehighlighthelpers.cpp:859
QString groupData(const KateSyntaxContextData *data, const QString &name)
Definition: katesyntaxdocument.cpp:181
bool nextItem(KateSyntaxContextData *data)
Jump to the next item, KateSyntaxContextData::item will point to the next item.
Definition: katesyntaxdocument.cpp:133
QList< KTextEditor::Attribute::Ptr > attributes(const QString &schema)
Definition: katehighlight.cpp:2172
int toInt(bool *ok, int base) const
KateSyntaxContextData * getConfig(const QString &mainGroupName, const QString &config)
Get the KateSyntaxContextData of the DomElement Config inside mainGroupName It just fills KateSyntaxC...
Definition: katesyntaxdocument.cpp:262
bool isEmpty() const
bool isEmpty() const
const_iterator constEnd() const
Definition: katehighlighthelpers.h:324
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
const QHash< QChar, QString > & getReverseCharacterEncodings(int attrib) const
Definition: katehighlight.cpp:728
Item next()
void markAsFoldingStartAttribute()
Mark as folding start line of an attribute based folding.
Definition: katetextline.h:248
Definition: katehighlighthelpers.h:219
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
Definition: katehighlighthelpers.h:257
void setContextStack(const ContextStack &val)
Sets the syntax highlight context number.
Definition: katetextline.h:350
T & front()
iterator end()
Definition: katehighlighthelpers.h:236
iterator begin()
iterator erase(iterator pos)
bool hlLineContinue() const
Returns true, if the line's hl-continue flag is set, otherwise returns false.
Definition: katetextline.h:273
QStringList getEmbeddedHighlightingModes() const
Returns a list of names of embedded modes.
Definition: katehighlight.cpp:2204
Definition: katehighlighthelpers.h:135
Definition: katedefaultcolors.h:70
void clear()
iterator end()
QString toLower() const
iterator find(const Key &key)
T & value()
bool contains(QChar ch, Qt::CaseSensitivity cs) const
Definition: katehighlighthelpers.h:265
Definition: katehighlighthelpers.h:123
bool markedAsFoldingStartAttribute() const
Is on this line a folding start per attribute?
Definition: katetextline.h:231
void getKateExtendedAttributeList(const QString &schema, QList< KateExtendedAttribute::Ptr > &, KConfig *cfg=0)
Definition: katehighlight.cpp:619
Definition: katehighlighthelpers.h:184
bool setIdentifier(const QString &identifier)
If the open hl file is different from the one needed, it opens the new one and assign some other thin...
Definition: katesyntaxdocument.cpp:59
const Key key(const T &value) const
Definition: katehighlighthelpers.h:149
QString & replace(int position, int n, QChar after)
static int indexForStyleName(const QString &name)
Definition: kateextendedattribute.cpp:34
QString mid(int position, int n) const
const Key & key() const
QString getCommentSingleLineStart(int attrib=0) const
Definition: katehighlight.cpp:1167
bool isEmpty() const
bool isEmpty() const
const QHash< QString, QChar > & getCharacterEncodings(int attrib) const
Definition: katehighlight.cpp:718
QString hlId
A unique highlight identifier. Used to look up correct properties.
Definition: katehighlighthelpers.h:83
Definition: katehighlighthelpers.h:273
QChar fromAscii(char c)
int firstChar() const
Returns the position of the first non-whitespace character.
Definition: katetextline.cpp:40
Definition: katehighlighthelpers.h:202
int length() const
void getDefaults(const QString &schema, KateAttributeList &, KConfig *cfg=0)
Definition: katesyntaxmanager.cpp:177
const QString & string() const
Returns the complete text line (as a QString reference).
Definition: katetextline.h:286
QString left(int n) const
void setKateExtendedAttributeList(const QString &schema, QList< KateExtendedAttribute::Ptr > &, KConfig *cfg=0, bool writeDefaultsToo=false)
Saves the attribute definitions to the config file.
Definition: katehighlight.cpp:686
void push_back(const T &value)
Definition: katehighlighthelpers.h:210
void getKateExtendedAttributeListCopy(const QString &schema, QList< KateExtendedAttribute::Ptr > &, KConfig *cfg=0)
Definition: katehighlight.cpp:668
virtual int checkHgl(const QString &text, int offset, int len)=0
int indexOf(const QRegExp &rx, int from) const
iterator insert(const Key &key, const T &value)
bool contains(const Key &key) const
Definition: katehighlighthelpers.h:102
QString hlKeyForContext(int attrib) const
Definition: katehighlight.cpp:1092
CSLPos
This enum is used for storing the information where a single line comment marker should be inserted...
Definition: katehighlight.h:227
Definition: katehighlighthelpers.h:310
iterator end()
void release()
Decrease the usage count, and trigger cleanup if needed.
Definition: katehighlight.cpp:759
int size() const
bool isInWord(QChar c, int attrib=0) const
Definition: katehighlight.cpp:1122
Definition: katedocument.h:1146
QString identifierForName(const QString &)
Definition: katesyntaxmanager.cpp:380
int compare(const QString &other) const
bool exactMatch(const QString &str) const
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
int size() const
void doHighlight(const Kate::TextLineData *prevLine, Kate::TextLineData *textLine, const Kate::TextLineData *nextLine, bool &ctxChanged, int tabWidth=0, QVector< ContextChange > *contextChanges=0)
Parse the text and fill in the context array and folding list array.
Definition: katehighlight.cpp:279
iterator end()
bool removeOne(const T &value)
Class holding the data around the current QDomElement.
Definition: katesyntaxdocument.h:62
Definition: katedocument.h:1146
int count(const Key &key) const
iterator begin()
KateSyntaxContextData * getGroupInfo(const QString &mainGroupName, const QString &group)
Get the KateSyntaxContextData of the QDomElement Config inside mainGroupName KateSyntaxContextData::p...
Definition: katesyntaxdocument.cpp:278
void append(const T &value)
An extension of the KTextEditor::Attribute class, with convenience functions for access to extra kate...
Definition: kateextendedattribute.h:35
QString groupItemData(const KateSyntaxContextData *data, const QString &name)
This function is used to fetch the atributes of the tags.
Definition: katesyntaxdocument.cpp:161
const T value(const Key &key) const
uint toUInt(bool *ok, int base) const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.