Hello!
I want to include a simple XML editor in my application and the StyledTextControl seems to be just right for this purpose, but I can't find any tutorials on how to use it.
How do I activated Folding?
How do I define syntax highlighting with a property file?
The first characters are "" before the root node. What's wrong?
XML with StyledTextControl Topic is solved
XML with StyledTextControl
Last edited by letij on Thu Jun 19, 2008 12:59 pm, edited 1 time in total.
Lots of information here:letij wrote:Edit: Got the hardcoded syntax highlighting working already
use StyleSetXXX( wx.stc.STC_H_YYY, <style> ) methods
the STC_H_ constants define the XML tokens
Edit: A lot of infos seems to be pack in the file "wxPython Docs and Demos/demo/StyledTextCtrl_2.py"
http://www.yellowbrain.com/stc/index.html
Follow the development of my screenplay authoring program at http://wxscreenplaywriter.blogspot.com/
I still can't get the issue with the "" characters resolved. Notepad++ says that my document is "ANSI" while after I save it with the StyledTextControl it is "UTF-8". Is there a way to convert the document to UTF-8 right away?
> Lots of information here:
> http://www.yellowbrain.com/stc/index.html
I know, but it's only an API documentation, no tutorial. Thanks anyway!
> Lots of information here:
> http://www.yellowbrain.com/stc/index.html
I know, but it's only an API documentation, no tutorial. Thanks anyway!
What you see at the start of your file is the UTF-8 byte order mark.
(I know it's redundant as UTF-8 consists of chains of single-byte units, but some processors _require_ a UTF-8 BOM which is why many editors offer to put it in.)
One way of handling this is to strip out the byte order mark before passing it to wxStyledTextCtrl.
In the following docBuffer is of type char *, docBufferLen is unsigned and isUtf8 is bool.
An example of a syntax highlighting property is the stedit component.
I derived from wxStyledTextCtrl for my XML editor and there are some issues: the lexer has serious bugs (e.g. embedded DTDs aren't highlighted correctly) and the Scintilla component is rather out of date. (Can't wait for wxW 2.8.8! Until it's released I can't use the update that's been in the source tree since November last year - it's easy on Windows but the Linux port relies on centrally maintained libraries...)
-Gerald
(I know it's redundant as UTF-8 consists of chains of single-byte units, but some processors _require_ a UTF-8 BOM which is why many editors offer to put it in.)
One way of handling this is to strip out the byte order mark before passing it to wxStyledTextCtrl.
In the following docBuffer is of type char *, docBufferLen is unsigned and isUtf8 is bool.
Code: Select all
// adjust for UTF-8 BOM
if ( docBuffer &&
( unsigned char ) docBuffer[0] == 0xEF &&
( unsigned char ) docBuffer[1] == 0xBB &&
( unsigned char ) docBuffer[2] == 0xBF )
{
docBuffer += 3;
docBufferLen -= 3;
isUtf8 = true;
}
An example of a syntax highlighting property is the stedit component.
I derived from wxStyledTextCtrl for my XML editor and there are some issues: the lexer has serious bugs (e.g. embedded DTDs aren't highlighted correctly) and the Scintilla component is rather out of date. (Can't wait for wxW 2.8.8! Until it's released I can't use the update that's been in the source tree since November last year - it's easy on Windows but the Linux port relies on centrally maintained libraries...)
-Gerald