• Keine Ergebnisse gefunden

THE LEAP MECHANISM

Im Dokument Cat Editor (Seite 192-197)

B. O GENERAL DISCUSSION

9. DOCUMENT COMMANDS

10.1 THE LEAP MECHANISM

The word called when either Leap key is pressed or another key is pressed while a Leap key is down is do-lex. Since many

operations are supported by the Leap mechanism, do-lex has the responsibility of deciding which of them it should perform.

10.1.0 Initializing a Leap Operation

The first action of do-lex is to check the contents of the lexxing integer to see if a leaping operation is already in progress. If leaping is not already in progress, init-lex performs general leaping preparations.

During leaping, all characters typed are considered to be

lowercase unless they are deliberately typed while the Shift key is down. The Lock key has no effect, and the Lock light is

turned off during leaping. The previous state of the Lock key is saved in the oldshiftlock integer. savepos saves the state of the current cursor-state integers. newlex and lexxing are turned on to indicate that a new Leap is being initiated and that Check Leap command. Therefore searching discards the character and calls spellcheckleap. enough to handle accent-character merging (like Insert). pattadd contains a begin ... again loop and, once called, will continue calling <?k) and adding or deleting characters from the pattern until no valid characters are available. This means that if the pattern is typed quickly, some intermediate character patterns may not be searched.

Once pattadd completes, the ptable is built and the search is started. If a single-character pattern occurs, searching will resort to the use of a standard string comparison search. The search for a repeated single character pattern is the worst case search on the Cat.

When the search has completed, end-search updates the cursor position and display if necessary.

10.1.1.0 Low-Level Search Routines

Text searches on the Cat will wrap around from the starting search position to the end of the text, then to the start of the text and back to the start position, if necessary.

The low-level routines used to perform the searching are

<search<> , <search», search<, and search>. The word <search<>

searches in a forward direction through a specified range of text. The word <search» searches in a backward direction through a specified range of text. None of these four routines are aware of the gap area and are able to skip over it. The words search< and search> are slightly higher level search words which directly use <search<> and <search».

10.1.1.1 Searching for Single Page Breaks described in finish-lex, whenever the display contents are scrolled up or down by holding down a Shift key and pressing a Leap key, a 4-byte -1 value will be placed in the pattern

integer. If do-lex receives a Use Front key press, it will know

that it should repeat the scrolling operation.

Before do-lex terminates execution, autorepeating will be turned on for the [Use FrontJ-[Leap key] combination so that the screen will scroll continually as long as Use Front and Leap are pressed.

10.1.3 Spell Check Leap Again

If pattern holds a -2 value when a Use Front key press is passed to do-lex, it means a Spell Check Leap command is being

repeated. The first time Spell Check Leap is used, it stores a -2 into pattern. do-lex will turn on the SPELLCHECK indicator light and call spellcheckleapagain. After autorepeating is

turned on for the [Use Front]-[Spell Check Leap] key combination, do-lex will be exited.

10.1.4 Search Again

If a Use Front key press is received, and pattern contains none of the special flag values described above, do-lex knows that it is being asked to repeat a search for the current leap pattern.

The ptable will be constructed for the current pattern and research performs the searching.

10.1.5 Finishing a Leap Operation

After checking for the start of a new leap operation, do-lex performs an opposite test and checks for the termination of a leap operation. If neither the left nor the right Leap key, nor the left nor the right Use Front keys are down, leaping is

terminating and finish-lex is executed.

finish-lex will restore the previous Shift Lock key state, re-enable the cursor, and set the lexxing integer to false in order to indicate that leaping is no longer occurring. Next, finish-lex must determine which type of leap operation is being completed.

10.1.6 Shift-Leap Scrolling

If newlex is true {new leap operation}, matched is false (no pattern was successfully matched during this leap operation). and a Shift key is down, finish-lex is being executed because Shift and Leap were pressed and released. The termination of Leap under these conditions will cause lex-scroll to be executed and a -1 to be placed in pattern. This makes lex-scroll the current Leap-repeat command.

10.1.7 Creeping

Creeping, or character-by-character cursor movement, takes place when a Leap key is pressed and released without a pattern being entered. Internally, if newlex is true (a new leap operation begun), matched is false (no pattern was successfully matched), and a Shift key is not down, finish-lex must be being executed.

This will cause lex-tap to be executed. No flag will be placed in pattern because creeping is not a repeatable leap operation.

lex-tap will cause the cursor to creep (move) one character position to the right or left.

10.1.8 Other Leap Terminations

If newlex is false (not a new leap operation) or matched is true (successful search), then finish-lex was called because either:

1. The Leap keys were used to highlight a selection and now they are being released.

2. The Leap keys were used to choose a new location for a section of text and are now being released so the drag operation can be performed.

3. A successful Leap or Spell Check Leap is finished; or ...

4.

An unsuccessful Leap or Spell Check Leap is finished.

10.1.8.0 Highlighting a SelectiJn

If finish-lex is called when the selection is expanded,

leave-extended ensures that the newly highlighted selection is left highlighted, and then finish-lex is exited.

10.1.8.1 Dragging a Selection

If finish-lex is called when the cursor is either split or

extended, dragging is desired. If the drag destination location is still within the highlighted text to be moved, the text cannot be dragged and the selection is collapsed and a narrow cursor is placed at the drag destination. If the drag destination is valid, drag moves the text and finish-lex is exited.

10.1.8.2 Successful Spell Check Leap

If finish-lex is executed when pattern contains a -2, a

successful Spell Check Leap has finished. p is saved in pop and the op is set to point to the end of the misspelled word so that if the user presses both Leap keys, the misspelled word will be selected and could be conveniently added to the user dictionary with Add Spelling.

10.1.8.3

Successful Leap

If finish-lex is executed when pattern did not contain -2, a successful Leap has finished. The cursor state integers are updated.

Im Dokument Cat Editor (Seite 192-197)