本文整理汇总了C++中ktexteditor::attribute::Ptr::dynamicAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::dynamicAttribute方法的具体用法?C++ Ptr::dynamicAttribute怎么用?C++ Ptr::dynamicAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ktexteditor::attribute::Ptr
的用法示例。
在下文中一共展示了Ptr::dynamicAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NormalRenderRange
QList<QTextLayout::FormatRange> KateRenderer::decorationsForLine( const Kate::TextLine& textLine, int line, bool selectionsOnly, KateRenderRange* completionHighlight, bool completionSelected ) const
{
QList<QTextLayout::FormatRange> newHighlight;
// Don't compute the highlighting if there isn't going to be any highlighting
QList<Kate::TextRange *> rangesWithAttributes = m_doc->buffer().rangesForLine (line, m_printerFriendly ? 0 : m_view, true);
if (selectionsOnly || textLine->attributesList().count() || rangesWithAttributes.count()) {
RenderRangeList renderRanges;
// Add the inbuilt highlighting to the list
NormalRenderRange* inbuiltHighlight = new NormalRenderRange();
const QVector<Kate::TextLineData::Attribute> &al = textLine->attributesList();
for (int i = 0; i < al.count(); ++i)
if (al[i].length > 0 && al[i].attributeValue > 0)
inbuiltHighlight->addRange(new KTextEditor::Range(KTextEditor::Cursor(line, al[i].offset), al[i].length), specificAttribute(al[i].attributeValue));
renderRanges.append(inbuiltHighlight);
if (!completionHighlight) {
// check for dynamic hl stuff
const QSet<Kate::TextRange *> *rangesMouseIn = m_view ? m_view->rangesMouseIn () : 0;
const QSet<Kate::TextRange *> *rangesCaretIn = m_view ? m_view->rangesCaretIn () : 0;
bool anyDynamicHlsActive = m_view && (!rangesMouseIn->empty() || !rangesCaretIn->empty());
// sort all ranges, we want that the most specific ranges win during rendering, multiple equal ranges are kind of random, still better than old smart rangs behavior ;)
qSort (rangesWithAttributes.begin(), rangesWithAttributes.end(), rangeLessThanForRenderer);
// loop over all ranges
for (int i = 0; i < rangesWithAttributes.size(); ++i) {
// real range
Kate::TextRange *kateRange = rangesWithAttributes[i];
// calculate attribute, default: normal attribute
KTextEditor::Attribute::Ptr attribute = kateRange->attribute();
if (anyDynamicHlsActive) {
// check mouse in
if (KTextEditor::Attribute::Ptr attributeMouseIn = attribute->dynamicAttribute (KTextEditor::Attribute::ActivateMouseIn)) {
if (rangesMouseIn->contains (kateRange))
attribute = attributeMouseIn;
}
// check caret in
if (KTextEditor::Attribute::Ptr attributeCaretIn = attribute->dynamicAttribute (KTextEditor::Attribute::ActivateCaretIn)) {
if (rangesCaretIn->contains (kateRange))
attribute = attributeCaretIn;
}
}
// span range
NormalRenderRange *additionaHl = new NormalRenderRange();
additionaHl->addRange(new KTextEditor::Range (*kateRange), attribute);
renderRanges.append(additionaHl);
}
} else {
// Add the code completion arbitrary highlight to the list
renderRanges.append(completionHighlight);
}
// Add selection highlighting if we're creating the selection decorations
if ((selectionsOnly && showSelections() && m_view->selection()) || (completionHighlight && completionSelected) || m_view->blockSelection()) {
NormalRenderRange* selectionHighlight = new NormalRenderRange();
// Set up the selection background attribute TODO: move this elsewhere, eg. into the config?
static KTextEditor::Attribute::Ptr backgroundAttribute;
if (!backgroundAttribute)
backgroundAttribute = KTextEditor::Attribute::Ptr(new KTextEditor::Attribute());
backgroundAttribute->setBackground(config()->selectionColor());
backgroundAttribute->setForeground(attribute(KTextEditor::HighlightInterface::dsNormal)->selectedForeground().color());
// Create a range for the current selection
if (completionHighlight && completionSelected)
selectionHighlight->addRange(new KTextEditor::Range(line, 0, line + 1, 0), backgroundAttribute);
else
if(m_view->blockSelection() && m_view->selectionRange().overlapsLine(line))
selectionHighlight->addRange(new KTextEditor::Range(m_doc->rangeOnLine(m_view->selectionRange(), line)), backgroundAttribute);
else {
selectionHighlight->addRange(new KTextEditor::Range(m_view->selectionRange()), backgroundAttribute);
}
renderRanges.append(selectionHighlight);
// highlighting for the vi visual modes
}
KTextEditor::Cursor currentPosition, endPosition;
// Calculate the range which we need to iterate in order to get the highlighting for just this line
if (selectionsOnly) {
if(m_view->blockSelection()) {
KTextEditor::Range subRange = m_doc->rangeOnLine(m_view->selectionRange(), line);
currentPosition = subRange.start();
endPosition = subRange.end();
} else {
KTextEditor::Range rangeNeeded = m_view->selectionRange() & KTextEditor::Range(line, 0, line + 1, 0);
currentPosition = qMax(KTextEditor::Cursor(line, 0), rangeNeeded.start());
endPosition = qMin(KTextEditor::Cursor(line + 1, 0), rangeNeeded.end());
}
} else {
currentPosition = KTextEditor::Cursor(line, 0);
endPosition = KTextEditor::Cursor(line + 1, 0);
//.........这里部分代码省略.........