1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2
! A control-code add on system for
4
! Version 1 by L. Ross Raszewski
7
! I was coding up an array of stings to be printed by a function in a game I
8
! was writng, when it occured to me that I wanted to used colored text, and,
9
! unfortunately, Inform requires the unsightly kludge of doing this:
10
! print "The last word in this sentence should be in ";
15
! So, I decided to write a library that would let me abbreviate control codes
16
! in the text of a string. Hence ZNSI.
17
! ZNSI is a set of control sequences which may be inserted into a string and
18
! and run at print-time. It uses the string-printing facilities of the
20
! In order to print a sequence of control characters, use the function
21
! LPrintString (or Printstring, for string arrays). The following
22
! control sequences have been defined: (all sequences start with the
23
! character '[' and are case sensitive)
24
! Sequence: Effect: Sequence: Effect:
25
! "[N" default font and color "[7" Foreground: Magenta
26
! "[B" Bold font "[8" Foreground: Cyan
27
! "[U" Underline font "[9" Foreground: White
28
! "[R" Reverse font "[d" Background: Default
29
! "[F" Monospace font "[r" Background: red
30
! "[f" Proportional font "[g" Background: green
31
! "[1" Foreground: default "[y" Background: Yellow
32
! "[2" Foreground: black "[l" Background: Blue
33
! "[3" Foreground: Red "[m" Background: Magenta
34
! "[4" Foreground: Green "[c" Background: Cyan
35
! "[5" Foreground: Yellow "[w" Background: White
36
! "[6" Foreground: Blue "[b" Background: Black
37
! "[[" Print the character '['
39
! So, the above example would become:
40
! LPrintString("The last word of this sentence should be in [3red[1.");
44
! Some words are *bold*, while others are [bracketed].
46
! LPrintString("Some words are [Bbold[N, while others are [[bracketed].");
48
! Any invalid control sequence will be printed without the '[' delimiter,
49
! so LPrintString("[A New Day]"); would print:
52
! StrLen and Lstrlen will return the number of non-control characters in
55
! This file must be included BEFORE Istring.h in order to work properly.
56
! If you are including utility.h, include it BEFORE this library,
57
! otherwise ZNSI will redefine the Emphasis function.
59
! Let me know what you think. I'm also accepting suggestions for new
62
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
70
Constant ZNSI_Symbols 22;
71
Array ZNSI --> 'N' Emphasis 0
73
'U' Emphasis UNDERLINE
97
for(j=0:j<ZNSI_Symbols:j++)
98
if (char==ZNSI-->(3*j))
116
[ PrintString str i j;
117
for(:i<(str-->0):i++)
119
if (str->(i+2)=='['){
122
j=ZNSI_Lookup(str->(i+2));
123
if (j>0) indirect(ZNSI-->j,ZNSI-->(j+1));
124
else print (char) str->(i+2);
126
print (char) str->(i+2);
132
for(:i<(str-->0):i++)
134
if (str->(i+2)=='['){
136
if (ZNSI_Lookup(str->(i+2))<=0) k++;
142
[ Justify str width align pad_chr i;
143
EmptyString(StringBuffer2,width+Zchars(str),pad_chr);
145
if (align==LEFT or 0) i=0;
146
else if (align==RIGHT) i=width-i;
147
else if (align==CENTERED) i=(width-i)/2;
148
StrCpy(StringBuffer2,str,i);
149
StringBuffer2-->0=width+Zchars(str);
150
PrintString(StringBuffer2);
153
for(:i<(str-->0):i++)
154
if (str->(i+2)=='['){
156
if (ZNSI_Lookup(str->(i+2))>0) k++;
166
if ((0->1)&1) @set_colour i 0;
169
if ((0->1)&1) @set_colour 0 i;