[QScintilla] Multiline selection text replacement
Phil Thompson
phil at riverbankcomputing.com
Sun Jun 17 12:03:02 BST 2018
On 15 Jun 2018, at 6:27 pm, Scott Bloom <scott at towel42.com> wrote:
>
> 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?
Does SCI_SETMULTIPASTE help?
Phil
More information about the QScintilla
mailing list