📄 ch42_06.htm
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 42] 42.6 Screen Size Testing Files </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly & Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly & Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:52:33Z"><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_05.htm"TITLE="42.5 Checklist: Screen Size Messed Up? "><LINKREL="next"HREF="ch42_07.htm"TITLE="42.7 termtest: Send Repeated Characters to Terminal "></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_05.htm"TITLE="42.5 Checklist: Screen Size Messed Up? "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 42.5 Checklist: Screen Size Messed Up? "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_07.htm"TITLE="42.7 termtest: Send Repeated Characters to Terminal "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 42.7 termtest: Send Repeated Characters to Terminal "BORDER="0"></A></TD></TR></TABLE> <HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-7000">42.6 Screen Size Testing Files </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-47151"></A><ACLASS="indexterm"NAME="AUTOID-47155"></A>How many lines and columns are there on your screen or window?<SPANCLASS="link">The answer can be important to some programs (<ACLASS="linkend"HREF="ch42_05.htm"TITLE="Checklist: Screen Size Messed Up? ">42.5</A>)</SPAN>.I've got a directory named <EMCLASS="emphasis">testing_files</EM> with a few files I'vedeveloped to test and set screen sizes.</P><DIVCLASS="sect2"><H3CLASS="sect2"><ACLASS="title"NAME="UPT-ART-7000-SECT-1.1">42.6.1 Single Line Screen Width: 80cols </A></H3><TABLECLASS="para.programreference"BORDER="1"><TR><THVALIGN="TOP"><ACLASS="programreference"HREF="examples/index.htm"TITLE="80cols">80cols</A><BR></TH><TDVALIGN="TOP"><ACLASS="indexterm"NAME="AUTOID-47163"></A><ACLASS="indexterm"NAME="AUTOID-47165"></A><ACLASS="indexterm"NAME="AUTOID-47168"></A>The <EMCLASS="emphasis">80cols</EM> file has a line of 80 numbers.I use it to see if the window has exactly 80 columns, as in<ACLASS="xref"HREF="ch42_06.htm#UPT-ART-7000-FIG-0"TITLE="The 80cols File">Figure 42.1</A>.</TD></TR></TABLE><H4CLASS="figure"><ACLASS="title"NAME="UPT-ART-7000-FIG-0">Figure 42.1: The 80cols File</A></H4><IMGCLASS="graphic"SRC="figs/7000b.gif"ALT="Figure 42.1"><PCLASS="para">The pattern repeats every ten characters, making it easy to count howmany columns the window has.</P><PCLASS="para">Some UNIX programs are set for 80-column screens - even if you canmake wider windows, you may not want to.If you want other widths, you can make <EMCLASS="emphasis">cols</EM> files for them, too.</P></DIV><DIVCLASS="sect2"><H3CLASS="sect2"><ACLASS="title"NAME="UPT-ART-7000-SECT-1.2">42.6.2 Screen Width and Height: screensize </A></H3><TABLECLASS="para.programreference"BORDER="1"><TR><THVALIGN="TOP"><ACLASS="programreference"HREF="examples/index.htm"TITLE="screensize">screensize</A><BR></TH><TDVALIGN="TOP"><ACLASS="indexterm"NAME="AUTOID-47183"></A><ACLASS="indexterm"NAME="AUTOID-47185"></A><ACLASS="indexterm"NAME="AUTOID-47188"></A>The <EMCLASS="emphasis">screensize</EM> file has 69 lines of numbers, starting at 69 andending at 1.Type <CODECLASS="literal">cat screensize</CODE>.As shown in<ACLASS="xref"HREF="ch42_06.htm#UPT-ART-7000-FIG-1"TITLE="Checking Window Height and Width with screensize">Figure 42.2</A>,when the file has all been displayed, count the number of lines filledon the screen.</TD></TR></TABLE><H4CLASS="figure"><ACLASS="title"NAME="UPT-ART-7000-FIG-1">Figure 42.2: Checking Window Height and Width with screensize</A></H4><IMGCLASS="graphic"SRC="figs/7000a.gif"ALT="Figure 42.2"><PCLASS="para">In Figure 2, the top number is 9.So, the window has 10 lines (counting the prompt on the last line).</P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-47199"></A>The <EMCLASS="emphasis">screensize</EM> file is also handywith a full-screen application like<SPANCLASS="link"><EMCLASS="emphasis">more</EM> (<ACLASS="linkend"HREF="ch25_03.htm"TITLE="Using more to Page Through Files ">25.3</A>)</SPAN>to see if theright number of lines and columns are displayed.When <EMCLASS="emphasis">more</EM> shows the first screenful, the line labeled <CODECLASS="literal">69</CODE> shouldbe at the top of the screen (the command line might be displayed above it).The last line should have the prompt, like <CODECLASS="literal">--More--</CODE>.When you ask for the next screenful, you should see the next consecutiveline at the top of the screen, maybe with a line or two from theprevious screen.</P><PCLASS="para">The same thing should work with editors like <EMCLASS="emphasis">vi</EM>.</P></DIV><DIVCLASS="sect2"><H3CLASS="sect2"><ACLASS="title"NAME="UPT-ART-7000-SECT-1.3">42.6.3 Set Width, Test Line Wrapping: longlines </A></H3><TABLECLASS="para.programreference"BORDER="1"><TR><THVALIGN="TOP"><ACLASS="programreference"HREF="examples/index.htm"TITLE="longlines">longlines</A><BR></TH><TDVALIGN="TOP"><ACLASS="indexterm"NAME="AUTOID-47214"></A><ACLASS="indexterm"NAME="AUTOID-47216"></A><ACLASS="indexterm"NAME="AUTOID-47219"></A><ACLASS="indexterm"NAME="AUTOID-47222"></A>The file <EMCLASS="emphasis">longlines</EM> in<ACLASS="xref"HREF="ch42_06.htm#UPT-ART-7000-FIG-2"TITLE="Using longlines File with the Emacs Editor">Figure 42.3</A>is like <EMCLASS="emphasis">screensize</EM>, but the 200-characterlines in it are too long for most screens.You can use it for two things:<SPANCLASS="link"> to adjust windows to a particular sizeand to see if long-line wrapping is working right . (<ACLASS="linkend"HREF="ch42_05.htm"TITLE="Checklist: Screen Size Messed Up? ">42.5</A>)</SPAN>This figure shows an example with the GNU Emacs editor, which shows a backslash(<CODECLASS="literal">\</CODE>) at the end of every line it wraps.</TD></TR></TABLE><H4CLASS="figure"><ACLASS="title"NAME="UPT-ART-7000-FIG-2">Figure 42.3: Using longlines File with the Emacs Editor</A></H4><IMGCLASS="graphic"SRC="figs/7000c.gif"ALT="Figure 42.3"><PCLASS="para">On an 80-column screen, if line wrapping is working right, each line of<EMCLASS="emphasis">longlines</EM> should take exactly two and one-half lines to display.(If you're using Emacs, remember that because it adds a backslash atthe line break, the third part of each line will have two more characters.)As the previous figure shows, there shouldn't be any missing numbers orblank lines.</P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-47235"></A>If you're using a windowing system like<SPANCLASS="link">X (<ACLASS="linkend"HREF="ch01_31.htm"TITLE="The X Window System ">1.31</A>)</SPAN>,look for a resize orwindow info function.For example, in the X Window System, the <EMCLASS="emphasis">twm</EM> window managerwill show a small box with the window dimensions as you hold down themouse button to resize a window.You don't have to resize the window; just look at the size-box.The X command <EMCLASS="emphasis">xwininfo</EM> gives lots of information-includingthe window size in pixels.</P></DIV><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">JP</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="ch42_05.htm"TITLE="42.5 Checklist: Screen Size Messed Up? "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 42.5 Checklist: Screen Size Messed Up? "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="ch42_07.htm"TITLE="42.7 termtest: Send Repeated Characters to Terminal "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 42.7 termtest: Send Repeated Characters to Terminal "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">42.5 Checklist: Screen Size Messed Up? </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">42.7 termtest: Send Repeated Characters to Terminal </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 + -