Modula-2 || Compiler & Tools || Library || Search Engine
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;
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.
Modula-2 || Compiler & Tools || Library || Search Engine