<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Is there a SCI_SETLINE type message (How to update a line)]]></title><description><![CDATA[<p dir="auto">I’m developing a Notepad++ plugin that allows a user to select a set of lines and then invoke the plugin to manipulate the lines and then update in Notepad++.</p>
<p dir="auto">I use the selection information to identify the lines to process. I iterate through the selected lines. Each line is read using SCI_GETLINE, modified, and then written back to Notepad++.  The modification may cause the line length to increase but it will never decrease.  What is the simplest way to write the line back to Notepad++?  I was looking for a message like SCI_SETLINE which I did not find.</p>
<p dir="auto">For another plugin, I have used the following code to update text that is selected but in this case I want to update a single line.   I am new to Notepad++ plugin development. If the below way is the only/preferred way to update text, the how would I set the selectionStart and selectionEnd to correspond to specific line?</p>
<p dir="auto"><strong>Code that I have used to modify selected text (but I need to modify by line, not selection):</strong></p>
<pre><code>	::SendMessage(curScint, SCI_SETTARGETRANGE, selectionStart, selectionEnd);
	::SendMessage(curScint, SCI_REPLACETARGET, strLen, reinterpret_cast&lt;LPARAM&gt;(selectedStr));
	::SendMessage(curScint, SCI_SETSEL, selectionStart, selectionEnd);
</code></pre>
<p dir="auto"><strong>Sample Code:</strong></p>
<pre><code>        // Get selected text start and end
	int selectionStart = (int)::SendMessage(curScint, SCI_GETSELECTIONSTART, 0, 0);
	int selectionEnd = (int)::SendMessage(curScint, SCI_GETSELECTIONEND, 0, 0);
	
        // identify the lines the selected text is on. 
	int line1 = (int)::SendMessage(curScint,SCI_LINEFROMPOSITION, selectionStart,0);
	int line2 = (int)::SendMessage(curScint, SCI_LINEFROMPOSITION, selectionEnd, 0);

        // Loop through each line, get the line, modify the line and write the line back
	int length;
	for (int i = line1; i &lt;= line2; i++) {
		::SendMessage(curScint, SCI_GOTOLINE, line1, 0);

		length = (int)::SendMessage(curScint, SCI_GETCURLINE, 0, 0);
		char* selectedStr = new char[max(length + 1,200)];
		::SendMessage(curScint, SCI_GETCURLINE, length, reinterpret_cast&lt;LPARAM&gt;(selectedStr));

		// Do something with selectedStr

		// Update Line in Notepad++  - How?

	}
</code></pre>
<p dir="auto">I’m using Notepad++ version 8.6.</p>
<p dir="auto">Thank you!</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/25321/is-there-a-sci_setline-type-message-how-to-update-a-line</link><generator>RSS for Node</generator><lastBuildDate>Fri, 12 Jun 2026 17:03:13 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/25321.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 06 Jan 2024 16:12:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Is there a SCI_SETLINE type message (How to update a line) on Fri, 12 Jan 2024 16:24:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mark-olson" aria-label="Profile: Mark-Olson">@<bdi>Mark-Olson</bdi></a> said in <a href="/post/91970">Is there a SCI_SETLINE type message (How to update a line)</a>:</p>
<blockquote>
<p dir="auto">much faster if you just slurp all the text out in one go, process it in C#, and then dump it all back into the file</p>
</blockquote>
<p dir="auto">…and watch your change-history go “all orange”, registering every character in the file as “changed”.  Secondary concern:  It also nullifies a plugin’s opportunity to provide step-by-step undo for possible individual modifications it makes.<br />
For me this would be a big problem, and I wouldn’t use a plugin that did this to me.<br />
Sure, for some people this would be absolutely no problem.<br />
But I wouldn’t make this approach a general recommendation.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91974</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91974</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 12 Jan 2024 16:24:34 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a SCI_SETLINE type message (How to update a line) on Fri, 12 Jan 2024 15:57:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/paul-baker" aria-label="Profile: Paul-Baker">@<bdi>Paul-Baker</bdi></a><br />
I’m glad it’s working!</p>
<p dir="auto">One note I would make (not just for you, for the general public) is that<br />
<strong>interacting with Scintilla is <em>really slow</em> compared to the .NET runtime</strong> and if you are concerned about performance, you will be much faster if you just slurp all the text out in one go, process it in C#, and then dump it all back into the file.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91970</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91970</guid><dc:creator><![CDATA[Mark Olson]]></dc:creator><pubDate>Fri, 12 Jan 2024 15:57:43 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a SCI_SETLINE type message (How to update a line) on Fri, 12 Jan 2024 15:43:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mark-olson" aria-label="Profile: Mark-Olson">@<bdi>Mark-Olson</bdi></a> said in <a href="/post/91811">Is there a SCI_SETLINE type message (How to update a line)</a>:</p>
<blockquote>
<p dir="auto">In that case I recommend this C# plugin template</p>
</blockquote>
<p dir="auto">Hi Mark, thank you and everyone that has helped me get started with Visual Studio and NPP Plugin development.  I looked into c# and yes it is easier.</p>
<p dir="auto">Here is the same logic I’ve been working on in c#.  All works well.</p>
<pre><code>        static void toggleCobolComment()
        {
            // Get selection start and end positions.
            // If selStr and selEnd are equal then there is no selection,
            // just process the line the caret is on.
            var strSel = editor.GetSelectionStart();
            var strEnd = editor.GetSelectionEnd();

            // Get the line numbers associated with the start and end positions.
            // The strLine and endLine may be the same line.
            var strLine = editor.LineFromPosition(strSel);
            var endLine = editor.LineFromPosition(strEnd);

            string lineText = "";
            char[] lineTextAsChars;

            int lineLen = 0;

            int strPos = 0;
            int endPos = 0;
                        
             // Loop through each line and toggle the comment char "*"
             // in column 7.  Skip lines that are shorter than 7 characters.
            for (var lineNum = strLine; lineNum &lt;= endLine; lineNum++)
            {
                // Calculate line size by getting the line start and end positions
                strPos = editor.PositionFromLine(lineNum);
                endPos = editor.GetLineEndPosition(lineNum);

                // Get the current line length
                lineLen = endPos - strPos + 1;

                // Skip lines that are empty.
                if (lineLen &lt;= 6)
                    continue;

                // Get line text and convert to char array
                editor.SetTargetRange(strPos, endPos);
                lineText = editor.GetTargetText();
                lineTextAsChars = lineText.ToCharArray();

                // Toggle comment character.
                if (lineTextAsChars[6] == '*')
                    lineTextAsChars[6] = ' ';
                else
                    lineTextAsChars[6] = '*';

                // Convert char array back to string 
                // and update line in editor. 
                lineText = new string(lineTextAsChars);
                editor.ReplaceTarget(lineText.Length, lineText);
            }

            return;
        }

</code></pre>
<p dir="auto">Thanks again… This thread is closed (for me).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91967</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91967</guid><dc:creator><![CDATA[Paul Baker]]></dc:creator><pubDate>Fri, 12 Jan 2024 15:43:08 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a SCI_SETLINE type message (How to update a line) on Mon, 08 Jan 2024 16:13:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rdipardo" aria-label="Profile: rdipardo">@<bdi>rdipardo</bdi></a> Thank you!!! I’ll make that change.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91852</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91852</guid><dc:creator><![CDATA[Paul Baker]]></dc:creator><pubDate>Mon, 08 Jan 2024 16:13:16 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a SCI_SETLINE type message (How to update a line) on Sun, 07 Jan 2024 16:40:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/paul-baker" aria-label="Profile: Paul-Baker">@<bdi>Paul-Baker</bdi></a> said in <a href="/post/91806">Is there a SCI_SETLINE type message (How to update a line)</a>:</p>
<blockquote>
<pre><code>  /* . . . */
 int strSel = (int)::SendMessage(curScint, SCI_GETSELECTIONSTART, 0, 0);
 int endSel = (int)::SendMessage(curScint, SCI_GETSELECTIONEND, 0, 0);
</code></pre>
</blockquote>
<p dir="auto">Those type casts are only safe for 32-bit plugins. Scintilla has supported multi-gigabyte files <a href="https://groups.google.com/g/scintilla-interest/c/4czxAqELLeQ/m/2XzoM5gsBwAJ" rel="nofollow ugc">since 4.1.6</a> (the current version is 5.4.1). While a character position beyond <code>0x7fffffff</code> isn’t likely, a 64-bit application would immediately crash if your plugin made one of the above calls in a document over 2 GB in size.</p>
<p dir="auto">It’s best to store all position values as the dynamically sized <code>Sci_Position</code> type (an alias for <code>intptr_t</code>, which is what the API functions <a href="https://scintilla.org/ScintillaDoc.html#:~:text=Positions%20and%20lengths%20in%20document.%20Equivalent%20to%20intptr_t." rel="nofollow ugc">actually return</a>).</p>
<p dir="auto">The type definition is probably in your project files already; all recent versions of the main Scintilla header include <code>Sci_Position.h</code>.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91813</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91813</guid><dc:creator><![CDATA[rdipardo]]></dc:creator><pubDate>Sun, 07 Jan 2024 16:40:50 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a SCI_SETLINE type message (How to update a line) on Sun, 07 Jan 2024 16:13:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/paul-baker" aria-label="Profile: Paul-Baker">@<bdi>Paul-Baker</bdi></a> said in <a href="/post/91807">Is there a SCI_SETLINE type message (How to update a line)</a>:</p>
<blockquote>
<p dir="auto">My comfortable language is java</p>
</blockquote>
<p dir="auto">In that case I recommend <a href="https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net" rel="nofollow ugc">this C# plugin template</a>.</p>
<p dir="auto">I’ve used it for two plugins and helped the development of another. C# is great, and very similar to Java.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91811</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91811</guid><dc:creator><![CDATA[Mark Olson]]></dc:creator><pubDate>Sun, 07 Jan 2024 16:13:38 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a SCI_SETLINE type message (How to update a line) on Sun, 07 Jan 2024 15:00:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> No shame… haha… I use to be a scripting basher (no pub intended).  My comfortable language is java, then python.  Imperative languages are all similar, if-then-else.  There are lots of how to blogs for creating npp plugins using cpp and I did not want to make a project out of it. I’m sure there are easy ways to do this for many languages, I just took the path of least resistance. All comments appreciated. Thanks!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91807</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91807</guid><dc:creator><![CDATA[Paul Baker]]></dc:creator><pubDate>Sun, 07 Jan 2024 15:00:20 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a SCI_SETLINE type message (How to update a line) on Sun, 07 Jan 2024 14:55:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/paul-baker" aria-label="Profile: Paul-Baker">@<bdi>Paul-Baker</bdi></a> Updated without mem leaks</p>
<pre><code>void updateCOBOLComments() {

	// Get handle to Scintilla editor
	int currentEdit;
	::SendMessage(nppData._nppHandle, NPPM_GETCURRENTSCINTILLA, 0, (LPARAM)&amp;currentEdit);
	HWND curScint = (currentEdit == 0) ? nppData._scintillaMainHandle : nppData._scintillaSecondHandle;

	// Get selection start and end positions.
	// If selectionStr and selectionEnd are equal then there is no selection,
	// just process the line the caret is on.   
	int strSel = (int)::SendMessage(curScint, SCI_GETSELECTIONSTART, 0, 0);
	int endSel = (int)::SendMessage(curScint, SCI_GETSELECTIONEND, 0, 0);

	// Get the line numbers associated with the start and end positions.
	// The strLine and endLine may be the same line.
	int strLine = (int)::SendMessage(curScint, SCI_LINEFROMPOSITION, strSel, 0);
	int endLine = (int)::SendMessage(curScint, SCI_LINEFROMPOSITION, endSel, 0);

	size_t lineLen;
	std::string lineText = "";

	int strPos;
	int endPos;

	for (int lineNum = strLine; lineNum &lt;= endLine; lineNum++) {

		// Calculate line size by getting the line start and end positions
		strPos = (int) ::SendMessage(curScint, SCI_POSITIONFROMLINE, lineNum, 0);
		endPos = (int) ::SendMessage(curScint, SCI_GETLINEENDPOSITION, lineNum, 0);

		// Get the current line. 
		lineLen = endPos - strPos + 1;
		lineText.resize(lineLen, ' ');
		::SendMessage(curScint, SCI_SETTARGETRANGE, strPos, endPos);
		::SendMessage(curScint, SCI_GETTARGETTEXT, 0, reinterpret_cast&lt;LPARAM&gt;(lineText.data()));

                 // *********************************
                 // ** Modify lineText as needed., *
                 // *********************************

		::SendMessage(curScint, SCI_REPLACETARGET, static_cast&lt;WPARAM&gt;(-1), reinterpret_cast&lt;LPARAM&gt;(lineText.data()));
	}

	return;
}
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/91806</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91806</guid><dc:creator><![CDATA[Paul Baker]]></dc:creator><pubDate>Sun, 07 Jan 2024 14:55:04 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a SCI_SETLINE type message (How to update a line) on Sun, 07 Jan 2024 13:18:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/paul-baker" aria-label="Profile: Paul-Baker">@<bdi>Paul-Baker</bdi></a> said in <a href="/post/91782">Is there a SCI_SETLINE type message (How to update a line)</a>:</p>
<blockquote>
<p dir="auto">I’m not a c++ guy</p>
</blockquote>
<p dir="auto">Maybe you should consider writing your plugin in a language you are comfortable in?<br />
Caveat: Perhaps getting started without a template could be a hurdle…</p>
<p dir="auto">Or consider scripting instead of a plugin?<br />
There’s no shame in scripting. :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91802</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91802</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sun, 07 Jan 2024 13:18:33 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a SCI_SETLINE type message (How to update a line) on Sun, 07 Jan 2024 04:31:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/coises" aria-label="Profile: Coises">@<bdi>Coises</bdi></a> Thanks, I struggled with that. I’ll try your suggestions.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91794</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91794</guid><dc:creator><![CDATA[Paul Baker]]></dc:creator><pubDate>Sun, 07 Jan 2024 04:31:57 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a SCI_SETLINE type message (How to update a line) on Sun, 07 Jan 2024 01:38:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/paul-baker" aria-label="Profile: Paul-Baker">@<bdi>Paul-Baker</bdi></a> said in <a href="/post/91782">Is there a SCI_SETLINE type message (How to update a line)</a>:</p>
<blockquote>
<p dir="auto">If you see any errors, please let me know.</p>
</blockquote>
<p dir="auto">You are leaking memory; you allocate new C-style strings, but you never delete them.</p>
<p dir="auto">Recommendation: Save yourself some grief and use the fact that as of C++17 you can modify the data of a std::string. (You can even overwrite the trailing null that comes one after the length, so long as you overwrite it with another null.)</p>
<pre><code>// Get the current line.
lineLen = endPos - strPos;
std::string lineText(lineLen, 0);
::SendMessage(curScint, SCI_SETTARGETRANGE, strPos, endPos);
::SendMessage(curScint, SCI_GETTARGETTEXT, 0, reinterpret_cast&lt;LPARAM&gt;(lineText.data()));

// Do something.

::SendMessage(curScint, SCI_REPLACETARGET, static_cast&lt;WPARAM&gt;(-1), reinterpret_cast&lt;LPARAM&gt;(lineText.data()));
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/91784</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91784</guid><dc:creator><![CDATA[Coises]]></dc:creator><pubDate>Sun, 07 Jan 2024 01:38:23 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a SCI_SETLINE type message (How to update a line) on Sun, 07 Jan 2024 01:04:26 GMT]]></title><description><![CDATA[<p dir="auto"><strong>Solved!</strong><br />
This is what I came up with.  I’m not a c++ guy so please don’t ding me for the code. Thank you for your suggestions.  That really helped.</p>
<p dir="auto"><strong>Use Case:</strong><br />
Provide capability that allows the user to select one or more lines to be reformatted per specs. The plugin will get the text for each line, manipulate it, and update in Scintilla.</p>
<p dir="auto">If you see any errors, please let me know.</p>
<pre><code>void UpdateText() {

	::MessageBox(nppData._nppHandle, TEXT("Comment Plugin"), TEXT("The Comment Plugin"), MB_OK);

	// Get handle to Scintilla editor
	int currentEdit;
	::SendMessage(nppData._nppHandle, NPPM_GETCURRENTSCINTILLA, 0, (LPARAM)&amp;currentEdit);
	HWND curScint = (currentEdit == 0) ? nppData._scintillaMainHandle : nppData._scintillaSecondHandle;

	// Get selection start and end positions.
	// If selectionStr and selectionEnd are equal then there is no selection,
	// just process the line the caret is on.   
	int strSel = (int)::SendMessage(curScint, SCI_GETSELECTIONSTART, 0, 0);
	int endSel = (int)::SendMessage(curScint, SCI_GETSELECTIONEND, 0, 0);
	
	// Get the line numbers associated with the start and end positions.
	// The strLine and endLine may be the same line.
	int strLine = (int)::SendMessage(curScint,SCI_LINEFROMPOSITION, strSel,0);
	int endLine = (int)::SendMessage(curScint, SCI_LINEFROMPOSITION, endSel, 0);

	size_t lineLen;
	int strPos;
	int endPos;
	char* selLine = 0;

	for (int lineNum = strLine; lineNum &lt;= endLine; lineNum++) {

		// Calculate line size by getting the line start and end positions
		strPos = (int) ::SendMessage(curScint, SCI_POSITIONFROMLINE, lineNum, 0);
		endPos = (int) ::SendMessage(curScint, SCI_GETLINEENDPOSITION, lineNum, 0);

		// Get the current line. 
		lineLen = endPos - strPos + 1;
		selLine = new char[lineLen];
		::SendMessage(curScint, SCI_SETTARGETRANGE, strPos, endPos);
		::SendMessage(curScint, SCI_GETTARGETTEXT, 0, reinterpret_cast&lt;LPARAM&gt;(selLine));

		// Move char* to string for easier (for me) string handling
		// First make sure line text is 
		selLine[lineLen - 1] = '\0';
		std::string lineText = selLine;

		// Do something.

		selLine = new char[lineText.length()];
		strcpy(selLine, lineText.c_str());
		::SendMessage(curScint, SCI_REPLACETARGET, static_cast&lt;WPARAM&gt;(-1), reinterpret_cast&lt;LPARAM&gt;(selLine));

	}

	return;
}
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/91782</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91782</guid><dc:creator><![CDATA[Paul Baker]]></dc:creator><pubDate>Sun, 07 Jan 2024 01:04:26 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a SCI_SETLINE type message (How to update a line) on Sat, 06 Jan 2024 19:53:19 GMT]]></title><description><![CDATA[<p dir="auto">Thanks everyone for the input… I’m glad you’re not AFK. :)  It’s a crappy day here in ATL so. I’ll give your suggestions a try.</p>
<p dir="auto">Thank you!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91779</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91779</guid><dc:creator><![CDATA[Paul Baker]]></dc:creator><pubDate>Sat, 06 Jan 2024 19:53:19 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a SCI_SETLINE type message (How to update a line) on Sat, 06 Jan 2024 17:38:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> said in <a href="/post/91774">Is there a SCI_SETLINE type message (How to update a line)</a>:</p>
<blockquote>
<p dir="auto">Perhaps ALL THREE of us need to go AFK and get out and enjoy the weekend! :-)</p>
</blockquote>
<p dir="auto">I already got in my walk this morning, between the downpours.</p>
<p dir="auto"><em>/me listens to the intense rainfall.</em></p>
<p dir="auto">Right now would be a really <em>bad</em> time for going out. :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91775</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91775</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Sat, 06 Jan 2024 17:38:43 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a SCI_SETLINE type message (How to update a line) on Sat, 06 Jan 2024 17:36:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> said in <a href="/post/91773">Is there a SCI_SETLINE type message (How to update a line)</a>:</p>
<blockquote>
<p dir="auto">following the suggestions that both <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> and <a class="plugin-mentions-user plugin-mentions-a" href="/user/coises" aria-label="Profile: Coises">@<bdi>Coises</bdi></a> made nearly simultaneously.</p>
</blockquote>
<p dir="auto">Perhaps ALL THREE of us need to go AFK and get out and enjoy the weekend! :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91774</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91774</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 06 Jan 2024 17:36:05 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a SCI_SETLINE type message (How to update a line) on Sat, 06 Jan 2024 17:37:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/paul-baker" aria-label="Profile: Paul-Baker">@<bdi>Paul-Baker</bdi></a> ,</p>
<p dir="auto">The PythonScript plugin made a wrapper/helper function called <code>replaceLine()</code> : you can find the source code for that function <a href="https://github.com/bruderstein/PythonScript/blob/b1b3b1edf325d2d4ed4d106272cfe63a6c042965/PythonScript/src/ScintillaWrapper.cpp#L534-L541" rel="nofollow ugc">here</a> – it is essentially following the suggestions that <a class="plugin-mentions-user plugin-mentions-a" href="/user/coises" aria-label="Profile: Coises">@<bdi>Coises</bdi></a> made …</p>
<p dir="auto">And I had been thinking along <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a>’s lines, with doing the  <a href="https://www.scintilla.org/ScintillaDoc.html#SCI_DELETERANGE" rel="nofollow ugc">SCI_DELETERANGE</a> then doing a <a href="https://www.scintilla.org/ScintillaDoc.html#SCI_INSERTTEXT" rel="nofollow ugc">SCI_INSERTTEXT</a> at the old start-position.</p>
<p dir="auto"><em>edited phrasing once I saw the subtle difference between Alan’s and Coises’ suggestions</em></p>
]]></description><link>https://community.notepad-plus-plus.org/post/91773</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91773</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Sat, 06 Jan 2024 17:37:10 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a SCI_SETLINE type message (How to update a line) on Sat, 06 Jan 2024 17:32:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/paul-baker" aria-label="Profile: Paul-Baker">@<bdi>Paul-Baker</bdi></a></p>
<p dir="auto">You can use <a href="https://www.scintilla.org/ScintillaDoc.html#SCI_POSITIONFROMLINE" rel="nofollow ugc">SCI_POSITIONFROMLINE</a> and <a href="https://www.scintilla.org/ScintillaDoc.html#SCI_GETLINEENDPOSITION" rel="nofollow ugc">SCI_GETLINEENDPOSITION</a> to get the character positions that correspond to a given line number. (No need to use SCI_GOTOLINE.) Then use <a href="https://www.scintilla.org/ScintillaDoc.html#SCI_SETTARGETRANGE" rel="nofollow ugc">SCI_SETTARGETRANGE</a> to set the target range, <a href="https://www.scintilla.org/ScintillaDoc.html#SCI_GETTARGETTEXT" rel="nofollow ugc">SCI_GETTARGETTEXT</a> to retrieve the current contents, and <a href="https://www.scintilla.org/ScintillaDoc.html#SCI_REPLACETARGET" rel="nofollow ugc">SCI_REPLACETARGET</a> to change it.</p>
<p dir="auto">If you will never add line-ending characters, you can just iterate through the selected line numbers. If the replacements could include line ending characters, you will have to be careful.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91772</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91772</guid><dc:creator><![CDATA[Coises]]></dc:creator><pubDate>Sat, 06 Jan 2024 17:32:32 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a SCI_SETLINE type message (How to update a line) on Sat, 06 Jan 2024 17:34:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/paul-baker" aria-label="Profile: Paul-Baker">@<bdi>Paul-Baker</bdi></a></p>
<p dir="auto">I believe what you want to do is:</p>
<ul>
<li>get the starting position of the line of interest</li>
<li>get the ending position of the line of interest (in all likelihood you want the position <em>before</em> the line ending characters)</li>
<li>delete the text between the two positions</li>
<li>insert your new text at the starting position</li>
</ul>
<p dir="auto">In other words, there isn’t (I don’t believe) a function for directly doing it in one step.</p>
<p dir="auto">But, you could make such a C++ function, and publish it here, and then future plugin developers could use it and thus benefit.</p>
<p dir="auto"><strong>EDIT</strong> after reading <a class="plugin-mentions-user plugin-mentions-a" href="/user/coises" aria-label="Profile: Coises">@<bdi>Coises</bdi></a> 's response below:  I didn’t mention “replace target” as an option, because apparently OP knows about that (it’s in his posting).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91771</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91771</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 06 Jan 2024 17:34:47 GMT</pubDate></item></channel></rss>