Indicator functions not available for PyPN?

Discussion Forums discussion Indicator functions not available for PyPN?

This topic contains 0 voices and has 2 replies.

Viewing 3 posts - 1 through 3 (of 3 total)
Author Posts
Author Posts
September 9, 2011 at 2:34 pm #5489

CoDEmanX
Member

Hey Simon,

you suggested to have a look at the TextUtil code to get an idea, how Scintilla indicator styles work and that one could use it with PyPN ( http://code.google.com/p/pnotepad/issues/detail?id=1374#c2 )

But the needed Indicator functions aren’t available: http://www.pnotepad.org/docs/pypn_api_pages

- Python error: <type ‘exceptions.AttributeError’>: ‘Scintilla’ object has no attribute ‘SetIndicatorCurrent‘ / ‘IndicatorClearRange‘ / ‘IndicatorFillRange

Am I overlooking something (imports?) or aren’t they supported yet?

September 12, 2011 at 10:06 am #18099

simon
Key Master

Ah yes, they haven’t been added yet. You should be able to do them manually using:

doc.SendMessage

You’ll need the message numbers for each of the APIs, which are:

# Set the indicator used for IndicatorFillRange and IndicatorClearRange
set void SetIndicatorCurrent=2500(int indicator,)

# Get the current indicator
get int GetIndicatorCurrent=2501(,)

# Set the value used for IndicatorFillRange
set void SetIndicatorValue=2502(int value,)

# Get the current indicator vaue
get int GetIndicatorValue=2503(,)

# Turn a indicator on over a range.
fun void IndicatorFillRange=2504(int position, int fillLength)

# Turn a indicator off over a range.
fun void IndicatorClearRange=2505(int position, int clearLength)

# Are any indicators present at position?
fun int IndicatorAllOnFor=2506(int position,)

# What value does a particular indicator have at at a position?
fun int IndicatorValueAt=2507(int indicator, int position)

# Where does a particular indicator start?
fun int IndicatorStart=2508(int indicator, int position)

# Where does a particular indicator end?
fun int IndicatorEnd=2509(int indicator, int position)

so for example to clear a range you want something like:

editor = scintilla.Scintilla(doc)
doc.SendMessage(2505, editor.SelectionStart, editor.SelectionEnd)

Also, if you wouldn’t mind filing a request I’ll add the missing commands to the next PyPN :)

September 12, 2011 at 12:45 pm #18100

CoDEmanX
Member

Great, thank you Simon!

Added request, issue #1437

This test script marks all numbers (I use it as PyPN textclip):

import string

doc = pn.CurrentDoc()
sci = scintilla.Scintilla(doc)

doc.SendMessage(2500, 8, '')

doc.SendMessage(2505, 0, sci.Length)

doc.SendMessage(2502, 7, '')

sci.IndicSetStyle(8, 7)

for i in range(0, sci.Length-1):
char = sci.GetTextRange(i, i+1)
if char in string.digits:
doc.SendMessage(2504, i, 1)

I wonder what the long/char* parameter is for (e.g. in SetIndicatorValue)…

ArgumentError: Python argument types in IDocument.SendMessage(IDocument, int, int) did not match C++ signature:
SendMessage(class extensions::IDocument {lvalue}, unsigned int, unsigned int, char const *)
SendMessage(class extensions::IDocument {lvalue}, unsigned int, unsigned int, long)

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.