⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch42_05.htm

📁 the unix power tools
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 42] 42.5 Checklist: Screen Size Messed Up? </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly &amp; Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly &amp; Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:52:29Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch42_01.htm"TITLE="42. Problems with Terminals"><LINKREL="prev"HREF="ch42_04.htm"TITLE="42.4 Checklist for Resetting a Messed Up Terminal "><LINKREL="next"HREF="ch42_06.htm"TITLE="42.6 Screen Size Testing Files "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch42_04.htm"TITLE="42.4 Checklist for Resetting a Messed Up Terminal "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 42.4 Checklist for Resetting a Messed Up Terminal "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 42<BR>Problems with Terminals</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch42_06.htm"TITLE="42.6 Screen Size Testing Files "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 42.6 Screen Size Testing Files "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-0092">42.5 Checklist: Screen Size Messed Up? </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-46951"></A>The<SPANCLASS="link">termcap and terminfo (<ACLASS="linkend"HREF="ch05_02.htm"TITLE="The Idea of a Terminal Database ">5.2</A>)</SPAN>systems used to be the only place where the size of your terminal screen(number of lines and characters) was set.These days, screen-oriented commands like <EMCLASS="emphasis">vi</EM> and <EMCLASS="emphasis">more</EM>on most UNIXes need to work with window systems.Users can shrink or stretchtheir windows without changing the <EMCLASS="emphasis">termcap</EM> or <EMCLASS="emphasis">terminfo</EM> definition.Depending on the command and version of UNIX you're using, you can runinto window-size problems even if you aren't using a window system.</P><PCLASS="para">Window systems don't cause all the problems though.&quot;Classic&quot; problems, such as files with lines that are longer than theterminal is wide, were around before UNIX did windows.</P><PCLASS="para">Here's a checklist of things to try.Once you figure out what's wrong and how to fix it on your terminal andversion of UNIX, you'll probably be able to fix problems with other programsyou run.</P><ULCLASS="itemizedlist"><LICLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-46964"></A>Displaying or editing a file with lines longer than the screen is widecan cause strange problems if everything isn't set up right.There are two places that may try to split a line into pieces when it thinksthat the line is too long.The problem, of course, is when these don't work together or one of themhas a wrong idea about the line length:</P><ULCLASS="itemizedlist"><LICLASS="listitem"><PCLASS="para">Your terminal or window may be set to autowrap lines that would crossthe right edge: The line is broken and the rest is shown beginning at theleft margin on the next line below.</P></LI><LICLASS="listitem"><PCLASS="para">If you use a screen-oriented program like <EMCLASS="emphasis">vi</EM> or <EMCLASS="emphasis">more</EM>, theymay wrap long lines.The <EMCLASS="emphasis">termcap</EM> and <EMCLASS="emphasis">terminfo</EM> definitions tell screen-oriented programswhether to wrap lines.(For more information, see O'Reilly &amp; Associates' <EMCLASS="emphasis">termcap &amp; terminfo</EM>.)</P></LI></UL><PCLASS="para">To find out what your terminal is doing, display a file with long lines like<SPANCLASS="link"><EMCLASS="emphasis">longlines</EM> (<ACLASS="linkend"HREF="ch42_06.htm"TITLE="Screen Size Testing Files ">42.6</A>)</SPAN>.The<SPANCLASS="link"><EMCLASS="emphasis">cat</EM> (<ACLASS="linkend"HREF="ch25_02.htm"TITLE="Four Ways to Skin a cat ">25.2</A>)</SPAN>and<SPANCLASS="link"><EMCLASS="emphasis">head</EM> (<ACLASS="linkend"HREF="ch25_20.htm"TITLE="Printing the Top of a File ">25.20</A>)</SPAN>programs don't use <EMCLASS="emphasis">termcap</EM> or <EMCLASS="emphasis">terminfo</EM>-they spit thefile directly to your screen.So, for example, a single 200-character line from <EMCLASS="emphasis">longlines</EM> should beshown as three lines on an 80-column screen.You shouldn't lose any of the characters at either side.Two lines would look like this:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>head -2 longlines</B></CODE>1  456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678902  45678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890</PRE></BLOCKQUOTE></P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-46991"></A><ACLASS="indexterm"NAME="AUTOID-46993"></A>If you see only two &quot;chopped&quot; lines, your terminal isn't wrapping lines.You may want to go into its setup mode and enable line-wrapping.If you do though, be sure that your termcap/terminfo definition liststhe terminal as autowrapping.If your terminal autowraps but the <EMCLASS="emphasis">termcap/terminfo</EM> definition doesn'tsay that, screen-oriented applications may try to wrap lines for you.Exactly what happens depends on the application you're using and yourterminal.One common problem is that the screen may look double-spaced&nbsp;- each part of asingle long line that's &quot;wrapped&quot; has a blank line after it.For instance, the <EMCLASS="emphasis">longlines</EM> file might look like this:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">1  456789012345678901234567890123456789012345678901234567890123456789012312345678901234567890123456789012345678901234567890123456789012345678901231234567890123456789012345678901234567890   ...</PRE></BLOCKQUOTE></P><PCLASS="para">In that case, both the terminal and the application are probably tryingto wrap the lines for you.Usually, then, the application won't know exactly how many lines yourterminal is displaying and will send twice as many lines as your screencan show.What a mess!Try to use another value of the<SPANCLASS="link"><EMCLASS="emphasis">TERM</EM> (<ACLASS="linkend"HREF="ch05_10.htm"TITLE="Finding What Terminal Names You Can Use ">5.10</A>)</SPAN>environment variable that defines your terminal as autowrapping.These can have names that end with <EMCLASS="emphasis">am</EM> or <EMCLASS="emphasis">aw</EM>, like <EMCLASS="emphasis">vt100aw</EM>.Or, if you want to dig in, it's not too hard to adapt your own<EMCLASS="emphasis">termcap</EM> or <EMCLASS="emphasis">terminfo</EM> definition from the standard system file.For more information, see article<ACLASS="xref"HREF="ch41_11.htm"TITLE="How termcap and terminfo Describe Terminals ">41.11</A>or O'Reilly &amp; Associates' <EMCLASS="emphasis">termcap &amp; terminfo</EM>.</P></LI><LICLASS="listitem"><PCLASS="para">Your screen can be mixed up when a full-screen application-a pager like<EMCLASS="emphasis">pg</EM>, for example&nbsp;- is displaying the standard output of some program.The program writes some messages to its standard error.These extra lines aren't counted by the application, but they show onyour screen.<ACLASS="indexterm"NAME="AUTOID-47012"></A><ACLASS="indexterm"NAME="AUTOID-47014"></A>If the application has a redraw screen command like CTRL-lyou may be able to get a fresh copy of the lines fromstandard output.Or, you can<SPANCLASS="link">pipe both <EMCLASS="emphasis">stdout</EM> and <EMCLASS="emphasis">stderr</EM> to the pager (<ACLASS="linkend"HREF="ch13_04.htm"TITLE="Problems Piping to a Pager ">13.4</A>)</SPAN>.</P></LI><LICLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-47021"></A><ACLASS="indexterm"NAME="AUTOID-47025"></A><ACLASS="indexterm"NAME="AUTOID-47027"></A>Some applications let you set their screen size in a configuration fileor environment variable.For example, Berkeley<SPANCLASS="link"><EMCLASS="emphasis">mail</EM> (<EMCLASS="emphasis">mailx</EM> (<ACLASS="linkend"HREF="ch01_33.htm"TITLE="UNIX Networking and Communications ">1.33</A>)</SPAN>on System V) has a <EMCLASS="emphasis">screen</EM>variable that might be set in its<EMCLASS="emphasis">.mailrc</EM>file or in a system file like <EMCLASS="emphasis">/usr/lib/Mail.rc</EM>.The <EMCLASS="emphasis">vi</EM> editor has a <EMCLASS="emphasis">window</EM> variable that might be set in your<SPANCLASS="link"><EMCLASS="emphasis">.exrc</EM> (<ACLASS="linkend"HREF="ch04_09.htm"TITLE="Setting Up vi with the .exrc File ">4.9</A>)</SPAN>file.</P><PCLASS="para">Unless you set those variables correctly for all the terminals you use,you'll usually be better off to let the application set its own window size.</P></LI><LICLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-47043"></A>Your version of UNIX may keep the screen size as part of the devicesettings.To find out, type the command:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>stty size</B></CODE>24 80</PRE></BLOCKQUOTE></P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-47049"></A>(If that doesn't work, try <EMCLASS="emphasis">stty&nbsp;-a</EM>; look for <CODECLASS="literal">rows</CODE>&nbsp;<CODECLASS="literal">=</CODE>and <CODECLASS="literal">columns</CODE>&nbsp;<CODECLASS="literal">=</CODE> in the output.)The command shows that UNIXthinks your screen has 24 lines and 80 columns.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -