Marker number
-
there should be a “cough up a free marker ID, and then don’t give that same marker ID to anyone else that asks for a free one” plugin message/function.
Oh wait, it appears there IS the plugin message I’m talking about. Doh!
See HERE in N++ code.
And then this in the PS docs:

I suppose I haven’t noticed this because in all of my scripting endeavors, I haven’t needed to use a custom marker (or, I just don’t remember – failing memory disclaimer!).
-
@Alan-Kilborn I tried in the PythonScript console:
>>> print(notepad.allocateMarker(25)) None >>> print(notepad.allocateMarker(0)) NoneWhat does that mean?
-
@Paul-Wormer said in Marker number:
BTW, how about your promise of a few day ago?
See HERE for “status”.
:-) -
@Paul-Wormer said in Marker number:
print(notepad.allocateMarker(25))
None
print(notepad.allocateMarker(0))
NoneWhat does that mean?
So the argument is numberRequested.
In the first case you are asking for 25, presumably contiguous, markers to be allocated. That’s way too many; that many aren’t going to be found.
In the second case you are asking for 0 markers to be allocated. That’s also pretty nonsensical.
If you want one marker, try
notepad.allocateMarker(1). Each time you call that, you should get a new number returned.(It appears you are thinking that you tell it which marker ID you want, at least from your usage of
25– that isn’t how it works) -
@Alan-Kilborn I expected a boolean upon return: if true markerNr is allocated; if false markerNr is free. That is not how it works apparently.
-
@Paul-Wormer said in Marker number:
I expected a boolean upon return: if true markerNr is allocated; if false markerNr is free. That is not how it works apparently.
No, it isn’t, but…why do you care what the actual number is?
In your code, go with:my_marker_id = notepad.allocateMarker(1)and then wherever you were using a hard-coded-magic-number for a marker number, use
my_marker_idinstead:my_marker_id = notepad.allocateMarker(1) editor.markerDefine(my_marker_id, MARKERSYMBOL.CIRCLEPLUS) nSymbol = editor.markerSymbolDefined(my_marker_id) editor.setMarginWidthN(marginNr, 16) editor.setMarginTypeN(marginNr, MARGINTYPE.SYMBOL) editor.setMarginMaskN(marginNr, 1<<my_marker_id ) editor.markerAdd(line-1,my_marker_id)Note that this kind of code will allocate a new number each time you run the script. So, as you’re working on the script, you’ll probably find you’ll be out of markers fairly quickly. :-(
To solve that, you could do:
try: # <-- important change! my_marker_id # <-- important change! except NameError: # <-- important change! my_marker_id = notepad.allocateMarker(1) # <-- important change! editor.markerDefine(my_marker_id, MARKERSYMBOL.CIRCLEPLUS) nSymbol = editor.markerSymbolDefined(my_marker_id) editor.setMarginWidthN(marginNr, 16) editor.setMarginTypeN(marginNr, MARGINTYPE.SYMBOL) editor.setMarginMaskN(marginNr, 1<<my_marker_id ) editor.markerAdd(line-1,my_marker_id) -
@Alan-Kilborn Yes, of course. It seems that the description of notepad.allocateMarker is wrong by stating
--> bool. Instead it should state--> int. That put me off. -
@Paul-Wormer said in Marker number:
It seems that the description of notepad.allocateMarker is wrong by stating --> bool. Instead it should state --> int. That put me off.
Good catch!
See HERE. -
@Alan-Kilborn Very good. Will Bruderstein listen, what is your experience?
-
@Paul-Wormer said in Marker number:
Will Bruderstein listen, what is your experience?
Dave Bruderstein and @chcg (Christian) are active on the PythonScript project; maybe not “super” active, but active.
I’d think they’d listen, it’s just an easy documentation error.
-
I wrote some test code:
for j in range(100): my_marker_id = notepad.allocateMarker(1) print(my_marker_id) if my_marker_id is None: breakand obtained as output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 NoneNot sure where
0,15, and16are…? -
@Alan-Kilborn When I run my original script with markerNr (is marker_id) = 0 or 15, all is OK. The circleplus appears where you would expect it.
When I run your little script I get:
7 8 9 10 11 12 13 14 NoneSo during my session I claimed 0 thru 6 and 15. You probably claimed only 0 and 15. Apparently 16 and higher are taken by some plugins.
-
@Paul-Wormer said in Marker number:
You probably claimed only 0 and 15. Apparently 16 and higher are taken by some plugins.
I ran on a virgin system with only the PythonScript plugin (aside from the plugins that come with Notepad++). I’m fairly confident (as I hinted before) that PS doesn’t claim any itself.
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