<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div><br>
</div>
<div style="font-size:100%;color:#000000"><!-- originalMessage -->
<div>-------- Original message --------</div>
<div>From: Phil Thompson <phil@riverbankcomputing.com> </div>
<div>Date: 6/17/18 04:03 (GMT-08:00) </div>
<div>To: Scott Bloom <scott@towel42.com> </div>
<div>Cc: qscintilla@riverbankcomputing.com </div>
<div>Subject: Re: [QScintilla] Multiline selection text replacement </div>
<div><br>
</div>
</div>
<font size="2"><span style="font-size:11pt;">
<div class="PlainText">On 15 Jun 2018, at 6:27 pm, Scott Bloom <scott@towel42.com> wrote:<br>
> <br>
> I would like to replace a multiline “rectangle” selection, with new text, separate text per line.<br>
> <br>
> 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.<br>
> <br>
> But when calling ::replaceSelectedText, it drops the whole text at the last selection (the primary selection according to the docs)<br>
> Simple example:<br>
> <br>
> Line [text 1]<br>
> Line [text 2]<br>
> Line [text 3]<br>
> <br>
> Where the [] represent a 3 line multi-line selection.<br>
> <br>
> int numSelections = SendScintilla( SCI_GETSELECTIONS );<br>
> QString txt<br>
> for( int ii = 0; ii < numSelections; ++ii )<br>
> txt += QString(“Line%1\r\n” ).arg( ii );<br>
> replaceSelectedText( txt );<br>
> <br>
> I would like to have<br>
> Line [Line0]<br>
> Line [Line1]<br>
> Line [Line2]<br>
> <br>
> What I get is<br>
> Line<br>
> Line<br>
> Line Line0<br>
> Line1<br>
> Line2<br>
> <br>
> Any thoughts on how to implement this?<br>
<br>
Does SCI_SETMULTIPASTE help?<br>
<br>
Phil</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">==</div>
<div class="PlainText">Not at all.what I was able to do was the following. </div>
<div class="PlainText"><br>
</div>
<div class="PlainText">Get the start and end of each individual selection using the get selection n. </div>
<div class="PlainText"><br>
</div>
<div class="PlainText">Then I clear the selection,</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">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</div>
</span></font>
</body>
</html>