Hi,<div><br></div><div><div>I am developing a plugins to Kate[1] with PyKDE .</div><div><br></div><div>In a plugin I want to highlight one piece of a text. Something like this[2]:</div><div><br></div><div><br></div><div> KTextEditor::Attribute::Ptr attr(new KTextEditor::Attribute());</div>
<div> attr->setBackground(Qt::yellow);</div><div> ...</div><div> KTextEditor::MovingRange* mr = miface->newMovingRange(matches.first());</div><div> mr->setAttribute(attr);</div><div><br></div><div>But in python this does not work:</div>
<div><br></div><div> attr = KTextEditor.Attribute(KTextEditor.Attribute())</div><div> attr.setBackground(Qt.yellow)</div><div><br></div><div> si = doc.smartInterface()</div><div> sstart = si.newSmartCursor(start.line()+1, start.column()+1)</div>
<div> send = si.newSmartCursor(end.line()-2, end.column()-2)</div><div> mr = si.newSmartRange(sstart, send)</div><div> mr.setAttribute(attr)</div><div><br></div><div> *** TypeError: argument 1 of SmartRange.setAttribute() has an invalid type</div>
<div><br></div><div>I think that the problem is that I am passing a param of the "KTextEditor::Attribute" class, and I have to pass a param of the "KTextEditor::Attribute::Ptr" class</div><div><br></div>
<div><br></div><div> [1]: <a href="https://github.com/goinnn/Kate-plugins">https://github.com/goinnn/Kate-plugins</a></div><div> [2]: <a href="https://projects.kde.org/projects/kde/kde-baseapps/kate/repository/revisions/master/entry/part/plugins/hlselection/hlselectionplugin.cpp#L144">https://projects.kde.org/projects/kde/kde-baseapps/kate/repository/revisions/master/entry/part/plugins/hlselection/hlselectionplugin.cpp#L144</a></div>
</div><div><br></div><div>Best Regards,</div><div><br></div><div>--</div><div><br></div><div>Pablo Martín</div>