Zap Documentation      Latest release     
ZapRedraw      Contact      Download     

Previous | Contents | Index | Next

Chapter 3: Simple operation

3.1 Loading and creating files

Once Zap has loaded onto the iconbar, you can create a new file by:

Alternatively, you can load an existing file into Zap:

If you load a file into Zap, it will check to see if it is a DOS file (line ends are CRLF) or Spool file (line ends are LFCR) as it does. If it is in either format, it doesn't just load the file, but converts it to use a lone LF for line ends first to make editing easier. It will then automatically convert back when you save - see section 6.9 for more details.

When you load a file into Zap, or create a new one, it works out the best mode to put it in. For the moment, don't worry about this - if you're new to Zap, just create a text file by clicking Select on Zap's icon, and we'll cover modes later, in chapter 10. However it is worth noting that you can override what Zap thinks is the best mode by holding down Control - this will drop the file into whatever's set as the 'default mode' - typically either Text or Byte. See the note at the end of section 12.2.1 for how to configure this.

If the file is already loaded into Zap and you have altered it, Zap will ask you whether you want to Cancel (don't load the file), Edit (load the file, but keep the altered file loaded as well), or Overwrite (close the altered file without giving you a chance to save it, and then opening the one on disc). The dialogue box Zap uses to ask you this also has a To Front button, which will bring all the windows on the altered file to the front of the window stack, so you can decide what you want to do. Several of Zap's dialogue boxes in similar situations have this button.

Zap can also grab the memory of running applications, the contents of dynamic areas, sectors from discs, and the code or workspace of a relocatable module; see section 10.1.3 for more information.

3.2 A Zap editing window

A Zap editing window is just a normal RISC OS window, with one slight exception (see section 3.4.4). As you'd expect, clicking Menu on a Zap editing window will bring up a menu which has options to let you save the file you are working on, and a range of other useful operations.

In common with many applications, Zap puts the filename in the window's title bar, but it also puts some other information there too. In any mode, the window title is of the form:

<filename> [*] ([mode name] [options]) [view number/number of views]

The title is centered unless the window is small, when it is right aligned so that you can see the leaf name and options of the file. A * indicates that the file has been altered since last saved (sometimes you will get a ? instead, which means that Zap isn't sure, but the file may have been changed). The view number is only shown if you have more than one view on a file.

3.2.1 Titlebar options characters

The options characters are one or more of:

3.3 Basic editing

Now we've got a new file, we probably ought to alter it in some way. First we need to briefly talk about Zap's cursor.

3.3.1 Zap's cursors

Unlike Edit, which has a point cursor - a single line which indicates where text that you type will be entered, Zap has a block cursor. When you open a new file, you will see it sitting at the top left of the window. Text you type will get inserted immediately to the left of the block cursor (unless you have overwrite turned on, in which case typing a character will overwrite the character displayed in the block cursor with the new character that you typed). You can position the cursor by clicking Select with the mouse (the mouse can also be used for other things - see chapter 5 for more information).

That said, you can now happily type some text in; the cursor keys work in the way you would expect.

Zap also has another three cursors. Firstly, it has a mark cursor. This shows where the cursor would be in a window that doesn't have the focus. To see this, open two new text files, and type some text into each. Resize them so you can see both - and you will see that the window with the focus has a block cursor, while the window without the focus has an empty square mark cursor to indicate where the cursor was when you last used that window. Clicking Select both sets the focus to the window you clicked on and moves the cursor; if you want to set the focus to a window, but not set the cursor, click Adjust - this will position the cursor where the mark cursor was. This way you can quickly move between windows with the mouse without having to click accurately to keep the cursor where you want it.

Secondly, Zap has a pair of copy cursorscopy cursors. If you turn copy mode on by pressing sCopy (hold down Shift and press the Copy key), you will have two separate cursors (although they will initially be at the same position, so you won't be able to see this). One, a block cursor will remain in place, while the other, a thin line drawn under the character it's at, can be moved around the file. In copy mode, pressing sCopy will copy the character under the line cursor to the position of the block cursor. Pressing Escape or Return will cancel copy mode. (This works in the way you'd expect from using the Copy key in BASIC or from the command line.)

You can configure how Zap draws its different cursors - see section 12.2.3.

3.4 Keyboard shortcuts

Many applications have some keyboard shortcuts to help you perform common operations quickly. Zap has lots of keyboard shortcuts, so that not only common operations but also less common ones can all be performed without having to move your hands from the keyboard. As with everything else, what each keypress does can be configured - see section 12.3.3 for more information; you might also like to look at section 6.4, which allows both for a series of keypresses to perform an action (eg: scF11 cX cS saves the file), and for different modes to have the same keypresses doing different things.

Keystrokes are shown on Zap's menus, where they are displayed using ^ to stand for Control, and an up arrow to stand for Shift (eg: ^F3). In this manual we will use s for Shift and c for Control (eg: cF3, scW). Control and Shift are modifiers - you hold them down while you press the key named afterwards. The keynames should all be fairly obvious; if it starts with k it means the named key on the keypad at the right of the keyboard (eg: k0, kEnter, sk1 and so on).

For a complete list of Zap's default keystrokes, see appendix A.

3.4.1 Moving around your file

You will probably already be familiar with the way cursor keys work. Not only can you use them to move around, one character or one line at a time, but you can use them to move quickly around your file. Their complete operation is as follows:

3.4.2 Other useful keystrokes

Zap's default configuration also contains many of the standard RISC OS shortcuts. For instance, the save box is opened by pressing F3, and the selection keys (cZ, cX, cC and cV) work as expected.

Some other useful keys are (these are clearly our idea of what is useful!):

3.4.3 Keystrokes in dialogue boxes

Zap's dialogue boxes all work in a consistent manner. Firstly, pressing Return always closes the dialogue and performs the action for that dialogue box. Secondly, the Up and Down keys always move between writeable fields, and the Tab key always moves onto the next field. These features are common with all normal RISC OS applications.

An additional feature with Zap dialogue boxes is that all buttons in the dialogue box will act as if clicked if you hold down Control and press the first capitalised letter in the button's descriptive text. For instance, in the goto line/address dialogue box (F5) the number you input in the writeable field can be interpreted in three ways: as a logical line, as (x,y) coordinates, or as an address. Each option (Logical line, Coordinates, Address) has its first letter capitalised (in some dialogues, the first letters clash and some options will have later letters capitalised) - so cL selects logical line, cC coordinates and cA address. In dialogue boxes without writable icons, you can simply press the first capitalised letter (ie: you don't have to hold down Control first).

Some dialogue boxes will have specific other keystrokes - for instance the search dialogues have commands to access the search history. Where it makes sense, some dialogues will use cP to insert Zap's current selection into the writable icon at the caret.

3.4.4 Zap's minibuffer

Sometimes you will run a command in Zap which needs more information - for instance cW sets the width for the window you're working on, but you need to tell it what width to use. In cases such as this, Zap will open a 'minibuffer' for you to type information into; this temporarily replaces the horizontal scrollbar.

(You can actually configure the minibuffer to be present constantly; see section 12.2.4.)

If you drag a file or directory into the minibuffer, its full pathname is inserted.

Several control keys have default meanings in the minibuffer. These cannot be reconfigured, but are compatible with the Emacs minibuffer keys:

If you have the Line editor module loaded (see section 13.2.1):.

The last four can be redefined by commands to the Line editor module, but you will probably want to keep them consistent with the rest of the commands for the minibuffer. For information on configuring the Line editor, see the files in !Zap.Code.Extensions.LineEditor.

In addition, you can access the recall buffer by clicking Menu over the minibuffer. You can also drag the minibuffer around with Select, and resize it with Adjust, although this gets reset next time the minibuffer is opened - it is of use primarily if you configure the minibuffer to be open all the time (see section 12.2.4).

One particular use of the minibuffer is to give commands directly to Zap. All Zap's menus and keystrokes are defined in terms of the commands, which are explored further in section 9.4. All you need to know for the moment is that cEscape opens the minibuffer and allows you to type a command directly. For instance, if you want to open the save box, type cEscape, enter SAVE into the minibuffer, and press Return. The minibuffer will close automatically, and the save box will open - just as if you'd pressed F3.

3.5 Further editing

Now we introduce undo and redo (enabling you to recover from mistakes), quoting (which allows you to insert any character into your file), and inserting files.

3.5.1 Undo and redo: recovering from mistakes

Often you will make a mistake and need to recover from it; you may have deleted a section, or formatted a paragraph you didn't mean to. Pressing F8 will undo your last action. Zap stores undo information right back until when you loaded or created the file, so you can undo several actions in a row. Of course, this can take a lot of memory - if you find that you are running short on memory you can turn undo off: it's in the File submenu.

Of course, just having undo would be a bit limiting - so pressing F9 redoes your last undo step. For instance, if you insert the letter a, then press F8 the a will disappear - pressing F9 will bring it back again.

Zap actually has two different forms of undo, fast and full. Fast takes the fastest route through the undo tree, and full follows it step by step - an example should make this clearer.

Suppose you insert the letters a then b, and then undo the last step. Now insert the letter c - so you have ac. If you undo the last step, you are left with just a again, and up to this point fast and full undo will behave in the same way. However if you undo another step, there are two choices: fast undo will remove the a, while full undo will insert the b.

Pressing F8 gives you fast undo; scBackspace is full undo.

3.5.2 Quoting characters

As we've already seen, Zap uses most combinations of Control and an alphabetic character to perform useful actions; therefore you can't use them to enter control characters - characters which you can't type on the keyboard. Instead, you can 'quote' the character you want, by pressing cQ (hold down control and press Q) and then typing the control character you want. For instance, cQ cA will insert and byte of value 1 (which is cA). Use cQ cSpace for a byte of value 0.

An alternative is to change into Byte mode, type the digits in hexadecimal, and then switch back to whatever mode you were working in - see chapter 10 for more information about modes in general, and section 10.1 for details on Byte mode.

Control characters are displayed by Zap in blue, as opposed to white - see section 7.3 for more information.

3.5.3 Inserting files

You can drag a file directly into a Zap window to insert its contents at the cursor. If you hold down Shift, then the filename of the file will be inserted instead.

You can also save from another application into Zap; this will always insert the file's contents.

Another way of inserting a file is to use the INSERTFILE command, which is available from the Misc->Insert menu. This will open the minibuffer to let you type in the filename. You can also prefix the filename with one or more of | and * - the first will indent the text as if you'd typed it in, and the second will run the file through GSTrans first, to allow you to use system variables.

3.6 Saving and closing files

In order to save your changes, bring up the save box by pressing F3, clicking on the File item in the main window menu, or opening it from the menu tree as File->Save->(Save box). While this doesn't look like a normal RISC OS save box, it essentially is - just with more information available to you. The icon at the top left is draggable as you'd expect, and the filename is near the bottom. In addition, the middle section gives you some information about the file - its current size, and the date and time it was last altered - and the top right allows you to change the filetype. You can either type in a new filetype (the upper icon allows you to type it in as text, while the lower one is numeric), or you can use the menu to get a list of filetypes.

Zap will warn you if you are about to overwrite a more recent file (the warning can be turned off - see section 12.3.1).

If you want to save the file quickly, without having to confirm the filename, you can press cF3, or click on File->Save in the menu. This is known as a 'quick save'.

cF2 closes the current window; when there are no more windows open on a particular file that file will be removed from Zap's memory. At this point, if you have made any changes, Zap will ask you whether you want to save the file to preserve your changes, discard it, or cancel (therefore not closing the last window). Similarly if you try to quit Zap with some modified files still hanging around, it will ask whether you want to lose your changes.

(Zap has an option to allow files to stay in memory even when you've closed all windows. This is similar to the way Impression, and some other applications, handle things - for more information, see section 12.3.1.)

3.6.1 Automatic backups

When you save a file, Zap will usually overwrite whatever was saved on disc under that filename. However, in many cases - particularly when you're programming - you might want to keep old versions of the files. While you could make sure you always move the old version before saving, it would be easy to forget - so Zap has a method for doing this for you.

When you save a file, Zap looks for a directory called ~ (just the tilde sign). If it exists, Zap will first move the old copy of the file into that directory (overwriting anything with the same name already there). If you want more than one old version, you can do that by having a number of directories called ~<number> - eg: ~1, ~2, ~3 ... ~n, and Zap will then keep the last n versions of the file. Zap won't bother backing up a file if you've saved to it in the last two minutes - so if you save every time you type a character you won't get a series of backup files with very little difference between them. (The length of time Zap will wait between backups can be configured - see section 12.3.1.)

The next section in the manual is chapter 4, which also covers moving blocks of text around the file, to other files, or even to other applications. It also covers various operations you can perform on blocks of text, such as sorting.

Alternatively, you might like to move on to chapter 6, which covers tabbing, wrapping and formatting, and other advanced editing issues.

Previous | Contents | Index | Next

© Copyright Zap Developers 1992-2004. All Rights Reserved.