home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 31
/
CDASC_31_1996_juillet_aout.iso
/
vrac
/
cddk9605.zip
/
HEADERS.ARJ
/
IO.INT
< prev
next >
Wrap
Text File
|
1996-05-17
|
24KB
|
715 lines
{ ───────────────────────────────────────────────────────────────────────── }
{ Name : IO.PAS }
{ Description : Concerto Input/Output Engine }
{ ───────────────────────────────────────────────────────────────────────── }
UNIT IO;
{ (outbound characters) }
{ ││ }
{ ┌─────┴┴─────┐ }
{ │ Zero-State │ }
{ │ Driver │ }
{ └─┬────────┬─┘ ┌────────┐ }
{ │ │ ┌───────>│ Driver │ (FOSSIL) }
{ (HotChar) (Other) │ └────────┘ }
{ │ │ │ ┌────────┐ }
{ ┌────────┴─┐ │ ┌───────────┴┐ ┌─>│ Driver │ (CRT) }
{ │ External │ └───>│ Driver ├────┘ └────────┘ }
{ │ Driver ├──────────>│ Collection ├────┐ ┌────────┐ }
{ └──────────┘ └───────────┬┘ └─>│ Driver │ (ImageLog) }
{ │ └────────┘ }
{ │ ┌────────┐ }
{ └───────>│ Driver │ (Other) }
{ └────────┘ }
{$B-} { . . . . . . . . . . . . . . . . . . . . Shortcut boolean evaluation }
{$F+} { . . . . . . . . . . . . . . . . . . . . Force far calls for safety }
{$I-} { . . . . . . . . . . . . . . . . . . . Disable input/output checking }
{$O+} { . . . . . . . . . . . . . . . . . . Allow this unit to be overlayed }
{$Q-} { . . . . . . . . . . . . . . Do not generate overflow-checking code }
{$R-} { . . . . . . . . . . . . . . . . Do not generate range-checking code }
{$S-} { . . . . . . . . . . . . . . . . Do not generate stack-checking code }
{$X+} { . . . . . . . . . . . Extended syntax for pChars and function calls }
INTERFACE
USES
Objects;
CONST
MaxStateDrivers = 50;
TYPE
tColorScheme = RECORD
Lower : Byte; { . . . . . . . . Lower case letters }
Upper : Byte; { . . . . . . . . Upper case letters }
Digit : Byte; { . . . . . . . . . Digits (numbers) }
HiBit : Byte; { . . . IBM Extended ASCII characters }
Punct : Byte; { . Punctuation and misc. characters }
END;
pColorScheme = ^tColorScheme;
{ ┌─────────────────────────────────────────────────────────────────────┐ }
{ │▒▒▒ tIODriver ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │ }
{ └─────────────────────────────────────────────────────────────────────┘ }
{ }
{ The I/O Driver is one of the fundamental concepts of Concerto. The }
{ stream of outbound characters is multiplexed (sprinkled) through all of }
{ the I/O drivers registered with the system. Each I/O driver is merely a }
{ descendent of tIODriver. }
tIODriver = OBJECT(tObject)
Active : Boolean; { . . Is this driver currently active? }
NameCRC : LongInt; { The 32-bit CRC of the driver's name. }
CONSTRUCTOR Init(p:pChar);
{ Default behavior of each method }
{ }
{ Abstract : run-time error 211 }
{ Ignore : no operation }
{ Other : calls other methods }
PROCEDURE ClrEOL; VIRTUAL; { Ignore }
PROCEDURE ClrScr; VIRTUAL; { Ignore }
PROCEDURE Color(c:Byte); VIRTUAL; { Ignore }
PROCEDURE CursorDown(n:Byte); VIRTUAL; { Ignore }
PROCEDURE CursorLeft(n:Byte); VIRTUAL; { Ignore }
PROCEDURE CursorRight(n:Byte); VIRTUAL; { Ignore }
PROCEDURE CursorUp(n:Byte); VIRTUAL; { Ignore }
PROCEDURE GotoXY(x,y:Byte); VIRTUAL; { Ignore }
PROCEDURE Home; VIRTUAL; { Other }
PROCEDURE PurgeInbound; VIRTUAL; { Ignore }
PROCEDURE PurgeOutbound; VIRTUAL; { Ignore }
PROCEDURE ReadChar(VAR c:Char); VIRTUAL; { Abstract }
PROCEDURE SendChar(c:Char); VIRTUAL; { Abstract }
PROCEDURE SendData(p:Pointer; s:Word); VIRTUAL; { Other }
PROCEDURE SendpChar(p:pChar); VIRTUAL; { Other }
PROCEDURE SendString(CONST s:OpenString); VIRTUAL; { Other }
FUNCTION Waiting:Boolean; VIRTUAL; { Abstract }
END;
pIODriver = ^tIODriver;
{ ┌─────────────────────────────────────────────────────────────────────┐ }
{ │▒▒▒ tIODriverTextGfx ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │ }
{ └─────────────────────────────────────────────────────────────────────┘ }
{ This descendent of tIODriver overrides the color/cursor procedures. }
{ The calls are converted to ASCII/ANSI/AVATAR text codes. }
tIODriverTextGfx = OBJECT(tIODriver)
Graphics : Byte;
PROCEDURE ClrEOL; VIRTUAL;
PROCEDURE ClrScr; VIRTUAL;
PROCEDURE Color(c:Byte); VIRTUAL;
PROCEDURE CursorLeft(n:Byte); VIRTUAL;
PROCEDURE CursorRight(n:Byte); VIRTUAL;
PROCEDURE GotoXY(x,y:Byte); VIRTUAL;
END;
pIODriverTextGfx = ^tIODriverTextGfx;
{ ┌─────────────────────────────────────────────────────────────────────┐ }
{ │▒▒▒ tIODriverRemote ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │ }
{ └─────────────────────────────────────────────────────────────────────┘ }
{ }
{ This object provides additional support for I/O drivers used in a }
{ communications setting. You will still need to override the IO- }
{ specific methods. Since many remote terminals use ANSI and other color }
{ protocols, this object is a descendent of tIODriverTextGfx. }
tIODriverRemote = OBJECT(tIODriverTextGfx)
Baud : LongInt;
ComPort : Word;
Locked : LongInt;
CONSTRUCTOR Init(p:pChar; c:Word; b,l:LongInt);
FUNCTION CarrierDetect:Boolean; VIRTUAL;
PROCEDURE LowerDTR; VIRTUAL;
PROCEDURE RaiseDTR; VIRTUAL;
PROCEDURE SetBaud(b,l:LongInt); VIRTUAL;
END;
pIODriverRemote = ^tIODriverRemote;
{ ┌─────────────────────────────────────────────────────────────────────┐ }
{ │▒▒▒ tStateDriver ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │ }
{ └─────────────────────────────────────────────────────────────────────┘ }
{ The state driver system allows you to install any color protocol without
recompiling the IO unit. This system will be documented in the next
release. }
tStateDriver = RECORD
Active : Boolean; { . . . . . Is this state driver active? }
Handler : PROCEDURE (c:Char); { . . Who gets the stream of characters? }
NameCRC : LongInt; { The 32-bit CRC of the driver's family. }
END;
pStateDriver = ^tStateDriver;
CONST
ColorScheme : pColorScheme = NIL; { . . . . . Current color scheme }
DBS : Boolean = False; { . . . . Destructive backspaces }
IOState : Byte = 0; { . . . . . . . Current I/O state }
LastChar : Char = #0; { . . . Last character processed }
LastPrinted : Char = #0; { . . . Last character displayed }
LastTime : LongInt = 0; { . Clock ticks at last keystroke }
NoTimeProc : PROCEDURE = NIL; { . . . . . Called if out of time }
Origin : pIODriver = NIL; { Origin of the last inbound char }
SaveX : Byte = 0; { . . . Saved cursor position (x) }
SaveY : Byte = 0; { . . . Saved cursor position (y) }
StartedAt : LongInt = 0; { . . Activation time of the unit }
TextAttr : Byte = 0; { . . . . . . Current text color }
TextBufferSize : Word = 1024; { Buffer size when loading files }
TextDir : pChar = NIL; { . . . . Location of text files }
Threshold : Word = 500; { . . . . . Timeslicer threshold }
TimeLeft : Word = 60; { . . Minutes before forced halt }
TimeOut : Word = 180; { . Seconds before timeout error }
TimeOutProc : PROCEDURE = NIL; { . . . Called if timeout occurs }
CONST
IceChatColors : tColorScheme =
( Lower : 15;
Upper : 07;
Digit : 11;
HiBit : 01;
Punct : 09 );
VAR
{ The following structures will be documented in the next version! }
StateChars : ARRAY[#0..#255] OF Byte;
StateDrivers : ARRAY[1..MaxStateDrivers] OF tStateDriver;
Drivers : tCollection;
PROCEDURE ActivateAll;
{
PURPOSE : Activates every I/O driver.
NOTES : This procedure is generally used after you have temporarily
suspended one or more drivers (such as when displaying a
sysop-only screen).
SEE ALSO : DeactivateAllExceptPtr
}
PROCEDURE DeactivateAllExceptPtr(p:pIODriver);
{
PURPOSE : Deactivates a specific I/O driver.
NOTES : The driver is suspended, not deallocated.
SEE ALSO : ActivateAll
}
FUNCTION DecTimeLeft(n:Word):Word;
{
PURPOSE : Subtracts the number of minutes remaining in the session.
SEE ALSO : IncTimeLeft
}
FUNCTION FirstOpenState:Byte;
{ INTERNAL USE ONLY UNTIL THE JUNE/JULY RELEASE OF CONCERTO! }
FUNCTION IncTimeLeft(n:Word):Word;
{
PURPOSE : Adds to the number of minutes remaining in this session.
SEE ALSO : DecTimeLeft
}
PROCEDURE RegisterAmpersand;
{
PURPOSE : Registers the Ampersand state driver.
NOTES : The ampersand driver handles both PCBoard @Xxx codes and
WildCat! @xx@ codes.
SEE ALSO : RegisterANSI, RegisterAVATAR, RegisterControlK, RegisterHexPipe,
RegisterLORD
}
PROCEDURE RegisterANSI;
{
PURPOSE : Registers the ANSI state driver.
NOTES : The driver implements a subset of the full ANSI standard.
SEE ALSO : RegisterAmpersand, RegisterAVATAR, RegisterControlK,
RegisterHexPipe, RegisterLORD
}
PROCEDURE RegisterAVATAR;
{
PURPOSE : Registers the AVATAR/0+ state driver.
NOTES : The driver does not handle AVATAR scrolling functions.
SEE ALSO : RegisterAmpersand, RegisterANSI, RegisterControlK,
RegisterHexPipe, RegisterLORD
}
PROCEDURE RegisterControlK;
{
PURPOSE : Registers the ^K state driver.
NOTES : Control-K codes are in the format ^K[xx, where ^K is ASCII
character #11 and xx is the hexadecimal representation of
a color. These codes are used by RemoteAccess.
SEE ALSO : RegisterAmpersand, RegisterANSI, RegisterAVATAR,
RegisterHexPipe, RegisterLORD
}
PROCEDURE RegisterHexPipe;
{
PURPOSE : Registers the HexPipe state driver.
NOTES : HexPipe codes are in the format |xx, where xx is the
hexadecimal representation of a color. This is similar to
RemoteAccess's control-k code system.
SEE ALSO : RegisterAmpersand, RegisterANSI, RegisterAVATAR,
RegisterControlK, RegisterLORD
}
PROCEDURE RegisterLORD;
{
PURPOSE : Registers the LORD (Legend of the Red Dragon) color system.
SEE ALSO : RegisterAmpersand, RegisterANSI, RegisterAVATAR,
RegisterControlK, RegisterHexPipe
}
PROCEDURE RegisterState(Family:pChar; VAR Index:Byte; Handler:Pointer);
{ }
{ INTERNAL USE ONLY UNTIL THE JUNE/JULY RELEASE! }
{ }
{ Registers a handler with the state-driver. }
{ }
{ Family The family name of the handler. The 32-bit CRC of the name }
{ is stored in an internal record. This allows an external }
{ facility (outside of IO.TPU) to reference a group of }
{ related handlers -- such as all of the handlers used to }
{ interpret ANSI sequences. }
{ }
{ Index An arbitrary number assigned to this handler. This number }
{ is used to identify this particular driver in the future. }
{ }
{ Handler A pointer to a procedure. }
FUNCTION SetColorScheme(p:pColorScheme):pColorScheme;
{
PURPOSE : Changes to the specified color scheme.
RETURN : The current color scheme. You should save this value for
later restoration.
}
PROCEDURE SetHotChar(c:Char; s:Byte);
{
INTERNAL USE ONLY UNTIL THE JUNE/JULY RELEASE!
}
FUNCTION SetNoTimeProcedure(p:Pointer):Pointer;
{
PURPOSE : Changes the no-time-left procedure.
RETURNS : A pointer to the current procedure, or NIL.
}
FUNCTION SetTimeOutProcedure(p:Pointer):Pointer;
{
PURPOSE : Changes the time-out procedure.
RETURNS : A pointer to the current time-out procedure, or NIL.
}
FUNCTION SI_Boolean(Prompt:pChar; Default:Boolean):Boolean;
{
PURPOSE : This is a high-level boolean-entry routine.
NOTES : The prompt and a color-coded selection-bar is displayed. The
user may press Y (true) or N (false). The screen is updated
with the response ("Yes" or "No").
}
PROCEDURE SI_Char(VAR c:Char);
{
PURPOSE : Reads a single character.
NOTES : The character is retrieved from the first IO driver with
a character waiting. Use the Origin pointer if you need to
know the exact driver.
This is the master keyboard polling routine. All input
routines ultimately call this procedure.
SEE ALSO : SI_KeyPressed, Origin
}
PROCEDURE SI_DefaultMorePrompt;
{
PURPOSE : Waits for the enter key (ASCII #13).
NOTES : Nothing is displayed.
SEE ALSO : SO_ReadChar
}
FUNCTION SI_KeyPressed:Boolean;
{
PURPOSE : Returns TRUE if a character is waiting.
NOTES : This is a non-destructive read. That is, you will need to
use SO_ReadChar to remove the character from the buffer.
SEE ALSO : SO_ReadChar
}
PROCEDURE SI_LORDMorePrompt;
{
PURPOSE : Simulates the LORD (Legend of the Red Dragon) <MORE> prompt.
SEE ALSO : SI_DefaultMorePrompt;
}
FUNCTION SI_pChar(p:pChar; MaxLen:Byte):pChar;
{
PURPOSE : Provides a simple string input routine.
NOTES : MaxLen specifies the maximum length of the string. It is up
to you to make sure that the input field does not wrap across
the screen. If p is not empty, the user will be able to
edit the characters. No range checking is performed.
SEE ALSO : SI_Char
}
PROCEDURE SI_Purge;
{
PURPOSE : Removes any characters from the inbound buffer.
SEE ALSO : SO_Purge
}
FUNCTION SI_Randomize(p:pChar):Word;
{
PURPOSE : Initializes the random number generator.
NOTES : If p is 'Timer', then the random number seed is obtained
from the system clock. If p is 'Ask', then the user is
prompted for the number. Anything other string is
converted to a numeric value.
}
PROCEDURE SO_Char(c:Char);
{
PURPOSE : Displays a single character.
SEE ALSO : SO_pChar, SO_SendString
}
PROCEDURE SO_ClearRegion(x,y1,y2:Byte);
{
PURPOSE : Clears the region within the box.
PARAMS : x Left-column of box
y1 Top row
y2 Bottom row
NOTES : This procedure uses the SO_ClrEOL procedure to quickly
clear the region. The cursor is moved to the upper-left
corner of the box when finished.
SEE ALSO : SO_ClrScr, SO_ClrScrWith
}
PROCEDURE SO_ClrEOL;
{
PURPOSE : Erases all of the characters between the cursor and the left
side of the screen, inclusively.
SEE ALSO : SO_ClrEOLWith, SO_ClrScr, SO_ClrScrWith
}
PROCEDURE SO_ClrEOLWith(c:Byte);
{
PURPOSE : Changes the color and calls SO_ClrEOL at the same time.
SEE ALSO : SO_ClrEOL, SO_ClrScr, SO_ClrScrWith, SO_Color
}
PROCEDURE SO_ClrScr;
{
PURPOSE : Clears the screen using the current color.
NOTES : The status line (if visible) is not affected. The cursor is
moved to the upper-left corner of the screen.
SEE ALSO : SO_ClearRegion, SO_ClrEOL, SO_ClrScrWith, SO_Color, SO_GotoXY,
SO_Home
}
PROCEDURE SO_ClrScrWith(c:Byte);
{
PURPOSE : Clears the screen using the specified color.
NOTES : The color change is permanent.
SEE ALSO : SO_ClearRegion, SO_ClrEOL, SO_ClrScr, SO_Color, SO_GotoXY,
SO_Home
}
FUNCTION SO_Color(c:Byte):Byte;
{
PURPOSE : Changes the current color.
RETURNS : The current color (before the change).
NOTES : You should never modify TextAttr directly, since the IO drivers
will not be aware of the change. Use this procedure instead,
which sends the color change to each driver.
SEE ALSO : SO_ClrEOLWith, SO_ClrScrWith
}
PROCEDURE SO_CRLF;
{
PURPOSE : Outputs a carriage-return/line-feed sequence.
NOTES : This is essentially the same as SO_pChar(#13#10).
SEE ALSO : SO_pChar, SO_pCharLn
}
PROCEDURE SO_CursorDown(n:Byte);
{
PURPOSE : Moves the cursor down.
SEE ALSO : SO_CursorLeft, SO_CursorRight, SO_CursorUp, SO_GotoXY, SO_Home
}
PROCEDURE SO_CursorLeft(n:Byte);
{
PURPOSE : Moves the cursor left.
SEE ALSO : SO_CursorDown, SO_CursorRight, SO_CursorUp, SO_GotoXY, SO_Home
}
PROCEDURE SO_CursorRight(n:Byte);
{
PURPOSE : Moves the cursor right.
SEE ALSO : SO_CursorDown, SO_CursorLeft, SO_CursorUp, SO_GotoXY, SO_Home
}
PROCEDURE SO_CursorUp(n:Byte);
{
PURPOSE : Moves the cursor up.
SEE ALSO : SO_CursorDown, SO_CursorLeft, SO_CursorRight, SO_GotoXY, SO_Home
}
FUNCTION SO_DetectANSI(p:pIODriverRemote; Msg:pChar):Boolean;
{
PURPOSE : Checks for ANSI capabilities on the remote system.
NOTES : The procedure first sends the special sequence ESC[6n, which
is normally used to request the current position of the cursor.
The procedure is not actually interested in the cursor position,
but rather the response of the terminal.
ANSI-capable terminals will return the cursor position in
the format ESC[#;#R. A valid response implies ANSI support.
If ANSI is not detected, the procedure will ask the user
for his/her preference.
}
FUNCTION SO_DisplayFile(p:pChar):Boolean;
{
PURPOSE : Displays the specified file.
NOTES : Concerto loads the specified file and sends it to SO_pChar for
processing. TRUE is returned if the operation was successful.
FALSE is returned if the procedure could not load the file.
Concerto will check the contents of TextDir. If this string
is not nil, then Concerto will use this directory rather then
the one specified by the programmer.
SEE ALSO : SO_pChar, TextDir
}
PROCEDURE SO_GotoXY(x,y:Byte);
{
PURPOSE : Changes the position of the the cursor.
NOTES : This procedure changes the position of the cursor in ANSI or
AVATAR mode. The upper-left corner of the screen has the
coordinates (1,1). Invalid coordinates are ignore.
SEE ALSO : SO_CursorDown, SO_CursorLeft, SO_CursorRight,
SO_CursorUp, SO_Home
EXAMPLE : FOR n:=1 TO Random(200) DO
BEGIN
SO_GotoXY(Random(80)+1,Random(23)+1);
SO_Color(Random(16));
SO_SendChar(#219);
END;
SEE ALSO : SO_CursorDown, SO_CursorLeft, SO_CursorRight,
SO_CursorUp, SO_Home
}
PROCEDURE SO_Home;
{
PURPOSE : Moves the cursor to the home position.
NOTES : This procedure moves the cursor to the upper-left corner
of the screen. This is essentially the same as calling
SO_GotoXY(1,1).
SEE ALSO : SO_CursorDown, SO_CursorLeft, SO_CursorRight,
SO_CursorUp, SO_GotoXY
}
PROCEDURE SO_Noise;
{
PURPOSE : Generates fake line noise.
}
PROCEDURE SO_Purge;
{
PURPOSE : Removes any characters from the outbound buffer.
SEE ALSO : SI_Purge;
}
PROCEDURE SO_pChar(p:pChar);
{
PURPOSE : Displays the null-terminated string. Color-codes are processed.
NOTES : This is the Master display routine. All other output procedures
ultimately call this procedure, except for the raw-output set
of procedures.
SEE ALSO : SO_pCharLn
}
PROCEDURE SO_pCharLn(p:pChar);
{
PURPOSE : Displays the null-terminated string.
NOTES : A carriage-return/line-feed sequence is also sent.
SEE ALSO : SO_CRLF, SO_pChar
}
PROCEDURE SO_RawChar(c:Char);
PROCEDURE SO_RawpChar(s:pChar);
PROCEDURE SO_RawString(CONST s:OpenString);
{ These procedures bypass the state-driver system; text is sent to each }
{ driver with no processing. HotChars are not intercepted. }
PROCEDURE SO_ShadeBar(Selection:Byte);
{
PURPOSE : Displays a shaded bar for general use.
NOTES : This procedure is used by SO_DetectANSI when inquiring the
caller about his/her ANSI capabilities. The bar is six
characters long. Future versions will support scaling.
Selection = 0 : Random color palette
1 : Darkgray -> White
2 : Green -> Yellow
3 : Red -> Yellow
4 : Cyan -> White
5 : Blue -> Light Cyan
6 : Magenta -> White
SEE ALSO : SO_DetectANSI
}
PROCEDURE SO_String(CONST s:OpenString);
{
PURPOSE : Displays a classic Turbo Pascal string.
NOTES : The string is converted to a pChar and sent to SO_pChar.
SEE ALSO : SO_pChar
}