Chapter 3

The Advantages of xterm

Introduction

In this chapter, we discover the advantages of workstations and genuine xterms compared with visual display units.

Visual display units

In the olden days, before workstations were widely available, Unix users used visual display units (VDUs). Here is a view of a typical VDU screen:
Diagram of an xterm
VDUs had room for only 24 lines of text and each line had 80 characters. The screens all had black backgrounds and all the text was one colour, usually white, green or orange. There were no facilities for copying or pasting. Each Unix user could use just one VDU at once so the 24 lines provided the user's only view of Unix. There were no facilities for scrolling back to review text that had disappeared off the top of the screen. All characters on the screen were the same size and most VDUs could only display text. One of the most widely used VDUs was the DEC VT102.

Workstations

A workstation is a fairly expensive device designed for displaying graphics on a screen; it has a keyboard and a mouse as well as one or more screens. Personal computers (PCs) are not workstations because the screens are generally too small and the graphics capability is usually not good enough. However, PCs do offer the same kind of windowing and graphics as workstations. Programs such a Vista Exceed allow PCs to emulate low quality workstations.

The two programs which are the most use to a workstation user are: xterm and a window manager. The xterm is the modern version of the old VDU; it emulates one VT102 in each window in which it is executed. However, it has some extra features which make it much better than a real VT102.

A window manager is the program that allows us to create, destroy, move and re-size windows. It allows each user to use as many windows as he or she wishes simultaneously. It is always waiting, behind the scenes, to change our windows for us. Most people do not know they are using a window manager because it is built into desktops such as Microsoft Windows, Gnome, KDE and CDE. Some people simply use a window manager instead of a desktop. Personally, I dislike desktops as they all feel like Microsoft Windows and are nearly as annoying to use. I use Window Maker to manage my on-screen work-spaces.

An example

Here is one of my work-spaces:
Diagram of an xterm
As you see, I have three xterms running. Two of them are VDU-sized and one is larger. The blue frames with titles are put around the xterms by Window Maker so they can be moved and re-sized. The currently active xterm has a white title and a solid magenta typing cursor.

I choose to use black backgrounds and white text because that is easier to read. The whole world got it wrong when it followed Apple into white backgrounds. White paper wouldn't be as easy to read if it glowed in the dark.

Genuine xterms only

It is important to stress that this chapter is about genuine xterms only. This is because they have a very simple, elegant method for copying text and inserting it into another window. This method is better than Microsoft's which was developed later. Unfortunately, because they meet Microsoft's way first, many people can't appreciate the xterm alternative. There are about a hundred VDU emulation programmes available today but most have adopted the inferior Microsoft technique, which is my reason for sticking with genuine xterms. It is possible that many of the other terminal types can be configured to work like xterm but only the original article works so well "out of the box".

Different sized fonts

The first extra xterm feature is different sized fonts. If you find the characters in the xterm either too small or too large for comfort, you can change the font for another. To do this you move the mouse cursor over the xterm, hold down the control key, press the right mouse button and hold it down. This causes a menu of font names such as Tiny and Huge to pop up; there should be a tick by the currently selected font name. You drag the mouse cursor down the menu and release it at the font you wish to select. The size of the characters should change more or less instantly and the xterm's window should automatically be re-sized to suit the new font.

Here an xterm using the Default font is being switched to the Huge font:
Diagram of an xterm
Notice that the menu always uses the default font size (unless your xterm is set up in a non-standard fashion).

Scrolling

The second advantage of xterms is that they can be scrolled to view thousands of lines of recent history. If your xterm is relatively up to date, and your window manager is properly configured, the simplest way of scrolling is to use the mouse wheel.

If there are very many lines available for scrolling, using the mouse wheel might be too tedious and it would then be better to use the scrollbar. Contrary to modern practice, this is at the left-hand side of the screen by default.

Here is an xterm with the scrollbar indicated by the green arrow:
Diagram of an xterm
The red arrow points to a slider or thumbwheel which shrinks as more text is displayed. You can tell at a glance whether you have enough text to scroll by looking at the scrollbar. If it is a solid block of half-tone colour you haven't enough text. If it is in two or three parts, some in the xterm's background colour and some in half-tone colour, then you can scroll. Our scrollbar is showing us that we are at the end of the displayable text, and that we could scroll backwards. The simplest way of scrolling via the scrollbar is with the middle button.

Middle button scrolling

To position the slider half way through the text, you place the mouse cursor half way down the scrollbar and click the middle button of the mouse. The xterm will scroll instantaneously to the desired position. After you have scrolled, the slider will be further up the scrollbar. Like this:
Diagram of an xterm

If your mouse only has two buttons, you have to simulate pressing the middle button by pressing the left and right buttons simultaneously.

Manual positioning

You can also position the slider manually by putting the mouse cursor over the slider and dragging it to a new position with the middle mouse button.

High precision scrolling

There is another way of scrolling that gives you fine control over the amount of scrolling; it uses the left and right mouse buttons over the scrollbar. To scroll backwards, towards earlier lines, you put the mouse cursor in the scrollbar area and click the right mouse button. To scroll back further, you click the right button again. To scroll forwards, towards the last line, you click the left mouse button.

How much to scroll precisely?

The amount xterm scrolls for left and right clicks depends on the cursor's position in the scrollbar. If it is at the bottom, xterm scrolls by a whole screenful; if it is right at the top, xterm scrolls one line. The amount is proportional to the distance of the mouse cursor from the top of the scrollbar.

Short cut to latest line

When you have scrolled backwards, you do not have to scroll forwards to get to the last line to continue typing. All you have to do is press a key - even the space bar - and the xterm will scroll instantaneously to the last line.

Copying text

We often have to type the same commands or words repeatedly. With an xterm we can make this a little easier by copying text already on the screen onto the last line. We can copy as much or a little as we wish. The job is done in two halves: selecting the text to be copied and inserting the text.

The easiest way of selecting text is to put the mouse cursor in the middle of a word and double-click the left mouse button. The word should be then highlighted in reverse video. Here the user has double-clicked somewhere in "selecting":
Diagram of an xterm

Selecting more text

If you wish to select several words, the simplest way is to select the first word in usual way, and then to click the right mouse button in the middle of the last word. This extends the original selection to cover all the words from the first to the last. Here the user has right-clicked somewhere in "cursor":
Diagram of an xterm

You can right-click again and again. Here the user has right-clicked in "appears":
Diagram of an xterm
Notice that the highlighted area now stretches to the right-hand edge of the screen. The area between the last character on the line and the side of the xterm represents the newline character at the end of the line. Newline characters can be pasted as well as text. However, be careful when pasting commands: if you selected the newline after a command, the command will be executed without you having time to reconsider it!

You can extend the selection up the screen too. Here the user has right-clicked on "We":
Diagram of an xterm
There are now sixteen and a half lines of text selected including two blank ones.

You can select from a particular word to the end of the line by treble clicking the left button in the word.
Diagram of an xterm
Here the user treble clicked on "The".

Selecting less than a word

You can select any amount of text by dragging the mouse cursor through the text with the left button. This is the Microsoft method referred to earlier; it is bit of a drag compared with just clicking - but sometimes we have no option:
Diagram of an xterm
This is the only way to select "red - eve" from the screen shown.

Selecting more than a screenful

To select more than a screenful of text, we have to use scrolling as well. The way to do this is to select the first word (by double-clicking) and then scroll down to the last word. Don't worry that the highlighted first word will disappear off the top of the window; even though it is out of sight, it remains the current X selection. Lastly we extend the X selection by right-clicking on the last word we want to select. The X selection now covers several screens full of text.
Diagram of an xterm
Of course, we don't have to select from top to bottom. We could select the last word first, and scroll up towards the first.

This method of selecting more than a screenful sounds complicated but it is far easier than the Microsoft method - which usually involves messing about as you undershoot and overshoot while text whizzes past in the window.

Inserting

Pasting is not really the correct word for what xterms do. Pasting implies that you can do it anywhere. Inserting is performed by clicking the middle mouse button anywhere in the window. The selected text is inserted where the keyboard cursor is - regardless of where the mouse cursor is in the text. Here we have selected two words separated by spaces:
Diagram of an xterm
and the user has inserted the selection twice on the command line by middle-clicking twice. Notice that the system is waiting for the user to press the enter (newline) key -- or erase the bad command.

Here the selection is still one line but this time it includes the newline character:
Diagram of an xterm
When the user middle-clicked, the system did not wait for the enter key. It tried to execute "vdu.text" as a command.

Inserting many lines

Inserting many lines is no problem but it has to be done while the system is expecting many lines. For example an email could be pasted into a text box in a browser to post it via gmail. In this case, paste is the correct word as the text would go wherever the user indicated by middle clicking. A common error is inserting a mult-line selection when the system is expecting a one line command.

Pasting from the keyboard

The "shift" and "insert" keys can usually be used together instead of a middle click. This is convenient when you wish to use the X selection as part of text that is being entered via the keyboard.

Xterm options

You might find that pressing a key does not make your xterm scroll to the last line. Or possibly, treble-clicking selects too much text - perhaps it always starts at the beginning of the line or it always includes the newline character. If any of these occur, it is because your system manager has chosen different options to me. You can select some of the options yourself from other xterm menus. Other options can only be corrected by setting up the .Xresources file shown in Appendix ??.

The other menus are obtained by holding down the control key and pressing the left or middle mouse buttons. The VT Options menu associated with the middle button is the most useful:
Diagram of an xterm
As you see, you can select Scroll to Bottom on Key Press from it; you can even remove the scrollbar altogether.

Not all xterm's options are available in menus. For example, the scrollbar can be made to appear on the right. However, that has to be done at the command line when the xterm is first started. Unfortunately, you would have to do it every time you started one. The more permanent solution is to set up an .Xresources file, or put the xterm command line in a shell script (see chapter??).

The joy of X

The best thing about the X Window System is that absolutely everything about it can be tailored - even the menus. For example, in Microsoft Windows we cannot choose how keyboard input is associated with a window - you have to click the left mouse button in the window. And when you do, the window is automatically brought to the top of any other windows. In X we can choose both: how to give focus to a window, and whether it is raised to the top or not. All tailoring is done by editing ordinary text files.

QUESTIONS

  1. pending

  2. pending

ANSWERS

  1. pending

  2. pending