I am attempting to write a script which places a marker on a line in the margin as a symbol, or preferably, as a character. I have this script below which changes the bookmark icon, but when I place a marker the line simply has its background changed. My understanding is that this might be because the margin where the marker would go has a 0 width. However, I tried giving each margin a width and it made no difference. The scintilla documentation explains that the marker will appear in the "selection margin" but fails to define what exactly that is.
pos = editor.getCurrentPos()
line = editor.lineFromPosition(pos)
editor.markerDefine(8, MARKERSYMBOL.CIRCLE) # use a colored symbol (possible symbols are CIRCLE, ROUNDRECT, ARROW, SMALLRECT, SHORTARROW, .
editor.markerSetFore(8, (255,0,0)) # contour of symbol
editor.markerSetBack(8, (255,255,0)) # filling
marker = editor.markerAdd(line,8)
You're just missing a
which just says that marker 8 (ie. 256 when expressed as a decimal), should be shown on margin 4.
Incidentally, you could set a flag if the "setup" has already been done (so all the margin and marker preparation), then only do that once. You could also remember the line the marker is on, then just remove that marker, rather than calling markerDeleteAll() - I'm not sure how quick markerDeleteAll is, although it's probably got a list of the line numbers cached somewhere so shouldn't be too problematic.
Ahh, okay, that makes sense. I think that single clarification will go a long way towards explaining other marker mysteries.
Thanks for the help, I'll make this change. The script is is going to be a replacement for the "numbered bookmarks" script I had questions about a while back. Turns out that approach has issues in that any time text is added the line numbers get rather un-aligned with the position bookmarked.
Another quick question. My original scripts had two scripts for ever bookmark. One to set it (i.e. to set margin text and save the line number) and a second script to go to that line number. I had shortcuts alt-# to set the bookmark, and ctrl-# to go to the bookmark I'd like to have shortcuts with this script as well but I'm curious as to whether or not there is a way to use a single shortcut to the script but then enter a number to indicate which mark to set or go to. Is it possible to start the script and then have it wait for a keypress (which would be a single number). Or maybe throw up a dialog to collect that number?
You could use notepad.prompt() to throw up a dialog, but that waits for a return key press afterwards - I don't *think* you could wait for an individual keypress, but there may be some way to do it (maybe with PyWin32?). There are some more Python-experienced people on here that may be able to answer that.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.