Syntax highlighting in the text editor widget

Syntax highlighting works only if you set the siUILanguage to one of cpp, c#, HTML, JScript, PerlScript, Python, VBScript, or XML. Then the language keywords are highlight, plus any keywords you add with the siUIKeywords attribute.


from sipyutils import si			# win32com.client.Dispatch('XSI.Application')
from sipyutils import C			# win32com.client.constants


p = XSIFactory.Createobject( 'CustomProperty' )
oParam = p.AddParameter3("TextEditorWidget", C.siString, '')

oLayout = p.PPGLayout

oItem = oLayout.AddItem( "TextEditorWidget", "Source Code", C.siControlTextEditor)
oItem.SetAttribute( "Language", "JScript" )
oItem.SetAttribute(C.siUIFont, "Courier New")
oItem.SetAttribute(C.siUIKeywords, "foo bar fubar snafu")
oItem.SetAttribute(C.siUIAutoComplete, "fubar");
oItem.SetAttribute(C.siUICommentFont, "Courier New")
oItem.SetAttribute(C.siUICommentColor, 0x75715e)
oItem.SetAttribute(C.siUIPreprocessorColor, 0x808080)
oItem.SetAttribute(C.siUIToolbar, True)
oItem.SetAttribute(C.siUIFontSize, 10)
oItem.SetAttribute(C.siUIHeight, 500)
oItem.SetAttribute(C.siUIBackgroundColor, 0xf8f8f2)
oItem.SetAttribute(C.siUIForegroundColor, 0x272822)
oItem.SetAttribute(C.siUIHorizontalScroll, True)
oItem.SetAttribute(C.siUIVerticalScroll, True)
oItem.SetAttribute(C.siUILineNumbering, True)
oItem.SetAttribute(C.siUILineWrap, False)
oItem.SetAttribute("UseSpacesForTab", True)
oItem.SetAttribute("TabSize", 2) 

si.inspectobj( p )

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s