Origami User Guide 1. Introduction 1.1. Origami Origami is a 'folding editor', similar to, and inspired by, the editor included in the Inmos TDS (Transputer Development System). Those of us who have become familiar with the TDS editor have long bemoaned the lack of a similar editor for use with other languages, for example Pascal and C. Origami is not a word processor (although many of its features would be useful in a word processor), but it comes into its own as a program editor for structured languages. The structuring of the code is obvious from the screen display (if Origami is sensibly used!), although no actual code may be visible. Existing files, not produced using Origami, may be imported into Origami, and then folded up for future use, and ease of development. These files can be further edited either using Origami or some other editor (if you can bear to use one afer Origami!), and compiled in the normal way. 1.2. The Folding Editor A 'folding editor' extends the principle of tree structured directories into a text file. This allows the simultaneous display of large amounts of text, by 'folding' sections of text away behind a descriptive heading. This results in a tree structure very similar to the sub-directory structure of, for example, MS-DOS. With suitable structuring of the text it should be possible in most circumstances to ensure that no display exceeds a single screen at any one time. To access text which is folded away you can either ENTER the containing fold, in which case the contents of the fold and its header are the only displayed text, or you can OPEN the fold, in which case the contents are displayed in the context of the surrounding text. The advantage of this system is that it eliminates the need for seemingly endless paging through long files to find the section of interest, allowing you to move down the tree structure, following the (hopefully) descriptive headers, to locate the text you require. 1.3. Examples of Origami Folding As an example, a Turbo Pascal file might look like this at the top level (eg immediately after starting Origami): program test; ... CONSTs ... TYPEs ... VARs ... procedures ... main body of code OPENing the VARs fold might lead to the following display: program test; ... CONSTs ... TYPEs {{{ VARs VAR i : integer; x : real; }}} ... procedures ... main body of code ENTERing the procedures fold might give: {{{ procedures ... statistical procedures ... string handling procedures ... procedure user_input }}} Each of these folds can be ENTERed further until actual code is reached - for example if we ENTER the 'procedure user_input' fold we might find: {{{ procedure user_input procedure user_input(prompt : str_type; var reply : str_type); ... local declarations ... local procedures begin repeat write(prompt); readln(reply); until verify_reply(reply); end; }}} 2. Using Origami 2.1. Getting Started Origami is contained in ORIGAMI.EXE file, and hence invoked by typing 'origami' after the MS-DOS system prompt (provided of course that a path exists to the directory containing ORIGAMI.EXE). A file name may be typed after 'origami' - if this is not done a prompt for a filename will be issued. If the file being read contains tab characters, Origami will ask for the tab size (in spaces) in order to preserve your formatting. 2.2. Editing Your File 2.2.1. The Screen Format On starting an Origami session, a command bar, containing the word 'Origami', appears near the top of the screen. This line will remain throughout your edit, and any prompts or warnings issued by the editor will appear on this line. If the current line (the line in which the cursor is placed, and which is marked by a '<' at the right of the screen) is too long to fit across the screen, the overflowing section is displayed on the top line of the screen, above the command bar. Lines (other than the current line) which overflow the screen are indicated by a diamond symbol at the end of the displayed line. 2.2.2. Editing Keys In Origami the keypad keys, the function keys, and certain ALT and CONTROL keys invoke editing functions which are similar in the main to those of the TDS editor. A list of these functions is given in Appendix A. Several keys have different functions in TDS and Origami, and these are indicated in the appendix. 2.2.3. The Editor Buffers There are three buffers in Origami. The 'move buffer' which can contain one line of text, the 'pick buffer' into which several lines can be accumulated before inserting it back into the file, and the 'delete buffer', which holds the last deleted line (in each case a line can be a closed fold, with all its contents). The operation of these buffers in Origami is slightly different from in TDS - the move and pick buffers are lost on exit from Origami, but the delete buffer may be recalled at any time up to exiting Origami, and the contents are inserted before the current position, and not at their original location as in TDS. 2.3. Compiling Origami Files In order for a saved file to pass a particular compiler, the fold structure must appear to the compiler as comments. As comments differ from one language to another, this means choosing the language before saving a new file for the first time, although on reading a file back into Origami the language type is retained (provided the file contained at least one fold). As a consequence of this you should take care not to include strings which the compiler would recognise as comments within the fold header, as this will lead to nested comments - not allowed in some languages. 2.4. Limitations of Origami Origami stores your complete file in memory while editing, so the file size is limited. This limits the number of lines to about 3000 on a 640k PC. The length of a line is limited to 150 characters, and the depth of folding is limited to 256. Appendix A In the description of key functions below, ^ indicates a control key and 'ALT_' indicates an alt key. 'ALT_' followed by a number relates to a numeric key on the MAIN keyboard (not the keypad). Most of the keys have identical or similar action to the TDS editor. The Function Keys. SHIFT_F1 Toggles between edit and browse modes. ALT_F1 Prompts for search and replace strings, and finds the first occurrence of the search string. If you terminate search string input with an Up Arrow (keypad 8) Origami will search backward. Note that terminating any question with up or down arrow will change the search direction. F1 Displays the HELP screen. SHIFT_F2 File or Unfile a fold. F2 Returns information on the fold depth and indent- ation of the current line, plus information about any fold the cursor is on. SHIFT_F3 Places the 'pick buffer' before the current line. ALT_F3 Removes a line from the file and adds it to the end of the 'pick buffer'. F3 If the move buffer is empty it removes a line from the file and adds it to the 'move buffer'. Other- wise the 'move buffer' is inserted before the current line. Note that the 'move buffer' is lost on exiting Origami, unlike TDS. ALT_F4 Copies a line into the end of the 'pick buffer' without deleting it from the file. F4 Duplicates the current line in the file. SHIFT_F5 Allows you to transfer to editting another file, saving the current one if required. F6 Allows you to select the language for which the code is to be saved - ie the format in which folds are to be saved. ALT_F7 Transfers the current line to the 'delete buffer', and places the old contents of the delete buffer in 'dispose chain'. SHIFT_F7 Move left one word. F7 Moves the cursor to the start of the current line - ie the first non-space (or the left margin if the line is empty). ALT_F8 Transfers the line currently stored in the delete buffer, back into the file before the current line. Repeating ALT_F8 MAY allow earlier deletions to be restored. SHIFT_F8 Move right one word. F8 Moves the cursor to the end of the current line - ie the last non-space (or the left margin if the line is empty). ^F9 Define macro. Remembers key presses until ^F9. SHIFT_F9 Cursor moves to the top line of the currently entered fold. ALT_F9 Page up. F9 Line up. ^F10 Call macro. SHIFT_F10 Cursor moves to the bottom line of the currently entered fold. ALT_F10 Page down. F10 Line down. Keypad Keys Esc Refresh screen. Home Enter the fold at the current line. ^Home Delete to end of line. Up Arrow Move cursor up a line (if not at top of entered fold). PgUp Exit fold. ^PgUp Remove fold at the current line - deletes the fold structure and inserts the contents of the fold in its place. Left Arrow Move the cursor one character left. ^Left Arrow Move the cursor one word left. Right Arrow Move the cursor one character right. ^Right Arrow Move the cursor one word right. End Open fold, and show the contents in the context of the current level. ^End Finish. If at top level, save file and exit from Origami. Down Arrow Move cursor down a line (if not at bottom of entered fold). PgDn If the cursor is within an opened fold, close this fold. Ins Create fold. Use twice - first to indicate the top of a new fold, then to indicate the bottom of it. Lines to be included within the fold must not be indented less than the fold itself. Several other keys are disabled while Create Fold is in operation. Del Delete the character at the cursor position. ALT Keys ALT_1 Attach a file to a fold. ALT_3 When the cursor is on a closed fold this key will copy the first line enclosed by that fold onto the fold line. ALT_5 Insert File. Prompts for a filename, and imports this file into the file being edited at the current position. ALT_8 Search. Begins a search for the current search string in the current search direction. ALT_9 Replace. If the cursor is at the beginning of a string matching the search string then the replace string will be substituted for it. ALT_0 Save File. File name and language type are prompted for. Control Keys Most of these duplicate the action of other keys. ^A Auto-fold: takes all lines to the first blank line, folds them up, inserts the first line as the fold header, and positions the cursor on the next non-blank line. ^B End of line ^E Delete to end of line. ^F Move left one word. ^G Move right one word. ^O Edit/browse. ^Q Quit from Origami. ^R Remove fold. ^S Special character. ^T Top of fold. ^U Put pick. ^X Finish. ^Y Delete line. ^Z Prompts for a line number, then goes to that line, counting from the top of the entered fold. Bk Space Deletes the character to the left of the cursor. ^Bk Space Undeletes the last deleted character.