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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.0.3, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- This manual documents GNU troff version 1.23.0.
Copyright 1994-2023 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
copy of the license is included in the section entitled "GNU Free
Documentation License". -->
<title>Input Line Traps (The GNU Troff Manual)</title>
<meta name="description" content="Input Line Traps (The GNU Troff Manual)">
<meta name="keywords" content="Input Line Traps (The GNU Troff Manual)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href="index.html" rel="start" title="Top">
<link href="Request-Index.html" rel="index" title="Request Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Traps.html" rel="up" title="Traps">
<link href="Blank-Line-Traps.html" rel="next" title="Blank Line Traps">
<link href="Diversion-Traps.html" rel="prev" title="Diversion Traps">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
span.r {font-family: initial; font-weight: normal; font-style: normal}
span:hover a.copiable-link {visibility: visible}
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
-->
</style>
</head>
<body lang="en">
<div class="subsection-level-extent" id="Input-Line-Traps">
<div class="nav-panel">
<p>
Next: <a href="Blank-Line-Traps.html" accesskey="n" rel="next">Blank Line Traps</a>, Previous: <a href="Diversion-Traps.html" accesskey="p" rel="prev">Diversion Traps</a>, Up: <a href="Traps.html" accesskey="u" rel="up">Traps</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Request-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h4 class="subsection" id="Input-Line-Traps-1">5.28.2 Input Line Traps</h4>
<a class="index-entry-id" id="index-input-line-traps"></a>
<a class="index-entry-id" id="index-traps_002c-input-line"></a>
<dl class="first-deffn">
<dt class="deffn" id="index-_002eit"><span class="category-def">Request: </span><span><strong class="def-name"><code class="t">.it</code></strong> <var class="def-var-arguments">[<span class="r"><i class="slanted">n</i></span> <span class="r"><i class="slanted">name</i></span>]</var><a class="copiable-link" href='#index-_002eit'> ¶</a></span></dt>
<dd><a class="index-entry-id" id="index-it"></a>
</dd><dt class="deffnx def-cmd-deffn" id="index-_002eitc"><span class="category-def">Request: </span><span><strong class="def-name"><code class="t">.itc</code></strong> <var class="def-var-arguments">[<span class="r"><i class="slanted">n</i></span> <span class="r"><i class="slanted">name</i></span>]</var><a class="copiable-link" href='#index-_002eitc'> ¶</a></span></dt>
<dd><a class="index-entry-id" id="index-itc"></a>
<a class="index-entry-id" id="index-setting-input-line-trap-_0028it_002c-itc_0029"></a>
<a class="index-entry-id" id="index-input-line-trap_002c-setting-_0028it_002c-itc_0029"></a>
<a class="index-entry-id" id="index-trap_002c-input-line_002c-setting-_0028it_002c-itc_0029"></a>
<a class="index-entry-id" id="index-clearing-input-line-trap-_0028it_002c-itc_0029"></a>
<a class="index-entry-id" id="index-input-line-trap_002c-clearing-_0028it_002c-itc_0029"></a>
<a class="index-entry-id" id="index-trap_002c-input-line_002c-clearing-_0028it_002c-itc_0029"></a>
<p>Set an input line trap, calling macro <var class="var">name</var> after processing the
next <var class="var">n</var> productive input lines (recall <a class="ref" href="Manipulating-Filling-and-Adjustment.html">Manipulating Filling and Adjustment</a>). Any existing input line trap in the
environment is replaced. Without arguments, <code class="code">it</code> and <code class="code">itc</code>
clear any input line trap that has not yet sprung.
</p>
<p>Consider a macro ‘<samp class="samp">.ST <var class="var">s n</var></samp>’ which sets the next
<var class="var">n</var> input lines in the font style <var class="var">s</var>.
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">.de ST \" Use style $1 for next $2 text lines.
. it \\$2 ES
. ft \\$1
..
.de ES \" end ST
. ft R
..
.ST I 1
oblique
face
.ST I 1
oblique\c
face
⇒ <i class="i">oblique</i> face <i class="i">oblique</i>face <span class="r">(second “face” upright)</span>
</pre></div></div>
<a class="index-entry-id" id="index-input-line-traps-and-interrupted-lines-_0028itc_0029"></a>
<a class="index-entry-id" id="index-interrupted-lines-and-input-line-traps-_0028itc_0029"></a>
<a class="index-entry-id" id="index-traps_002c-input-line_002c-and-interrupted-lines-_0028itc_0029"></a>
<a class="index-entry-id" id="index-lines_002c-interrupted_002c-and-input-line-traps-_0028itc_0029"></a>
<p>Unlike the <code class="code">ce</code> and <code class="code">rj</code> requests, <code class="code">it</code> counts lines
interrupted with the <code class="code">\c</code> escape sequence separately (see <a class="pxref" href="Line-Continuation.html">Line Continuation</a>); <code class="code">itc</code> does not. To see the difference, let’s
change the previous example to use <code class="code">itc</code> instead.
</p>
<div class="example">
<div class="group"><pre class="example-preformatted"><span class="r">…</span>
. itc \\$2 ES
<span class="r">…</span>
⇒ <i class="i">oblique</i> face <i class="i">obliqueface</i> <span class="r">(second “face” oblique)</span>
</pre></div></div>
<p>You can think of the <code class="code">ce</code> and <code class="code">rj</code> requests as implicitly
creating an input line trap with <code class="code">itc</code> that schedules a break when
the trap is sprung.
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">.de BR
. br
. <i class="slanted">internal: disable centering-without-filling</i>
..
.
.de ce
. if \\n[.br] .br
. itc \\$1 BR
. <i class="slanted">internal: enable centering-without-filling</i>
..
</pre></div></div>
<p>Let us consider in more detail the sorts of input lines that are or are
not “productive”.
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">.de Trap
TRAP SPRUNG
..
.de Mac
.if r a \l'5n'
..
.it 2 Trap
.
foo
.Mac
bar
baz
.it 1 Trap
.sp \" moves, but does not write or draw
qux
.itc 1 Trap
\h'5n'\c \" moves, but does not write or draw
jat
</pre></div></div>
<p>When ‘<samp class="samp">Trap</samp>’ gets called depends on whether the ‘<samp class="samp">a</samp>’ register is
defined; the control line with the <code class="code">if</code> request may or may not
produce written output. We also see that the spacing request <code class="code">sp</code>,
while certainly affecting the output, does not spring the input line
trap. Similarly, the horizontal motion escape sequence <code class="code">\h</code> also
affected the output, but was not “written”. Observe that we had to
follow it with <code class="code">\c</code> and use <code class="code">itc</code> to prevent the newline at
the end of the text line from causing a word break, which, like an
ordinary space character, counts as written output.
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">$ groff -Tascii input-trap-example.groff
⇒ foo bar TRAP SPRUNG baz
⇒
⇒ qux TRAP SPRUNG jat TRAP SPRUNG
$ groff -Tascii -ra1 input-trap-example.groff
⇒ foo _____ TRAP SPRUNG bar baz
⇒
⇒ qux TRAP SPRUNG jat TRAP SPRUNG
</pre></div></div>
</dd></dl>
<p>Input line traps are associated with the environment
(see <a class="pxref" href="Environments.html">Environments</a>); switching to another environment suspends the
current input line trap, and going back resumes it, restoring the count
of qualifying lines enumerated in that environment.
</p>
</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Blank-Line-Traps.html">Blank Line Traps</a>, Previous: <a href="Diversion-Traps.html">Diversion Traps</a>, Up: <a href="Traps.html">Traps</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Request-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|