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

wxStyledTextCtrl - Line Endings

  • ConvertEOLs

  • GetEOLMode

  • GetViewEOL

  • SetEOLMode

  • SetViewEOL

Summary:

The STC can use any of the three common EOL markers:

  • DOS, Windows : \r\n (or CRLF) (this is the default)

  • Unix® : \n (or LF)

  • Apple® Macintosh : \r (or CR)

The selected line ending is inserted into the current position of the active Document when the <ENTER> button is pressed on the keyboard.

The SetEOLMode command allows you to change the line ending that's used. The SetViewEOL command allows you to set whether or not line endings are displayed in the STC display.

The ConvertEOLs command lets you change all of the line endings from one type to another.

WxPython has three defined variables that act as constants to select or test for the particular type of line endings:

 wxSTC_EOL_CR   : CR only
 wxSTC_EOL_CRLF : CRLF
 wxSTC_EOL_LF   : LF only

----

ConvertEOLs(eolMode)

Goes thru the active document and does deletes and inserts as necessary to convert whatever form of line ending currently exist to the type of line ending set by the integer parameter eolMode.

eolMode must be one of:

 wxSTC_EOL_CR   : CR only
 wxSTC_EOL_CRLF : CRLF
 wxSTC_EOL_LF   : LF only

Returns None.

top

----

GetEOLMode()

Returns an integer with the current line ending mode. The return value will be one of:

 wxSTC_EOL_CR   : CR only
 wxSTC_EOL_CRLF : CRLF
 wxSTC_EOL_LF   : LF only

It is important to note that this is only correct for the active Document. See SetEOLMode.

top

----

GetViewEOL()

Returns 1 if the view end-of-line mode is on or 0 if it is not.

top

----

SetEOLMode(eolMode)

Sets the line ending mode for the active Document to the integer value eolMode. It is important to realize that this is NOT a global setting, but is done on a document-by-document basis. When a new document is created its internal EOL mode flag is set to LF only (wxSTC_EOL_LF) if the OS is Unix or to CRLF (wxSTC_EOL_CRLF) otherwise (this is a result of a compile-time #ifdef in the Scintilla code).

If you are concerned about cross-platform compatibility, you may wish to programmatically set this every time a new Document is created. Otherwise, if your app is run on a Mac the EOL mode will be set to CRLF.

The values to use for eolMode are shown below:

 wxSTC_EOL_CR   : CR only
 wxSTC_EOL_CRLF : CRLF
 wxSTC_EOL_LF   : LF only

Returns None

top

----

SetViewEOL(visible)

If you'd like to have the line endings visible, set the visible integer parameter to 1; to shut this off use visible = 0. You can affect the way that the control characters are displayed with SetControlCharSymbol, otherwise the control characters are displayed as the ASCII mnenonics in a rounded rectangle or some similar appearance. The style wxSTC_STYLE_CONTROLCHAR is used to draw control characters, see Styling if you want to change, for example, the foreground and background colors for the control character display.

Returns None

top

----