Save found files?
-
BTW, I’m still confused after looking at N++ source on how N++ identifies the hit text, so that the “search result” lexer knows where it is, so if you can shed any light on that… if you’re sufficiently interested in doing so… :-)
-
Is N++ source using hardcoded magic numbers for this instead of
Not sure I understand the question correctly.
Every lexer has hard coded style ids, which then get mapped
with a color via stylers.xml. See searchResult.how N++ identifies the hit text
It uses an internal struct MarkingsStruct which seems to be filled and provided
as a property to the document. Maybe something you can use to your advantage? -
Sorry, Forgot to include the structure reference.
-
Made me a bit of a headache because I assumed that the pointer was an integer data type
but the npp code actually said that it was a const char pointer.
In short, here’s a python script that can determine the positions of the matches.I leave the changes from py3 to py2 to you :-)
class SearchResultMarking(ctypes.Structure): _fields_ = [('_start', ctypes.c_long), ('_end', ctypes.c_long)] class SearchResultMarkings(ctypes.Structure): _fields_ = [('_length', ctypes.c_long), ('_markings', ctypes.POINTER(SearchResultMarking))] # const char *addrMarkingsStruct = (styler.pprops)->Get("@MarkingsStruct"); addrMarkingsStruct = f_editor.getProperty("@MarkingsStruct").encode() # SearchResultMarkings* pMarkings = NULL; pMarkings = ctypes.pointer(SearchResultMarkings()) # sscanf(addrMarkingsStruct, "%p", (void**)&pMarkings); ctypes.cdll.msvcrt.sscanf(addrMarkingsStruct, b"%p", ctypes.byref(pMarkings)) for i in range(pMarkings.contents._length): print(f'line {i} start:{pMarkings.contents._markings[i]._start} - end:{pMarkings.contents._markings[i]._end}') -
@Ekopalypse said in Save found files?:
I leave the changes from py3 to py2 to you
Not a big burden, only the “print” line for that…
But…What’s your magic behind
f_editor? Instead of that I would have expected something like what I did in the earlier code I posted in this thread; something much messier, like:ctypes.WinDLL('SciLexer.dll', use_last_error=True).Scintilla_DirectFunction(self.direct_pointer, 2182, length_of_text, text_of_document)``` but using a different number than `2182` and different parameters, of course... -
Not a big burden, only the “print” line for that…
and the encode is not needed as py2 returns bytes
as well as the b before the “%p”.But…What’s your magic behind f_editor?
Nothing, this is just my object which represents the editor in the find in files window.
As you said, what you would have expected must be done on your side.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login