R & D, Downloads, Source Code

bcchang.com / Research / VR / Downloads

Ygdrasil Syntax Coloring For Kate

Kate, the K Advanced Text Editor, is a great text-editing program that comes with the KDE desktop. One of its nice features is syntax coloring and highlighting for different languages, which makes programming much easier and helps you catch typos and errors. Here's a fragment of a Yg scene without syntax highlighting:
object skyscrapers (file(field_skyscrapers.b3d), wall(true),size(1 1 .001)) object cityground (file(field_cityground.b3d),floor(true)) userTrigger (volume (sphere 0 -20 0 10), when (enter, activatedFlag.set(true) )) boolean activatedFlag (set(false), when(changedTrue, treetimer1.start, treetimer2.start+3, treetimer3.start+6, ) )
And the same code, with syntax highlighting :
object skyscrapers (file(field_skyscrapers.b3d), wall(true),size(1 1 .001)) object cityground (file(field_cityground.b3d),floor(true)) userTrigger (volume (sphere 0 -20 0 10), when (enter, activatedFlag.set(true) )) boolean activatedFlag (set(false), when(changedTrue, treetimer1.start, treetimer2.start+3, treetimer3.start+6, ) )

Downloading and Installing Syntax Highlighting

ygdrasil.xml is the syntax definition file. Save it and copy it into Kate's syntax definition directory. In SUSE Linux, this is /opt/kde3/share/apps/katepart/syntax/. Other linux distributions that don't use the /opt directory tree will have it somewhere else, like /usr/share/apps/katepart/syntax.

Using Syntax Highlighting

When Kate loads a file with the extension ".scene", it will know it's a Ygdrasil file and color it appropriately. You can also turn highlighting on automatically from the Tools->Highlighting menu.