home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 42.5 Checklist: Screen Size Messed Up? Chapter 42
Problems with Terminals
Next: 42.7 termtest: Send Repeated Characters to Terminal

42.6 Screen Size Testing Files

How many lines and columns are there on your screen or window? The answer can be important to some programs ( 42.5 ) . I've got a directory named testing_files with a few files I've developed to test and set screen sizes.

42.6.1 Single Line Screen Width: 80cols

The 80cols file has a line of 80 numbers. I use it to see if the window has exactly 80 columns, as in Figure 42.1 .

Figure 42.1: The 80cols File

Figure 42.1

The pattern repeats every ten characters, making it easy to count how many columns the window has.

Some UNIX programs are set for 80-column screens - even if you can make wider windows, you may not want to. If you want other widths, you can make cols files for them, too.

42.6.2 Screen Width and Height: screensize

The screensize file has 69 lines of numbers, starting at 69 and ending at 1. Type cat screensize . As shown in Figure 42.2 , when the file has all been displayed, count the number of lines filled on the screen.

Figure 42.2: Checking Window Height and Width with screensize

Figure 42.2

In Figure 2, the top number is 9. So, the window has 10 lines (counting the prompt on the last line).

The screensize file is also handy with a full-screen application like more ( 25.3 ) to see if the right number of lines and columns are displayed. When more shows the first screenful, the line labeled 69 should be at the top of the screen (the command line might be displayed above it). The last line should have the prompt, like --More-- . When you ask for the next screenful, you should see the next consecutive line at the top of the screen, maybe with a line or two from the previous screen.

The same thing should work with editors like vi .

42.6.3 Set Width, Test Line Wrapping: longlines

The file longlines in Figure 42.3 is like screensize , but the 200-character lines in it are too long for most screens. You can use it for two things: to adjust windows to a particular sizeand to see if long-line wrapping is working right . ( 42.5 ) This figure shows an example with the GNU Emacs editor, which shows a backslash ( \ ) at the end of every line it wraps.

Figure 42.3: Using longlines File with the Emacs Editor

Figure 42.3

On an 80-column screen, if line wrapping is working right, each line of longlines should take exactly two and one-half lines to display. (If you're using Emacs, remember that because it adds a backslash at the 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 or blank lines.

If you're using a windowing system like X ( 1.31 ) , look for a resize or window info function. For example, in the X Window System, the twm window manager will show a small box with the window dimensions as you hold down the mouse button to resize a window. You don't have to resize the window; just look at the size-box. The X command xwininfo gives lots of information-including the window size in pixels.

- JP

Previous: 42.5 Checklist: Screen Size Messed Up? UNIX Power Tools Next: 42.7 termtest: Send Repeated Characters to Terminal
42.5 Checklist: Screen Size Messed Up? Book Index 42.7 termtest: Send Repeated Characters to Terminal

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System