[QScintilla] Multiline selection text replacement

Scott Bloom scott at towel42.com
Sun Jun 17 15:47:03 BST 2018


-------- Original message --------
From: Phil Thompson <phil at riverbankcomputing.com>
Date: 6/17/18 04:03 (GMT-08:00)
To: Scott Bloom <scott at towel42.com>
Cc: qscintilla at riverbankcomputing.com
Subject: Re: [QScintilla] Multiline selection text replacement

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

==
Not at all.what I was able to do was the following.

Get the start and end of each individual selection using the get selection n.

Then I clear the selection,

Then I loop over the list of selections I created backwards, and create a new selection one at a time, and replace the appropriate texr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/qscintilla/attachments/20180617/25e16c96/attachment.html>


More information about the QScintilla mailing list