Hi Daniel,

let's move this discussion to kwrite-de...@kde.org.

On Thursday, 16. February 2012 04:01:21 Daniel Nagy wrote:
> Therefore I want to highlight a KTextEditor::Range object in a
> KTextEditor::View object as kdevplatform does it in its duchain
> highlighting.
> [...]
> It seems to me that there are two different highlighting layers.
> First the one that katepart itself provides and your custom one, but I
> am not sure about that.

Right, KatePart internally does syntax highlighting based on the xml-files.
This has nothing to do with Range highlighting.

Additionally to that, i.e. as "overlay", applications (KDevelop, Kate) but
also other code parts like search&replace can add ranges with special
highlighting.

If you have a view pointer, i.e. KTextEditor::View* view, then you can do
the hightlighting as follows:

  KTextEditor::MovingInterface* if =
    qobject_cast<KTextEditor::MovingInterface*>(view->document());

  if (!if) return;

  KTextEditor::Attribute::Ptr attr(new KTextEditor::Attribute());

  attr->setBackground(Qt::yellow);    // yellow background

  KTextEditor::MovingRange* mr = if->newMovingRange(KTextEditor::Range(3, 0, 3, 
20)); // range spans 20 characters
  mr->setAttribute(attr);
  mr->setView(view);                  // only show in this signel view
  mr->setZDepth(-90000.0);            // set the z-depth to slightly worse than 
the selection
  mr->setAttributeOnlyForViews(true); // ignore this highlighting when printing

So basically it's
1. get the MovingInterface,
2. create a newMovingRange,
3. set the attributes.

All this is thoroughly documented in the API documentation (MovingRange, 
MovingInterface):

  
http://api.kde.org/4.x-api/kdelibs-apidocs/interfaces/ktexteditor/html/group__kte__group__moving__classes.html

Greetings,
Dominik

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

Reply via email to