Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
TermKeys


NAME

TermKeys - support of function keys on ASCII terminals

SYNOPSIS

(* function keys *)
CONST f0 = 0;
CONST f1 = 1;
CONST f2 = 2;
CONST f3 = 3;
CONST f4 = 4;
CONST f5 = 5;
CONST f6 = 6;
CONST f7 = 7;
CONST f8 = 8;
CONST f9 = 9;
CONST f10 = 10;
CONST f11 = 11;
CONST f12 = 12;
CONST f13 = 13;
CONST f14 = 14;
CONST f15 = 15;
CONST f16 = 16;
CONST f17 = 17;
CONST f18 = 18;
CONST f19 = 19;
CONST f20 = 20;
CONST cursorup = 21;
CONST cursordown = 22;
CONST cursorleft = 23;
CONST cursorright = 24;
CONST insert = 25;
CONST delete = 26;
CONST home = 27;
CONST end = 28;
CONST previous = 29;
CONST next = 30;
CONST functionkeys = 31;


TYPE FunctionKeySet = ARRAY functionkeys+1 DIV Sets.setsize OF SET; TYPE Key = POINTER TO KeyRec; TYPE KeyRec = RECORD (PersistentObjects.ObjectRec) END; TYPE SimpleKey = POINTER TO SimpleKeyRec; TYPE SimpleKeyRec = RECORD (KeyRec) char: CHAR; END; TYPE FunctionKey = POINTER TO FunctionKeyRec; TYPE FunctionKeyRec = RECORD (KeyRec) code: INTEGER; END; TYPE ReadProc = PROCEDURE(s: Streams.Stream; VAR key: Key): BOOLEAN; TYPE Interface = POINTER TO InterfaceRec; TYPE InterfaceRec = RECORD (Objects.ObjectRec) read: ReadProc; END; PROCEDURE Init(s: Streams.Stream; available: FunctionKeySet; if: Interface); PROCEDURE Read(s: Streams.Stream; VAR key: Key): BOOLEAN; PROCEDURE Available(s: Streams.Stream; VAR keys: FunctionKeySet);

DESCRIPTION

TermKeys adds the capability to read function keys from terminals that have a keypad, which transmits sequences of bytes when keys are pressed. TermKeys therefore distinguishes two types of keys:

SimpleKey is a key, which transmits a single character when pressed, (i.e. it's ASCII code).

FunctionKey is a key which transmits a sequence of characters.

Every function key is assigned a number. TermKeys predefines numbers for a small set of keys. Implementations are free to add their own numbers for additional keys.

Init has to be called by the underlying terminal implementation with the set of available function keys in available and the interface procedure for reading in if.

Read reads a key from the terminal. On success, Read returns TRUE. FALSE is returned in case of errors or if the interface has not yet been initialized by the underlying terminal implementation.

Available returns the set of available function keys.

SEE ALSO

Terminals
abstraction for terminals

AUTHOR

Ralf Beck
Edited by: rbeck, last change: 1996/01/04, revision: 1.6, converted to HTML: 1997/04/28

Oberon || Library || Module Index || Search Engine || Definition || Module