19 #include "katearbitraryhighlight.h"
20 #include "katearbitraryhighlight.moc"
22 #include "katesupercursor.h"
23 #include "katedocument.h"
29 KateArbitraryHighlightRange::KateArbitraryHighlightRange(
KateSuperCursor* start,
34 KateArbitraryHighlightRange::KateArbitraryHighlightRange(KateDocument* doc,
const KateRange& range, TQObject* parent,
const char* name)
39 KateArbitraryHighlightRange::KateArbitraryHighlightRange(KateDocument* doc,
const KateTextCursor& start,
const KateTextCursor& end, TQObject* parent,
const char* name)
44 KateArbitraryHighlightRange::~KateArbitraryHighlightRange()
48 KateArbitraryHighlight::KateArbitraryHighlight(KateDocument* parent,
const char* name)
49 : TQObject(parent,
name)
53 KateAttribute KateArbitraryHighlightRange::merge(TQPtrList<KateSuperRange> ranges)
59 if (ranges.first() && ranges.current()->inherits(
"KateArbitraryHighlightRange"))
60 ret = *(
static_cast<KateArbitraryHighlightRange*
>(ranges.current()));
63 while ((r = ranges.next())) {
64 if (r->inherits(
"KateArbitraryHighlightRange")) {
65 KateArbitraryHighlightRange* hl =
static_cast<KateArbitraryHighlightRange*
>(r);
73 void KateArbitraryHighlight::addHighlightToDocument(KateSuperRangeList* list)
75 m_docHLs.append(list);
77 connect(list, TQ_SIGNAL(destroyed(TQObject*)),TQ_SLOT(slotRangeListDeleted(TQObject*)));
80 void KateArbitraryHighlight::addHighlightToView(KateSuperRangeList* list, KateView* view)
83 m_viewHLs.insert(view,
new TQPtrList<KateSuperRangeList>());
85 m_viewHLs[view]->append(list);
89 connect(list, TQ_SIGNAL(destroyed(TQObject*)),TQ_SLOT(slotRangeListDeleted(TQObject*)));
92 void KateArbitraryHighlight::slotRangeListDeleted(TQObject* obj) {
93 int id=m_docHLs.findRef(
static_cast<KateSuperRangeList*
>(obj));
94 if (
id>=0) m_docHLs.take(
id);
96 for (TQMap<KateView*, TQPtrList<KateSuperRangeList>* >::Iterator it = m_viewHLs.begin(); it != m_viewHLs.end(); ++it)
97 for (KateSuperRangeList* l = (*it)->first(); l; l = (*it)->next())
104 KateSuperRangeList& KateArbitraryHighlight::rangesIncluding(uint line, KateView* view)
108 static KateSuperRangeList s_return(
false);
110 Q_ASSERT(!s_return.autoDelete());
114 if (m_docHLs.count() + m_viewHLs.count() == 0)
116 else if (m_docHLs.count() + m_viewHLs.count() == 1)
117 if (m_docHLs.count())
118 return *(m_docHLs.first());
120 if (m_viewHLs.values().first() && m_viewHLs.values().first()->count() == 1)
121 if (m_viewHLs.keys().first() == view && m_viewHLs.values().first())
122 return *(m_viewHLs.values().first()->first());
126 TQPtrList<KateSuperRangeList>* list = m_viewHLs[view];
128 for (KateSuperRangeList* l = list->first(); l; l = list->next())
130 s_return.appendList(l->rangesIncluding(line));
133 for (TQMap<KateView*, TQPtrList<KateSuperRangeList>* >::Iterator it = m_viewHLs.begin(); it != m_viewHLs.end(); ++it)
134 for (KateSuperRangeList* l = (*it)->first(); l; l = (*it)->next())
136 s_return.appendList(l->rangesIncluding(line));
139 for (KateSuperRangeList* l = m_docHLs.first(); l; l = m_docHLs.next())
141 s_return.appendList(l->rangesIncluding(line));
148 emit tagLines(viewForRange(range), range);
151 KateView* KateArbitraryHighlight::viewForRange(
KateSuperRange* range)
153 for (TQMap<KateView*, TQPtrList<KateSuperRangeList>* >::Iterator it = m_viewHLs.begin(); it != m_viewHLs.end(); ++it)
154 for (KateSuperRangeList* l = (*it)->first(); l; l = (*it)->next())
155 if (l->contains(range))
The Attribute class incorporates all text decorations supported by Kate.
Possible additional features:
Represents a range of text, from the start() to the end().
Simple cursor class with no document pointer.
TQString name(StdAccel id)
const TDEShortcut & end()