aboutsummaryrefslogtreecommitdiffstats
path: root/doc/user/cpp_tabs
diff options
context:
space:
mode:
authorJeffrey H. Kingston <jeff@it.usyd.edu.au>2010-09-14 19:21:41 +0000
committerJeffrey H. Kingston <jeff@it.usyd.edu.au>2010-09-14 19:21:41 +0000
commit71bdb35d52747e6d7d9f55df4524d57c2966be94 (patch)
tree480ee5eefccc40d5f3331cc52d66f722fd19bfb9 /doc/user/cpp_tabs
parentb41263ea7578fa9742486135c762803b52794105 (diff)
downloadlout-71bdb35d52747e6d7d9f55df4524d57c2966be94.tar.gz
Lout 3.17.
git-svn-id: http://svn.savannah.nongnu.org/svn/lout/trunk@2 9365b830-b601-4143-9ba8-b4a8e2c3339c
Diffstat (limited to 'doc/user/cpp_tabs')
-rw-r--r--doc/user/cpp_tabs62
1 files changed, 62 insertions, 0 deletions
diff --git a/doc/user/cpp_tabs b/doc/user/cpp_tabs
new file mode 100644
index 0000000..1157a51
--- /dev/null
+++ b/doc/user/cpp_tabs
@@ -0,0 +1,62 @@
+@Section
+ @Title { Tab characters }
+ @Tag { tabs }
+@Begin
+@PP
+Tab characters provide a convenient way to indent and align parts of C
+tab.c @Index { tab characters in C programs }
+programs. With care, this alignment can be preserved in the final
+print even with varying-width fonts.
+@PP
+The distance between two tab stops in the input file is by default taken
+to be 8 characters, which is standard for Unix. This can be changed with
+the @Code "tabin" option. For example,
+@ID @Code "@CP tabin { 4 }"
+informs Lout that tab stops occur every 4 characters in the input file.
+@PP
+The distance between two tab stops in the output file (on the printed
+page) is quite a different thing, and it is determined by the value of
+the @Code "tabout" option, which must be a Lout length. For example,
+@ID @Code "@CP tabout { 0.5i }"
+requests that tab stops be placed at half-inch intervals. In other
+words, a distance of one tab stop in the input will be equivalent to a
+distance of half an inch in the output. For example,
+@ID @Code "@CP style { varying } tabout { 3f }"
+might produce the following, where tab characters in the input file
+have been used for indenting and also to align the comments:
+@ID @OneRow @CP style { varying } tabout { 3f } {
+struct tnode { /* the basic node */
+ char *word; /* points to the text */
+ int count; /* number of occurrences */
+ struct tnode *left; /* left child */
+ struct tnode *right; /* right child */
+};
+}
+The value {@Code "3f"} means three times the current font size, and
+it is the default value of @Code "tabout" for the @Code { varying }
+and @Code { symbol } styles (Section {@NumberOf cpsetup}). In a
+12 point font this is 36 points, or half an inch.
+@PP
+If @Code "tabout" is made too small, there is a danger that the
+alignment might fail. For example,
+@ID @Code "@CP style { varying } tabout { 0.2i }"
+produces
+@ID @OneRow @CP style { varying } tabout { 0.2i } {
+struct tnode { /* the basic node */
+ char *word; /* points to the text */
+ int count; /* number of occurrences */
+ struct tnode *left; /* left child */
+ struct tnode *right; /* right child */
+};
+}
+given the same C text as the previous example. The problem here is that
+we are asking for @CP { /* } to appear four tab stops or 0.8 inches
+from the left edge, and yet the material to its left on the line is
+wider than this. This causes @CP { /* } to be shifted further to the
+right than expected, and the alignment is lost. The only solution is
+to increase {@Code "tabout"}.
+@PP
+In stand-alone mode there are @Code "-t" and @Code "-T" options
+equivalent to @Code "tabin" and @Code "tabout" respectively. For
+example, @Code "-T0.5i" produces a half-inch tab width.
+@End @Section