Prev Next codei

Switch Between Code and Italic Preformatted Font

Syntax
See Also
Purpose
escape
codei
icode
text
Example
     Escape
Remark

Syntax
$codei%text1%text2%...%textN%$$
$icode%text1%text2%...%textN%$$

See Also
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.

codei
In this case, text1 is in code font, text2 is in italic font, ...

icode
In this case, text1 is in italic font, text2 is in code font, ...

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 font (and corresponding color), the characters in text2 are in the second font, 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
 
     $escape #$$
     $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 easier to read 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: omh/codei.omh