The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

PyFrame Guide to wxPython

Copyright and License information Home

__ A B C D E F G H I L M P R S T U V W

Braces

  • BraceBadLight

  • BraceHighlight

  • BraceMatch

Summary:

Brace highlighting is a very useful feature for programming and HTML/XML editors, among others.

To use brace highlighting, one first calls BraceMatch to locate a matching brace given the location of one brace. If a match is found (BraceMatch return value <> wxSTC_INVALID_POSITION), then BraceHighlight is used to highlight the two braces using the brace highlighting style (style number 34).

If there is no matching brace (BraceMatch returns value = wxSTC_INVALID_POSITION) then BraceBadLight can be used to highlight the brace that is unmatched using the brace badlighting style (style number 35)

When you're done using brace highlighting and want to remove it, use BraceBadLight or BraceHighlight again, with the position or positions set to wxSTC_INVALID_POSITION (wxSTC_INVALID_POSITION = -1). This will remove the highlighting.

----

BraceBadLight(pos)

Sets the style for the character at the position specified by the integer pos to style 35. Use pos = wxSTC_INVALID_POSITION to remove the highlight. Returns None.

top

----

BraceHighlight(pos1,pos2)

Sets the style for the characters at the positions specified by the integers pos1 and pos2 to style 34. Use pos1 = pos2 = wxSTC_INVALID_POSITION to remove the highlighting. Returns None.

top

----

BraceMatch(pos)

This method finds a matching brace given the location of the first brace. The integer object pos is a position in the active document where a brace exists. If there's no brace at that location or if no matching brace can be found, the return value is wxSTC_INVALID_POSITION (which = -1). Otherwise the return value is the position of the matching brace.

The brace characters that can be matched are: ( ) [ ] { } < >

A match only occurs if the style of the matching brace is the same as the style of the starting brace or if the matching brace is beyond the end of styling. Nested braces are handled correctly.

It's important to realize that this method does NOT do any highlighting, it just finds the matching brace.

top

----