Oberon || Library || Module Index || Search Engine || Definition || Module
(* terminal characteristics *) CONST autoleftmargin = 0; autorightmargin = 1; CONST overstrikes = 2; safelastcolumn = 3; (* errorcodes *) CONST cannotSetEcho = 0; CONST cannotSetTermMode = 1; CONST cannotSetCursor = 2; CONST cannotMoveCursor = 3; CONST cannotSetAppearance = 4; CONST cannotScroll = 5; CONST cannotSetScrollRegion = 6; CONST cannotClearScreen = 7; CONST invalidDirection = 8; CONST invalidRegion = 9; CONST invalidPosition = 10; CONST notSupported = 11; CONST errorcodes = 12; (* echo *) CONST on = 0; off = 1; (* terminal modes *) CONST raw = 0; cooked = 1; (* directions *) CONST forward = 0; reverse = 1; (* cursor shapes *) CONST visible = 0; invisible = 1; (* capabilities *) CONST setEcho = 0; CONST setTermMode = 1; CONST setCursor = 2; CONST moveCursor = 3; CONST setAppearance = 4; CONST scroll = 5; CONST setScrollRegion = 6; CONST clearScreen = 7;
TYPE CapabilitySet = SET; TYPE Echomode = SHORTINT; TYPE Termmode = SHORTINT; TYPE Direction = SHORTINT; TYPE Shape = SHORTINT; TYPE Stream = POINTER TO StreamRec; TYPE WindowChangeEvent = POINTER TO WindowChangeEventRec; TYPE WindowChangeEventRec = RECORD (Events.EventRec) stream: Streams.Stream; END; TYPE InterruptEvent = POINTER TO InterruptEventRec; TYPE InterruptEventRec = RECORD (Events.EventRec) stream: Streams.Stream; END; TYPE QuitEvent = POINTER TO QuitEventRec; TYPE QuitEventRec = RECORD (Events.EventRec) stream: Streams.Stream; END; TYPE HangupEvent = POINTER TO HangupEventRec; TYPE HangupEventRec = RECORD (Events.EventRec) stream: Streams.Stream; END; TYPE ErrorEvent = POINTER TO ErrorEventRec; TYPE ErrorEventRec = RECORD (Events.EventRec) errorcode: SHORTINT; END; (* interface procedures *) TYPE SetTermModeProc = PROCEDURE (s: Streams.Stream; mode: Termmode); TYPE SetEchoProc = PROCEDURE (s: Streams.Stream; mode: Echomode); TYPE SetCursorProc = PROCEDURE (s: Streams.Stream; line, column: INTEGER); TYPE MoveCursorProc = PROCEDURE(s: Streams.Stream; fromline, fromcolumn, toline, tocolumn: INTEGER); TYPE SetAppearanceProc = PROCEDURE(s: Streams.Stream; ap: Shape); TYPE ScrollProc = PROCEDURE(s: Streams.Stream; dir: Direction); TYPE SetScrollRegionProc = PROCEDURE(s: Streams.Stream; top, bottom: INTEGER); TYPE ClearProc = PROCEDURE(s: Streams.Stream); TYPE Interface = POINTER TO InterfaceRec; TYPE InterfaceRec = RECORD (Objects.ObjectRec) setEcho: SetEchoProc; setTermMode: SetTermModeProc; setCursor: SetCursorProc; moveCursor: MoveCursorProc; setAppearance: SetAppearanceProc; scroll: ScrollProc; setScrollRegion: SetScrollRegionProc; clearScreen: ClearProc; END; TYPE Status = RECORD (Objects.ObjectRec) lines, columns: INTEGER; (* of physical screen *) scrtop, scrbottom: INTEGER; (* top and bottom of scroll region *) echo: Echomode; (* on or off *) mode: Termmode; (* raw or cooked *) characteristics: SET; (* of terminal characteristics *) scrollDirections: SET; (* up, down *) cursorShape: Shape; (* current shape of cursor *) END; TYPE StreamRec = RECORD (Streams.StreamRec) END;
VAR console: Streams.Stream; VAR windowchanged: Events.EventType; VAR interrupt: Events.EventType; VAR quit: Events.EventType; VAR hangup: Events.EventType; VAR error: Events.EventType; VAR errormsg: ARRAY errorcodes OF Events.Message;
PROCEDURE Init(s: Streams.Stream; status: Status; caps: CapabilitySet; if: Interface); PROCEDURE ClearScreen(s: Streams.Stream); PROCEDURE Echo(s: Streams.Stream; mode: Echomode); PROCEDURE SetTermMode(s: Streams.Stream; mode: Termmode); PROCEDURE SetCursor(s: Streams.Stream; line, column: INTEGER); PROCEDURE MoveCursor(s: Streams.Stream; fromline, fromcolumn, toline, tocolumn: INTEGER); PROCEDURE CursorAppearance(s: Streams.Stream; ap: Shape); PROCEDURE Scroll(s: Streams.Stream; dir: Direction); PROCEDURE SetScrollRegion(s: Streams.Stream; top, bottom: INTEGER); PROCEDURE Capabilities(s: Streams.Stream): CapabilitySet; PROCEDURE GetStatus(s: Streams.Stream; VAR status: Status);
Terminals stores some characteristics of the terminal's display:
A terminal can operate in two modes:
The set of procedures which implement a terminal-abstraction of a specific form is given by an interface. Not every procedure must be implemented. The set of implemented procedures is given by the caps parameter of Init. The interface procedures should meet following specifications:
Init initializes the terminal s for the interface specified by if and caps. status has to hold the initial state of the terminal.
SetTermMode sets the terminal's mode to raw or cooked.
Echo turns echoing of input on or off.
ClearScreen clears the terminal's screen.
Scroll scrolls the contents of the scrollregion once in direction dir.
SetScrollRegion sets the scrollregion to (top, bottom).
SetCursor sets the cursor to the position denoted by line and column.
MoveCursor moves the cursor from position (fromline, fromcolumn) to to position (toline, tocolumn). Clients must track the current cursor position themselves in order to use this procedure properly.
CursorAppearance sets the cursor's appearance. Available modes are visible and invisible.
Capabilities returns the capabilities of the terminal.
GetStatus returns the status of the terminal.
Terminals defines four event types for handling of signals generated by terminals:
The default handling for the events is:
Following errorcodes are currently implemented:
Oberon || Library || Module Index || Search Engine || Definition || Module