[DGD] colorification object

Krister Svanlund krister.svanlund at gmail.com
Sat Jul 24 23:00:01 CEST 2010


I've written a program for DGD that parses strings containing %COLOR%
tags and replacing it with correct ansi escape-sequence
http://drunkcoding.tumblr.com/post/853534887/ansid-c

The syntax is as follows (semi-regexp):

+ %([A-Z]+|[0-9])[!._-]*% - This makes text a certain color specified
with either a word in caps or a number either one can be followed by a
series of modifications, '!' makes the text brighter, '.' makes it
fainter, '_' and '-' makes different strikings of the text. '%RED!_%'
makes bright red underlined text.

+ %[<>v^][0-9]*% - Moves the cursor a certain number of columns or
rows. '%^2%' moves the cursor up two lines.

+ %CLEAR[<>v^|]?% - Clears the text in either directions, '|' clears
the entire screen and no arrow clears the current line. '%CLEAR^%'
clear all rows above this one.

+ %COL[0-9]*% - Puts the cursor at a specific column or 1 if none is
specified. '%COL1%' puts the cursor on the first column of the current
row.

Working with a basic setup built on the kernel lib I just implemented
the message function in the /usr/System/obj/user.c program and there
called the parent message using ::message(ANSID->colorize_string(s));

Hope it enjoys someone and comments are appreciated!



More information about the DGD mailing list