Something similar to before might do it. You might need to monkey around with this a bit.
Must admit I would be a little surprised if this works on a Scintilla control created in another process as we are effectively passing a UTF8 buffer across to the other process!
Code: Select all
Procedure Sci_ReplaceLines(hWnd, fromLine, toLine, text$)
Protected numLines, lineLength, startPos, endPos, utf8Text
If toLine >= fromLine And fromLine >=0 And toLine >=0
If SendMessage_(hWnd, #SCI_GETLENGTH, 0, 0)
utf8Text = UTF8(text$)
If utf8Text
numLines = SendMessage_(hWnd, #SCI_GETLINECOUNT, 0, 0)
startPos = SendMessage_(hWnd, #SCI_POSITIONFROMLINE, fromLine, 0)
endPos = SendMessage_(hWnd, #SCI_POSITIONFROMLINE, toLine, 0) + SendMessage_(hWnd, #SCI_LINELENGTH, toLine, 0)
;We may have to delete the EOL characters in the previous line.
If fromLine And fromLine = numLines - 1
Select SendMessage_(hWnd, #SCI_GETEOLMODE, 0, 0)
Case #SC_EOL_CRLF
startPos-2
Default
startpos-1
EndSelect
EndIf
;We now replace the text.
SendMessage_(hWnd, #SCI_SETTARGETSTART, startPos, 0)
SendMessage_(hWnd, #SCI_SETTARGETEND, endPos, 0)
SendMessage_(hWnd, #SCI_REPLACETARGET, -1, utf8Text)
FreeMemory(utf8Text)
EndIf
EndIf
EndIf
EndProcedure
I may look like a mule, but I'm not a complete ass.