Community
    • Login
    1. Home
    2. Popular
    Log in to post
    • All Time
    • Day
    • Week
    • Month
    • All Topics
    • New Topics
    • Watched Topics
    • Unreplied Topics
    • All categories
    • Mark BoonieM

      Show (or keep) subsets of a file

      Watching Ignoring Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
      16
      0 Votes
      16 Posts
      139 Views
      guy038G

      Hello, @mark-boonie and All,

      I said in this post that we can translate the regex’s logic to :

      What_I_do_not_want(*SKIP)(*F)|What_I_want. See also the excellent article, on this topic, at https://www.rexegg.com/backtracking-control-verbs.php#skipfail !

      But, regarding your present example, @mark-boonie, I suppose that we should invert the logic and tell :

      What_I_want_to_keep(*SKIP)(*F)|What_I_want_to_delete

      This means that any multi-lines block, with delimiters Block start and Block end containing the string 80     00010000 is not considered ( text is skipped ) and that any single line contents, with its line-break, due to the (?-s) modifier, must be deleted

      Note that the use of the Backtracking Control Verbs (*SKIP) and (*F) is not mandatory at all ! we could have used this syntax, instead, for similar results :

      SEARCH (?s)^\*Block start\h*((?!\*Block start).)+?80 00010000.+?^\*Block end\h*\R?|(?-s)^.*\R?

      REPLACE (?1$0)

      We simply change the non-capturing group (?:(?!\*Block start).)+? into a capturing group ((?!\*Block start).)+?

      We tell that, in replacement, we must rewrite any block entirely ( $0 ), if the group 1 exists, thus the (?1$0) syntax

      And, as there is no colon char and text after (?1$0, nothing must be taken in account if the group 1 is absent, which is the case in the (?-s)^.*\R? part !

      Best regards,

      guy038

    • Fred MorantF

      "In Find, Regex Search in Current File Limited to "Find Next" Downward Direction Only"

      Watching Ignoring Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
      5
      0 Votes
      5 Posts
      107 Views
      PeterJonesP

      @Fred-Morant said in "In Find, Regex Search in Current File Limited to "Find Next" Downward Direction Only":

      @PeterJones ,

      This solution requires a change in config.xml,

      As described in the user manual, yes.

      regexBackward4PowerUser at yes seems to be not an accepted value for my version V8.9.1.

      Nope. Works just fine for me in v8.9.1. My guess is you used your active Notepad++ to edit config.xml. But Notepad++ overwrites config.xml when it exits, so you lost your change. The user manual has a few paragraphs at Config Files Details > Editing Configuration Files which explains how to edit most of the Notepad++ configuration files, and then explains the workaround for the config.xml exception.

      Until you properly edit and save the config.xml, Notepad++ will not see your regexBackward4PowerUser="yes"

      if config.xml is detected with value not conformed at start then config.xml is not considered and default parameters are used,
      if config.xml is not conformed then config.xml is rewritten at close,

      Correct. That’s described in more detail in the user manual, where I just linked you.

      Reason for considering regexBackward4PowerUser at yes as not a accepted value :
      going backward with a regex requires more computation than going forward, and that value is not accepted in V8.9.1,

      Wrong. Don’t believe AI hallucinations. It has nothing to do with computation. Regular expressions parse characters in byte order, and when they do that but go backwards through the bytes for the start of the match, there are quirks that users don’t expect; the Developer got tired of people reporting bugs in the regex engine because they didn’t understand the implications of how backward mode interacts with regular expression parsing, so turned it off by default, but gave power users the ability to turn it back on. That ability has not been taken away, despite the lies the AI is telling you.

      Do you confirm ?

      I confirm it’s nonsense from AI that just says the most likely next words based on context. “Most likely” does not equal “true”.

    • Anderson NascimentoA

      Monokai and JS versão 8.9.1

      Watching Ignoring Scheduled Pinned Locked Moved Notepad++ & Plugin Development
      2
      1 Votes
      2 Posts
      6 Views
      PeterJonesP

      @Anderson-Nascimento ,

      What was your upgrade path? If you ran v8.8.9 or v8.9.0 at some point, there were issues we discovered in those two versions which would cause things like that, and it would have saved the theme in just the way you show – that’s a known issue that all experiments have shown have been fixed. On the other hand, if you started from v8.8.8 or earlier, and then upgraded directly to v8.9.1 (without every installing or running v8.8.9 or v8.9.0), that corruption shouldn’t’ve happened; if that’s the path you took, I will need specifics (what version you started with, when you did the update, and confirmation that you never updated between the two), so I can try to replicate it, because every experiment I’ve seen shows that going from v8.8.8 (or earlier) to v8.9.1 doesn’t have any such problems.

      This FAQ explains how to fix the problem (especially the v8.9 section, which talks specifically about the JavaScript issue). Essentially: if you haven’t customized anything in the Style Configurator for your theme, you just have to replace the theme file in the installation directory; if you had any customization (either from your earlier version, or that you’ve done since your upgrade), you’ll have to go through a more-involved process, including updating both the copy of the theme in the installation directory and in your AppData directory, and it will be more involved, because you will have to copy specific information from inside the XML files.

      (updated: rephrased the post to hopefully make it more clear)

      update 2:

      if I start with a fresh v8.8.8 in Light Mode + Monokai (to match your screenshot), then upgrade to v8.8.9 and then to v8.9.1, I can see something akin to your screenshot.
      4ac9413d-03d4-4853-8ca1-78c962cebfd9-image.png

      if I start with a fresh v8.8.8 in Light Mode + Monokai, then upgrade to v8.9.0 and then to v8.9.1, I see something different: the *.js appears to have no highlighting, because it’s set to default fg and bg for all styles (but Style Configurator lets you change those):
      da0f0024-a90e-49fc-9634-984df262bf1d-image.png

      if I start with a fresh v8.8.8 in Light Mode + Monokai, then upgrade to v8.9.1 directly, then everything works as I expect:
      283bbc55-324e-467a-80e9-204915e9f565-image.png

      Given your screenshot, I am very confident that you started at some older version, updated to v8.8.9 and ran at least once (but maybe hadn’t looked at any javascript to notice the problem), then updated again to v8.9.1 and finally saw the problem. If that’s what happened, then the instructions in the FAQ will help you get the theme fixed.

    • Fred MorantF

      "Search result" are not more stacked,

      Watching Ignoring Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
      2
      0 Votes
      2 Posts
      41 Views
      PeterJonesP

      @Fred-Morant said in "Search result" are not more stacked,:

      Every new search replaced the previous one,

      In the Search Results panel, Right Click, then uncheckmark “Purge for every search”

      f9b80104-3491-4a95-9a71-8cc5b64a683d-image.png
      =>
      534dcf2f-da9e-4350-82ff-673e4afd1558-image.png

    • David Smith 2D

      How to change the colors used for html/css that is exported

      Watching Ignoring Scheduled Pinned Locked Moved General Discussion
      2
      0 Votes
      2 Posts
      53 Views
      David Smith 2D

      This issue has been fixed:
      I did the following. As I use a inline style sheet I created a “css color.css” file in Notepad++. Just a blank page that I can do the following:

      I can now paste my HTMLPad 2025 css code into Notepad++ with the colors I changed under Settings> Style Configurator.

      I also created a “html-colors.html” blank file and I can copy the html code with colors that Notepad++ provides that has been updated in the Style Configurator.

      Next I highlight the text then go to “Plugins” on the toolbar then “NppExport” then “Copy all formats to clipboard”.

      I can now paste in the html/css code into Word with the colors I want.

      I still cannot create a style in Word 2024 with colors as I suspect it would be too complicated for Word to figure what parts the different text it should color.

    • Thorsten HeuerT

      Feature Request / Question: Soft Wrap at Vertical Edge (Column 80) regardless of window size

      Watching Ignoring Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
      16
      1 Votes
      16 Posts
      533 Views
      PeterJonesP

      @Alan-Kilborn ,

      Okay, since I didn’t know how to hook the message loop I found this old post by you (I remembered you had done it for the alt+scrollwheel, thankfully), and I was able to use that as a basis for a two-file solution to @fml2’s request

      file 1: MsgHooker.py

      # -*- coding: utf-8 -*- # original author: @Alan-Kilborn # reference: https://community.notepad-plus-plus.org/post/100127 # modified by: @PeterJones # - updated to add the .unhook() and .__del__() methods import platform from ctypes import (WinDLL, WINFUNCTYPE) from ctypes.wintypes import (HWND, INT, LPARAM, UINT, WPARAM) user32 = WinDLL('user32') GWL_WNDPROC = -4 # used to set a new address for the window procedure LRESULT = LPARAM WndProcType = WINFUNCTYPE( LRESULT, # return type HWND, UINT, WPARAM, LPARAM # function arguments ) running_32bit = platform.architecture()[0] == '32bit' SetWindowLong = user32.SetWindowLongW if running_32bit else user32.SetWindowLongPtrW SetWindowLong.restype = WndProcType SetWindowLong.argtypes = [ HWND, INT, WndProcType ] class MH(object): def __init__(self, hwnd_to_hook_list, hook_function, # supplied hook_function must have args: hwnd, msg, wparam, lparam # and must return True/False (False means the function handled the msg) msgs_to_hook_list=None, # None means ALL msgs ): self.users_hook_fn = hook_function self.msg_list = msgs_to_hook_list if msgs_to_hook_list is not None else [] self.new_wnd_proc_hook_for_SetWindowLong = WndProcType(self._new_wnd_proc_hook) # the result of this call must be a self.xxx variable! self.orig_wnd_proc_by_hwnd_dict = {} for h in hwnd_to_hook_list: self.orig_wnd_proc_by_hwnd_dict[h] = SetWindowLong(h, GWL_WNDPROC, self.new_wnd_proc_hook_for_SetWindowLong) v = self.orig_wnd_proc_by_hwnd_dict[h] #print(f"add {h:08x} => {v}") def __del__(self): self.unhook() def unhook(self): #print(f"unhook: self:{self} => <{self.orig_wnd_proc_by_hwnd_dict}>"); mykeys = [] for h in self.orig_wnd_proc_by_hwnd_dict.keys(): orig = self.orig_wnd_proc_by_hwnd_dict[h] print(f"\tdel {h:08x} => {orig}") SetWindowLong(h, GWL_WNDPROC, orig) mykeys.append(h) for h in mykeys: del self.orig_wnd_proc_by_hwnd_dict[h] def _new_wnd_proc_hook(self, hwnd, msg, wParam, lParam): retval = True # assume that this message will go unhandled (by us) need_to_call_orig_proc = True if len(self.msg_list) == 0 or msg in self.msg_list: retval = self.users_hook_fn(hwnd, msg, wParam, lParam) if not retval: need_to_call_orig_proc = False if need_to_call_orig_proc: retval = self.orig_wnd_proc_by_hwnd_dict[hwnd](hwnd, msg, wParam, lParam) return retval

      file 2: the main script:

      # encoding=utf-8 """in response to https://community.notepad-plus-plus.org/topic/27351/ Trying to implement @Coises idea for setting the wrap to exactly 80 """ from Npp import * import ctypes from ctypes import wintypes from MsgHooker import MH as MsgHook WM_SIZE = 0x0005 # Define the RECT structure to match Win32 API class RECT(ctypes.Structure): _fields_ = [ ("left", wintypes.LONG), ("top", wintypes.LONG), ("right", wintypes.LONG), ("bottom", wintypes.LONG) ] def width(self): return self.right - self.left def height(self): return self.bottom - self.top def pysc_setWrap80(ed=editor): #console.write("ed={}\n".format(ed)) WRAPCHARS = 80 # Setup the Win32 function prototype user32 = ctypes.windll.user32 user32.GetClientRect.argtypes = [wintypes.HWND, ctypes.POINTER(RECT)] user32.GetClientRect.restype = wintypes.BOOL def get_window_size(hwnd): # 2. Instantiate the RECT structure rect = RECT() # 3. Call GetClientRect passing the rect by reference if user32.GetClientRect(hwnd, ctypes.byref(rect)): # 4. Parse the results # Client coordinates: top-left is always (0,0) return rect else: raise Exception("GetClientRect failed") sz = get_window_size(ed.hwnd) #console.write("{} => {}\n".format(ed.hwnd, {"width": sz.width(), "height": sz.height()})) usableWidth = sz.width() for m in range(0, 1+ed.getMargins()): w = ed.getMarginWidthN(m) usableWidth -= w #console.write("m#{}: {} => usableWidth: {}\n".format(m, w, usableWidth)) widthWrappedChars = ed.textWidth(0,"_"*WRAPCHARS)+1 # one extra pixel to be able to show the VerticalEdge indicator line wantMargin = usableWidth - widthWrappedChars if wantMargin < 1: wantMargin = 0 #console.write("{}\n".format({"windowWidth": sz.width(), "usableWidth": usableWidth, "pixelsFor80Char": widthWrappedChars, "wantMargin": wantMargin})) ed.setMarginRight(wantMargin) ed.setMarginLeft(0) def HIWORD(value): return (value >> 16) & 0xFFFF def LOWORD(value): return value & 0xFFFF def pysc_size_callback( hwnd, msg, wParam, lParam): #console.write(f"cb(h:{hwnd}, m:{msg}, w:{wParam}, l:{lParam}) => {LOWORD(lParam)} x {HIWORD(lParam)}\n") if hwnd == editor1.hwnd: pysc_setWrap80(editor1) elif hwnd == editor2.hwnd: pysc_setWrap80(editor2) return True pysc_setWrap80(editor1) pysc_setWrap80(editor2) pysc_size_hook = MsgHook([ editor1.hwnd, editor2.hwnd ], pysc_size_callback, [WM_SIZE]) console.write("SetWrap80 registered WM_SIZE callback\n") def pysc_unsetWrap80(args=None): """ To stop pysc_unsetWrap80() """ editor1.setMarginRight(0) editor2.setMarginRight(0) global pysc_size_hook if pysc_size_hook: pysc_size_hook.unhook() del pysc_size_hook # use the following in the console (no #) to stop it from always wrapping at 80 # # pysc_unsetWrap80()

      You run the main script (or call it from startup.py) to get it to start watching for WM_SIZE, and when it gets that, it does the calcs needed to keep the wrap margin at 80 characters (+1 pixel so that the Vertical Edge line would be visible if you’ve got it on)

      Both scripts should go in the main %AppData%\Notepad++\plugins\Config\PythonScript\scripts directory (or equivalent for non-AppData setups, or you need to have added their parent directory to sys.path)