Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to obtain NPP bookmark ID #258

Open
jremus opened this issue Nov 18, 2022 · 9 comments
Open

How to obtain NPP bookmark ID #258

jremus opened this issue Nov 18, 2022 · 9 comments
Labels

Comments

@jremus
Copy link

jremus commented Nov 18, 2022

I created two small utility scripts. One that exports the bookmarked line numbers of an editor view and another that imports (bookmarks) specified lines in an editor view.

For that purpose I hardcoded the following (from the HideLines.py sample):

NPP_MARK_BOOKMARK = 24
NPP_MARK_BOOKMARK_MASK = 1 << NPP_MARK_BOOKMARK

Which I then use with editor.markerNext(line, NPP_MARK_BOOKMARK_MASK) and editor.markerAdd(line, NPP_MARK_BOOKMARK).

With the latest Notepad++ the value of MARK_BOOKMARK changed from 24 to 20 with Notepad++ commit 9455684 ("Renumber Notepad++ marks for preparing Scintilla 5.3.0's integration").

In the Notepad++ source I found that there is a NPP message NPPM_GETBOOKMARKID to get the bookmark ID. Is there any function in PythonScript to make use of that, so that I can replace the hardcoded bookmark ID with the one provided by the NPP API?

Thanks and regards,
Jens

@alankilborn
Copy link

alankilborn commented Nov 18, 2022

Is there any function in PythonScript to make use of that

There isn't, but I think you've just made a feature-request for it. :-)

Comment made current to PS releases 2.0 and 3.0.14

@jremus
Copy link
Author

jremus commented Nov 18, 2022

In the meantime I am using the following workaround:

# https://github.com/notepad-plus-plus/notepad-plus-plus/commit/9455684b429449f668c1aedb77ec9dcb1642c244
NPP_MARK_BOOKMARK = 24 if notepad.getVersion() < (8, 4, 6) else 20
NPP_MARK_BOOKMARK_MASK = 1 << NPP_MARK_BOOKMARK

@chcg chcg added the Feature label Nov 20, 2022
chcg added a commit that referenced this issue Nov 20, 2022
@alankilborn
Copy link

Mainly as a curiousity, @Ekopalypse provided some code (hope it is OK to share) that will obtain the bookmark id from Notepad++ 8.4.7 and later, before PythonScript supports a first-class "Notepad" object function for it:

import ctypes
NPP_MARK_BOOKMARK = ctypes.windll.user32.SendMessageW(ctypes.c_size_t(ctypes.windll.user32.FindWindowW(u'Notepad++', None)), ctypes.c_uint32(1024+1000+111), ctypes.c_size_t(0), ctypes.c_ssize_t(0))

@Ekopalypse
Copy link
Contributor

getBookMarkID is available now, can this be closed?

@alankilborn
Copy link

getBookMarkID is available now, can this be closed?

What does "now" mean in this context?

>>> notepad.getBookMarkID()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'Notepad' object has no attribute 'getBookMarkID'

with:

Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:25:05) [MSC v.1500 64 bit (AMD64)]

@Ekopalypse
Copy link
Contributor

Ah, ok - so this is only available with a recent PS3 version, I see ...

@alankilborn
Copy link

I have no explanation why this would be part of PS3 and not PS2, since PS2 is the currently the non-beta version. Features such as this should be present in both versions, IMO.

@Ekopalypse
Copy link
Contributor

... looks like the MS way. Offer a new product with new features to attract users for beta testing :-D

@alankilborn
Copy link

I don't think our wonderful PS developers are dumb and would use that strategy. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants