
Typing Forth Command Lines
**************************

This chapter describes the editing facilities that are available when you are 
typing command lines to RISC OS Forthmacs.  These facilities are much more 
powerful than those of most other systems.  Study this carefully, and it will 
save you a great deal of typing in the future.  


    Quick Reference Chart:
        Moving:         Character       Word            Line
            backward:   left-arrow      ESC-b           ^A
                        or ^B   
            forward:    right-arrow     ESC-f           ^E
                        or ^F
        Erasing:        Character       Word            Line

            backward:   ^H              ESC-h   
                        or Backspace    or ^W   
            forward:    ^D              ESC-d           ^K
                        or Delete
            entire line:                                ^U

        Others:
            previous command            up-arrow  or  ^P
            next command                down-arrow  or  ^N

            complete word               ^C
            show matches                ^S

            retype line                 ^L
            quote next character        ^Q


Typing Forth Command Lines
==========================


Notation
========

  ^B      hold down the Control key and simultaneously type the b key.
  ESC-b   first type the Esc key, release it, and then type the b key.
  ^X^C    first press ^X, release it, and then press ^C

Note that for Control, two keys are typed at the same time, whereas for Esc, 
the Esc key is first typed and released, then the other key is typed.  


Moving
======

  left-arrow   or  ^B     Backs up one character without erasing
  right-arrow  or  ^F     Moves forward one character without erasing
  ESC-b                   Backs up one word without erasing
  ESC-f                   Moves forward one word without erasing
  ^A                      Moves to the beginning of the line
  ^E                      Moves to the end of the line


Erasing
=======

  Backspace or ^H         Erases character to the left of the cursor
  Delete or ^D            Erases character at the cursor
  ESC-h                   Erases the word to the left of the cursor
  ESC-d                   Erases the word to the right of the cursor
  ^K                      Erases from the cursor to the end of the line


History
=======

RISC OS Forthmacs remembers the last 8 lines you typed, so you can easily 

  repeat or modify previously-typed commands.
  up-arrow    or ^P       Steps backward through the list of
                          previous commands.
  down-arrow  or ^N       Steps forward through the list of
                          previous commands.


Command Completion
==================

When you are typing a Forth word, it is not always necessary to type the whole 
word.  If you type the first few characters of the word, then type ^C (i.e.  
hold down the Control key and type the C), Forth will try to finish the word 
for you by looking in its dictionary for words which start with the characters 
you have typed.  If there is only one possible word, Forth will complete the 
word for you.  

Sometimes Forth will be unable to finish the word.  If there are no words in 
the Forth dictionary which start with the characters you have already typed, 
Forth will remove characters from the end until the characters that are left 
start some word in the dictionary.  If there are several words which start 
with your characters, Forth will complete the word as far as it can.  In 
either case, you can then type some more characters to further specify the 
desired word, then try ^C again.  

  ^C            Forth attempts to complete the word you have started
  ^S            Shows a list of all the words which start with the
                characters you have typed.


Miscellaneous
=============

  ^L              Retypes the current line.
  ^Q              The next character typed (usually a control
                  character) is inserted into the line being typed,
                  instead of being treated as an editing command.

  ^X^C            Quit Forthmacs at once


Mnemonics
=========

To make it easier to remember the control commands, here are some mnemonics: 

  ^F   ESC-f      Forward character or word
  ^B   ESC-b      Backward character or word
  ^E              End of line
  ^D   ESC-d      Delete character or word
  ^K              Kill rest of line
  ^P              Previous line
  ^N              Next line
  ^Q              Quote next character


Tips
====

To delete the entire line, type ^A followed by ^K.  It is not necessary to 
release the Control key between the typing of the A and the typing of the K.  

Practice using the history mechanism (^P and ^N).  Forth commands are 
frequently repeated, and the history feature can save you much typing.  

The "show matches" command (^S) can be used to find all the Forth words which 
start with a particular string of characters.  Just type that string of 
characters then type ^S.  (There is a Forth command sifting that will find all 
the words which contain a particular string anywhere in the name, not just at 
the start as in ^S.  sifting is described in the master glossary.  

Try to train your fingers to type ^F, ^B, ^A, ^E, and ^D without using your 
right hand.  This can make editing very fast because you don't have to move 
your hands very far, and it is relatively easy to type these combinations 
without looking at your fingers.  

Why do many functions have two different key assignments? Some people prefer 
to use the arrow keys because they are easier to remember.  Others prefer to 
use the ^ keys because they can be typed without moving the hands from the 
home keys on the keyboard.  




For Experts
===========

If you do not like the assignment of functions to keys (for instance you might 
prefer to use ^S and ^D to move forward and backward, as in Wordstar), you can 
easily change the assignments.  The vocabulary keys-forth contains a colon 
definition or alias for each key assignment.  These assignments may be 
redefined using normal colon definitions.  

However, note that the existing key assignments are the same as the ones in 
the Emacs editor.  The Emacs key assignments cannot be easily changed, so if 
you change the assignments in keys-forth you will make them different from the 
ones in Emacs.  

