Screen editing is a feature of all BBC Micros, the Electron and RISC OS machines, where text on the screen may be copied as if it was being typed on the keyboard. The most important use of this feature is to correct BASIC program listings without having to re-key the whole line.
Like all contemporary BASICs, BBC BASIC adopted the first-generation paradigm of interactive editing: the user identifies the line to be changed and keys in the complete replacement line. (Compare ed in Unix and EDLIN in MS-DOS.) This was the most appropriate method in the days of teleprinters, but terminal screens were less comfortable to read and could not display long listings in their entirety.
The remedy in the near-contemporary program, Microsoft GW-BASIC (1983), was to allow the cursor to move around the screen, inserting or deleting characters at any position and executing the line under the cursor when Enter was pressed. If there was a listing on the screen then the lines were already in the required format to update the program.
The BBC Micro MOS, however, had a stricter 'glass TTY' model of the console: lines were 'dead' once they were printed, and user input could only come from the keyboard or a substitute - the DELETE key was the only way to edit a line while typing it. This was partly due to the screen being bitmapped in most MODEs. The MOS's concession to BASIC was to provide simple character recognition of text on the screen.
Any time the computer is waiting for input from the OSRDCH input stream, the user can press any of the arrow keys on the keyboard. Namely at the
> prompt, INPUT statement, GET($), or INKEY($) with a +ve argument. (With a -ve argument, INKEY and INKEY$ scan the keyboard directly so OSRDCH is not called.) The same goes for the equivalents in other languages and machine code.
When an arrow key is pressed, the cursor divides: a write cursor (a block) appears in the original position, and a read cursor (a rapidly blinking underscore) moves one place in the direction of the arrow. Further presses move the read cursor again. Using the arrow keys the user can move the read cursor to any position on the screen.
When the COPY key is pressed, the character at the read cursor is recognised and inserted in the input stream. Whatever is waiting for input gets the character as if it was typed. INPUT statements (including the command line) echo the character at the write cursor, and move both cursors one place to the right, wrapping-around as appropriate. By holding down the COPY key, part or all of a line on screen can be conveniently re-entered as input.
If the read cursor is underscoring the write cursor, the read cursor is moved to the right and no character is inserted.
If the character at the read cursor is not recognised, the computer beeps instead.
When the input statement is ended, the write cursor is deleted and the read cursor put in its place, blinking normally.
The COPY key will not copy a character if:
- the current foreground and background COLOUR are not those of the character to be copied;
- the character has graphics drawn over it;
- part of the character has been deleted;
- the text and graphics cursors have been coupled with VDU 5;
- the character is out-of-alignment with the text character cells (as may happen when the cursors are coupled);
- the character is scaled, or not in the system font (such as those on the Desktop.)
As only printable characters appear on screen in MODEs 0 to 6, it is not possible to COPY an ASCII control code such as carriage return. In MODE 7 the COPY key simply fetches the underlying byte of display memory, so if ASCII codes have been poked there they can be duplicated. Copying ESC, however, does not cause an
The MOS offers the character recognition function to user programs via OSBYTE &87 (135). This attempts to recognise a character on the screen.
The B+ User Guide states:
On exit X will contain the character at the text cursor's position and Y will contain a value representing the current graphics display
MODE. If the character cannot be recognised then X will contain zero. [...] The call takes typically 120 microseconds.
OSBYTE call &04 changes the function of the arrow keys. When
*FX 4,0 is in effect (the default) the keys activate cursor editing. Under
*FX 4,1 they produce character codes like the other keys. Under
*FX 4,2 they become programmable soft keys like the red function keys. In the latter two cases, screen editing is disabled.
The text copy-and-paste feature of Linux consoles, based on the mouse, can be considered a direct equivalent of this feature.
-- beardo 04:04, 1 July 2007 (BST)