= StyledTextCtrl Log Window Demo =
I often here people bemoan the lack of a 'simple' demo for the StyledTextCtrl, so I present here the simplest possible useful application of the control that I can think of.

This demo shows how to use a StyledTextCtrl as a log window with the ability to display messages in colour and that allows users to zoom the text with the keyboard(Ctrl + or Ctrl -) and the mouse ( Ctrl Scroll Wheel.)

I hope to show in this demo that although the StyledTextCtrl is a complicated beast and takes a lot of effort to master, it is possible to achieve very worthwhile results with very little effort.

When I say that this is the simplest useful application of a StyledTextCtrl that I can think of, thats not quite true. This application would still be worthwhile even if the colour facility was left out. Whenever you use the control in wxPython you get the ability to zoom text for free, it comes as standard, you don't need to do anything to enable it.

I get very annoyed with programs that display log messages, and scrolled message dialogs, in tiny fonts that I can barely read. ( Linux programs seem to be particularly susceptible to this crime.) Be kind to yourself and your users, use a StyledTextCtrl for log and message output.

==== Platform ====
This demo has been tested by the author on:

 * Window XP with Python 2.4 and wxPython 2.6.3
 * Debian GNU/Linux 3.1(Sarge) with Python 2.3 and wxPython 2.6.3
and by others on:

 * (add your platform here if different from above)
{{attachment:colourlog.py}}

----

== Requests ==
If you would like to see a particular feature of the StyledTextCtrl demonstrated, state your request below in '''20 words''' or less. If you are specific and concise, there is a small but finite probability that your request will be considered.

Q) '''Request: When using a XML lexer, I would like to see an example how to enable (un)folding of XML sections.'''

A) Replacing YourStc with the instance of your StyledTextCtrl and making these two calls should do

{{{
YourStc.SetProperty("fold", "1")
YourStc.SetProperty("fold.html", "1")}}}
Q) '''Using XML, is there an option to hand over a DTD or XSD to the wxStyledTextCtrl for the AutoCompletion feature ?'''

----

== Comments ==
Any comments and suggestions will be welcome and you can be as verbose as you like in this section. Bug reports most welcome.

==== Don't forget to set cursor position ====
Don't forget to issue the following statement before calling AddText(). This statement will restore the cursor position to the end of text, before the insertion of the new text. This will give you the "append" behaviour you want.

Otherwise, in case the user plays with the log window (which in the example is NOT read only), or places the cursor somewhere in the log window, the text will not be inserted in the correct place. Also your nice formatting might be messed. So to avoid this, use the below statement.

 . SetCurrentPos(self.GetTextLength())