<?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[Replace 1 + lines?]]></title><description><![CDATA[<p dir="auto">Hello, is it possible to replace, lets say 1-50 lines with new code(same line amount)?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/13754/replace-1-lines</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 09:17:33 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/13754.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 01 May 2017 07:27:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Replace 1 + lines? on Tue, 19 Feb 2019 00:10:53 GMT]]></title><description><![CDATA[<p dir="auto">As a result, several plugins, but there is much to strive for.<br />
<a href="https://yadi.sk/d/VYtvMq8ECMou9g" rel="nofollow ugc">https://yadi.sk/d/VYtvMq8ECMou9g</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/40025</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/40025</guid><dc:creator><![CDATA[AZJIO AZJIO]]></dc:creator><pubDate>Tue, 19 Feb 2019 00:10:53 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Sat, 16 Feb 2019 23:50:34 GMT]]></title><description><![CDATA[<p dir="auto">Thank! The previous code helped. I saw in it the absence of a handle in FindWindowExW(None<br />
I am intensively writing 2 plugins</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39904</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39904</guid><dc:creator><![CDATA[AZJIO AZJIO]]></dc:creator><pubDate>Sat, 16 Feb 2019 23:50:34 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Sat, 16 Feb 2019 21:47:21 GMT]]></title><description><![CDATA[<p dir="auto">Maybe I have a wrong assumption what you are actually doing.<br />
When you talk about an exe I assume that this is a different standalone program, correct?<br />
When you talked about dll I assumed that this might be a npp plugin.<br />
Now I get the feeling this is incorrect. Would you mind to explain what exactly is what<br />
and what your ultimate goal is?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39896</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39896</guid><dc:creator><![CDATA[Eko palypse]]></dc:creator><pubDate>Sat, 16 Feb 2019 21:47:21 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Sat, 16 Feb 2019 21:36:48 GMT]]></title><description><![CDATA[<p dir="auto">I have done just that. Keyword only “Extended”. But using AutoIt3</p>
<p dir="auto">$hWnd = WinGetHandle(“[CLASS:Notepad++]”)<br />
If Not @error Then<br />
If BitAND(WinGetState($hWnd), 16) Then WinActivate($hWnd)<br />
_SendMessage($hWnd, $NPPM_MENUCOMMAND, 0, $IDM_SEARCH_REPLACE)<br />
$hWnd = WinWait(“[CLASS:#32770]”, “Extended”, 2)<br />
If $hWnd Then<br />
ControlSetText($hWnd, “Extended”, “Edit1”, _GUICtrlRichEdit_GetText($hRichEdit_SPE))<br />
ControlSetText($hWnd, “Extended”, “Edit2”, GUICtrlRead($PtnRep))<br />
ControlCommand($hWnd, “Extended”, “Button18”, ‘Check’) ; 18 - regular expression (16 - normal)<br />
EndIf<br />
EndIf</p>
<hr />
<p dir="auto">on PureBasic code is the same for exe and dll. Search window “#32770” starts at the top, so it does not cause a problem. There are either no such windows or they are below.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39895</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39895</guid><dc:creator><![CDATA[AZJIO AZJIO]]></dc:creator><pubDate>Sat, 16 Feb 2019 21:36:48 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Sat, 16 Feb 2019 20:38:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/8960">@AZJIO-AZJIO</a></p>
<p dir="auto">Sorry, didn’t recognize the update.<br />
Windows, sometimes,  treats retrieving external and internal information differently.<br />
Means, something you retrieved from an exe might differ from something<br />
you want to retrieve within its own process.</p>
<p dir="auto">In python, I would it do like this</p>
<pre><code>import ctypes
user32 = ctypes.WinDLL('user32')
hwnd = user32.FindWindowExW(None, None, u'#32770', u'Replace')
hwndEdit_1 = user32.GetDlgItem(hwnd, 1601)
hwndEdit_2 = user32.GetDlgItem(hwnd, 1602)
</code></pre>
<p dir="auto">This takes care that only the dialog with name Replace is found.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39892</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39892</guid><dc:creator><![CDATA[Eko palypse]]></dc:creator><pubDate>Sat, 16 Feb 2019 20:38:59 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Sat, 16 Feb 2019 19:05:31 GMT]]></title><description><![CDATA[<p dir="auto">I know it. I do not set the window class. I have no way to change this. The external program, as I said, works.<br />
<a href="https://a.radikal.ru/a21/1902/55/0723e06a798a.png" rel="nofollow ugc">https://a.radikal.ru/a21/1902/55/0723e06a798a.png</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/39888</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39888</guid><dc:creator><![CDATA[AZJIO AZJIO]]></dc:creator><pubDate>Sat, 16 Feb 2019 19:05:31 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Sat, 16 Feb 2019 18:32:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/8960">@AZJIO-AZJIO</a> said:</p>
<blockquote>
<p dir="auto">#32770</p>
</blockquote>
<p dir="auto">be careful about searching for the ordinal only, as every dialog uses it.<br />
<a href="https://docs.microsoft.com/en-us/windows/desktop/winmsg/about-window-classes" rel="nofollow ugc">https://docs.microsoft.com/en-us/windows/desktop/winmsg/about-window-classes</a><br />
Most plugins and internal npp windows are dialogs.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39883</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39883</guid><dc:creator><![CDATA[Eko palypse]]></dc:creator><pubDate>Sat, 16 Feb 2019 18:32:54 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Sat, 16 Feb 2019 17:38:34 GMT]]></title><description><![CDATA[<p dir="auto">; PureBasic<br />
hwnd = FindWindowEx_(NppData_nppHandle, 0, “#32770”, 0) ; hwnd = yes<br />
If Not IsWindowVisible_(hwnd)<br />
SendMessage_(NppData_nppHandle, #NPPM_MENUCOMMAND, 0, #IDM_SEARCH_REPLACE) ; Показать диалог поиска используя команду меню<br />
EndIf<br />
hwndEdit_1 = GetDlgItem_(hwnd, 1601) ; hwndEdit_1 = 0<br />
hwndEdit_2 = GetDlgItem_(hwnd, 1602) ; hwndEdit_2 = 0<br />
SendMessage_(hwndEdit_1,#WM_SETTEXT,0,GetGadgetItemText(#Combo_2 , n-1, 0))<br />
SendMessage_(hwndEdit_2,#WM_SETTEXT,0,GetGadgetItemText(#Combo_2 , n-1, 1))</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39881</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39881</guid><dc:creator><![CDATA[AZJIO AZJIO]]></dc:creator><pubDate>Sat, 16 Feb 2019 17:38:34 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Sat, 16 Feb 2019 14:25:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/8960">@AZJIO-AZJIO</a></p>
<p dir="auto">without seeing/understanding the actual code it is hard to say what might be the issue<br />
but, personally, I would not recommend using EnumChildWindows when trying to find a<br />
dialog control window handle, instead use <a href="https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getdlgitem" rel="nofollow ugc">GetDlgItem</a>.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39871</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39871</guid><dc:creator><![CDATA[Eko palypse]]></dc:creator><pubDate>Sat, 16 Feb 2019 14:25:48 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Sat, 16 Feb 2019 00:18:52 GMT]]></title><description><![CDATA[<p dir="auto">I wrote a program for the test of regular expressions. It serves as a database. When you click a button, it fills in the search and replace fields.<br />
I decided to make a plugin that will do the same. But the same program (exe and dll) work differently. EXE fills the fields, but the DLL can not fill.<br />
I tried using EnumChildWindows to find the elements of the window, as is done in the examples above. But as a result, he found only 3 elements.<br />
0 hwnd = 725602	Class = Button	Title = Caption<br />
1 hwnd = 2233572	Class = Static	Title =<br />
2 hwnd = 1707882	Class = SysTabControl32	Title = Tab1</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39836</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39836</guid><dc:creator><![CDATA[AZJIO AZJIO]]></dc:creator><pubDate>Sat, 16 Feb 2019 00:18:52 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Fri, 15 Feb 2019 23:03:21 GMT]]></title><description><![CDATA[<p dir="auto">Sorry, but what are you try to tell us?<br />
Which external program and which meaning has EnumChildWindows API in this context?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39833</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39833</guid><dc:creator><![CDATA[Eko palypse]]></dc:creator><pubDate>Fri, 15 Feb 2019 23:03:21 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Fri, 15 Feb 2019 01:15:02 GMT]]></title><description><![CDATA[<p dir="auto">The external program is working. I make a plugin and no longer works (EnumChildWindows).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/39796</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/39796</guid><dc:creator><![CDATA[AZJIO AZJIO]]></dc:creator><pubDate>Fri, 15 Feb 2019 01:15:02 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Mon, 03 Jul 2017 16:18:16 GMT]]></title><description><![CDATA[<p dir="auto">It would be nice if the author would make an additional window when the button is clicked<br />
[<a href="http://radikal.ru/big/m0wcdchejv3ve" rel="nofollow ugc">http://radikal.ru/big/m0wcdchejv3ve</a>](link url)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25356</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25356</guid><dc:creator><![CDATA[AZJIO AZJIO]]></dc:creator><pubDate>Mon, 03 Jul 2017 16:18:16 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Mon, 03 Jul 2017 11:04:56 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3662">@claudia-frank</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/374">@Scott-sumner</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/8667">@pouemes44</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/8732">@go2to</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/8430">@jorge-campos</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/8529">@herofiles</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/8960">@azjio-azjio</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a> and <strong>All</strong></p>
<p dir="auto"><strong>Thanks</strong> to <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3662">@claudia-frank</a>, this <strong>present</strong> topic and the discussions, below, about <strong>multi-lines</strong> search AND <strong>multi-lines</strong> Replacement :</p>
<p dir="auto"><a href="https://notepad-plus-plus.org/community/topic/13823/replace-function/1" rel="nofollow ugc">https://notepad-plus-plus.org/community/topic/13823/replace-function/1</a></p>
<p dir="auto"><a href="https://notepad-plus-plus.org/community/topic/13684/feature-request-textarea-search-replace/1" rel="nofollow ugc">https://notepad-plus-plus.org/community/topic/13684/feature-request-textarea-search-replace/1</a></p>
<p dir="auto">have, now, an <strong>ELEGANT</strong> solution, with her <strong>Python</strong>’s script, just <strong>above</strong> !</p>
<p dir="auto">You just need to be able to do <strong>multiple</strong> selections  ( Option <strong>Settings &gt; Preferences… &gt; Editing &gt; Multi-Editing Settings &gt; Enable</strong> <strong>CHECKED</strong> )</p>
<hr />
<p dir="auto">BTW, the <strong>upper</strong> limit of <strong>2046</strong> characters, in the <strong>Find what:</strong> box  of the <strong>Find/Replace</strong> dialog, only, could be <strong>by-passed</strong>, easily :-). Indeed, just use the <strong>Regular expression</strong> search mode and use the <strong>generic</strong> regex <strong><code>(?s)Left-boundary.+?Right-boundary</code></strong> !</p>
<p dir="auto">For instance, you can choose a <strong>particular</strong> character, which does <strong>not</strong> exist,yet, in your file(s) to be modified, and build the regex :</p>
<p dir="auto"><strong><code>(?s)(#####\R).+?\1</code></strong></p>
<p dir="auto">This regex contains any <strong>non-null</strong> amount of characters between <strong>TWO same</strong> complete lines <strong>#####</strong>, with their <strong>line-breaks</strong></p>
<p dir="auto">So :</p>
<ul>
<li>
<p dir="auto">Do a <strong>normal selection</strong> of this regex <strong><code>(?s)(#####\R).+?\1</code></strong>, using the mouse</p>
</li>
<li>
<p dir="auto">Then, with a <strong><code>Ctrl + Left Click</code></strong> action, simply, select your <strong>Replace</strong> block, <strong>multi-lines</strong> or not</p>
</li>
<li>
<p dir="auto">Run the <strong>Claudia</strong>’s script above</p>
</li>
</ul>
<p dir="auto">=&gt; Immediately, the <strong>Find/Replace</strong> dialog pops-up and :</p>
<ul>
<li>
<p dir="auto">The <strong>Find what:</strong> box is filled with the regex <strong><code>(?s)(#####\R).+?\1</code></strong></p>
</li>
<li>
<p dir="auto">The <strong>Replace with:</strong> box is filled with the <strong>block</strong> of text, which must replace the <strong>searched</strong> text</p>
</li>
</ul>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3662">@claudia-frank</a>, I understand your point of view. Your <strong>script</strong> is quite <strong>flexible</strong> :-D. For instance, I was able to :</p>
<ul>
<li>
<p dir="auto">First, do a <strong><code>Ctrl + Clic</code></strong> selection of a <strong>multi-lines</strong> block of text</p>
</li>
<li>
<p dir="auto">Run your script =&gt; <strong>Find what:</strong> box empty and <strong>Replace with:</strong> box filled with that <strong>multi-lines</strong> block</p>
</li>
<li>
<p dir="auto">Select an <strong>second</strong> file, containing the text <strong><code>(?s)(#####\R).+?\1</code></strong></p>
</li>
<li>
<p dir="auto">Do a <strong><code>normal</code> selection</strong> of that regex</p>
</li>
<li>
<p dir="auto">Run again, your script =&gt; The find.Replace dialog, presently in the <strong>background</strong>, is, then, <strong>updated</strong> with this <strong>regex</strong>, filled in the <strong>Find what:</strong> box</p>
</li>
<li>
<p dir="auto">Select a <strong>third</strong> file, containing the <strong><code>#####</code> boundaries</strong> lines</p>
</li>
<li>
<p dir="auto">Perform the <strong>S/R</strong> on the contents of this <strong>third</strong> file</p>
</li>
</ul>
<p dir="auto">Et voilà !!</p>
<p dir="auto"><strong>Many thanks</strong>, again, for this very, very, <strong>valuable</strong> script, indeed !!!</p>
<p dir="auto">Hum… Already <strong>3 h 25</strong> !! I’d better go to bed : working tomorrow !</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25334</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25334</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Mon, 03 Jul 2017 11:04:56 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Sun, 02 Jul 2017 20:56:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a></p>
<p dir="auto">Guy, here the updated one.<br />
A <strong>“one-selection”</strong> action results in opening the standard replace dialog behavior.<br />
A <strong>“two-selections”</strong> action, even with an empty one, results in modifying the fields.<br />
I see it as a benefit that you are able to decide that only one of the fields should be filled<br />
and the other should be empty in any case.</p>
<pre><code>import ctypes
from ctypes.wintypes import BOOL, HWND, LPARAM

WNDENUMPROC = ctypes.WINFUNCTYPE(BOOL, HWND, LPARAM)

FindWindow = ctypes.windll.user32.FindWindowW
FindWindowEx = ctypes.windll.user32.FindWindowExW
SendMessage = ctypes.windll.user32.SendMessageW
EnumChildWindows = ctypes.windll.user32.EnumChildWindows
GetClassName = ctypes.windll.user32.GetClassNameW
GetWindowText = ctypes.windll.user32.GetWindowTextW
GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW
SetWindowText = ctypes.windll.user32.SetWindowTextW
GetACP = ctypes.windll.kernel32.GetACP
create_unicode_buffer = ctypes.create_unicode_buffer

replace_tab_caption  = u'Replace'
replacewith_caption = u'Rep&amp;lace with :'
replacewith_is_next_ctrl = False
replacewith_handle = None
replacewith_text = None
findwhat_caption = u'&amp;Find what :'
findwhat_is_next_ctrl = False
findwhat_handle = None
findwhat_text = None


def EnumCallback(hwnd, lparam):
    global replacewith_is_next_ctrl
    global findwhat_is_next_ctrl
    global replacewith_handle
    global findwhat_handle
    curr_class = create_unicode_buffer(256)
    GetClassName(hwnd, curr_class, 256)
    length = GetWindowTextLength(hwnd)
    buff = ctypes.create_unicode_buffer(length + 1)
    GetWindowText(hwnd, buff, length + 1)
    if curr_class.value.lower() == 'static':
        if buff.value == replacewith_caption:
            replacewith_is_next_ctrl = True
        elif buff.value == findwhat_caption:
            findwhat_is_next_ctrl = True
    elif curr_class.value.lower() == 'edit':
        if findwhat_is_next_ctrl:
            findwhat_handle = hwnd
            findwhat_is_next_ctrl = False
        elif replacewith_is_next_ctrl:
            replacewith_handle = hwnd
            replacewith_is_next_ctrl = False
            return False  # stop enumeration
    return True  # let enumeration continue

def return_proper_string(selected_text):
    if notepad.getEncoding() == BUFFERENCODING.ENC8BIT:
        _selected_text = unicode(selected_text, '{}'.format(GetACP()))
    else:
        _selected_text = unicode(selected_text, 'utf-8')
    return _selected_text

def main():
    msg = ''
    if editor.getSelections() == 1:
        notepad.menuCommand(MENUCOMMAND.SEARCH_REPLACE)
    elif editor.getSelections() == 2:
        if editor.getSelectionMode() == 0 and not editor.getSelectionEmpty():
            _find_what = editor.getTextRange(editor.getSelectionNStart(0), editor.getSelectionNEnd(0))
            _replace_with = editor.getTextRange(editor.getSelectionNStart(1), editor.getSelectionNEnd(1))

            if len(_find_what) &gt; 2046:
                _find_what = _find_what[:2046]
                msg += 'Warning:  Selected text too long for find-what box; truncating to 2046 characters.  '
                    
            if len(_replace_with) &gt; 2046:
                _replace_with = _replace_with[:2046]
                msg += 'Warning:  Selected text too long for replace-with box; truncating to 2046 characters.  '
                                        
            notepad.menuCommand(MENUCOMMAND.SEARCH_REPLACE)
            find_dialog_hwnd = FindWindow(None, replace_tab_caption)
            
            if find_dialog_hwnd:
                EnumChildWindows(find_dialog_hwnd, WNDENUMPROC(EnumCallback), 0)
                if findwhat_handle and replacewith_handle:
                    if SetWindowText(findwhat_handle, return_proper_string(_find_what)) == 0:
                        msg += 'Error:  Problem setting find-what text'
                    if SetWindowText(replacewith_handle, return_proper_string(_replace_with)) == 0:
                        msg += 'Error:  Problem setting replace-with text'
                else:
                    msg += 'Error:  Bad value for replacewith_handle'
            else:
                msg += 'Error:  Bad value for find_dialog_hwnd'
        else:
            msg += 'Error:  Either empty selection or unsupported selection mode detected'
    else:
        msg += 'Warning:  Only one or two selections are possible. Received:{}'.format(editor.getSelections())
    if len(msg) &gt; 0: notepad.messageBox(msg)

main()
</code></pre>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25332</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25332</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Sun, 02 Jul 2017 20:56:06 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Sun, 02 Jul 2017 16:59:12 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3662">@claudia-frank</a>,</p>
<p dir="auto">What to say else ? Just <strong>wonderful</strong> and <strong>awesome</strong>, indeed !!!</p>
<p dir="auto">I already tested the case of <strong>rectangular</strong> selection(s) and the <strong>upper</strong> limit of <strong>2046</strong> characters =&gt; No problem, it acts as <strong>expected</strong> :-)</p>
<hr />
<p dir="auto">Now, as always, when building a program, there’s a small <strong>bug</strong> with the <strong>lower</strong> limit of <strong>0</strong> character !</p>
<p dir="auto">I, successively, tried to make an <strong>empty search</strong> selection, then an <strong>empty replace</strong> selection and, finally,  both <strong>search</strong> and <strong>replace</strong> selections <strong>empty</strong>.</p>
<p dir="auto"><strong>Note</strong> : To obtain, physically, a <strong>zero-length</strong> selection, I just select <strong>one</strong> character with the <strong>mouse</strong>, then move <strong>back</strong> the mouse, with a possible hit on the <strong>CTRL</strong> key, to only get the <strong>caret</strong></p>
<p dir="auto"><strong>Results</strong> :</p>
<ul>
<li>
<p dir="auto">If <strong>both</strong> selections are <strong>empty</strong>, the message <strong>Error:  Either empty selection or unsupported selection mode detected</strong> occurs, as expected. Nice !</p>
</li>
<li>
<p dir="auto">If, ONLY, the <strong>search</strong> selection is <strong>empty</strong>, the <strong>Find/Replace</strong> opens normally. May be, in that case, <strong>Claudia</strong>, a message would be better !</p>
</li>
<li>
<p dir="auto">If, ONLY, the <strong>replace</strong> selection is <strong>empty</strong>, the <strong>Find/Replace</strong> opens normally, with the <strong>Find what:</strong> box filled and the <strong>Replace with:</strong> empty. That the <strong>expected</strong> behaviour, in order to <strong>delete all</strong> the <strong>search</strong> blocks of text found</p>
</li>
</ul>
<p dir="auto">I also noticed that if I <strong><code>Ctrl + click</code></strong> and <strong>select</strong> some text, ONLY, it is, logically, inserted in the <strong>Replace with</strong> box, leaving the <strong>Find what:</strong> box <strong>empty</strong> :-D</p>
<p dir="auto">But, if I, simply, <strong>click</strong>, without the <strong>Ctrl</strong> key, and <strong>select</strong> some text, the message <strong>Warning:  Only two selections are possible. Received:1</strong> occurs. However, <strong>Claudia</strong>, I think it’s a <strong>valid</strong> case.</p>
<p dir="auto">So, in the case of a <strong>normal selection 0</strong>, only, the <strong>Find/Replace</strong> dialog should <strong>pop up</strong> and contain :</p>
<ul>
<li>
<p dir="auto">A <strong>Find what:</strong> box, <strong>filled</strong> with the <strong>selection</strong> contents</p>
</li>
<li>
<p dir="auto">A <strong>Replace with:</strong> box, <strong>wiped out</strong> of any [previous] character</p>
</li>
</ul>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<p dir="auto">I found out something weird, but <strong>logic</strong> : If I build a <strong>one-line rectangular</strong> selection, this selection is <strong>correctly</strong> written in the <strong>Find what:</strong> box !!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25328</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25328</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sun, 02 Jul 2017 16:59:12 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Sun, 02 Jul 2017 14:17:30 GMT]]></title><description><![CDATA[<p dir="auto">From my basic tests it looks like it should do the trick.<br />
Tested utf-8, ansi, winows-1250, winows-1251 and winows-1252.<br />
It works only with normal selection - not with column mode selection.</p>
<pre><code>import ctypes
from ctypes.wintypes import BOOL, HWND, LPARAM

WNDENUMPROC = ctypes.WINFUNCTYPE(BOOL, HWND, LPARAM)

FindWindow = ctypes.windll.user32.FindWindowW
FindWindowEx = ctypes.windll.user32.FindWindowExW
SendMessage = ctypes.windll.user32.SendMessageW
EnumChildWindows = ctypes.windll.user32.EnumChildWindows
GetClassName = ctypes.windll.user32.GetClassNameW
GetWindowText = ctypes.windll.user32.GetWindowTextW
GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW
SetWindowText = ctypes.windll.user32.SetWindowTextW
GetACP = ctypes.windll.kernel32.GetACP
create_unicode_buffer = ctypes.create_unicode_buffer

replace_tab_caption  = u'Replace'
replacewith_caption = u'Rep&amp;lace with :'
replacewith_is_next_ctrl = False
replacewith_handle = None
replacewith_text = None
findwhat_caption = u'&amp;Find what :'
findwhat_is_next_ctrl = False
findwhat_handle = None
findwhat_text = None


def EnumCallback(hwnd, lparam):
    global replacewith_is_next_ctrl
    global findwhat_is_next_ctrl
    global replacewith_handle
    global findwhat_handle
    curr_class = create_unicode_buffer(256)
    GetClassName(hwnd, curr_class, 256)
    length = GetWindowTextLength(hwnd)
    buff = ctypes.create_unicode_buffer(length + 1)
    GetWindowText(hwnd, buff, length + 1)
    if curr_class.value.lower() == 'static':
        if buff.value == replacewith_caption:
            replacewith_is_next_ctrl = True
        elif buff.value == findwhat_caption:
            findwhat_is_next_ctrl = True
    elif curr_class.value.lower() == 'edit':
        if findwhat_is_next_ctrl:
            findwhat_handle = hwnd
            findwhat_is_next_ctrl = False
        elif replacewith_is_next_ctrl:
            replacewith_handle = hwnd
            replacewith_is_next_ctrl = False
            return False  # stop enumeration
    return True  # let enumeration continue

def return_proper_string(selected_text):
    if notepad.getEncoding() == BUFFERENCODING.ENC8BIT:
        _selected_text = unicode(selected_text, '{}'.format(GetACP()))
    else:
        _selected_text = unicode(selected_text, 'utf-8')
    return _selected_text

def main():
    msg = ''
    if editor.getSelections() == 2:
        if editor.getSelectionMode() == 0 and not editor.getSelectionEmpty():
            _find_what = editor.getTextRange(editor.getSelectionNStart(0), editor.getSelectionNEnd(0))
            _replace_with = editor.getTextRange(editor.getSelectionNStart(1), editor.getSelectionNEnd(1))

            if len(_find_what) &gt; 2046:
                _find_what = _find_what[:2046]
                msg += 'Warning:  Selected text too long for find-what box; truncating to 2046 characters.  '
                    
            if len(_replace_with) &gt; 2046:
                _replace_with = _replace_with[:2046]
                msg += 'Warning:  Selected text too long for replace-with box; truncating to 2046 characters.  '
                                        
            notepad.menuCommand(MENUCOMMAND.SEARCH_REPLACE)
            find_dialog_hwnd = FindWindow(None, replace_tab_caption)
            
            if find_dialog_hwnd:
                EnumChildWindows(find_dialog_hwnd, WNDENUMPROC(EnumCallback), 0)
                if findwhat_handle and replacewith_handle:
                    if SetWindowText(findwhat_handle, return_proper_string(_find_what)) == 0:
                        msg += 'Error:  Problem setting find-what text'
                    if SetWindowText(replacewith_handle, return_proper_string(_replace_with)) == 0:
                        msg += 'Error:  Problem setting replace-with text'
                else:
                    msg += 'Error:  Bad value for replacewith_handle'
            else:
                msg += 'Error:  Bad value for find_dialog_hwnd'
        else:
            msg += 'Error:  Either empty selection or unsupported selection mode detected'
    else:
        msg += 'Warning:  Only two selections are possible. Received:{}'.format(editor.getSelections())
    if len(msg) &gt; 0: notepad.messageBox(msg)

main()
</code></pre>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25326</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25326</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Sun, 02 Jul 2017 14:17:30 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Sun, 02 Jul 2017 13:32:34 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3662">@claudia-frank</a>,</p>
<p dir="auto">Don’t worry, <strong>Claudia</strong> and just enjoy these <strong>family</strong>’s moments ! Luckily, we, all, own more <strong>valuable</strong> things than <strong>Notepad++</strong> and some <strong>Python</strong> scripts :-D</p>
<p dir="auto">…I’m just thinking about <strong>actualities</strong> and the <strong>death</strong>’s celebration of <strong>Helmut Kohl</strong>. Thanks to him and some <strong>important</strong>  European women and men, we all enjoy, in <strong>Europe</strong>, a <strong>peace</strong> period, of near <strong>75</strong> years ! and <strong>THIS</strong>, it’s a basic point !!</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25325</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25325</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sun, 02 Jul 2017 13:32:34 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Sun, 02 Jul 2017 10:39:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/374">@scott-sumner</a></p>
<p dir="auto">Hi Guy,</p>
<p dir="auto">sorry, family celebration was a bit longer than expected.<br />
Just did the script and some basic tests and discovered that encoding<br />
is an issue like Scott already mentioned.<br />
Will try to find a way to make it work regardless which encoding is used.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25319</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25319</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Sun, 02 Jul 2017 10:39:38 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Sat, 01 Jul 2017 16:59:22 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/374">@scott-sumner</a> and <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3662">@claudia-frank</a></p>
<p dir="auto"><strong>Many thanks</strong>, in advance, for this <strong>future</strong> script ! This short post give me the opportunity to express, once again, all my <strong>gratitude</strong> towards you, <strong>Claudia</strong> and <strong>Scott</strong>, for your <strong>numerous</strong> scripts, on various topics, which helped us, <strong>significantly</strong>, so many times :-D</p>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25310</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25310</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sat, 01 Jul 2017 16:59:22 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Sat, 01 Jul 2017 12:19:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> said:</p>
<blockquote>
<p dir="auto">This topic makes me think about an other possibility</p>
</blockquote>
<p dir="auto">I like your idea and it should be easy, but I will defer to Claudia as I am extremely busy at the moment.  :-D</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25305</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25305</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Sat, 01 Jul 2017 12:19:57 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Sat, 01 Jul 2017 12:17:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> said:</p>
<blockquote>
<p dir="auto">copies the current normal and unique selection, BOTH, in the Find what : and in the Replace with: boxes</p>
</blockquote>
<p dir="auto">Hmmm.  Yes, that is what it does but that was actually UNINTENTIONAL!  I guess I didn’t notice because for years I have had an AutoIt script which does just that behavior.  A lot of the time when doing replacements, I’m just doing a minor adjustment to the text I am finding, so it saves time to have both the Find-what and Replace-with fields initally set to the same data.  I just make my minor tweak to the replace-with part and I am off to the races.</p>
<p dir="auto">In this thread’s script (<code>ReplaceWithBoxFromSelection.py</code>), however, I believe this happens due to the normal invocation of the Replace command (with <code>notepad.menuCommand(MENUCOMMAND.SEARCH_REPLACE)</code>)–when a selection is active, Notepad++ on its own puts the selected text in the Find-what box.  Perhaps that is less than desirable here in this script.  :(</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25304</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25304</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Sat, 01 Jul 2017 12:17:53 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Sat, 01 Jul 2017 11:54:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/374">@Scott-Sumner</a> and <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a></p>
<p dir="auto">Scott, I discovered something similar but thought it was related to using npp with wine.<br />
If I open the find dialog and then switch from english to english_customizable and back<br />
to english I loose the &gt;&gt; from “find next” button and the underscores (ampersands in text)<br />
for the “count” and “find all in all opened documents” buttons.<br />
I don’t see it as an issue as you normally set this once and done, but I see why it bothered you. ;-)<br />
I have a shortcut to  “Run Previous Script” which I use quite often.<br />
What happens from time to time is that I execute another script while editing<br />
the “current” script and then when I use the shortcut I assume that the current script<br />
should be executed, which isn’t the case as another script was executed in between.<br />
First thought I have in such a case is always, damn - what did I miss why isn’t it working anymore? What did I broke?<br />
Checking the source again and again just to find out that haven’t executed the script. :-)<br />
You see - seems to be “normal” programmer behavior ;-)</p>
<p dir="auto">Guy, haven’t check it yet but I guess it should be easy to implement, yes.<br />
If Scott, or anyone else hasn’t proposed a solution, I will give it a try in 10-12 hours.<br />
Need to leave now.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25303</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25303</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Sat, 01 Jul 2017 11:54:18 GMT</pubDate></item><item><title><![CDATA[Reply to Replace 1 + lines? on Sat, 01 Jul 2017 09:23:38 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/374">@scott-sumner</a> and <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3662">@claudia-frank</a>,</p>
<p dir="auto"><strong>Claudia</strong>, your automatic counting of any <strong>normal</strong> selection, <strong>multi</strong>-lines or not, works fine !</p>
<p dir="auto"><strong>Scott</strong>, your <strong><code>ReplaceWithBoxFromSelection.py</code></strong> script is working <strong>nice</strong>, too !. I’ve just noticed that your script, <strong>automatically</strong>, copies the current <strong>normal and unique</strong> selection, <strong>BOTH</strong>, in the <strong>Find what :</strong> and in the <strong>Replace with:</strong> boxes. Is it the <strong>normal</strong> behaviour or am I <strong>wrong</strong> about it ?</p>
<hr />
<p dir="auto">This topic makes me think about an other possibility ! Let’s suppose that the option <strong>Settings &gt; Preferences…&gt; Editing &gt; Multi-Editing Settings</strong> is <strong>enabled</strong></p>
<p dir="auto">Now, the <strong>goal</strong> would be :</p>
<ul>
<li>
<p dir="auto">To define <strong>TWO</strong> selected blocks of text, which could, <strong>independently</strong>, include <strong>multiple</strong> lines</p>
</li>
<li>
<p dir="auto">To Write a <strong>Python</strong> script which :</p>
<ul>
<li>
<p dir="auto">Opens the <strong>Find/Replace</strong> dialog</p>
</li>
<li>
<p dir="auto">Writes the <strong>first</strong> user selection, in the <strong>Find what:</strong> box</p>
</li>
<li>
<p dir="auto">Writes the <strong>second</strong> user selection, in the <strong>Replace with:</strong> box</p>
</li>
</ul>
</li>
</ul>
<p dir="auto"><strong>Scott</strong> and <strong>Claudia</strong>, what is your feeling about it ?</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25299</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25299</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sat, 01 Jul 2017 09:23:38 GMT</pubDate></item></channel></rss>