Kate
katehighlight.cpp
Go to the documentation of this file.
129 KateHlContext *KateHighlighting::generateContextStack (Kate::TextLineData::ContextStack &contextStack,
157 contextStack.resize ((modification.pops >= contextStack.size()) ? 0 : (contextStack.size() - modification.pops));
171 contextStack.resize ((modification.pops >= contextStack.size()) ? 0 : (contextStack.size() - modification.pops));
229 // kDebug(13010) << "Dynamic context: using context #" << value << " (for model " << model << " with args " << *args << ")";
246 qDeleteAll(m_contexts.begin()+base_startctx, m_contexts.end()); // delete dynamic contexts (after base_startctx)
288 context = generateContextStack(ctx, contextNum(0)->lineEndContext, previousLine); //get stack ID to use
293 //kDebug(13010) << "\t\tctxNum = " << ctxNum << " contextList[ctxNum] = " << contextList[ctxNum]; // ellis
300 previousLine = ctx.size()-1; //position of the last context ID of th previous line within the stack
306 context = generateContextStack(ctx, context->lineEndContext, previousLine); //get stack ID to use
409 if ( item->lookAhead && ( item->ctx.pops < 2 && item->ctx.newContext == ( ctx.isEmpty() ? 0 : ctx.last() ) ) )
462 textLine->addAttribute (Kate::TextLineData::Attribute (offset, offset2-offset, attribute, item->region2));
559 if (m_foldingIndentationSensitive && (tabWidth > 0) && !textLine->markedAsFoldingStartAttribute ()) {
584 void KateHighlighting::getKateExtendedAttributeList (const QString &schema, QList<KateExtendedAttribute::Ptr> &list, KConfig* cfg)
639 void KateHighlighting::getKateExtendedAttributeListCopy( const QString &schema, QList< KateExtendedAttribute::Ptr >& list, KConfig* cfg )
657 void KateHighlighting::setKateExtendedAttributeList(const QString &schema, QList<KateExtendedAttribute::Ptr> &list, KConfig *cfg, bool writeDefaultsToo)
675 settings<<(p->hasProperty(QTextFormat::ForegroundBrush)?QString::number(p->foreground().color().rgb(),16):(writeDefaultsToo?QString::number(a->foreground().color().rgb(),16):""));
676 settings<<(p->hasProperty(KTextEditor::Attribute::SelectedForeground)?QString::number(p->selectedForeground().color().rgb(),16):(writeDefaultsToo?QString::number(a->selectedForeground().color().rgb(),16):""));
677 settings<<(p->hasProperty(QTextFormat::FontWeight)?(p->fontBold()?"1":"0"):(writeDefaultsToo?(a->fontBold()?"1":"0"):""));
678 settings<<(p->hasProperty(QTextFormat::FontItalic)?(p->fontItalic()?"1":"0"):(writeDefaultsToo?(a->fontItalic()?"1":"0"):""));
679 settings<<(p->hasProperty(QTextFormat::FontStrikeOut)?(p->fontStrikeOut()?"1":"0"):(writeDefaultsToo?(a->fontStrikeOut()?"1":"0"):""));
680 settings<<(p->hasProperty(QTextFormat::FontUnderline)?(p->fontUnderline()?"1":"0"):(writeDefaultsToo?(a->fontUnderline()?"1":"0"):""));
681 settings<<(p->hasProperty(QTextFormat::BackgroundBrush)?QString::number(p->background().color().rgb(),16):((writeDefaultsToo && a->hasProperty(QTextFormat::BackgroundBrush))?QString::number(a->background().color().rgb(),16):""));
682 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):""));
683 settings<<(p->hasProperty(QTextFormat::FontFamily)?(p->fontFamily()):(writeDefaultsToo?a->fontFamily():QString()));
709 void KateHighlighting::addCharacterEncoding( const QString& key, const QString& encoding, const QChar& c )
785 list.append(KateExtendedAttribute::Ptr(new KateExtendedAttribute(i18n("Normal Text"), KTextEditor::HighlightInterface::dsNormal)));
795 KateSyntaxContextData *data = KateHlManager::self()->syntax->getGroupInfo("highlighting","itemData");
808 QString selBgColor = KateHlManager::self()->syntax->groupData(data,QString("selBackgroundColor"));
809 QString spellChecking = KateHlManager::self()->syntax->groupData(data,QString("spellChecking"));
814 KateExtendedAttribute::indexForStyleName(KateHlManager::self()->syntax->groupData(data,QString("defStyleNum")))));
848 int KateHighlighting::lookupAttrName(const QString& name, QList<KateExtendedAttribute::Ptr> &iDl)
887 QString beginRegionStr=KateHlManager::self()->syntax->groupItemData(data,QString("beginRegion"));
928 QString tmpAttr=KateHlManager::self()->syntax->groupItemData(data,QString("attribute")).simplified();
968 const QString & insensitive_str = KateHlManager::self()->syntax->groupItemData(data,QString("insensitive"));
972 bool minimal = IS_TRUE( KateHlManager::self()->syntax->groupItemData(data,QString("minimal")) );
974 // dominik: look ahead and do not change offset. so we can change contexts w/o changing offset1.
975 bool lookAhead = IS_TRUE( KateHlManager::self()->syntax->groupItemData(data,QString("lookAhead")) );
979 bool firstNonSpace = IS_TRUE(KateHlManager::self()->syntax->groupItemData(data,QString("firstNonSpace")) );
1001 else if (dataname=="DetectChar") tmpItem=(new KateHlCharDetect(attr,context,regionId,regionId2,chr));
1002 else if (dataname=="Detect2Chars") tmpItem=(new KateHl2CharDetect(attr,context,regionId,regionId2,chr,chr1));
1003 else if (dataname=="RangeDetect") tmpItem=(new KateHlRangeDetect(attr,context,regionId,regionId2, chr, chr1));
1004 else if (dataname=="LineContinue") tmpItem=(new KateHlLineContinue(attr,context,regionId,regionId2));
1005 else if (dataname=="StringDetect") tmpItem=(new KateHlStringDetect(attr,context,regionId,regionId2,stringdata,insensitive));
1006 else if (dataname=="WordDetect") tmpItem=(new KateHlWordDetect(attr,context,regionId,regionId2,stringdata,insensitive));
1007 else if (dataname=="AnyChar") tmpItem=(new KateHlAnyChar(attr,context,regionId,regionId2,stringdata));
1008 else if (dataname=="RegExpr") tmpItem=(new KateHlRegExpr(attr,context,regionId,regionId2,stringdata, insensitive, minimal));
1013 else if (dataname=="HlCStringChar") tmpItem= (new KateHlCStringChar(attr,context,regionId,regionId2));
1014 else if (dataname=="DetectSpaces") tmpItem= (new KateHlDetectSpaces(attr,context,regionId,regionId2));
1015 else if (dataname=="DetectIdentifier") tmpItem= (new KateHlDetectIdentifier(attr,context,regionId,regionId2));
1048 if(attr < attributeList.length() && attributeList[attr]->hasProperty(KateExtendedAttribute::Spellchecking)) {
1094 return (m_additionalData[ hlKeyForAttrib( attrib ) ]->wordWrapDeliminator.indexOf(c) != -1) && (sq.indexOf(c) == -1);
1115 ( ( !m_additionalData[k]->multiLineCommentStart.isEmpty() && !m_additionalData[k]->multiLineCommentEnd.isEmpty() ) ||
1193 KateSyntaxContextData *data=KateHlManager::self()->syntax->getGroupInfo("general","emptyLine");
1206 bool regexprcase=(KateHlManager::self()->syntax->groupData(data,"casesensitive").toUpper().compare("TRUE")==0);
1243 casesensitive = IS_TRUE( KateHlManager::self()->syntax->groupItemData(data,QString("casesensitive")) );
1246 weakDeliminator=(KateHlManager::self()->syntax->groupItemData(data,QString("weakDeliminator")));
1261 QString addDelim = (KateHlManager::self()->syntax->groupItemData(data,QString("additionalDeliminator")));
1310 wordWrapDeliminator = (KateHlManager::self()->syntax->groupItemData(data,QString("wordWrapDeliminator")));
1333 KateSyntaxContextData *data = KateHlManager::self()->syntax->getConfig("general","indentation");
1359 m_foldingIndentationSensitive = IS_TRUE( KateHlManager::self()->syntax->groupItemData(data, QString("indentationsensitive")) );
1371 kDebug(13010)<<"############################ use indent for fold are: "<<m_foldingIndentationSensitive;
1378 KateSyntaxContextData *data=KateHlManager::self()->syntax->getGroupInfo("spellchecking","encoding");
1413 QString policy = KateHlManager::self()->syntax->groupItemData(data,"encodingReplacementPolicy");
1444 KateSyntaxContextData *data=KateHlManager::self()->syntax->getGroupInfo("highlighting","context");
1456 errorsAndWarnings += i18n("<b>%1</b>: Deprecated syntax. Context %2 has no symbolic name<br />", buildIdentifier, id-ctx0);
1470 KateHlContextModification KateHighlighting::getContextModificationFromString(QStringList *ContextNameList, QString tmpLineEndContext, /*NO CONST*/ QString &unres)
1559 if (noHl) // if this a highlighting for "normal texts" only, tere is no need for a context list creation
1610 kWarning(13010)<<"Unknown highlighting description referenced:" << it.key() << "in" << identifier;
1640 kDebug(13010)<<"Unresolved contexts, which need attention: "<<unresolvedContextReferences.count();
1733 (*it)->incCtx=getContextModificationFromString(&ContextNameList,(*it)->incCtxN,dummy).newContext;
1736 kDebug(13010)<<"Resolved "<<(*it)->incCtxN<< " to "<<(*it)->incCtx.newContext<<" for include rule";
1759 if (index < 0 || index >= list->count()) return; //invalid iterator, shouldn't happen, but better have a rule prepared ;)
1792 kWarning() << "infinite recursion in IncludeRules in language file for " << iName << "in context" << list->at(index1)->incCtxN;
1901 KateSyntaxContextData * data = KateHlManager::self()->syntax->getGroupInfo("highlighting", "context");
1911 QString tmpAttr=KateHlManager::self()->syntax->groupData(data,QString("attribute")).simplified();
1919 QString tmpLineEndContext=KateHlManager::self()->syntax->groupData(data,QString("lineEndContext")).simplified();
1924 QString tmpNIBF = KateHlManager::self()->syntax->groupData(data, QString("noIndentationBasedFolding") );
1933 QString tmpFtc = KateHlManager::self()->syntax->groupData( data, QString("fallthroughContext") );
1947 QString emptyLineContext = KateHlManager::self()->syntax->groupData( data, QString("lineEmptyContext") );
1950 emptyLineContextModification = getContextModificationFromString(&ContextNameList, emptyLineContext, dummy);
1978 if ( tag == "IncludeRules" ) //if the new item is an Include rule, we have to take special care
1981 QString incAttrib = KateHlManager::self()->syntax->groupItemData( data, QString("includeAttrib"));
1999 KateHlIncludeRule *ir=new KateHlIncludeRule(i,m_contexts[i]->items.count(),incCtxN,includeAttrib);
2017 includeRules.append(new KateHlIncludeRule(i,m_contexts[i]->items.count(),incCtx, includeAttrib));
2031 KateHlManager::self()->syntax->groupKateExtendedAttribute( data, QString("context")),dummy); // the index is *required*
2039 kDebug(13010)<<"Context "<<ctxId<<"not defined. You can not include the rules of an undefined context";
2057 c->subItems[c->subItems.size()-1] = createKateHlItem(datasub,iDl,&RegionList,&ContextNameList);
2124 KTextEditor::Attribute::Ptr newAttribute( new KTextEditor::Attribute(*defaultStyleList.at(itemData->defaultStyleIndex())) );
2153 KTextEditor::Attribute::Ptr newAttribute( new KTextEditor::Attribute(*defaultStyleList.at(itemData->defaultStyleIndex())) );
Definition: katehighlight.h:103
This class can be used to efficiently search for occurrences of strings in a given string...
Definition: prefixstore.h:41
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
QScriptValue i18n(QScriptContext *context, QScriptEngine *engine)
i18n("text", arguments [optional])
Definition: katescripthelpers.cpp:186
bool canComment(int startAttr, int endAttr) const
Definition: katehighlight.cpp:1111
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
QScriptValue i18nc(QScriptContext *context, QScriptEngine *engine)
i18nc("context", "text", arguments [optional])
Definition: katescripthelpers.cpp:210
int pops
number of contexts to pop from the stack before pushing a new context on it
Definition: katehighlight.h:100
int defaultStyleIndex() const
Definition: kateextendedattribute.cpp:69
Definition: katehighlighthelpers.h:28
KateHighlighting(const KateSyntaxModeListItem *def)
Definition: katehighlight.cpp:71
static void information(QWidget *parent, const QString &text, const QString &caption=QString(), const QString &dontShowAgainName=QString(), Options options=Notify)
Definition: katehighlighthelpers.h:163
QString getCommentStart(int attrib=0) const
Definition: katehighlight.cpp:1119
void use()
Increase the usage count, and trigger initialization if needed.
Definition: katehighlight.cpp:719
Definition: katehighlighthelpers.h:243
QBrush selectedForeground() const
void writeEntry(const QString &key, const QVariant &value, WriteConfigFlags pFlags=Normal)
void addAttribute(const Attribute &attribute)
Add attribute to this line.
Definition: katetextline.cpp:185
bool isEmptyLine(const Kate::TextLineData *textline) const
Definition: katehighlight.cpp:2171
bool canBreakAt(QChar c, int attrib=0) const
Definition: katehighlight.cpp:1091
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
void setSelectedForeground(const QBrush &foreground)
QString hlKeyForAttrib(int attrib) const
map attribute to its highlighting file.
Definition: katehighlight.cpp:1068
QLinkedList< QRegExp > emptyLines(int attribute=0) const
Definition: katehighlight.cpp:1097
QString getCommentEnd(int attrib=0) const
Definition: katehighlight.cpp:1124
KSharedConfigPtr config()
virtual void capturedTexts(QStringList &)
Definition: katehighlighthelpers.h:42
Definition: katehighlighthelpers.h:227
bool fontBold() const
const KatePrefixStore & getCharacterEncodingsPrefixStore(int attrib) const
Definition: katehighlight.cpp:694
describe a modification of the context stack
Definition: katehighlight.h:61
Definition: katehighlighthelpers.h:72
CSLPos getCommentSingleLinePosition(int attrib=0) const
Definition: katehighlight.cpp:1134
void setDefaultStyleIndex(int index)
Definition: kateextendedattribute.cpp:74
bool attributeRequiresSpellchecking(int attr)
Definition: katehighlight.cpp:1045
bool hasAnyProperty() const
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
Definition: katehighlighthelpers.h:172
signed char commentRegion(int attr) const
Definition: katehighlight.cpp:1106
int getEncodedCharactersInsertionPolicy(int attrib) const
Definition: katehighlight.cpp:704
KateHlContextModification emptyLineContextModification
Definition: katehighlighthelpers.h:99
const QHash< QString, QChar > & characterEncodings(int attrib=0) const
Definition: katehighlight.cpp:1139
bool noIndentationBasedFolding
Definition: katehighlighthelpers.h:96
bool performSpellchecking() const
Definition: kateextendedattribute.cpp:79
void markAsFoldingStartIndentation()
Mark as folding start line of an indentation based folding.
Definition: katetextline.h:257
Definition: katehighlighthelpers.h:280
KateHlContext * clone(const QStringList *args)
Definition: katehighlighthelpers.cpp:845
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:2134
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
void setSelectedBackground(const QBrush &brush)
void setFontBold(bool bold=true)
Definition: katehighlighthelpers.h:320
const QHash< QChar, QString > & getReverseCharacterEncodings(int attrib) const
Definition: katehighlight.cpp:699
void markAsFoldingStartAttribute()
Mark as folding start line of an attribute based folding.
Definition: katetextline.h:248
Definition: katehighlighthelpers.h:218
Definition: katehighlighthelpers.h:253
void setContextStack(const ContextStack &val)
Sets the syntax highlight context number.
Definition: katetextline.h:350
Definition: katehighlighthelpers.h:235
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:2166
Definition: katehighlighthelpers.h:135
QBrush selectedBackground() const
Definition: katehighlighthelpers.h:261
Definition: katehighlighthelpers.h:123
bool markedAsFoldingStartAttribute() const
Is on this line a folding start per attribute?
Definition: katetextline.h:231
void doHighlight(const Kate::TextLineData *prevLine, Kate::TextLineData *textLine, const Kate::TextLineData *nextLine, bool &ctxChanged, int tabWidth=0)
Parse the text and fill in the context array and folding list array.
Definition: katehighlight.cpp:253
void getKateExtendedAttributeList(const QString &schema, QList< KateExtendedAttribute::Ptr > &, KConfig *cfg=0)
Definition: katehighlight.cpp:584
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
Definition: katehighlighthelpers.h:149
static int indexForStyleName(const QString &name)
Definition: kateextendedattribute.cpp:34
QString getCommentSingleLineStart(int attrib=0) const
Definition: katehighlight.cpp:1129
const QHash< QString, QChar > & getCharacterEncodings(int attrib) const
Definition: katehighlight.cpp:689
QString hlId
A unique highlight identifier. Used to look up correct properties.
Definition: katehighlighthelpers.h:83
Definition: katehighlighthelpers.h:269
QSharedPointer< TextLineData > TextLine
The normal world only accesses the text lines with shared pointers.
Definition: katetextline.h:443
void setName(const QString &name)
Definition: kateextendedattribute.cpp:59
int firstChar() const
Returns the position of the first non-whitespace character.
Definition: katetextline.cpp:40
Definition: katehighlighthelpers.h:201
static void detailedSorry(QWidget *parent, const QString &text, const QString &details, const QString &caption=QString(), Options options=Notify)
void getDefaults(const QString &schema, KateAttributeList &, KConfig *cfg=0)
Definition: katesyntaxmanager.cpp:177
static QDebug kWarning(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
const QString & string() const
Returns the complete text line (as a QString reference).
Definition: katetextline.h:286
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:657
Definition: katehighlighthelpers.h:209
void getKateExtendedAttributeListCopy(const QString &schema, QList< KateExtendedAttribute::Ptr > &, KConfig *cfg=0)
Definition: katehighlight.cpp:639
virtual int checkHgl(const QString &text, int offset, int len)=0
Definition: katehighlighthelpers.h:102
QString hlKeyForContext(int attrib) const
Definition: katehighlight.cpp:1054
CSLPos
This enum is used for storing the information where a single line comment marker should be inserted...
Definition: katehighlight.h:219
Definition: katehighlighthelpers.h:306
const QString & staticQString(const char *str)
void release()
Decrease the usage count, and trigger cleanup if needed.
Definition: katehighlight.cpp:730
bool isInWord(QChar c, int attrib=0) const
Definition: katehighlight.cpp:1084
Definition: katedocument.h:1144
QString identifierForName(const QString &)
Definition: katesyntaxmanager.cpp:380
const KShortcut & end()
T readEntry(const QString &key, const T &aDefault) const
Class holding the data around the current QDomElement.
Definition: katesyntaxdocument.h:62
Definition: katedocument.h:1144
void setPerformSpellchecking(bool spellchecking)
Definition: kateextendedattribute.cpp:84
void clear()
KateSyntaxContextData * getGroupInfo(const QString &mainGroupName, const QString &group)
Get the KateSyntaxContextData of the QDomElement Config inside mainGroupName KateSyntaxContextData::p...
Definition: katesyntaxdocument.cpp:278
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
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:52 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:52 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.