📄 ch41_11.htm
字号:
CLASS="term"><EMCLASS="emphasis">up=^K</EM></DT><DTCLASS="term"><EMCLASS="emphasis">cuu1=^K</EM></DT><DDCLASS="listitem"><PCLASS="para">is the up capability; it says that to move the cursor up one line,send the <CODECLASS="literal">^K</CODE> character to the terminal.</P></DD><DTCLASS="term"><EMCLASS="emphasis">cl=^Z</EM></DT><DTCLASS="term"><EMCLASS="emphasis">clear=^Z</EM></DT><DDCLASS="listitem"><PCLASS="para">is the clear capability; it says that to clear the screen,send the <CODECLASS="literal">^Z</CODE> character to the terminal.</P></DD><DTCLASS="term"><EMCLASS="emphasis">ho=^^</EM></DT><DTCLASS="term"><EMCLASS="emphasis">home=^^</EM></DT><DDCLASS="listitem"><PCLASS="para">is the home capability; it says that to move the cursor Home (upper-left corner), send the <CODECLASS="literal">^^</CODE> character (CTRL-<CODECLASS="literal">^</CODE>) to the terminal.</P></DD><DTCLASS="term"><EMCLASS="emphasis">nd=^L</EM></DT><DTCLASS="term"><EMCLASS="emphasis">cuf1=^L</EM></DT><DDCLASS="listitem"><PCLASS="para"> is the non-destructive space capability; it says that to move the cursor onespace to the right without changing the text, send the <CODECLASS="literal">^L</CODE> character to the terminal.</P></DD></DL><DIVCLASS="sect2"><H3CLASS="sect2"><ACLASS="title"NAME="UPT-ART-7967-SECT-1.0.1">41.11.1 Special Character Codes </A></H3><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-46295"></A><ACLASS="indexterm"NAME="AUTOID-46297"></A>No doubt the symbols <CODECLASS="literal">^K</CODE>, <CODECLASS="literal">^Z</CODE>, <CODECLASS="literal">^^</CODE>, and <CODECLASS="literal">^L</CODE> shown above are familiar to you.A caret (<CODECLASS="literal">^</CODE>) followed by a letter is a convention for representing an unprintable control character generated by holding down the CONTROL(CTRL) key on the keyboard while typing another.Note that control charactersare entered into a terminal description as two characters by typingthe caret character (<CODECLASS="literal">^</CODE>) followed by a letter, rather than by inserting the actual control character.</P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-46307"></A>Both <EMCLASS="emphasis">termcap</EM> and <EMCLASS="emphasis">terminfo</EM> use other codes to write other unprintable characters, as well as characters that have special meaningin <EMCLASS="emphasis">termcap</EM> or <EMCLASS="emphasis">terminfo</EM> syntax.The other<ACLASS="indexterm"NAME="AUTOID-46314"></A>codes, most of which should be familiar to C programmers, are listed in<ACLASS="xref"HREF="ch41_11.htm#UPT-ART-7967-TAB-0"TITLE="Termcap and Terminfo Special Character Codes">Table 41.1</A>. </P><TABLECLASS="table"><CAPTIONCLASS="table"><ACLASS="title"NAME="UPT-ART-7967-TAB-0">Table 41.1: Termcap and Terminfo Special Character Codes</A></CAPTION><THEADCLASS="thead"><TRCLASS="row"VALIGN="TOP"><THCLASS="entry"ALIGN="LEFT"ROWSPAN="1"COLSPAN="1">Code</TH><THCLASS="entry"ALIGN="LEFT"ROWSPAN="1"COLSPAN="1">Description</TH><THCLASS="entry"ALIGN="LEFT"ROWSPAN="1"COLSPAN="1">Comment</TH></TR></THEAD><TBODYCLASS="tbody"><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">\E</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">escape</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">termcap and terminfo</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">\e</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">escape</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">terminfo only</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">^<CODECLASS="userinput"><B>x</B></CODE></TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">control-<CODECLASS="userinput"><B>x</B></CODE></TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">where <CODECLASS="userinput"><B>x</B></CODE> is any letter</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">\n</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">newline</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1"></TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">\r</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">return</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1"></TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">\t</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">tab</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1"></TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">\b</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">backspace</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1"></TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">\f</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">formfeed</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1"></TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">\s</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">space</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">terminfo only</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">\l</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">linefeed</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">terminfo only</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">\<CODECLASS="userinput"><B>xxx</B></CODE></TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">octal value of <CODECLASS="userinput"><B>xxx</B></CODE></TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">must be three characters</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">\041</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">exclamation point <CODECLASS="literal">!</CODE></TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">C shell history uses <CODECLASS="literal">!</CODE></TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">\072</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">the character <CODECLASS="literal">:</CODE></TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">termcap uses ordinary : as separator</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">\200</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">null</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">\\000 for null does not work</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">\0</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">null</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">terminfo only</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">\^</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">caret</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">terminfo only</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">\\</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">backslash</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">terminfo only</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">\,</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">comma</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">terminfo only</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">\:</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">colon</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">terminfo only</TD></TR></TBODY></TABLE></DIV><DIVCLASS="sect2"><H3CLASS="sect2"><ACLASS="title"NAME="UPT-ART-7967-SECT-1.0.2">41.11.2 Encoding Arguments </A></H3><PCLASS="para">The last capability in the Wyse-50 example is the most complicated.<EMCLASS="emphasis">cm=</EM> (<EMCLASS="emphasis">termcap</EM>) and <EMCLASS="emphasis">cup=</EM> (<EMCLASS="emphasis">terminfo</EM>) specify the cursor motion capability, which describes how to move the cursor directly to a specific location.Since the desired location is specified by theprogram at run-time, the capability must providesome mechanism for encoding arguments.The program uses thisdescription to figure out what string it needs to send to move thecursor to the desired location.</P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-46418"></A>Because we aren't telling you how to write <EMCLASS="emphasis">termcap</EM> or <EMCLASS="emphasis">terminfo</EM> entries, but just to read them, all you need to knowis that the percent sign (<CODECLASS="literal">%</CODE>) is used forencoding, and when it appears in a terminal entry, the capability isusing run-time parameters.</P><PCLASS="para">If you need to write an entry, see O'Reilly & Associates' <EMCLASS="emphasis">termcap& terminfo</EM>.</P></DIV><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">JS</SPAN>, <SPANCLASS="authorinitials">TOR</SPAN></P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch41_10.htm"TITLE="41.10 Using terminfo Capabilities in Shell Programs "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 41.10 Using terminfo Capabilities in Shell Programs "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch41_12.htm"TITLE="41.12 Finding Out What Characters Your Terminal's Special Keys Send"><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 41.12 Finding Out What Characters Your Terminal's Special Keys Send"BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">41.10 Using terminfo Capabilities in Shell Programs </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">41.12 Finding Out What Characters Your Terminal's Special Keys Send</TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed & awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -