[QScintilla] Multiline selection text replacement

Scott Bloom scott at towel42.com
Fri Jun 15 18:27:20 BST 2018


I would like to replace a multiline "rectangle" selection, with new text, separate text per line.

What I have done so far, is to create a string separated by the editors "eol".  It was a guess, based on ::selectedText() returning a similar string when multiple selections exist.

But when calling ::replaceSelectedText, it drops the whole text at the last selection (the primary selection according to the docs)
Simple example:

Line [text 1]
Line [text 2]
Line [text 3]

Where the [] represent a 3 line multi-line selection.

int numSelections = SendScintilla( SCI_GETSELECTIONS );
QString txt
for( int ii = 0; ii < numSelections; ++ii )
    txt += QString("Line%1\r\n" ).arg( ii );
replaceSelectedText( txt );

I would like to have
Line [Line0]
Line [Line1]
Line [Line2]

What I get is
Line
Line
Line Line0
Line1
Line2

Any thoughts on how to implement this?

Scott
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/qscintilla/attachments/20180615/446e36b8/attachment.html>


More information about the QScintilla mailing list