Modula-2 || Compiler & Tools || Library || Search Engine


Ulm's Modula-2 Library:
FunctionKeys


NAME

FunctionKeys - scan input for function keys

SYNOPSIS

FROM StdIO IMPORT FILE;
FROM TermInfo IMPORT Term;


TYPE FunctionKey = (nokey, (* no function key *) backspace, catab, (* clear-all-tabs *) clear, (* clear screen or erase *) ctab, (* clear tab *) dc, (* delete character *) dl, (* delete line *) down, (* down arrow key *) eic, (* sent by rmir or smir in insert mode *) eol, (* clear-to-end-of-line *) eos, (* clear-to-end-of-screen *) f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, home, ic, (* ins char/enter ins mode key *) il, (* insert line *) left, (* left arrow *) ll, (* home-down *) npage, (* next page *) right, (* right arrow *) sf, (* scroll-forward *) sr, (* scroll-backward *) stab, (* set-tab *) up); (* up arrow *) TYPE FunctionKeySet = SET OF FunctionKey; TYPE CharSet = SET OF CHAR; TYPE FKInfo;

PROCEDURE OpenFKInfo(VAR fki: FKInfo; VAR t: Term; baudrate: CARDINAL; in, out: FILE); PROCEDURE CloseFKInfo(VAR fki: FKInfo); PROCEDURE Available(fki: FKInfo; VAR fkeys: FunctionKeySet); PROCEDURE StartSet(fki: FKInfo; VAR startset: CharSet); PROCEDURE EnableFunctionKeys(fki: FKInfo); PROCEDURE DisableFunctionKeys(fki: FKInfo); PROCEDURE Read(fki: FKInfo; timeout: BOOLEAN; VAR fkey: FunctionKey; VAR ch: CHAR) : BOOLEAN;

DESCRIPTION

FunctionKeys allows to process function keys as defined in the terminfo(4) database. OpenFKInfo associates fki (which is to be given as reference on further calls) with a terminal description and file pointers (out is used by EnableFunctionKeys and DisableFunctionKeys and in is used by Read). Padding depends on baudrate. If baudrate is zero no padding will be done. The terminal description t must be non-local because FunctionKeys does not copy it but keeps a pointer to it. The space associated with fki can be released by calling CloseFKInfo.

Available returns the set of supported function keys. StartSet returns the set of characters function key codes start with. This is useful to decide whether timeouts are needed or not. Single character function key codes are not included in this set.

EnableFunctionKeys and DisableFunctionKeys output code (if defined in the terminfo database) to enable, or disable respectively, the generation of function key codes.

Read reads subsequently characters from input until a function key is encoded, or the input read so far cannot be a function key, or if timeout is set and a timeout (one second) occurred. If no function key has been found, fkey is set to nokey and the first character read is returned in ch. Remaining characters are returned in subsequent calls. Function keys are returned in fkey. Single character function key codes are returned in fkey and ch. Else ch is set to 0C.

SEE ALSO

TermInfo, Windows
Edited by: borchert, last change: 1997/02/25, revision: 1.2, converted to HTML: 1997/04/28

Modula-2 || Compiler & Tools || Library || Search Engine