Prev Next codei

Switch Between Code and Italic Pre-formatted Font

Syntax
$cmd%text1%text2%...%textN%$$

See Also
syntax , font , color

Purpose
Display text that alternates between a pre-formatted code font and a pre-formatted italic font. The code font is the same as for the $code command. Because it is pre-formatted, the italic font is different from the $italic command.

escape
Any occurrences of the escape character appears in the text, are not put in the output. This is helpful when aligning rows that have a different number of delimiters in them.

cmd
The value of cmd specifies which font starts first.
$
cmd
This command is one of the following:
$codei    start with code, then italic, then code ...
$icode    start with italic, then code, then italic ...

text
The text %text1%text2%...%textN% is a delimiter sequence and % can be any character that is not a letter. The characters in text1 , ..., textN are using in a pre-formatted font . The characters in text1 are in the first color, the characters in text2 are in the second color, and so on.

Example
The syntax above was created using the $codei command. The input
 
	$codei%extern void f(int %i% , const char *%s%);%$$
produces the following output:
     extern void f(int 
i , const char *s);
The input
 
	$codei|
	extern void f(
		int         |i| ,
		const char *|s| 
	);|$$
produces the following output
     extern void f(
          int         
i ,
          const char *
s
     );

Escape
The escape character is useful because the delimiter character does not appear in the output (the default value for this character is \). For example, the input
 
	$codei%
	%x%   = 1 + %a% + %b%
	%y%   = 2 + \ \   %b%
	%$$
produces the following output
     
x   = 1 + a + b
     
y   = 2 +     b

Remark
The $codei and $icode commands provide similar functionality to the syntax command. The differences are
  1. You can begin with either the code or italic font.
  2. Both fonts are pre-formatted.
The advantage of beginning with either color is that it makes for shorter commands. For example, the input
 
	$icode i$$
can be used to reference i in the prototypes above (remember that when the delimiter is a space, there is only one entry in the delimiter sequence and the other spaces are not delimiters).
Input File: codei.omh