The new Text() control support many color, font, highlight and style.
Therefore, we are now capable of making a more decent editor.
Here's an example how python source code can be syntax-colored.
You need first to install the PyFontify module from here
http://linux.duke.edu/~mstenner/free...y/pyfontify.py
See screenshot here.Code:from appuifw import * from pyfontify import fontify import os, e32 src = ur""" __version__ = "0.4" import string, re, keyword commentPat = "#.*" # Build up a regular expression pat = "q[^\q\n]*(\\\\[\000-\377][^\q\n]*)*q" """ color = { 'keyword': 0x0000ff, 'string': 0xff00ff, 'comment': 0x008000, 'function': 0x008080, 'class': 0x008080 } t = Text() pos = 0 for tag, start, end, sl in fontify(src): t.color = 0 t.add(src[pos:start]) t.color = color[tag] t.add(src[start:end]) pos = end t.color = 0 t.add(src[pos:]) app.body = t e32.ao_sleep(10)
http://photos22.flickr.com/30187174_8598b800ec_o.jpg


Reply With Quote


