aboutsummaryrefslogtreecommitdiffstats
path: root/doc/user/cpp_opti
blob: 538bda2e59f8a205f6a93476e104aed12207ed32 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
@Section
   @Title { Changing the appearance of a program }
   @Tag { cpp_opti }
@Begin
@PP
The {@Code "@CP"}, {@Code "@Eiffel"} etc. symbols have a number of
options for changing the appearance of the printed program.  These
options are the same for all symbols, although their default values
may vary.  The @Code "style" option changes the printing style; its
value may be {@Code "fixed"} (fixed-width font), {@Code "varying"}
(varying-width font), or {@Code "symbol"} (varying-width font with
mathematical symbols used for some operators).  Its default value
depends on the language, and may be found in the fourth column of
the table at the start of this chapter.  The example in the previous
section was in @Code fixed style; we can switch styles like this:
@ID @OneRow @Code {
"@CP"
"    style { varying }"
"{"
"#include <stdio.h>"
""
"treeprint(p)        /* print tree p recursively */"
"struct tnode *p;"
"{"
"        if (p != NULL) {"
"                treeprint(p->left);"
"                printf(\"%4d %s\\n\", p->count, p->word);"
"                treeprint(p->right);"
"        }"
"}"
"}"
}
The result in this case will be
@ID @OneRow @CP style { varying }
{
#include <stdio.h>

treeprint(p)        /* print tree p recursively */
struct tnode *p;
{
        if (p != NULL) {
                treeprint(p->left);
                printf("%4d %s\n", p->count, p->word);
                treeprint(p->right);
        }
}
}
If we use @Code "style { symbol }" we get this:
@ID @OneRow @CP style { symbol }
{
#include <stdio.h>

treeprint(p)        /* print tree p recursively */
struct tnode *p;
{
        if (p != NULL) {
                treeprint(p->left);
                printf("%4d %s\n", p->count, p->word);
                treeprint(p->right);
        }
}
}
with mathematical symbols replacing some of the operators.
@PP
The {@Code "@CP"}, {@Code "@Eiffel"} etc. symbols have additional options
which allow a finer control over the style.  Here they all are, with their
default values:
@ID @OneRow @Code {
"@CP         [ or @Eiffel, @Blue, etc. ]"
"    style { fixed }"
"    font { Courier }"
"    strings { Base }"
"    identifiers { Base }"
"    comments { Base }"
"    keywords { Base }"
"    numbers { Base }"
"    operators { Base }"
"    size { -1.0p }"
"    line { 1.0vx }"
"    tabin { 8 }"
"    tabout { 8s }"
"{"
"    ..."
"}"
}
We are already familiar with {@Code "style"}.  After that comes
{@Code "font"}, which determines the font family to use, followed
by six options giving the particular faces within that family in which to
print strings, identifiers, comments, keywords, numbers, and
operators.  {@Code "Base"} means the basic face; other commonly available
choices are {@Code "Slope"} and {@Code "Bold"}.  These options may all be
set to different faces if desired.  The default values shown are correct
for @Code "style { fixed }" only; the other styles have other defaults
(Section {@NumberOf cpsetup}).
@PP
The @Code "size" option is the font size to use, and @Code "line" is the
inter-line spacing.  The default values specify that @Code "size" is
to be one point smaller than in the surrounding document; this was done
to compensate for Courier's relatively large appearance compared
to other fonts of the same nominal size.  Again, these defaults are
different for different values of {@Code "style"}.
@PP
The @Code "tabin" and @Code "tabout" options are the subject of
Section {@NumberOf tabs}.
@End @Section