<> <> <> <> DIRECTORY ColorDisplayDefs USING [ColorMode, ColorValue, ChannelsVisible, ChannelValue], CountedVM USING [Handle], TerminalDefs USING [Background, Cursor, KeyBits, Position]; Terminal: CEDAR DEFINITIONS ~ BEGIN <> <> <<1) The human user at the keyboard can cycle through the extant virtual terminals by a particular key combination (control-shift-shift). (This is equivalent to an implicit call of Select[NIL]; see below.)>> <<2) A client program can select which virtual terminal is to be connected to the physical terminal, and can prevent a change of virtual terminal by clients or the user.>> <<3) Clients may register procedures to be invoked whenever the virtual-to-physical terminal correspondence changes.>> <> <<>> Virtual: TYPE ~ REF VirtualRep; VirtualRep: TYPE ~ RECORD[ <> hasBlackAndWhiteDisplay: BOOL, bwWidth: NAT, bwHeight: NAT, bwHasBorder: BOOL, bwPixelsPerInch: REAL, <> hasColorDisplay: BOOL, colorWidth: NAT, colorHeight: NAT, colorPixelsPerInch: REAL, <> hasSoundGenerator: BOOL, <> impl: REF VirtualImplRep ]; VirtualImplRep: TYPE; FrameBuffer: TYPE ~ REF FrameBufferRep; FrameBufferRep: TYPE ~ RECORD [ vm: CountedVM.Handle, -- virtual memory interval base: LONG POINTER, -- starting address wordsPerLine: NAT, -- words per scan line bitsPerPixel: NAT, -- bits per pixel width: NAT, -- width in pixels height: NAT -- height in scan lines ]; CantDoIt: ERROR; Create: PROC RETURNS [vt: Virtual]; <<... creates a new virtual terminal. If the hardware includes a black-and-white display, vt.hasBlackAndWhiteDisplay is TRUE and the border, screen dimensions, and resolution values are set to the characteristics of the hardware. Analogous remarks apply to the color display information in vt. The initial state of this terminal, in terms of the procedures below, is:>> <> <> <> <> <> <> <> <<>> Select: PROC [vt: Virtual _ NIL]; <<... causes the indicated virtual terminal to be "connected" to the physical terminal.>> <> <> <> Current: PROC RETURNS [Virtual]; <<... returns the identity of the presently selected virtual terminal.>> <> <<>> <<>> DisableKeyboardWatcher: PROC; EnableKeyboardWatcher: PROC; <> <> <<>> SwapAction: TYPE ~ {coming, here, going, gone}; SwapNotifier: TYPE ~ PROC [vt: Virtual, action: SwapAction, clientData: REF]; RegisterNotifier: PROC [vt: Virtual, notifier: SwapNotifier, clientData: REF ANY _ NIL]; <> <<1) Notifiers for current terminal are called with SwapAction[going].>> <<2) Notifiers for the new terminal are called with SwapAction[coming].>> <<3) The actual terminal swap occurs.>> <<4) Notifiers for the former current terminal are called with SwapAction[gone].>> <<5) Notifiers for the new current terminal are called with SwapAction[here].>> <> <> <> <> <<>> UnregisterNotifier: PROC [vt: Virtual, notifier: SwapNotifier, clientData: REF ANY _ NIL]; <> <> <<>> <> <> <<>> KeyBits: TYPE ~ TerminalDefs.KeyBits; -- PACKED ARRAY KeyName OF DownUp GetKeys: PROC [vt: Virtual] RETURNS [KeyBits]; <<... returns the state of keyboard keys and mouse buttons.>> <<>> Position: TYPE ~ TerminalDefs.Position; -- RECORD [x, y: INTEGER] GetMousePosition: PROC [vt: Virtual] RETURNS [Position]; <<... returns the current position of the mouse.>> <<>> SetMousePosition: PROC [vt: Virtual, position: Position]; <<... redefines the present mouse position.>> <> <<>> <> <> <> BitmapState: TYPE ~ {none, allocated, displayed}; <> SetBWBitmapState: PROC [vt: Virtual, new: BitmapState] RETURNS [old: BitmapState]; GetBWBitmapState: PROC [vt: Virtual] RETURNS [BitmapState]; <<... manages the virtual memory used for the black-and-white display's bitmap.>> <> <> <> <> <<>> GetBWFrameBuffer: PROC [vt: Virtual] RETURNS [FrameBuffer]; <<... returns a description of the black-and-white display bitmap.>> BWBackground: TYPE ~ TerminalDefs.Background; -- {white, black} GetBWBackground: PROC [vt: Virtual] RETURNS [BWBackground]; SetBWBackground: PROC [vt: Virtual, new: BWBackground] RETURNS [old: BWBackground]; <<... controls the interpretation of bits in the black-and-white display's bitmap.>> <> <> <<(A non-existent bitmap is equivalent to a bitmap containing all zeros.)>> BWBorder: TYPE ~ [0..256); GetBWBorder: PROC [vt: Virtual] RETURNS [oddPairs, evenPairs: BWBorder]; SetBWBorder: PROC [vt: Virtual, oddPairs, evenPairs: BWBorder]; <<... controls the appearance of the black-and-white display region not occupied by the bitmap.>> GetBWCursorPosition: PROC [vt: Virtual] RETURNS [position: Position]; <<... returns the position of the cursor on vt's black-and-white display.>> <> <<>> SetBWCursorPosition: PROC [vt: Virtual, position: Position]; <<... sets the position of the cursor on vt's black-and-white display.>> <> <<>> BWCursorBitmap: TYPE ~ TerminalDefs.Cursor; GetBWCursorPattern: PROC [vt: Virtual] RETURNS [pattern: BWCursorBitmap]; <<... returns the bitmap for vt's black-and-white cursor.>> <> <<>> SetBWCursorPattern: PROC [vt: Virtual, pattern: BWCursorBitmap]; <<... sets the bitmap for vt's black-and-white cursor.>> <<>> WaitForBWVerticalRetrace: PROC [vt: Virtual]; <<... waits until vt is selected, then waits until the next black-and-white display scan begins.>> <<>> BlinkBWDisplay: PROC [vt: Virtual]; <<... blinks the black-and-white display if vt is presently selected; otherwise, has no effect.>> <<>> <> <> <> ColorMode: TYPE ~ ColorDisplayDefs.ColorMode; <> ChannelValue: TYPE ~ ColorDisplayDefs.ChannelValue; -- [0..256) ColorValue: TYPE ~ ColorDisplayDefs.ColorValue; -- [0..256) ChannelsVisible: TYPE ~ ColorDisplayDefs.ChannelsVisible; -- {none, aOnly, bOnly, all} GetColorBitmapState: PROC [vt: Virtual] RETURNS [BitmapState]; SetColorBitmapState: PROC [vt: Virtual, newState: BitmapState, newMode: ColorMode, newVisibility: ChannelsVisible] RETURNS [oldState: BitmapState, oldMode: ColorMode, oldVisibility: ChannelsVisible]; <> <> <> <> <> < and . However, these two situtions have different performance characteristics. When newMode = displayed, the bitmap and colormap are pinned in memory; that is, the real memory they occupy cannot be stolen by the virtual memory machinery. In other modes, the bitmap and colormap (if any) can be swapped out. Therefore, should be used only for short-term disabling of the display, since the bitmap and colormap remained pinned.>> <> <> <<>> GetColorFrameBufferA: PROC [vt: Virtual] RETURNS [FrameBuffer]; GetColorFrameBufferB: PROC [vt: Virtual] RETURNS [FrameBuffer]; <<... returns a description of the specified color frame buffer.>> LegalColorMode: PROC [vt: Virtual, mode: ColorMode] RETURNS [BOOL]; <<... returns TRUE if the color display implements the indicated mode.>> <<>> GetColorMode: PROC [vt: Virtual] RETURNS [ColorMode]; <<... returns the current ColorMode.>> SetColorMode: PROC [vt: Virtual, new: ColorMode] RETURNS [old: ColorMode]; <<... equivalent to RETURN[SetColorBitmapState[vt, allocated, new, all].oldMode]>> TurnOnColorDisplay: PROC [vt: Virtual]; <<... equivalent to [] _ SetColorBitmapState[vt, displayed, GetColorMode[vt], all]>> <<>> TurnOffColorDisplay: PROC [vt: Virtual]; <<... equivalent to [] _ SetColorBitmapState[vt, allocated, GetColorMode[vt], all]>> GetVisibility: PROC [vt: Virtual] RETURNS [ChannelsVisible]; <<... returns the current setting of ChannelsVisible.>> SetVisibility: PROC [vt: Virtual, visibility: ChannelsVisible]; <<... manipulates the visibility of the bitmaps accessed on the color channels. The effect of SetVisibility can be seen only when vt is selected and GetColorBitmapState[vt]=displayed, but it can be invoked in any state. >> <<>> GetColor: PROC [vt: Virtual, aChannelValue, bChannelValue: ChannelValue _ 0] RETURNS [red, green, blue: ColorValue]; SetColor: PROC [vt: Virtual, aChannelValue, bChannelValue: ChannelValue _ 0, red, green, blue: ColorValue]; <> <<>> GetRedMap: PROC [vt: Virtual, in: ChannelValue] RETURNS [out: ColorValue]; GetGreenMap: PROC [vt: Virtual, in: ChannelValue] RETURNS [out: ColorValue]; GetBlueMap: PROC [vt: Virtual, in: ChannelValue] RETURNS [out: ColorValue]; SetRedMap: PROC [vt: Virtual, in: ChannelValue, out: ColorValue]; SetGreenMap: PROC [vt: Virtual, in: ChannelValue, out: ColorValue]; SetBlueMap: PROC [vt: Virtual, in: ChannelValue, out: ColorValue]; <> GetColorCursorPosition: PROC [vt: Virtual] RETURNS [Position]; <<... returns the position of the virtual cursor associated with the color display on the specified virtual terminal. This position changes only as a result of calls on SetColorCursorPosition.>> <<>> SetColorCursorPosition: PROC [vt: Virtual, position: Position]; <<... sets the cursor position of the specified virtual terminal to the indicated value. This position will be reflected on the screen when the virtual terminal is next selected (or, if it is presently selected, immediately). It is the responsibility of the client to clip the position, if desired, to ensure that the cursor remains on the visible area of the display.>> ColorCursorBitmap: TYPE ~ TerminalDefs.Cursor; <> <<>> GetColorCursorPattern: PROC [vt: Virtual] RETURNS [pattern: ColorCursorBitmap]; <<... returns the bitmap of the virtual cursor associated with the color display on the specified virtual terminal. This bitmap changes only as a result of calls on SetColorCursorPattern.>> <<>> SetColorCursorPattern: PROC [vt: Virtual, pattern: ColorCursorBitmap]; <<... sets the cursor bitmap of the specified virtual terminal to the indicated value. This bitmap will be reflected on the screen when the virtual terminal is next selected (or, if it is presently selected, immediately).>> ColorCursorPresentation: TYPE ~ {onesAreWhite, onesAreBlack}; GetColorCursorPresentation: PROC [vt: Virtual] RETURNS [ColorCursorPresentation]; SetColorCursorPresentation: PROC [vt: Virtual, new: ColorCursorPresentation] RETURNS [old: ColorCursorPresentation]; <> <<>> ColorCursorBitmapState: TYPE ~ {visible, invisible}; GetColorCursorState: PROC [vt: Virtual] RETURNS [ColorCursorBitmapState]; SetColorCursorState: PROC [vt: Virtual, new: ColorCursorBitmapState] RETURNS [old: ColorCursorBitmapState]; <> ModifyColorFrame: PROC [vt: Virtual, action: PROC, xmin, ymin: NAT _ 0, xmax, ymax: NAT _ NAT.LAST]; <<... excludes the color cursor from the specified rectangle while calling action[].>> <> <> <> <> <<>> Beep: PROC [vt: Virtual, frequency, duration: CARDINAL]; <<... emits a beep of the specified frequency (in Hz.) and duration (in milliseconds).>> <> END.