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


Book HomeLearning UnixSearch this book

2.4. Working with a Mouse

Let's look at basics of using a mouse or other pointing device. We assume that your mouse has three buttons, as mice on Unix systems usually do. (If your mouse has two buttons, you may be able to simulate the missing middle button by pressing both of the other buttons at once. Your X system may need to be reconfigured to work this way, though.) When we say "the first button," we mean the leftmost button for right-handed users, or the rightmost button for left-handed users. (Under X, a mouse can be set for either left-handed or right-handed users, so the button you use to click on and drag is the button under your index finger.)

2.4.1. Pointer Shape

As you move the mouse pointer[6] from the desktop on to other windows or menus, the shape of the pointer changes. For instance, on some window systems, while the pointer is over the desktop, it's shaped like a big X. The pointer may change to an hourglass shape to tell you to wait. When you resize a window, the pointer could change to a cross with arrows.

[6] The correct word for this symbol is cursor. But xterm and some other windows also have separate cursors to show where text will be entered. To avoid confusion, we use the word "pointer" for the cursor that moves all across the screen under control of the mouse.

2.4.2. Using a Mouse with xterm Windows

One advantage terminal windows have over plain (nonwindowing) terminals is you can copy and paste text within an xterm window or between xterm windows.

NOTE: Although this section is specifically about xterm windows, most tips here also apply to other kinds of terminal windows. Check your documentation or just try these and see!

To get started, move the pointer inside an xterm window and be sure it has the focus (if your window manager doesn't do that automatically). Notice that the pointer changes to an "I-beam" shape as you move it into the window. We discuss this I-beam pointer later in this section. There's also a block cursor (which is shown in all terminal windows in this chapter--and labeled at Figure 2-4.) The block cursor is the window's insertion point, where text goes when you type on the keyboard. The block cursor doesn't follow the mouse.

If your window doesn't have some previously completed command lines, as in Figure 2-3, type command lines at a couple of prompts; this gives you text to copy. (The mail command, shown in Figure 2-3 and explained in Chapter 6, is a good example, but you can use any command line that you want to rerun from another window.)

The I-beam pointer selects text for copying. Let's try it. Point to the first character of a command line (not the prompt) and click the first mouse button. Next, move the pointer to the end of the text you want to select and click the third button. The text between the first and third clicks should be highlighted; your xterm window should look something like Figure 2-3. (Problems? If you select the wrong text, you can undo the selection by clicking the first button anywhere in the window. If you accidentally click the second button, this may paste some random text at the block cursor; in that case, you can erase the pasted text with your backspace key.)

Another way to select text is by pointing to the first character you want to copy, then holding down the first mouse button while you drag the pointer across the text. By the time you release the mouse button, the whole area of text should be highlighted.

The instant you highlight text (as you did a moment ago), the text is also automatically copied, so you can paste it somewhere else. (In an original xterm window, there's no menu with a "Copy" command on it. In most X window programs--the original X programs, at least--highlighting text copies it automatically.)

You can paste text in the window you copied it from or in another window. Let's choose another open terminal window. With the block cursor at a shell prompt, click the middle mouse button anywhere in the window. (You don't have to click at the block cursor!) The selected text will be inserted (pasted) into the window at the block cursor, just as if you had typed it in. Press RETURN to run the command; otherwise, backspace over it to get back to the prompt.

You can also select text in a window just by clicking. Point to a word and double-click the first button; the word should be highlighted. Next, let's select an entire line. Point to any character on a line (a space is OK too) and triple-click the first button to highlight the whole line.

You can select and copy any text, not just command lines. With the mail command, for instance, you can copy a line from the body of the email message.

Figure 2-3

Figure 2-3. Copying a command line

The same copying and pasting works between xterm windows and between many other (but not all) windows that handle text. Before you paste text into an xterm window, always be sure the block cursor is at the place you want to insert the newly pasted text!

2.4.2.1. Problem checklist

When I try to paste text into a terminal window, it doesn't appear where I want it.
One common mistake is clicking the mouse at a particular point in the terminal window and expecting the text to be pasted there. In most terminal-based Unix applications, you need to move the insertion point (typically, a block-shaped cursor) using keyboard commands or the arrow keys. Before you paste, be sure that the insertion point is at the place you want it.

I've copied text from one window, but it won't appear when I paste it.
Unfortunately, there are several possible causes, including the following list:

  • Be sure you're pressing the second (middle) mouse button to paste. If you have a two-button mouse, pressing both buttons (to act like the missing middle button) can be tough: it takes precise timing.

  • Some things can erase the clipboard where your text was copied--for instance, opening certain kinds of new windows. Try copying the text again, then pasting it right away.

  • The window system actually has many clipboards, and some programs don't check all clipboards to find your copied text. You may be able to paste the text into another window (such as a window-based text editor), then copy the text again and paste it where you want it.

  • Some programs will let you highlight text, but the text actually isn't copied and/or pasted unless you use the "Copy" and/or "Paste" commands on the program's menu.

Can you save some or all of the text you want to copy into a temporary file? If so, you may be able to open that file in another type of window (such as a text editor), then copy from that new window. Also try using a text editor to put just the text you want into the temporary file, then read that file into the program where you originally wanted to paste the text.



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.