<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=US-ASCII">
<meta name="author" content="mailto:webmaster@zap.tartarus.org">
<meta name="description" content="Zap is a configurable programmers' editor for Acorn RISC OS">
<title>Selections</title>
</head>
<body background='/img/background.png' text="#000000" bgcolor="#DCDCDC" link="#20209F" vlink="#008000" alink="#FF2020">
<p align='center'><a href="Chapter3">Previous</a> | <a href="Contents">Contents</a> | <a href="IndexPage">Index</a> | <a href="Chapter5">Next</a></p>

<ul>
<li><a href="#C4">Chapter 4: Selections</a>
<ul>
<li><a href="#S4.1">4.1 Making a selection</a></li>
<li><a href="#S4.2">4.2 Copying, pasting, cutting, yanking and moving</a>
<ul>
<li><a href="#S4.2.1">4.2.1 The global clipboard</a></li>
</ul></li>
<li><a href="#S4.3">4.3 Saving the selection</a></li>
<li><a href="#S4.4">4.4 Processing the selection</a>
<ul>
<li><a href="#S4.4.1">4.4.1 Indent</a></li>
<li><a href="#S4.4.2">4.4.2 Outdent</a></li>
<li><a href="#S4.4.3">4.4.3 GNU filters</a></li>
<li><a href="#S4.4.4">4.4.4 Sort</a></li>
<li><a href="#S4.4.5">4.4.5 Format</a></li>
<li><a href="#S4.4.6">4.4.6 Swap case</a></li>
<li><a href="#S4.4.7">4.4.7 Upper case</a></li>
<li><a href="#S4.4.8">4.4.8 Lower case</a></li>
<li><a href="#S4.4.9">4.4.9 Bracket ()</a></li>
<li><a href="#S4.4.10">4.4.10 Filters</a></li>
<li><a href="#S4.4.11">4.4.11 Filter <code>ZF:sort</code></a></li>
<li><a href="#S4.4.12">4.4.12 Filter <code>ZF:format</code></a></li>
<li><a href="#S4.4.13">4.4.13 Filter <code>ZF:untab</code></a></li>
</ul></li>
<li><a href="#S4.5">4.5 "Sending" the selection</a></li>
</ul></li>
</ul>
<h1><a name="C4"></a>Chapter 4: Selections</h1>
<p>
A common need when editing files is to perform an operation on a particular section of the file. For instance you might want to reformat it to a different line length, or move one section so it comes before another. In Zap, as in many editors, you do this by <a name="i0"></a><em>selecting</em> a continuous section of the file; there are then a set of commands that you can perform on that section to do the jobs you need.
</p>
<h2><a name="S4.1"></a>4.1 Making a selection</h2>
<p>
There are several ways to make a selection in Zap. The most obvious is to use the mouse, which we'll cover first.
</p>
<p>
If there is no selection, then dragging <code>Select</code> will select a new region, and clicking/dragging <code>Adjust</code> will select between the clicked point and the cursor. If there is already a selection, then dragging <code>Select</code> will start a new selection; clicking/dragging <code>Adjust</code> will alter the old region. In either case, hold down the <code>Control</code> key to leave the cursor unaffected by the selection.
</p>
<p>
Alternatively, there are a variety of methods for selecting via the keyboard, which can be quicker in some cases because you don't have to move from keyboard to mouse and back again repeatedly. To select via the keyboard, either hold down <code>Escape</code> while moving the cursor via the cursor keys (releasing <code>Escape</code> ends the selection), or type <code>cSpace</code> to start the selection, move the cursor to the end, and type <code>cSpace</code> again.
</p>
<p>
A third method is to use multiple clicks; double clicking selects a word, triple clicking a line, quadruple clicking a paragraph, and quintuple clicking the entire file. For more information about using the mouse in Zap, see <a href="Chapter5#C5">chapter 5</a>.
</p>
<p>
You can select the entire text using <code>cT</code>, and clear the selection by using <code>cZ</code>.
</p>
<h2><a name="S4.2"></a>4.2 Copying, pasting, cutting, yanking and moving</h2>
<p>
Zap implements both the <a name="i1"></a><em>Edit</em> style copy/move of selections, and the <a name="i2"></a><em>Emacs</em> style paste/yank. Both of these will work happily across different windows, files and even from one mode to another (although if you copy a selection in, say, Code mode into Text mode you won't get the disassembled text but rather the binary data - see <a href="Chapter7#S7.4">section 7.4</a> for a solution to this).
</p>
<p>
The <a name="i3"></a><em>Edit</em> method: to <a name="i4"></a>move a selection to the cursor position press <code>cV</code>. To <a name="i5"></a>copy the selection to the cursor position press <code>cC</code>.
</p>
<p>
The <a name="i6"></a><em>Emacs</em> method: to move a selection, <a name="i7"></a><em>cut</em> it with <code>cX</code> and then <a name="i8"></a><em>paste</em> it with <code>cY</code> (the <a name="i9"></a>undo buffer must be turned on for this to work - see <a href="Chapter3#S3.5.1">section 3.5.1</a>). To copy a selection, grab it with <code>cE</code> (this is called <a name="i10"></a><em>keeping</em>) and paste it with <code>cY</code>. Press <code>scY</code> to cycle through the previously cut selections (this is called <a name="i11"></a><em>yanking</em>).
</p>
<p>
Note that the <code>DELTOEND</code> (<code>cK</code>) and <code>DELLINE</code> (<code>F10</code>) commands also produce data which can be pasted by <code>cY</code>.
</p>
<p>
Another way to copy text is via the <code>Copy</code> key - see <a href="Chapter3#S3.3">section 3.3</a> for more information.
</p>
<h3><a name="S4.2.1"></a>4.2.1 The global clipboard</h3>
<p>
One very useful (but sadly little-known) feature common to several <a name="i12"></a>RISC OS applications is the <a name="i13"></a><em>global clipboard</em>. Put simply, this is a way of using cut and paste,as described above, across different applications. Unlike Zap's 'yank ring' which allows yanking, as described above, the global clipboard can only contain one object at a time.
</p>
<p>
The way it works in Zap is that when you copy or cut anything to Zap's clipboard (the 'local' clipboard), it also gets put into the global clipboard too, so that other applications can use it. When someone else puts something into the global clipboard, Zap will use that in preference to its own local clipboard when pasting using <code>cY</code> (the <code>PASTE</code> command).
</p>
<p>
If there is something on the global clipboard and you want to use Zap's local clipboard instead, you can use the <code>LOCALPASTE</code> command (<code>cEscape</code> will bring up a <a name="i14"></a>minibuffer to type the command into - see <a href="Chapter11#C11">chapter 11</a>). If Zap has put something on the global clipboard which you don't want available to other applications any more, you can use the <code>Disown clipboard</code> option which is on the <code>Misc-&gt;Clipboard</code> submenu (the command is <code>CLEARGC</code>).
</p>
<h2><a name="S4.3"></a>4.3 Saving the selection</h2>
<p>
If you have a selection, you can save it by pressing <code>sF3</code> to bring up the <a name="i15"></a>save selection dialogue box. This works in exactly the same way as the normal save box (except that it only saves the selection); you can drag the file icon to a Filer window, or another application as you'd expect.
</p>
<p>
Another way to quickly save the selection is to <code>Shift</code> drag it with <code>Select</code>. This will save the selection with the filename '<a name="i16"></a>Selection', but is really useful for quickly saving things into other applications. You can even <code>Shift</code> drag the selection into a Zap editing window - it will be copied to the point that you drag it to.
</p>
<h2><a name="S4.4"></a>4.4 Processing the selection</h2>
<p>
There are a number of actions you can perform on an entire selection; here we will just cover the most important ones. These are all available from the <code>Selection-&gt;Process</code> submenu.
</p>
<p>
A related topic here is <a name="i17"></a>block editing, which allows you to make alterations on one line in the selection which are mirrored on all the others - see <a href="Chapter6#S6.6">section 6.6</a>.
</p>
<h3><a name="S4.4.1"></a>4.4.1 Indent</h3>
<p>
Indent simply indents the selection by whatever you type into the indent submenu. In other words, it adds text at the beginning of each line of the selection depending on what the parameter is.
</p>
<p>
If you type in a number to the indent submenu, it will indent the selection by that number of spaces; otherwise it will indent it with whatever you type in. For instance, you might put the string <code>&gt; </code> in the indent submenu to 'quote' the selection in the manner of an email reply.
</p>
<p>
Indent is also available by pressing <code>cJ</code>.
</p>
<h3><a name="S4.4.2"></a>4.4.2 Outdent</h3>
<p>
Outdent simply un-indents the selection depending on whatever is in the indent submenu. If the indent parameter is currently a number, it will remove that many characters from the beginning of each line. If the indent parameter is some text, it will remove the same number of characters as are in the parameter (so two if the parameter is <code>&gt; </code>, three if it is <code>&gt; &gt;</code> and so on).
</p>
<h3><a name="S4.4.3"></a>4.4.3 GNU filters</h3>
<p>
This is a menu containing various GNU filter programs you can apply to the selection. Darren Salt has ported a range of GNU text filters to RISC OS; these are available from <a href="ftp://zap.tartarus.org/pub/ds/GNU/">ftp://zap.tartarus.org/pub/ds/GNU/</a>.
</p>
<p>
See <a href="#S4.4.10">section 4.4.10</a> for more information on general filtering within Zap.
</p>
<h3><a name="S4.4.4"></a>4.4.4 Sort</h3>
<p>
This simply sorts the lines of the selection into alphabetical order. See <a href="#S4.4.11">section 4.4.11</a> for more details.
</p>
<h3><a name="S4.4.5"></a>4.4.5 Format</h3>
<p>
This simply formats the selection to 77 characters, with a first-line indent for each paragraph. See <a href="#S4.4.12">section 4.4.12</a> for more details.
</p>
<h3><a name="S4.4.6"></a>4.4.6 Swap case</h3>
<p>
This simply swaps the case of all the characters in the selection. It recognises the full <a name="i18"></a>ISO Latin 1 character set, so accented characters will have their cases swapped too.
</p>
<h3><a name="S4.4.7"></a>4.4.7 Upper case</h3>
<p>
This does the same as swap case, but leaves all characters in upper case.
</p>
<h3><a name="S4.4.8"></a>4.4.8 Lower case</h3>
<p>
This does the same as swap case, but leaves all characters in lower case.
</p>
<h3><a name="S4.4.9"></a>4.4.9 Bracket ()</h3>
<p>
This simply places the selection in brackets.
</p>
<h3><a name="S4.4.10"></a>4.4.10 <a name="i19"></a>Filters</h3>
<p>
Zap provides a way of <em>filtering</em> the selection (or the entire file, for that matter - see the documentation that comes with <a name="i20"></a><em>ZapText</em>) through an external program. What actually happens is that the selection is fed through the filter program, and the output replaces the selection in the file. Several useful filters are supplied with Zap, and we introduce some of them here. For more information, see the files in <code>!Zap.Code.Filters.Docs</code>.
</p>
<p>
The menu options call these filters using the default options (assuming the filter has options); if you want to use different options you'll need to call the command yourself. The Zap command being used here is <code>FILTERSEL</code>, and the filters supplied with Zap are kept in a special place which you access by prefixing their names with <code>ZF:</code>. For instance <code>FILTERSEL ZF:Sort -descending -case</code> will give a case sensitive, descending ASCII sort. For more information, see <a href="Chapter11#C11">chapter 11</a> and the documentation supplied both with <a name="i21"></a><em>ZapText</em> and the filters.
</p>
<p>
A number of useful filters are supplied with Zap, and are described below. You can use the <code>Selection-&gt;Process-&gt;Filter...</code> menu option to enter their names: eg, for filter <code>ZF:sort</code>, you would type <code>ZF:sort</code> at the minibuffer that pops up.
</p>
<h3><a name="S4.4.11"></a>4.4.11 Filter <a name="i22"></a><code>ZF:sort</code></h3>
<p>
The sort filter sorts in straight ASCII order. The option on the menu (<code>Selection-&gt;Process-&gt;Sort</code>) does an ascending case insensitive sort - if you call the filter yourself you can change those options, as well as making it skip leading spaces and tabs on each line.
</p>
<h3><a name="S4.4.12"></a>4.4.12 Filter <a name="i23"></a><code>ZF:format</code></h3>
<p>
The format filter is a simple text formatter. A paragraph is recognised by either starting with a space, or ending with two line feeds. Tab characters are treated as spaces. This filter has a fair number of options, and it's probably easier to read the documentation that comes with it than to describe only part of it here. You'll almost certainly want to call it directly yourself to be able to take advantage of all the features, but it is also on the menu as <code>Selection-&gt;Process-&gt;Filter</code>.
</p>
<p>
Note that Zap has an internal command, <code>FORMATTEXT</code> (<code>cF6</code>), which does not work in the same way. For information on that, see <a href="Chapter6#S6.3">section 6.3</a>, which explains Zap's various internal formatting and wrapping modes.
</p>
<h3><a name="S4.4.13"></a>4.4.13 Filter <a name="i24"></a><code>ZF:untab</code></h3>
<p>
The untab filter simply replaces each tab character in a file with an equivalent number of spaces. It is different to the <code>UNTABIFY</code> command, which leaves tabs inside quotes ("") alone in program source modes such as C, Java and so on.
</p>
<h2><a name="S4.5"></a>4.5 "Sending" the selection</h2>
<p>
Zap can send the selection straight to the keyboard buffer. You can start this through the <code>Selection-&gt;Send</code> menu option. Zap sends the selection a character at a time; you can abort at any time by pressing <code>Escape</code>.
</p>
<p>
The menu option will strip out control characters; if you need to send them too you'll need to use the <code>SENDSEL</code> command directly.
</p>
<p>
Only one selection at a time may be in the process of being sent.
</p>
<hr>
<p>
The next section in the manual is <a href="Chapter5#C5">chapter 5</a>, which gives a complete description of how the mouse is used in Zap.
</p>
<p>
Alternatively, you might like to move on to <a href="Chapter6#C6">chapter 6</a>, which covers tabbing, wrapping and formatting, and other advanced editing issues.
</p>

<hr><address><a href='/copyright'>&copy; Copyright Zap Developers 1992-2004</a>. All Rights Reserved.
</address></body>
</html>
