diff --git a/docs/crt.xml b/docs/crt.xml new file mode 100644 index 0000000000..0977d16568 --- /dev/null +++ b/docs/crt.xml @@ -0,0 +1,667 @@ + + + + + +CRT - Turbo Pascal screen and keyboard handling unit + + +

+This chapter describes the CRT unit for Free Pascal, both under dos +linux and Windows. The unit was first written for dos by Florian klaempfl. +The unit was ported to linux by Mark May and enhanced by Michael Van Canneyt +and Peter Vreman. It works on the linux console, and in xterm and rxvt windows +under X-Windows. The functionality for both is the same, except that under +linux the use of an early implementation (versions 0.9.1 and earlier of the +compiler) the crt unit automatically cleared the screen at program startup. +

+

+There are some caveats when using the CRT unit: +

+
    +
  • Programs using the CRT unit will not be usable when input/output +is being redirected on the command-line. +
  • +
  • For similar reasons they are not usable as CGI-scripts for use with a +webserver. +
  • +
  • The use of the CRT unit and the graph unit may not always be supported. +
  • +
  • On linux or other unix OSes , executing other programs that expect +special terminal behaviour (using one of the special functions in the linux +unit) will not work. The terminal is set in RAW mode, which will destroy +most terminal emulation settings. +
  • +
+
+ + +Black color attribute + + + +Blue color attribute + + + +Green color attribute + + + +Cyan color attribute + + + +Red color attribute + + + +Magenta color attribute + + + +Brown color attribute + + + +Light gray color attribute + + + +Dark gray color attribute + + + +Light Blue color attribute + + + +Light green color attribute + + + +Light cyan color attribute + + + +Light red color attribute + + + +Light magenta color attribute + + + +Yellow color attribute + + + +White color attribute + + + +Blink attribute + + + +Mask to filter text attribute + +The TextAttr variable controls the attributes with which characters +are written to screen. + + + + +Text character used when filling + + + +Check for CTRL-Break keystroke. Not used. + + + +Check for EOF on standard input. Not used. + + + +Check snow on CGA screens. Not used. + + + +Use direct video access. DOS only + +The DirectVideo variable controls the writing to the screen. If it is +True, the the cursor is set via direct port access. If False, +then the BIOS is used. This is defined under dos only. + + + + +Last screen mode. + +The Lastmode variable tells you which mode was last selected for the +screen. It is defined on DOS only. + + + + +Minimum window dimension + + + +Maximum window dimension + + + +Maximum window X size + + + +Maximum window Y size + + + +Minimum window X size + + + +Minimum window Y size + + + +Current screen width + + + +Current screen height. + + + +40 columns black and white screen mode. + + + +40 columns color screen mode. + + + +40 columns color screen mode. + + + +80 columns black and white screen mode. + + + +80 columns color screen mode. + + + +80 columns color screen mode. + + + +Monochrome screen mode (hercules screens) + + + +Internal ROM font mode + + + + + + + + + + + + +Assign file to CRT. + +AssignCrt Assigns a file F to the console. Everything written to +the file F goes to the console instead. If the console contains a window, +everything is written to the window instead. + + +None. + + + + + + + + + +Show big cursor + +CursorBig makes the cursor a big rectangle. +Not implemented on unixes. + + +None. + + + + + + + + +Clear from cursor position till end of line. + +ClrEol clears the current line, starting from the cursor position, to the +end of the window. The cursor doesn't move + + +None. + + + + + + + + + + + +Clear current window. + +ClrScr clears the current window (using the current colors), +and sets the cursor in the top left +corner of the current window. + + +None. + + + + + + + + + +Hide cursor + +CursorOff switches the cursor off (i.e. the cursor is no +longer visible). Not implemented on unixes. + + +None. + + + + + + + + +Display cursor + +CursorOn switches the cursor on. Not implemented on unixes. + + +None. + + + + + + + + +Delay program execution. + +Delay waits a specified number of milliseconds. The number of specified +seconds is an approximation, and may be off a lot, if system load is high. + + +None + + + + + + + + + + +Delete line at cursor position. + +DelLine removes the current line. Lines following the current line are +scrolled 1 line up, and an empty line is inserted at the bottom of the +current window. The cursor doesn't move. + + +None. + + + + + + + + + + + +Set cursor position on screen. + +GotoXY positions the cursor at (X,Y), X in horizontal, Y in +vertical direction relative to the origin of the current window. The origin +is located at (1,1), the upper-left corner of the window. + + +None. + + + + + + + + + + + +Switch to highlighted text mode + +HighVideo switches the output to highlighted text. (It sets the high +intensity bit of the video attribute) + + +None. + + + + + + + + + + + + +Insert an empty line at cursor position + +InsLine inserts an empty line at the current cursor position. +Lines following the current line are scrolled 1 line down, +causing the last line to disappear from the window. +The cursor doesn't move. + + +None. + + + + + + + + + + + +Check if there is a keypress in the keybuffer + +Keypressed scans the keyboard buffer and sees if a key has +been pressed. If this is the case, True is returned. If not, +False is returned. The Shift, Alt, Ctrl keys are not reported. +The key is not removed from the buffer, and can hence still be read after +the KeyPressed function has been called. + + +None. + + + + + + + + + +Switch to low intensity colors. + +

+LowVideo switches the output to non-highlighted text. (It clears the high +intensity bit of the video attribute) +

+

+For an example, see +

+
+ +None. + + + + + + + +
+ + +Return to normal (startup) modus + +

+NormVideo switches the output to the defaults, read at startup. (The +defaults are read from the cursor position at startup) +

+

+For an example, see +

+
+ +None. + + + + + + + +
+ + +Stop system speaker + +NoSound stops the speaker sound. +This call is not supported on all operating systems. + + +None. + + + + + + + + +Read key from keybuffer + +

+ReadKey reads 1 key from the keyboard buffer, and returns this. +If an extended or function key has been pressed, then the zero ASCII code is +returned. You can then read the scan code of the key with a second ReadKey +call. +

+

+Key mappings under Linux can cause the wrong key to be +reported by ReadKey, so caution is needed when using +ReadKey. +

+
+ +None. + + + + + +
+ + + +Sound system speaker + +Sound sounds the speaker at a frequency of hz. Under Windows, +a system sound is played and the frequency parameter is ignored. +On other operating systems, this routine may not be implemented. + + +None. + + + + + + + +Set text background + +TextBackground sets the background color to CL. CL can be one of the +predefined color constants. + + +None. + + + + + + + + + + + + +Set text color + +TextColor sets the foreground color to CL. CL can be one of the +predefined color constants. + + +None. + + + + + + + + + + + +Set screen mode. + +

+TextMode sets the textmode of the screen (i.e. the number of lines +and columns of the screen). The lower byte is use to set the VGA text mode. +

+

+This procedure is only implemented on dos. +

+
+ +None. + + + + +
+ + +Return X (horizontal) cursor position + +WhereX returns the current X-coordinate of the cursor, relative to the +current window. The origin is (1,1), in the upper-left corner of the +window. + + +None. + + + + + + + + + + +Return Y (vertical) cursor position + +WhereY returns the current Y-coordinate of the cursor, relative to the +current window. The origin is (1,1), in the upper-left corner of the +window. + + + +None. + + + + + + + + + + + +Create new window on screen. + +Window creates a window on the screen, to which output will be sent. +(X1,Y1) are the coordinates of the upper left corner of the window, +(X2,Y2) are the coordinates of the bottom right corner of the window. +These coordinates are relative to the entire screen, with the top left +corner equal to (1,1). +Further coordinate operations, except for the next Window call, +are relative to the window's top left corner. + + +None. + + + + + + + + + + +
+
+
\ No newline at end of file diff --git a/docs/dos.xml b/docs/dos.xml new file mode 100644 index 0000000000..06c44ee813 --- /dev/null +++ b/docs/dos.xml @@ -0,0 +1,1418 @@ + + + + + +DOS - Turbo Pascal MS-DOS interface + + +

+The DOS unit gives access to some operating system calls +related to files, the file system, date and time. Except for the +PalmOS target, this unit is available to all supported platforms. +

+

+The unit was first written for dos by Florian Klaempfl. It was ported to +linux by Mark May and enhanced by Michael Van Canneyt. +The Amiga version was ported by Nils Sjoholm. +

+

+Under non-DOS systems, some of the functionality is lost, as it is either impossible +or meaningless to implement it. Other than that, the functionality for all +operating systems is the same. +

+
+ + +File attributes + +

+The File Attribute constants are used in , + to +determine what type of special file to search for in addition to normal files. +These flags are also used in the and routines to +set and retrieve attributes of files. For their definitions consult +. +

+ + + + + + + + + + +
Possible file attributes
ConstantDescriptionValue
readonly $01
hidden $02
sysfile $04
volumeid $08
directory $10
archive $20
anyfile $3F
+
+
+ + +File open mode constants. + +

+These constants are used in the Mode field of the TextRec +record. Gives information on the filemode of the text I/O. For their +definitions consult the following table: +

+ + + + + + + +
Possible mode constants
ConstantDescriptionValue
fmclosed$D7B0
fminput$D7B1
fmoutput$D7B2
fminout$D7B3
+
+
+ + +File handling + +

+Routines to handle files on disk. +

+ + + + + + + + + + + + + + +
NameDescription
Expand filename to full path
Close finfirst/findnext session
Start find of file
Find next file
Search for file in a path
Split filename in parts
Return file attributes
Return file time
Convert short filename to long filename (DOS only)
Convert long filename to short filename (DOS only)
Set file attributes
Set file time
+
+
+ + +Directory and disk handling + +

+Routines to handle disk information. +

+ + + + + +
NameDescription
Add disk to list of disks (UNIX only)
Return size of free disk space
Return total disk size
+
+
+ + +Process handling + +

+Functions to handle process information and starting new processes. +

+ + + + + + + +
NameDescription
Exit code of last executed program
Return number of environment variables
Return environment string pair
Execute program
Return specified environment string
+
+
+ + +System information + +

+Functions for retrieving and setting general system information such as date +and time. +

+ + + + + + + + + + + + + + + + + + + +
NameDescription
Get OS version
Get setting of control-break handling flag
Get system date
Get interrupt vector status
Get system time
Get verify flag
Execute an interrupt
Keep process in memory and exit
Execute MS-dos function call
Pack time for file time
Set control-break handling flag
Set system date
Set interrupt vectors
Set system time
Set verify flag
Swap interrupt vectors
Unpack file time
+
+
+ + + +File is closed + + + +File is read only + + + +File is write only + + + +File is read and write + + + +CPU carry flag. Not used. + + + +CPU parity flag. Not used. + + + +CPU auxiliary flag. Not used. + + + +CPU zero flag. Not used. + + + +CPU sign flag. Not used. + + + +CPU overflow flag. Not used. + + + +Read-Only file attribute + + + +Hidden file attribute + + + +System file attribute + + + +Volumd ID file attribute + + + +Directory file attribute + + + +Archive file attribute + + + +Maximum length of a filename + + + +Match any file attribute + + + +Command-line string type + + + +Full File path string type. + + + +Full directory string type. + + + +Fill filename string type. + + + +Filename extension string type. + + + +File Search Results record + +

+SearchRec is filled by the call and can be +used in subsequent calls to search for files. The +structure of this record depends on the platform. Only the following +fields are present on all platforms: +

+
+
Attr
File attributes.
+
Time
File modification time.
+
Size
File size
+
Name
File name (name part only, no path)
+
+
+
+ + +Maximum length of FileName part in + + + +Record describing an untyped file + +FileRec is used for internal representation of typed and untyped files. + + + + +OS file handle + + + +File open mode + + + +Size of a record (in bytes) + + + +Private data, do not use + + + +User data, for implementing a user driver. + + + +File name + + + +Maximum length of filename in + + + +Size of default buffer in + + + +Type for default buffer in + + + +Record describing Text files + +

+TextRec describes the internal working of a Text file. +

+

+Remark that this is not binary compatible with the Turbo Pascal definition +of TextRec, since the sizes of the different fields are different. +

+
+
+ + +OS file handle for this record + + + +File open mode + + + +Current buffer size. + + + +Current buffer position. + + + +Current length of data in buffer + + + +Pointer tuo buffer. + + + +Called when file needs to be opened. + + + +Called when an I/O operation needs to be performed. + + + +Called when buffer must be flushed. + + + +Called when file must be closed. + + + +Room for user data when implementing custom text file. + + + +File name. + + + +Default buffer. + + + +Record to keep CPU registers for call. Unused. + + +Record containing a date/time description + +The DateTime type is used in and for +setting/reading file times with and . + + + + +Year part + + +Month of the year + + +Day of the month + + +Hour of the day + + +Minute of the hour + + +Second in the minute + + + +Last OS (MS-DOS) error + +

+The DosError variable is used by the procedures in the dos unit to +report errors. It can have the following values : +

+ + + + + + + + + + + +
Dos error codes
ValueMeaning
2 File not found.
3 path not found.
5 Access denied.
6 Invalid handle.
8 Not enough memory.
10 Invalid environment.
11 Invalid format.
18 No more files.
+

+Other values are possible, but are not documented. +

+
+
+ + +Pathnames representing drives. + +This variable is defined in the linux version of the dos unit. It is used +in the and calls. + + + + +Add disk definition to list if drives (Unix only) + +

+AddDisk adds a filename S to the internal list of disks. It is +implemented for systems which do not use DOS type drive letters. + This list is used to determine which disks to use in the +and calls. +The and functions need a file on the +specified drive, since this is required for the statfs system call. +The names are added sequentially. The dos +initialization code presets the first three disks to: +

+
    +
  • '.' for the current drive,
  • +
  • '/fd0/.' for the first floppy-drive (linux only).
  • +
  • '/fd1/.' for the second floppy-drive (linux only).
  • +
  • '/' for the first hard disk.
  • +
+

+The first call to AddDisk will therefore add a name for the second +harddisk, The second call for the third drive, and so on until 23 drives +have been added (corresponding to drives 'D:' to 'Z:') +

+
+ +None + + + + + +
+ + + +Get free size on Disk. + +

+DiskFree returns the number of free bytes on a disk. The parameter +Drive indicates which disk should be checked. This parameter is 1 for +floppy a:, 2 for floppy b:, etc. A value of 0 returns the free +space on the current drive. +

+ +For Unices: +The diskfree and disksize functions need a file on the +specified drive, since this is required for the statfs system call. +These filenames are set in the initialization of the dos unit, and have +been preset to : + +
    +
  • '.' for the current drive,
  • +
  • '/fd0/.' for the first floppy-drive (linux only).
  • +
  • '/fd1/.' for the second floppy-drive (linux only).
  • +
  • '/' for the first hard disk.
  • +
+

+There is room for 1-26 drives. You can add a drive with the + procedure. +These settings can be coded in dos.pp, in the initialization part. +

+
+ +-1 when a failure occurs, or an invalid drive number is given. + + + + + + +
+ + + +Get total size of disk. + +

+DiskSize returns the total size (in bytes) of a disk. The parameter +Drive indicates which disk should be checked. This parameter is 1 for +floppy a:, 2 for floppy b:, etc. A value of 0 returns the size +of the current drive. +

+ +For unix only: +The diskfree and disksize functions need a file on the specified drive, since this +is required for the statfs system call. +These filenames are set in the initialization of the dos unit, and have +been preset to : + +
    +
  • '.' for the current drive,
  • +
  • '/fd0/.' for the first floppy-drive (linux only).
  • +
  • '/fd1/.' for the second floppy-drive (linux only).
  • +
  • '/' for the first hard disk.
  • +
+

+There is room for 1-26 drives. You can add a drive with the + procedure. +These settings can be coded in dos.pp, in the initialization part. +

+

+For an example, see . +

+
+ +-1 when a failure occurs, or an invalid drive number is given. + + + + + +
+ + +Exit code of last executed program. + +DosExitCode contains (in the low byte) the exit-code of a program +executed with the Exec call. + + +None. + + + + + + + + +Current OS version + +

+DosVersion returns the operating system or kernel version. The +low byte contains the major version number, while the high byte +contains the minor version number. +

+ +On systems where versions consists of more then two numbers, +only the first two numbers will be returned. For example Linux version 2.1.76 +will give you DosVersion 2.1. Some operating systems, such as FreeBSD, do not +have system calls to return the kernel version, in that case a value of 0 will +be returned. + +
+ +None. + + + + +
+ + +Return the number of environment variables + +EnvCount returns the number of environment variables. + + +None. + + + + + + + + +Return environment variable by index + + +EnvStr returns the Index-th Name=Value pair from the list +of environment variables. +The index of the first pair is zero. + + +The length is limited to 255 characters. + + + + + + + + + + +Execute another program, and wait for it to finish. + +

+Exec executes the program in Path, with the options given by +ComLine. +

+

+After the program has terminated, the procedure returns. The Exit value of +the program can be consulted with the DosExitCode function. +

+

+For an example, see +

+
+ +Errors are reported in DosError. + + + + +
+ + +Expand a relative path to an absolute path + +

+FExpand takes its argument and expands it to a complete filename, i.e. +a filename starting from the root directory of the current drive, prepended +with the drive-letter or volume name (when supported). +

+ +On case sensitive file systems (such as unix and linux), the resulting +name is left as it is, otherwise it is converted to uppercase. + +
+ + + + + + +
+ + + +Dispose resources allocated by a / sequence. + +

+FindClose frees any resources associated with the search record +F. +

+

+This call is needed to free any internal resources allocated by the + or calls. +

+

+The unix implementation of the dos unit therefore keeps a table of open +directories, and when the table is full, closes one of the directories, and +reopens another. This system is adequate but slow if you use a lot of +searchrecs. +

+

+So, to speed up the findfirst/findnext system, the FindClose call was +implemented. When you don't need a searchrec any more, you can tell +this to the dos unit by issuing a FindClose call. The directory +which is kept open for this searchrec is then closed, and the table slot +freed. +

+ +It is recommended to use the linux call Glob when looking for files +on linux. + +
+ +Errors are reported in DosError. + + + + + +
+ + +Start search for one or more files. + +

+FindFirst searches the file specified in Path. Normal files, +as well as all special files which have the attributes specified in +Attr will be returned. +

+

+It returns a SearchRec record for further searching in F. +Path can contain the wildcard characters ? (matches any single +character) and * (matches 0 ore more arbitrary characters). In this +case FindFirst will return the first file which matches the specified +criteria. +If DosError is different from zero, no file(s) matching the criteria +was(were) found. +

+ +On os/2, you cannot issue two different FindFirst calls. That is, +you must close any previous search operation with before +starting a new one. Failure to do so will end in a Run-Time Error 6 +(Invalid file handle) + +
+ +Errors are reported in DosError. + + +, + + + +
+ + + +Find next matching file after + +

+FindNext takes as an argument a SearchRec from a previous +FindNext call, or a FindFirst call, and tries to find another +file which matches the criteria, specified in the FindFirst call. +If DosError is different from zero, no more files matching the +criteria were found. +

+

+For an example, see . +

+
+ +DosError is used to report errors. + + + + + +
+ + +Search a file in searchpath + +

+FSearch searches the file Path in all directories listed in +DirList. The full name of the found file is returned. +DirList must be a list of directories, separated by semi-colons. +When no file is found, an empty string is returned. +

+ +On unix systems, DirList can also be separated by colons, as is +customary on those environments. + +
+ +None. + + +FExpand + + +
+ + + + +Split a full-path filename in parts. + +FSplit splits a full file name into 3 parts : A Path, a +Name and an extension (in ext.) +The extension is taken to be all letters after the last dot (.). For +dos, however, an exception is made when LFNSupport=False, then +the extension is defined as all characters after the first dot. + + +None. + + +FSearch + + + + + + +Get control-Break flag + +

+GetCBreak gets the status of CTRL-Break checking under dos and Amiga. +When BreakValue is false, then dos only checks for the +CTRL-Break key-press when I/O is performed. When it is set to True, +then a check is done at every system call. +

+ +Under non-dos and non-Amiga operating systems, BreakValue always returns +True. + +
+ +None + + + + +
+ + +Get the current date + +GetDate returns the system's date. Year is a number in the range +1980..2099.mday is the day of the month, +wday is the day of the week, starting with Sunday as day 0. + + +None. + + + + + + + + + + +Get environment variable by name. + +

+Getenv returns the value of the environment variable EnvVar. +When there is no environment variable EnvVar defined, an empty +string is returned. +

+ +Under some operating systems (such as unix), case is important when looking +for EnvVar. + +
+ +None. + + + + + + +
+ + +Get file attributes + +

+GetFAttr returns the file attributes of the file-variable f. + F can be a untyped or typed file, or of type Text. f must +have been assigned, but not opened. The attributes can be examined with the +following constants : +

+
    +
  • ReadOnly
  • +
  • Hidden
  • +
  • SysFile
  • +
  • VolumeId
  • +
  • Directory
  • +
  • Archive
  • +
+

+Under linux, supported attributes are: +

+
    +
  • Directory
  • +
  • ReadOnly if the current process doesn't have access to the file.
  • +
  • Hidden for files whose name starts with a dot ('.').
  • +
+
+ +Errors are reported in DosError + + + + + +
+ + + +Get file last modification time. + +GetFTime returns the modification time of a file. +This time is encoded and must be decoded with UnPackTime. +F must be a file type, which has been assigned, and +opened. + + +Errors are reported in DosError + + + + + + + + + + + +Get interrupt vector + +

+GetIntVec returns the address of interrupt vector +IntNo. +

+ +This call does nothing, it is present for compatibility only. Modern systems +do not allow low level access to the hardware. + +
+ +None. + + + + +
+ + +Get the long filename of a DOS 8.3 filename. + +

+This function is only implemented in the GO32V2 version of Free Pascal. +

+

+GetLongName changes the filename p to a long filename +if the dos call to do this is successful. The resulting string +is the long file name corresponding to the short filename p. +

+

+The function returns True if the dos call was successful, +False otherwise. +

+

+This function should only be necessary when using the DOS extender +under Windows 95 and higher. +

+
+ +If the dos call was not succesfull, False is returned. + + + + +
+ + +Get the short (8.3) filename of a long filename. + +

+This function is only implemented in the GO32V2 version of Free Pascal. +

+

+GetShortName changes the filename p to a short filename +if the dos call to do this is successful. The resulting string +is the short file name corresponding to the long filename p. +

+

+The function returns True if the dos call was successful, +False otherwise. +

+

+This function should only be necessary when using the DOS extender +under Windows 95 and higher. +

+
+ +If the dos call was not successful, False is returned. + + + + +
+ + +Return the current time + +

+GetTime returns the system's time. Hour is a on a 24-hour time +scale. sec100 is in hundredth of a +second. +

+ +Certain operating systems (such as Amiga), always set the sec100 field +to zero. + +
+ +None. + + + + + + +
+ + + +Get verify flag + +

+GetVerify returns the status of the verify flag under dos. When +Verify is True, then dos checks data which are written to disk, +by reading them after writing. If Verify is False, then data +written to disk are not verified. +

+ +Under non-dos systems (excluding os/2 applications running under vanilla DOS), +Verify is always True. + +
+ +None. + + + + +
+ + +Execute interrupt + +

+Intr executes a software interrupt number IntNo (must be between +0 and 255), with processor registers set to Regs. After the interrupt call +returned, the processor registers are saved in Regs. +

+ +Under non-dos operating systems, this call does nothing. + +
+ +None. + + + + +
+ + +Terminate and stay resident. + +

+Keep terminates the program, but stays in memory. This is used for TSR +(Terminate Stay Resident) programs which catch some interrupt. +ExitCode is the same parameter as the Halt function takes. +

+ +This call does nothing, it is present for compatibility only. + +
+ +None. + + + +
+ + +Return the day of the week + +WeekDay returns the day of the week on which the day +Y/M/D falls. Sunday is represented by 0, Saturday is 6. + + +On error, -1 is returned. + + + + + + + + + + +Convert a DateTime to unix timestamp + +DTToUnixDate converts the DateTime value in DT to a +unix timestamp. It is an internal function, implemented on Unix platforms, +and should not be used. + + +None. + + + + + + + + + + + +Convert a unix timestamp to a DateTime record + +DTToUnixDate converts the unix timestamp value in SecsPast to a +DateTime representation in DT. It is an internal function, implemented on Unix platforms, +and should not be used. + + +None. + + + + + + + + + + + + +Execute MS-DOS system call + +

+MSDos executes an operating system call. This is the same as doing a +Intr call with the interrupt number for an os call. +

+ +Under non-dos operating systems, this call does nothing. On DOS systems, +this calls interrupt $21. + +
+ +None. + + + + +
+ + +Pack DateTime value to a packed-time format. + +UnPackTime converts the date and time specified in T +to a packed-time format which can be fed to SetFTime. + + +None. + + + + + + + + + + + + +Set Control-Break flag status + +

+SetCBreak sets the status of CTRL-Break checking. When +BreakValue is false, then dos only checks for the CTRL-Break +key-press when I/O is performed. When it is set to True, then a +check is done at every system call. +

+ +Under non-dos and non-Amiga operating systems, this call does nothing. + +
+ +None. + + + + +
+ + +Set system date + +

+SetDate sets the system's internal date. Year is a number +between 1980 and 2099. +

+ +On a unix machine, there must be root privileges, otherwise this +routine will do nothing. On other unix systems, this call currently +does nothing. + +
+ +None. + + + + + +
+ + +Set file attributes + +

+SetFAttr sets the file attributes of the file-variable F. + F can be a untyped or typed file, or of type Text. F must +have been assigned, but not opened. The attributes can be a sum of the +following constants: +

+
    +
  • ReadOnly
  • +
  • Hidden
  • +
  • SysFile
  • +
  • VolumeId
  • +
  • Directory
  • +
  • Archive
  • +
+ +Under unix like systems (such as linux and BeOS) the call exists, but is not implemented, +i.e. it does nothing. + +
+ +Errors are reported in DosError. + + + + +
+ + + +Set file modification time. + +

+SetFTime sets the modification time of a file, +this time is encoded and must be encoded with PackTime. +F must be a file type, which has been assigned, and +opened. +

+ +Under unix like systems (such as linux and BeOS) the call exists, but is not implemented, +i.e. it does nothing. + +
+ +Errors are reported in DosError + + + + + + +
+ + +Set interrupt vector + +

+SetIntVec sets interrupt vector IntNo to Vector. +Vector should point to an interrupt procedure. +

+ +This call does nothing, it is present for compatibility only. + +
+ +None. + + + + +
+ + +Set system time + +

+SetTime sets the system's internal clock. The Hour parameter is +on a 24-hour time scale. +

+ +On a linux machine, there must be root privileges, otherwise this +routine will do nothing. On other unix systems, this call currently +does nothing. + +
+ +None. + + + + + +
+ + +Set verify flag + +

+SetVerify sets the status of the verify flag under dos. When +Verify is True, then dos checks data which are written to disk, +by reading them after writing. If Verify is False, then data +written to disk are not verified. +

+ +Under non-dos operating systems (excluding os/2 applications running +under vanilla dos), Verify is always True. + +
+ +None. + + + + +
+ + +Swap interrupt vectors + +

+SwapVectors swaps the contents of the internal table of interrupt +vectors with the current contents of the interrupt vectors. +This is called typically in before and after an Exec call. +

+ +Under certain operating systems, this routine may be implemented +as an empty stub. + +
+ +None. + + + + + + +
+ +Unpack packed file time to a DateTime value + +

+UnPackTime converts the file-modification time in p +to a DateTime record. The file-modification time can be +returned by GetFTime, FindFirst or FindNext calls. +

+

+For an example, see . +

+
+ +None. + + + + + + + +
+ + +
+
+
\ No newline at end of file diff --git a/docs/keyboard.xml b/docs/keyboard.xml new file mode 100644 index 0000000000..04b0c863f9 --- /dev/null +++ b/docs/keyboard.xml @@ -0,0 +1,1060 @@ + + + + + +The KEYBOARD unit + + +

+The KeyBoard unit implements a keyboard access layer which is system +independent. It can be used to poll the keyboard state and wait for certain +events. Waiting for a keyboard event can be done with the +function, which will return a driver-dependent key event. This key event can +be translated to a interpretable event by the +function. The result of this function can be used in the other event +examining functions. +

+

+A custom keyboard driver can be installed using the +function. The current keyboard driver can be retrieved using the + function. The last section of this chapter +demonstrates how to make a keyboard driver. +

+
+ + +Base of keyboard routine error reporting constants. + + + +Failed to initialize keyboard driver + + + +Keyboard driver not implemented. + + + +F1 function key pressed. + + + +F2 function key pressed. + + + +F3 function key pressed. + + + +F4 function key pressed. + + + +F5 function key pressed. + + + +F6 function key pressed. + + + +F7 function key pressed. + + + +F8 function key pressed. + + + +F9 function key pressed. + + + +F10 function key pressed. + + + +F12 function key pressed. + + + +F12 function key pressed. + + + +F13 function key pressed. + + + +F14 function key pressed. + + + +F15 function key pressed. + + + +F16 function key pressed. + + + +F17 function key pressed. + + + +F18 function key pressed. + + + +F19 function key pressed. + + + +F20 function key pressed. + + + +function key pressed. + + + +Shift key name index. + + + +Alt key name index. + + + + +Alt key name index. + + + + + +Shift key name index. + + + + + +Home key pressed + + + +Arrow up key pressed + + + +Arrow down key pressed + + + +Page Up key pressed + + + +Arrow left key pressed + + + +Middle key pad key pressed (numerical 5) + + + +Arrow right key pressed + + + +End key pressed + + + +Page down key pressed + + + + +Insert key pressed + + + +Delete key pressed + + + +Ascii code key event + + + +Unicode code key event + + + +Physical key code event + + + +Key release event + + + +Left shift key modifier + + + +Right shift key modifier + + + +Shift key modifier + + + +Control key modifier + + + +Alt key modifier + + + +Names of modifier keys + +This constant describes the various modifier keys. +This constant is used by the key event description routines. +It can be changed to localize the key descriptions when needed. + + + + + + + + +Names for left-right keys + +This constant contains strings to describe left and right keys. +This constant is used by the key event description routines. +It can be changed to localize the key descriptions when needed. + + + + + + + + +Unicode character string. + +This constant contains a string to denote a unicode key event. +This constant is used by the key event description routines. +It can be changed to localize the key descriptions when needed. + + + + + + + + +Scancode key + +This constant contains a string to denote a scancode key event. +This constant is used by the key event description routines. +It can be changed to localize the key descriptions when needed. + + + + + + + + +Unknown function key + +This constant contains a string to denote that an unknown function key was +found. This constant is used by the key event description routines. +It can be changed to localize the key descriptions when needed. + + + + + + + + +'And' description string + +This constant is used as the 'And' word in key descriptions. +This constant is used by the key event description routines. +It can be changed to localize the key descriptions when needed. + + + + + + + + +Names of keypad keys + +This constant describes all keypad keys. +This constant is used by the key event description routines. +It can be changed to localize the key descriptions when needed. + + + + + + + + +Base type to describe all key events. + +

+The TKeyEvent type is the base type for all keyboard events. +

+

+The key stroke is encoded in the 4 bytes of the TKeyEvent type. +The various fields of the key stroke encoding can be obtained by typecasting +the TKeyEvent type to the type. +

+
+
+ + +Key event decoding type. + +

+The structure of a TKeyRecord structure is explained in the +following table: +

+ + + + + + + + + +
Structure of TKeyRecord
FieldMeaning
KeyCode +Depending on flags either the physical representation of a key +(under DOS scancode, ascii code pair), or the translated +ASCII/unicode character. +
ShiftState +Shift-state when this key was pressed (or shortly after) +
Flags +Determine how to interpret KeyCode +
+

+The shift-state can be checked using the various shift-state constants, +and the flags in the last byte can be checked using one of the +kbASCII, kbUniCode, kbFnKey, kbPhys, kbReleased constants. +

+

+If there are two keys returning the same char-code, there's no way to find +out which one was pressed (Gray+ and Simple+). If it needs to be known which +was pressed, the untranslated keycodes must be used, but these are system +dependent. System dependent constants may be defined to cover those, with +possibily having the same name (but different value). +

+
+ + + + +
+ + +Keyboard driver structure + +

+The TKeyboardDriver record can be used to install a custom keyboard +driver with the function. +

+

+The various fields correspond to the different functions of the keyboard unit +interface. For more information about this record see +

+
+ + + + +
+ + +Deactivate keyboard driver. + +

+DoneKeyboard de-initializes the keyboard interface if the keyboard +driver is active. If the keyboard driver is not active, the function does +nothing. +

+

+This will cause the keyboard driver to clear up any allocated memory, +or restores the console or terminal the program was running in to its +initial state before the call to . This function should +be called on program exit. Failing to do so may leave the terminal or +console window in an unusable state. Its exact action depends on the +platform on which the program is running. +

+

+For an example, see most other functions. +

+
+ +None. + + + + +
+ + + +Return string representation of a function key code. + +FunctionKeyName returns a string representation of the function key +with code KeyCode. This can be an actual function key, or one of the +cursor movement keys. + + +In case KeyCode does not contain a function code, the +SUnknownFunctionKey string is returned, appended with the +KeyCode. + + + + + + + + + + +Return the current keyboard driver record. + +

+GetKeyBoardDriver returns in Driver the currently active +keyboard driver. This function can be used to enhance an existing +keyboarddriver. +

+

+For more information on getting and setting the keyboard driver +. +

+
+ +None. + + + + +
+ + +Get the next raw key event, wait if needed. + +

+GetKeyEvent returns the last keyevent if one was stored in +PendingKeyEvent, or waits for one if none is available. +A non-blocking version is available in . +

+

+The returned key is encoded as a TKeyEvent type variable, and +is normally the physical key scan code, (the scan code is driver +dependent) which can be translated with one of the translation +functions or . +See the types section for a description of how the key is described. +

+
+ +If no key became available, 0 is returned. + + + + +, + + + +
+ + + +Get the character key part of a key event. + +

+GetKeyEventChar returns the charcode part of the given +KeyEvent, if it contains a translated character key +keycode. The charcode is simply the ascii code of the +character key that was pressed. +

+

+It returns the null character if the key was not a character key, but e.g. a +function key. +

+

+For an example, see +

+
+ +None. + + +, +, +, +, + + +
+ + + +Translate function key part of a key event code. + +

+GetKeyEventCode returns the translated function keycode part of +the given KeyEvent, if it contains a translated function key. +

+

+If the key pressed was not a function key, the null character is returned. +

+
+ +None. + + +, +, +, +, + + + +
+ + +Extract the flags from a key event. + +

+GetKeyEventFlags returns the flags part of the given +KeyEvent. +

+

+For an example, see +

+
+ +None. + + +, +, +, +, + + +
+ + + +Return the current state of the shift keys. + +

+GetKeyEventShiftState returns the shift-state values of +the given KeyEvent. This can be used to detect which of the modifier +keys Shift, Alt or Ctrl were pressed. If none were +pressed, zero is returned. +

+

+Note that this function does not always return expected results; +In a unix X-Term, the modifier keys do not always work. +

+
+ +None. + + +, +, +, +, + + + +
+ + + +Return the unicode key event. + +GetKeyEventUniCode returns the unicode part of the +given KeyEvent if it contains a translated unicode +character. + + +None. + + +, +, +, +, + + + + + +Initialize the keyboard driver. + +

+InitKeyboard initializes the keyboard driver. +If the driver is already active, it does nothing. When the driver is +initialized, it will do everything necessary to ensure the functioning of +the keyboard, including allocating memory, initializing the terminal etc. +

+

+This function should be called once, before using any of the +keyboard functions. When it is called, the function +should also be called before exiting the program or changing the keyboard +driver with . +

+

+For an example, see most other functions. +

+
+ +None. + + + + + +
+ + + + + + + + + +Check whether a given event is a function key event. + +IsFunctionKey returns True if the given key event +in KeyEvent was a function key or not. + + +None. + + + + + + + + + +Return a string describing the key event. + +

+KeyEventToString translates the key event in KeyEvent to a +human-readable description of the pressed key. It will use the constants +described in the constants section to do so. +

+

+For an example, see most other functions. +

+
+ +If an unknown key is passed, the scancode is returned, prefixed with the +SScanCode string. + + + + + +
+ + +Check event queue for key press + +KeyPressed checks the keyboard event queue to see whether a key +event is present, and returns True if a key event is available. +This function simply calls and checks for a valid +result. + + +None. + + + + + + + + + + +Get next key event, but does not wait. + +

+PollKeyEvent checks whether a key event is available, +and returns it if one is found. If no event is pending, +it returns 0. +

+

+Note that this does not remove the key from the pending keys. +The key should still be retrieved from the pending key events +list with the function. +

+
+ +None. + + + + + + +
+ + + +Check current shift state. + +PollShiftStateEvent returns the current shiftstate in a +keyevent. This will return 0 if there is no key event pending. + + +None. + + + + + + + + + + +Put a key event in the event queue. + +PutKeyEvent adds the given KeyEvent to the input +queue. Please note that depending on the implementation this +can hold only one value, i.e. when calling PutKeyEvent +multiple times, only the last pushed key will be remembered. + + +None + + + + + + + + + + +Set a new keyboard driver. + +

+SetKeyBoardDriver sets the keyboard driver to Driver, if the +current keyboard driver is not yet initialized. If the current +keyboard driver is initialized, then SetKeyboardDriver does +nothing. Before setting the driver, the currently active driver should +be disabled with a call to . +

+

+The function returns True if the driver was set, False if not. +

+

+For more information on setting the keyboard driver, see . +

+
+ +None. + + + +. + +
+ + +Return description of key event shift state + +

+ShiftStateToString returns a string description of the shift state +of the key event KeyEvent. This can be an empty string. +

+

+The shift state is described using the strings in the SShift constant. +

+

+For an example, see . +

+
+ +None. + + + + + +
+ + + +Translate raw event to ascii key event + +

+TranslateKeyEvent performs ASCII translation of the KeyEvent. +It translates a physical key to a function key if the key is a function key, +and translates the physical key to the ordinal of the ascii character if +there is an equivalent character key. +

+

+For an example, see +

+
+ +None. + + + + +
+ + + +Translate raw event to UNICode key event + +TranslateKeyEventUniCode performs Unicode translation of the +KeyEvent. It is not yet implemented for all platforms. + + +If the function is not yet implemented, then the ErrorCode of the +system unit will be set to errKbdNotImplemented + + + + + + + +Keyboard scan codes + +

+Special physical keys are encoded with the DOS scan codes for these keys +in the second byte of the type. +A complete list of scan codes can be found in the below table. +This is the list of keys that is used by the default key event translation mechanism. +When writing a keyboard driver, either these constants should be returned +by the various key event functions, or the TranslateKeyEvent hook +should be implemented by the driver. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Key Scancodes
CodeKeyCodeKeyCodeKey
00 NoKey 3D F3 70 ALT-F9
01 ALT-Esc 3E F4 71 ALT-F10
02 ALT-Space 3F F5 72 CTRL-PrtSc
04 CTRL-Ins 40 F6 73 CTRL-Left
05 SHIFT-Ins 41 F7 74 CTRL-Right
06 CTRL-Del 42 F8 75 CTRL-end
07 SHIFT-Del 43 F9 76 CTRL-PgDn
08 ALT-Back 44 F10 77 CTRL-Home
09 ALT-SHIFT-Back 47 Home 78 ALT-1
0F SHIFT-Tab 48 Up 79 ALT-2
10 ALT-Q 49 PgUp 7A ALT-3
11 ALT-W 4B Left 7B ALT-4
12 ALT-E 4C Center 7C ALT-5
13 ALT-R 4D Right 7D ALT-6
14 ALT-T 4E ALT-GrayPlus 7E ALT-7
15 ALT-Y 4F end 7F ALT-8
16 ALT-U 50 Down 80 ALT-9
17 ALT-I 51 PgDn 81 ALT-0
18 ALT-O 52 Ins 82 ALT-Minus
19 ALT-P 53 Del 83 ALT-Equal
1A ALT-LftBrack 54 SHIFT-F1 84 CTRL-PgUp
1B ALT-RgtBrack 55 SHIFT-F2 85 F11
1E ALT-A 56 SHIFT-F3 86 F12
1F ALT-S 57 SHIFT-F4 87 SHIFT-F11
20 ALT-D 58 SHIFT-F5 88 SHIFT-F12
21 ALT-F 59 SHIFT-F6 89 CTRL-F11
22 ALT-G 5A SHIFT-F7 8A CTRL-F12
23 ALT-H 5B SHIFT-F8 8B ALT-F11
24 ALT-J 5C SHIFT-F9 8C ALT-F12
25 ALT-K 5D SHIFT-F10 8D CTRL-Up
26 ALT-L 5E CTRL-F1 8E CTRL-Minus
27 ALT-SemiCol 5F CTRL-F2 8F CTRL-Center
28 ALT-Quote 60 CTRL-F3 90 CTRL-GreyPlus
29 ALT-OpQuote 61 CTRL-F4 91 CTRL-Down
2B ALT-BkSlash 62 CTRL-F5 94 CTRL-Tab
2C ALT-Z 63 CTRL-F6 97 ALT-Home
2D ALT-X 64 CTRL-F7 98 ALT-Up
2E ALT-C 65 CTRL-F8 99 ALT-PgUp
2F ALT-V 66 CTRL-F9 9B ALT-Left
30 ALT-B 67 CTRL-F10 9D ALT-Right
31 ALT-N 68 ALT-F1 9F ALT-end
32 ALT-M 69 ALT-F2 A0 ALT-Down
33 ALT-Comma 6A ALT-F3 A1 ALT-PgDn
34 ALT-Period 6B ALT-F4 A2 ALT-Ins
35 ALT-Slash 6C ALT-F5 A3 ALT-Del
37 ALT-GreyAst 6D ALT-F6 A5 ALT-Tab
3B F1 6E ALT-F7
3C F2 6F ALT-F8
+

+A list of scan codes for special keys and combinations with the SHIFT, ALT +and CTRL keys can be found in the following table: They are for quick reference +only. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Special keys scan codes
Key Code SHIFT-Key CTRL-Key Alt-Key
NoKey 00
F1 3B 54 5E 68
F2 3C 55 5F 69
F3 3D 56 60 6A
F4 3E 57 61 6B
F5 3F 58 62 6C
F6 40 59 63 6D
F7 41 5A 64 6E
F8 42 5A 65 6F
F9 43 5B 66 70
F10 44 5C 67 71
F11 85 87 89 8B
F12 86 88 8A 8C
Home 47 77 97
Up 48 8D 98
PgUp 49 84 99
Left 4B 73 9B
Center 4C 8F
Right 4D 74 9D
end 4F 75 9F
Down 50 91 A0
PgDn 51 76 A1
Ins 52 05 04 A2
Del 53 07 06 A3
Tab 8 0F 94 A5
GreyPlus 90 4E
+
+
+ + +Writing a keyboard driver + +

+Writing a keyboard driver means that hooks must be created for most of the +keyboard unit functions. The TKeyBoardDriver record contains a field +for each of the possible hooks: +

+ +TKeyboardDriver = Record + InitDriver : Procedure; + DoneDriver : Procedure; + GetKeyEvent : Function : TKeyEvent; + PollKeyEvent : Function : TKeyEvent; + GetShiftState : Function : Byte; + TranslateKeyEvent : Function (KeyEvent: TKeyEvent): TKeyEvent; + TranslateKeyEventUniCode: Function (KeyEvent: TKeyEvent): TKeyEvent; +end; + +

+The meaning of these hooks is explained below: +

+
+
InitDriver
+
Called to initialize and enable the driver. +Guaranteed to be called only once. This should initialize all needed things +for the driver. +
+
DoneDriver
+
Called to disable and clean up the driver. Guaranteed to be +called after a call to initDriver. This should clean up all +things initialized by InitDriver. +
+
GetKeyEvent
+
Called by . Must wait for and return the +next key event. It should NOT store keys. +
+
PollKeyEvent
+
Called by . It must return the next key +event if there is one. Should not store keys. +
+
GetShiftState
+
Called by . Must return the current +shift state. +
+
TranslateKeyEvent
+
Should translate a raw key event to a cOrrect +key event, i.e. should fill in the shiftstate and convert function key +scancodes to function key keycodes. If the +TranslateKeyEvent is not filled in, a default translation function +will be called which converts the known scancodes from the tables in the +previous section to a correct keyevent. +
+
TranslateKeyEventUniCode
+
Should translate a key event to a unicode key +representation. +
+
+

+Strictly speaking, only the GetKeyEvent and PollKeyEvent +hooks must be implemented for the driver to function correctly. +

+

+The example unit demonstrates how a keyboard driver can be installed. +It takes the installed driver, and hooks into the GetKeyEvent +function to register and log the key events in a file. This driver +can work on top of any other driver, as long as it is inserted in the +uses clause after the real driver unit, and the real driver unit +should set the driver record in its initialization section. +

+

+Note that with a simple extension of this unit could be used to make a +driver that is capable of recording and storing a set of keyboard strokes, +and replaying them at a later time, so a 'keyboard macro' capable driver. +This driver could sit on top of any other driver. +

+
+ + +
+ +
+
+
\ No newline at end of file diff --git a/docs/mouse.xml b/docs/mouse.xml new file mode 100644 index 0000000000..98469b2844 --- /dev/null +++ b/docs/mouse.xml @@ -0,0 +1,527 @@ + + + + + +Mouse event handling unit + + +The Mouse unit implements a platform independent mouse handling +interface. It is implemented identically on all platforms supported by +Free Pascal and can be enhanced with custom drivers, should this be needed. +It is intended to be used only in text-based screens, for instance in +conjunction with the keyboard and video unit. No support for graphical +screens is implemented, and there are (currently) no plans to implement +this. + + + +Base for mouse error codes. + + + +Mouse initialization error + + + +Mouse driver not implemented. + + + +Mouse button down event signal. + + + +Mouse button up event signal. + + + +Mouse cursor move event signal. + + + +Left mouse button event. + + + +Right mouse button event. + + + +Middle mouse button event. + + + +Mouse event buffer size + +The mouse unit has a mechanism to buffer mouse events. This +constant defines the size of the event buffer. + + + + +Pointer to record. + + + +Mouse event reporting record. + +

+The TMouseEvent is the central type of the mouse unit, it is used +to describe all mouse events. +

+

+The Buttons field describes which buttons were down when the event +occurred. The x,y fields describe where the event occurred on the +screen. The Action describes what action was going on when the event +occurred. The Buttons and Action field can be examined using the +constants defined in the unit interface. +

+
+ + + + + +
+ + +Horizontal position of mouse cursor. + + +Vertical position of mouse cursor. + + +Pressed buttons at time of event. + + + +Type of event. + + + +Mouse driver structure + +The TMouseDriver record is used to implement a mouse driver in the + function. Its fields must be filled in before +calling the function. + + + + + + + +Should the default event queue mechanism be used. + + +Called when the driver must be initialized + + +Called when the driver will be unloaded. + + +Function called when the mouse must be detected. + + +Function called when the mouse cursor must be shown. + + +Function called when the mouse cursor must be hidden. + + +Called to get the mouse cursors horizontal position. + + +Called to get the mouse cursors vertical position. + + +Called to get the currently pressed mouse buttons. + + +Called when the current mouse position must be set. + + +Called to get the next mouse event. Waits if needed. + + +Called to get the next mouse event. Does not wait. + + +Called to put a mouse event back in the queue. + + + +Internal mouse flag +This variable keeps track of the last known internal mouse state. Do not use. + + + +Mouse button state +This variable keeps track of the last known mouse button state. Do not use. + + + +Mouse cursor horizontal position +This variable keeps track of the last known cursor position. Do not use. + + + +Mouse cursor vertical position +This variable keeps track of the last known cursor position. Do not use. + + + +Detect the presence of a mouse. + +

+DetectMouse detects whether a mouse is attached to the system or not. +If there is no mouse, then zero is returned. If a mouse is attached, then +the number of mouse buttons is returnead. +

+

+This function should be called after the mouse driver was initialized. +

+
+ +None. + + + +, + + +
+ + +Deinitialize mouse driver. + +

+DoneMouse De-initializes the mouse driver. It cleans up any memory +allocated when the mouse was initialized, or removes possible mouse hooks +from memory. The mouse functions will not work after DoneMouse was +called. If DoneMouse is called a second time, it will exit at once. +InitMouse should be called before DoneMouse can be called again. +

+

+For an example, see most other mouse functions. +

+
+ +None. + + + + + +
+ + + +Get the state of the mouse buttons + +

+GetMouseButtons returns the current button state of the mouse, i.e. +it returns a or-ed combination of the following constants: +

+
+
MouseLeftButton
+
When the left mouse button is held down. +
+
MouseRightButton
+
When the right mouse button is held down. +
+
MouseMiddleButton
+
When the middle mouse button is held down. +
+
+
+ +None. + + + + + + + +
+ + +Get a copy of the currently active mouse driver. + +

+GetMouseDriver returns the currently set mouse driver. It can be used +to retrieve the current mouse driver, and override certain callbacks. +

+

+A more detailed explanation about getting and setting mouse drivers can be found in +. +

+

+For an example, see the section on writing a custom mouse driver, + +

+
+ +None. + + + + +
+ + + +Get next mouse event from the queue. + +

+GetMouseEvent returns the next mouse event (a movement, button press or +button release), and waits for one if none is available in the queue. +

+

+Some mouse drivers can implement a mouse event queue which can hold multiple +events till they are fetched. Others don't, and in that case, a one-event +queue is implemented for use with . +

+
+ +None. + + + + + + +
+ + +Query the current horizontal position of the mouse cursor. + +GetMouseX returns the current X position of the mouse. X is +measured in characters, starting at 0 for the left side of the screen. + + +None. + + + + + + + + + + +Query the current vertical position of the mouse cursor. + +

+GetMouseY returns the current Y position of the mouse. Y is +measured in characters, starting at 0 for the top of the screen. +

+

+For an example, see +

+
+ +None. + + + + + + +
+ + + +Hide the mouse cursor. + +HideMouse hides the mouse cursor. This may or may not be implemented +on all systems, and depends on the driver. + + +None. + + + + + + + + + +Initialize the FPC mouse driver. + +

+InitMouse Initializes the mouse driver. This will allocate any data +structures needed for the mouse to function. All mouse functions can be +used after a call to InitMouse. +

+

+A call to InitMouse must always be followed by a call to +at program exit. Failing to do so may leave the mouse in an unusable state, +or may result in memory leaks. +

+

+For an example, see most other functions. +

+
+ +None. + + + + + +
+ + + +Query next mouse event. Do not wait if none available. + +

+PollMouseEvent checks whether a mouse event is available, and +returns it in MouseEvent if one is found. The function result is +True in that case. If no mouse event is pending, the function result +is False, and the contents of MouseEvent is undefined. +

+

+Note that after a call to PollMouseEvent, the event should still +be removed from the mouse event queue with a call to GetMouseEvent. +

+
+ +None. + + + + + +
+ + +Put a mouse event in the venet queue. + +

+PutMouseEvent adds MouseEvent to the input queue. The next +call to or PollMouseEvent will then return +MouseEvent. +

+

+Please note that depending on the implementation the mouse event queue +can hold only one value. +

+
+ +None. + + + + + +
+ + +Set a new mouse driver. + +

+SetMouseDriver sets the mouse driver to Driver. This function +should be called before is called, or after DoneMouse +is called. If it is called after the mouse has been initialized, it does +nothing. +

+

+For more information on setting the mouse driver, . +

+

+For an example, see +

+
+ + + + + + + +
+ + + +Set the mouse cursor position. + +SetMouseXY places the mouse cursor on X,Y. X and Y are zero +based character coordinates: 0,0 is the top-left corner of the screen, +and the position is in character cells (i.e. not in pixels). + + +None. + + + + + + + + + + +Show the mouse cursor. + +

+ShowMouse shows the mouse cursor if it was previously hidden. The +capability to hide or show the mouse cursor depends on the driver. +

+

+For an example, see +

+
+ +None. + + + + +
+ + +Writing a custom mouse driver + +

+The mouse unit has support for adding a custom mouse driver. This can be +used to add support for mouses not supported by the standard Free Pascal driver, +but also to enhance an existing driver for instance to log mouse events or +to implement a record and playback function. +

+

+The following unit shows how a mouse driver can be enhanced by adding some +logging capabilities to the driver. +

+
+ +
+ +
+
+
\ No newline at end of file diff --git a/docs/objects.xml b/docs/objects.xml new file mode 100644 index 0000000000..a09f9506af --- /dev/null +++ b/docs/objects.xml @@ -0,0 +1,3264 @@ + + + + + +The Objects unit. + + +

+This document documents the objects unit. The unit was implemented by +many people, and was mainly taken from the FreeVision sources. It has been +ported to all supported platforms. +

+

+The methods and fields that are in a Private part of an object +declaration have been left out of this documentation. +

+
+ + +Stream error codes: No error + + + +Stream error codes: Access error + + + +Stream error codes: Initialize error + + + +Stream error codes: Stream read error + + + +Stream error codes: Stream write error + + + +Stream error codes: Get object error + + + +Stream error codes: Put object error + + + +Stream error codes: Seek error in stream + + + +Stream error codes: Error opening stream + + + +Stream initialization mode: Create new file + + + +Stream initialization mode: Read access only + + + +Stream initialization mode: Write access only + + + +Stream initialization mode: Read/write access + + + +Collection list error: Index out of range + + + +Collection list error: Overflow + + + +Maximum data size (in bytes) + + + +Maximum data size (in words) + + + +Maximum data size (in pointers) + + + +Maximum data that can be read from a stream (not used) + + + +Maximum collection size (in items) + + + +Is the default stream content TP compatible + +This variable determines whether the default stream is filled or read in a +TP compatible way. The TPCompatible field can be set on a +per-stream basis, and is initialized with the DefaulTPCompatible +value. + + + + +Default stream record for the object. + + + +Default stream record for the object. + + + +Default stream record for the object. + + + +Default stream record for the object. + + + +Default stream record for the object. + + + +Pointer to default stream error handler. + + + +Size of the VMT header in an object (not used). + + + + +Maximum collection size (in items, same value as in TP) + + + + +Generic set of characters type. + + + +Pointer to . + + + +Array with maxmimum allowed number of bytes. + + + +Pointer to + + + +Array with maxmimum allowed number of words. + + + +Pointer to + + + +Array with maxmimum allowed number of pointers + + + +Pointer to + + + +Pointer to a shortstring. + + + +Filename - null terminated array of characters. + + + +Filename - shortstring version. + + + +Alias for Cardinal + + + +Alias for longint + + + +Record describing a Word (in bytes) + + + +High byte of a word + + + +Low byte of a word + + + +Record describing a longint (in Words) + + + +Lower word of longint + + + +High word of longint + + + +Record describing a pointer to a memory location. + + + +Pointer offset + + + +Pointer segment + + + +Pointer to + + + +Record used in streaming mechanism. + +TSreamRec is used by the Objects unit streaming +mechanism: when an object is registered, a TStreamRec record is +added to a list of records. This list is used when objects need to be +streamed from/streamed to a stream. It contains all the information needed +to stream the object. + + + + +Unique identifier for this object type. + + + +Pointer to object VMT + + + +Procedure to call when object must be loaded from a stream + + + +Procedure to call when object must be stored in a stream. + + + +Next item in list + + + +Pointer to record. + + + +Record describing a point in a 2 dimensional plane. + + + +X coordinate + + + +Y coordinate + + + +Pointer array type used in a + + + +Pointer array type used in a + + + +Record type used in a to store the strings + + + +String key value + + + +String character count + + + +String offset in stream + + + +Allocate a copy of a shortstring on the heap. + +

+NewStr makes a copy of the string S on the heap, +and returns a pointer to this copy. If the string is empty then +Nil is returned. +

+

+The allocated memory is not based on the declared size of the string passed +to NewStr, but is baed on the actual length of the string. +

+
+ +If not enough memory is available, an 'out of memory' error will occur. + + + + + + +
+ + +Allocate a copy of a shortstring on the heap. + +

+SetStr makes a copy of the string S on the heap and +returns the pointer to this copy in P. If P pointed to +another string (i.e. was not Nil, the memory is released first. +Contrary to , if the string is empty then a pointer to +an empty string is returned. +

+

+The allocated memory is not based on the declared size of the string passed +to NewStr, but is based on the actual length of the string. +

+
+ +If not enough memory is available, an 'out of memory' error will occur. + + + + + +
+ + + + +Dispose of a shortstring which was allocated on the heap. + +

+DisposeStr removes a dynamically allocated string from the heap. +

+

+For an example, see . +

+
+ +None. + + + + + +
+ + + +Abstract error handler. + +

+When implementing abstract methods, do not declare them as abstract. +Instead, define them simply as virtual. In the implementation of such +abstract methods, call the Abstract procedure. This allows explicit +control of what happens when an abstract method is called. +

+

+The current implementation of Abstract terminates the program with +a run-time error 211. +

+
+ +None. + +
+ + +Register standard objects. + +

+RegisterObjects registers the following objects for streaming: +

+
    +
  1. TCollection, see .
  2. +
  3. TStringCollection, see .
  4. +
  5. TStrCollection, see .
  6. +
+
+ +None. + + + + +
+ + +Register new object for streaming. + +

+RegisterType registers a new type for streaming. An object cannot +be streamed unless it has been registered first. +The stream record S needs to have the following fields set: +

+
+
ObjType: Sw_Word
+
This should be a unique identifier. Each possible +type should have it's own identifier. +
+
VmtLink: pointer
+
This should contain a pointer to the VMT (Virtual +Method Table) of the object you try to register. +
+
Load : Pointer
+
is a pointer to a method that initializes an instance +of that object, and reads the initial values from a stream. This method +should accept as it's sole argument a PStream type variable. +
+
Store: Pointer
+
is a pointer to a method that stores an instance of the +object to a stream. This method should accept as it's sole argument + a PStream type variable. +
+
+

+The VMT of the object can be retrieved with the +following expression: +

+ + VmtLink: Ofs(TypeOf(MyType)^); + +
+ +In case of error (if a object with the same ObjType) is already +registered), run-time error 212 occurs. + + +
+ + + +Overflow safe multiply. + +LongMul multiplies X with Y. The result is of +type Longint. This avoids possible overflow errors you would normally +get when multiplying X and Y that are too big. + + +None. + + + + + + + +Overflow safe divide + +LongDiv divides X by Y. The result is of +type Integer instead of type Longint, as you would get +normally. + + +If Y is zero, a run-time error will be generated. + + + + + + + +Describes a rectangular region in a plane. + + + +Top left corner of rectangle + + + +Bottom right corner of rectangle + + + +Is the surface of the rectangle zero + +Empty returns True if the rectangle defined by the corner points +A, B has zero or negative surface. + + +None. + + + + + + + + + + +Do the corners of the rectangles match + +

+Equals returns True if the rectangle has the +same corner points A,B as the rectangle R, and False +otherwise. +

+

+For an example, see +

+
+ +None. + + + + + +
+ + + +Determine if a point is inside the rectangle + +Contains returns True if the point P is contained +in the rectangle (including borders), False otherwise. + + +None. + + + + + + + + +Copy cornerpoints from another rectangle. + +Assigns the rectangle R to the object. After the call to Copy, the +rectangle R has been copied to the object that invoked Copy. + + +None. + + + + + + + + + +Enlarges rectangle to encompas another rectangle. + +Union enlarges the current rectangle so that it becomes the union +of the current rectangle with the rectangle R. + + +None. + + + + + + + + + +Reduce rectangle to intersection with another rectangle + +Intersect makes the intersection of the current rectangle with +R. If the intersection is empty, then the rectangle is set to the empty +rectangle at coordinate (0,0). + + +None. + + + + + + + + +Move rectangle along a vector. + +Move moves the current rectangle along a vector with components +(ADX,ADY). It adds ADX to the X-coordinate of both corner +points, and ADY to both end points. + + +None. + + + + + + + + + +Expand rectangle with certain size. + +

+Grow expands the rectangle with an amount ADX in the X +direction (both on the left and right side of the rectangle, thus adding a +length 2*ADX to the width of the rectangle), and an amount ADY in +the Y direction (both on the top and the bottom side of the rectangle, +adding a length 2*ADY to the height of the rectangle. +

+

+ADX and ADY can be negative. If the resulting rectangle is empty, it is set +to the empty rectangle at (0,0). +

+
+ +None. + + + + + +
+ + +Set rectangle corners. + +

+Assign sets the corner points of the rectangle to (XA,YA) and +(Xb,Yb). +

+

+For an example, see . +

+
+ +None. + + + + +
+ + +Basis of all objects + +This type serves as the basic object for all other objects in the +Objects unit. + + + + +Construct (initialize) a new object + +

+Instantiates a new object of type TObject. It fills the instance up +with Zero bytes. +

+

+For an example, see Free +

+
+ +None. + + + + + +
+ + + +Destroy an object and release all memory. + +Free calls the destructor of the object, and releases the memory +occupied by the instance of the object. + + +No checking is performed to see whether self is nil and whether +the object is indeed allocated on the heap. + + + + + + + + + + +Destroy an object. + +

+Done, the destructor of TObject does nothing. It is mainly +intended to be used in the method. +

+

+The destructore Done does not free the memory occupied by the object. +

+
+ +None. + + + + + + +
+ + + +Base stream class + +

+The TStream object is the ancestor for all streaming objects, i.e. +objects that have the capability to store and retrieve data. +

+

+It defines a number of methods that are common to all objects that implement +streaming, many of them are virtual, and are only implemented in the +descendent types. +

+

+Programs should not instantiate objects of type TStream directly, but +instead instantiate a descendant type, such as TDosStream, +TMemoryStream. +

+
+ + + + + +
+ + +Pointer type to + + + +Current stream status + + + +Additional error info when there is an error. + + + +Current size of the stream + + + +Current Stream position + + + +If set to True streamed data is written in a TP compatible format. + + + +Read an object definition from the stream. + +Get reads an object definition from a stream, and returns +a pointer to an instance of this object. + + +On error, is set, and NIL is returned. + + + + + + + + + +Read a null-terminated string from the stream. + +StrRead reads a string from the stream, allocates memory +for it, and returns a pointer to a null-terminated copy of the string +on the heap. + + +On error, Nil is returned. + + + + + + + + + + + +Return current position in the stream + +If the stream's status is stOk, GetPos returns the current +position in the stream. Otherwise it returns -1 + + +-1 is returned if the status is an error condition. + + + + + + + + + + + +Return the size of the stream. + +If the stream's status is stOk then GetSize returns +the size of the stream, otherwise it returns -1. + + +-1 is returned if the status is an error condition. + + + + + + + + + +Read a shortstring from the stream. + +ReadStr reads a string from the stream, copies it to the heap +and returns a pointer to this copy. The string is saved as a pascal +string, and hence is NOT null terminated. + + +On error (e.g. not enough memory), Nil is returned. + + + + + + + + +Open the stream + +

+Open is an abstract method, that should be overridden by descendent +objects. Since opening a stream depends on the stream's type this is not +surprising. +

+

+For an example, see . +

+
+ +None. + + + + + +
+ + + +Close the stream + +

+Close is an abstract method, that should be overridden by descendent +objects. Since Closing a stream depends on the stream's type this is not +surprising. +

+

+for an example, see . +

+
+ +None. + + + + + +
+ + +Reset the stream + +Reset sets the stream's status to 0, as well as the ErrorInfo + + +None. + + + + + + + + +Flush the stream data from the buffer, if any. + +

+Flush is an abstract method that should be overridden by descendent +objects. It serves to enable the programmer to tell streams that implement +a buffer to clear the buffer. +

+

+for an example, see . +

+
+ +None. + + + + +
+ + + +Truncate the stream size on current position. + +

+Truncate is an abstract procedure that should be overridden by +descendent objects. It serves to enable the programmer to truncate the +size of the stream to the current file position. +

+

+For an example, see . +

+
+ +None. + + + + +
+ + + +Write an object to the stream. + +

+Put writes the object pointed to by P. P should be +non-nil. The object type must have been registered with . +

+

+After the object has been written, it can be read again with Get. +

+

+For an example, see ; +

+
+ +No check is done whether P is Nil or not. Passing Nil will cause +a run-time error 216 to be generated. If the object has not been registered, +the status of the stream will be set to stPutError. + + + + +
+ + + +Write a null-terminated string to the stream. + +

+StrWrite writes the null-terminated string P to the stream. +P can only be 65355 bytes long. +

+

+For an example, see . +

+
+ +None. + + + + + + +
+ + + +Write a pascal string to the stream. + +

+StrWrite writes the pascal string pointed to by P to the stream. +

+

+For an example, see . +

+
+ +None. + + + + + + +
+ + +Set stream position. + +

+Seek sets the position to Pos. This position is counted +from the beginning, and is zero based. (i.e. seeek(0) sets the position +pointer on the first byte of the stream) +

+

+For an example, see . +

+
+ +If Pos is larger than the stream size, Status is set to +StSeekError. + + + + + +
+ + + + +Set stream status + +

+Error sets the stream's status to Code and ErrorInfo +to Info. If the StreamError procedural variable is set, +Error executes it, passing Self as an argument. +

+

+This method should not be called directly from a program. It is intended to +be used in descendent objects. +

+
+ +None. + +
+ + +Read data from stream to buffer. + +

+Read is an abstract method that should be overridden by descendent +objects. +

+

+Read reads Count bytes from the stream into Buf. +It updates the position pointer, increasing it's value with Count. +Buf must be large enough to contain Count bytes. +

+
+ +No checking is done to see if Buf is large enough to contain +Count bytes. + + + + + + + +
+ + + + +Write a number of bytes to the stream. + +

+Write is an abstract method that should be overridden by descendent +objects. +

+

+Write writes Count bytes to the stream from Buf. +It updates the position pointer, increasing it's value with Count. +

+

+For an example, see . +

+
+ +No checking is done to see if Buf actually contains Count bytes. + + + + + + +
+ + + +Copy data from another stream. + +CopyFrom reads Count bytes from stream S and stores them +in the current stream. It uses the Read method +to read the data, and the Write method to +write in the current stream. + + +None. + + +Read +Write + + + + + + + +DOS file stream + +

+TDosStream is a stream that stores it's contents in a file. +it overrides a couple of methods of for this. +

+

+In addition to the fields inherited from TStream (see ), +there are some extra fields, that describe the file. (mainly the name and +the OS file handle) +

+

+No buffering in memory is done when using TDosStream. +All data are written directly to the file. For a stream that buffers +in memory, see . +

+
+
+ + +OS file handle for stream + + + +File name + + + +Instantiate a new instance of TDosStream. + +

+Init instantiates an instance of TDosStream. The name of the +file that contains (or will contain) the data of the stream is given in +FileName. The Mode parameter determines whether a new file +should be created and what access rights you have on the file. +It can be one of the following constants: +

+
+
stCreate
Creates a new file.
+
stOpenRead
Read access only.
+
stOpenWrite
Write access only.
+
stOpen
Read and write access.
+
+

+For an example, see . +

+
+ +On error, Status is set to stInitError, and ErrorInfo +is set to the dos error code. + + + + +
+ + + +Closes the file and cleans up the instance. + +

+Done closes the file if it was open and cleans up the +instance of TDosStream. +

+

+for an example, see e.g. . +

+
+ +None. + + + + + +
+ + + +Close the file. + +

+Close closes the file if it was open, and sets Handle to -1. +Contrary to Done it does not clean up the instance +of TDosStream +

+

+For an example, see . +

+
+ +None. + + + + + + +
+ + + +Truncate the file on the current position. + +If the status of the stream is stOK, then Truncate tries to +truncate the stream size to the current file position. + + +If an error occurs, the stream's status is set to stError and +ErrorInfo is set to the OS error code. + + + + + + + + + + + +Set file position. + +If the stream's status is stOK, then Seek sets the +file position to Pos. Pos is a zero-based offset, counted from +the beginning of the file. + + +In case an error occurs, the stream's status is set to stSeekError, +and the OS error code is stored in ErrorInfo. + + + + + + + + + + + +Open the file stream + +If the stream's status is stOK, and the stream is closed then +Open re-opens the file stream with mode OpenMode. +This call can be used after a Close call. + + +If an error occurs when re-opening the file, then Status is set +to stOpenError, and the OS error code is stored in ErrorInfo + + + + + + + + + +Read data from the stream to a buffer. + +

+If the Stream is open and the stream status is stOK then +Read will read Count bytes from the stream and place them +in Buf. +

+

+For an example, see . +

+
+ +In case of an error, Status is set to StReadError, and +ErrorInfo gets the OS specific error, or 0 when an attempt was +made to read beyond the end of the stream. + + + + + +
+ + +Write data from a buffer to the stream. + +

+If the Stream is open and the stream status is stOK then +Write will write Count bytes from Buf and place them +in the stream. +

+

+For an example, see . +

+
+ +In case of an error, Status is set to StWriteError, and +ErrorInfo gets the OS specific error. + + + + + +
+ + + +Pointer to object. + + + +Pointer to object. + + + +Pointer to object. + + + + +Pointer to object. + + + + +Pointer to object. + + + + +Pointer to object. + + + +Pointer to object. + + + +Pointer to object. + + + +Pointer to object. + + + +Pointer to object. + + + +Pointer to object. + + + +Pointer to object. + + + +Pointer to object. + + + +Pointer to object. + + + + +Pointer to object. + + + + +Pointer to array. + + + + + +Pointer to object. + + + + +Buffered file stream + +

+Bufstream implements a buffered file stream. That is, all data written +to the stream is written to memory first. Only when the buffer is full, or +on explicit request, the data is written to disk. +

+

+Also, when reading from the stream, first the buffer is checked if there is +any unread data in it. If so, this is read first. If not the buffer is +filled again, and then the data is read from the buffer. +

+

+The size of the buffer is fixed and is set when constructing the file. +

+

+This is useful if you need heavy throughput for your stream, because it +speeds up operations. +

+
+ +link id + +
+ + +Last file open mode + + + +Size of buffer + + + +Pointer to current position in buffer + + + +End of data in buffer. + + + +Actual buffer + + + +Initialize an instance of TBufStream and open the file. + +

+Init instantiates an instance of TBufStream. The name of the +file that contains (or will contain) the data of the stream is given in +FileName. The Mode parameter determines whether a new file +should be created and what access rights you have on the file. +It can be one of the following constants: +

+
+
stCreate
Creates a new file.
+
stOpenRead
Read access only.
+
stOpenWrite
Write access only.
+
stOpen
Read and write access.
+
+

+The Size parameter determines the size of the buffer that will be +created. It should be different from zero. +

+

+For an example see . +

+
+ +On error, Status is set to stInitError, and ErrorInfo +is set to the dos error code. + + + + + +
+ + + +Close the file and cleans up the instance. + +

+Done flushes and closes the file if it was open and cleans up the +instance of TBufStream. +

+

+For an example see . +

+
+ +None. + + + + + + +
+ + + +Flush data and Close the file. + +

+Close flushes and closes the file if it was open, and sets Handle to -1. +Contrary to Done it does not clean up the instance +of TBufStream +

+

+For an example see . +

+
+ +None. + + + + + + +
+ + + +FLush data from buffer, and write it to stream. + +When the stream is in write mode, the contents of the buffer are written to +disk, and the buffer position is set to zero. + +When the stream is in read mode, the buffer position is set to zero. + + +Write errors may occur if the file was in write mode. +see Write for more info on the errors. + + + + + + + + + + + + +Flush buffer, and truncate the file at current position. + +

+If the status of the stream is stOK, then Truncate tries to +flush the buffer, and then truncates the stream size to the current +file position. +

+

+For an example, see . +

+
+ +Errors can be those of Flush or +. + + + + + + +
+ + + +Set current position in file. + +

+If the stream's status is stOK, then Seek sets the +file position to Pos. Pos is a zero-based offset, counted from +the beginning of the file. +

+

+For an example, see ; +

+
+ +In case an error occurs, the stream's status is set to stSeekError, +and the OS error code is stored in ErrorInfo. + + + + + +
+ + + +Open the file if it is closed. + +

+If the stream's status is stOK, and the stream is closed then +Open re-opens the file stream with mode OpenMode. +This call can be used after a Close call. +

+

+For an example, see . +

+
+ +If an error occurs when re-opening the file, then Status is set +to stOpenError, and the OS error code is stored in ErrorInfo + + + + + +
+ + + +Read data from the file to a buffer in memory. + +

+If the Stream is open and the stream status is stOK then +Read will read Count bytes from the stream and place them +in Buf. +

+

+Read will first try to read the data from the stream's internal +buffer. If insufficient data is available, the buffer will be filled before +contiunuing to read. This process is repeated until all needed data +has been read. +

+

+For an example, see . +

+
+ +In case of an error, Status is set to StReadError, and +ErrorInfo gets the OS specific error, or 0 when an attempt was +made to read beyond the end of the stream. + + + + + +
+ + + +Write data to the file from a buffer in memory. + +

+If the Stream is open and the stream status is stOK then +Write will write Count bytes from Buf and place them +in the stream. +

+

+Write will first try to write the data to the stream's internal +buffer. When the internal buffer is full, then the contents will be written +to disk. This process is repeated until all data has been written. +

+

+For an example, see . +

+
+ +In case of an error, Status is set to StWriteError, and +ErrorInfo gets the OS specific error. + + + + + +
+ + + +Stream which keeps data in memory. + +

+The TMemoryStream object implements a stream that stores it's data +in memory. The data is stored on the heap, with the possibility to specify +the maximum amout of data, and the the size of the memory blocks being used. +

+
+ + + +
+ + +Number of allocated memory blocks + + + +Size of one memory block + + + +Total memory size + + + +Pointer to list of allocated blocks. + + + +Initialize memory stream, reserves memory for stream data. + +

+Init instantiates a new TMemoryStream object. The +memorystreamobject will initially allocate at least ALimit bytes memory, +divided into memory blocks of size ABlockSize. +The number of blocks needed to get to ALimit bytes is rounded up. +

+

+By default, the number of blocks is 1, and the size of a block is 8192. This +is selected if you specify 0 as the blocksize. +

+

+For an example, see e.g . +

+
+ +If the stream cannot allocate the initial memory needed for the memory blocks, then +the stream's status is set to stInitError. + + + + +
+ + + +Clean up memory and destroy the object instance. + +

+Done releases the memory blocks used by the stream, and then cleans up +the memory used by the stream object itself. +

+

+For an example, see e.g . +

+
+ +None. + + + + +
+ + + +Set the stream size to the current position. + +Truncate sets the size of the memory stream equal to the current +position. It de-allocates any memory-blocks that are no longer needed, so +that the new size of the stream is the current position in the stream, +rounded up to the first multiple of the stream blocksize. + + +If an error occurs during memory de-allocation, the stream's status is set +to stError + + + + + + + + + + +Read data from the stream to a location in memory. + +

+Read reads Count bytes from the stream to Buf. It updates +the position of the stream. +

+

+For an example, see . +

+
+ +If there is not enough data available, no data is read, and the stream's +status is set to stReadError. + + + + + +
+ + + +Write data to the stream. + +

+Write copies Count bytes from Buf to the stream. It +updates the position of the stream. +

+

+If not enough memory is available to hold the extra Count bytes, +then the stream will try to expand, by allocating as much blocks with +size BlkSize (as specified in the constuctor call +Init) as needed. +

+

+For an example, see . +

+
+ +If the stream cannot allocate more memory, then the status is set to +stWriteError + + + + + +
+ + + +Manage a collection of pointers of objects + +

+The TCollection object manages a collection of pointers or objects. +It also provides a series of methods to manipulate these pointers or +objects. +

+

+Whether or not objects are used depends on the kind of calls you use. +All kinds come in 2 flavors, one for objects, one for pointers. +

+
+
+ + +Pointer to list of items. + + + +Current count of items + + + +Max number of items + + + +Number of pointers to allocate when adding items. + + + +Instantiate a new collection. + +

+Init initializes a new instance of a collection. It sets the (initial) maximum number +of items in the collection to ALimit. ADelta is the increase +size : The number of memory places that will be allocatiod in case ALimit is reached, +and another element is added to the collection. +

+

+For an example, see . +

+
+ +None. + + + + + +
+ + + +Initialize a new collection and load collection from a stream. + +Load initializes a new instance of a collection. It reads from stream +S the item count, the item limit count, and the increase size. After +that, it reads the specified number of items from the stream. + + + +Errors returned can be those of GetItem. + + + + + + + + + + + + +Clean up collection, release all memory. + +

+Done frees all objects in the collection, and then releases all memory +occupied by the instance. +

+

+For an example, see . +

+ +
+ +None. + + + + + +
+ + + +Return the item at a certain index. + +At returns the item at position Index. + + +If Index is less than zero or larger than the number of items +in the collection, seepl{Error}{TCollection.Error} is called with +coIndexError and Index as arguments, resulting in a run-time +error. + + + + + + + + + + +Find the position of a certain item. + +IndexOf returns the index of Item in the collection. +If Item isn't present in the collection, -1 is returned. + + +If the item is not present, -1 is returned. + + + + + + + + + + + + +Read one item off the stream. + +GetItem reads a single item off the stream S, and +returns a pointer to this item. This method is used internally by the Load +method, and should not be used directly. + + +Possible errors are the ones from . + + +, + + + + + +Return last item which matches a test. + +This function returns the last item in the collection for which Test +returns a non-nil result. Test is a function that accepts 1 argument: +a pointer to an object, and that returns a pointer as a result. + + +None. + + + + + + + + + + +Return first item which matches a test. + +This function returns the first item in the collection for which Test +returns a non-nil result. Test is a function that accepts 1 argument: +a pointer to an object, and that returns a pointer as a result. + + +None. + + + + + + + + + + +Remove all >Nil pointers from the collection. + +Pack removes all Nil pointers from the collection, and adjusts +Count to reflect this change. No memory is freed as a result of this +call. In order to free any memory, you can call SetLimit with an +argument of Count after a call to Pack. + + +None. + + + + + + + + + + +Release all objects from the collection. + +FreeAll calls the destructor of each object in the collection. +It doesn't release any memory occumpied by the collection itself, but it +does set Count to zero. + + + + + + + + + + + +Delete all elements from the collection. Objects are not destroyed. + +DeleteAll deletes all elements from the collection. It just sets +the Count variable to zero. Contrary to +FreeAll, DeletAll doesn't call the +destructor of the objects. + + +None. + + + + + + + + + + + +Free item from collection, calling it's destructor. + +Free Deletes Item from the collection, and calls the destructor +Done of the object. + + +If the Item is not in the collection, Error will be called with +coIndexError. + + + + + + + + + + +Insert a new item in the collection at the end. + +Insert inserts Item in the collection. TCollection +inserts this item at the end, but descendent objects may insert it at +another place. + + +None. + + + + + + + + + +Delete an item from the collection, but does not destroy it. + +Delete deletes Item from the collection. It doesn't call the +item's destructor, though. For this the Free +call is provided. + + +If the Item is not in the collection, Error will be called with +coIndexError. + + + + + + + + + + + +Free an item at the indicates position, calling it's destructor. + +AtFree deletes the item at position Index in the collection, +and calls the item's destructor if it is not Nil. + + +If Index isn't valid then Error is called +with CoIndexError. + + + + + + + + + + +Destroy a non-nil item. + +

+FreeItem calls the destructor of Item if it is not +nil. +

+ +This function is used internally by the TCollection object, and should not be +called directly. + +
+ +None. + + + + + +
+ + + +Delete item at certain position. + +AtDelete deletes the pointer at position Index in the +collection. It doesn't call the object's destructor. + + +If Index isn't valid then Error is called +with CoIndexError. + + + + + + + + + +Execute procedure for each item in the list. + +

+ForEach calls Action for each element in the collection, +and passes the element as an argument to Action. +

+

+Action is a procedural type variable that accepts a pointer as an +argument. +

+
+ +None. + + + + + + +
+ + + + +Set maximum number of elements in the collection. + +

+SetLimit sets the maximum number of elements in the collection. +ALimit must not be less than Count, and should not be larger +than MaxCollectionSize +

+

+For an example, see Pack. +

+
+ +None. + + + + +
+ + + +Set error code. + +

+Error is called by the various TCollection methods +in case of an error condition. The default behaviour is to make +a call to RunError with an error of 212-Code. +

+

+This method can be overridden by descendent objects to implement +a different error-handling. +

+
+ + + + + +
+ + +Set collection item, overwriting an existing value. + +

+AtPut sets the element at position Index in the collection +to Item. Any previous value is overwritten. +

+

+For an example, see Pack. +

+
+ +If Index isn't valid then Error is called +with CoIndexError. + + + +
+ + + +Insert an element at a certain position in the collection. + +AtInsert inserts Item in the collection at position Index, +shifting all elements by one position. In case the current limit is reached, +the collection will try to expand with a call to SetLimit + + +If Index isn't valid then Error is called +with CoIndexError. If the collection fails to expand, then +coOverFlow is passd to Error. + + + + + + + + + + +Write collection to a stream. + +

+Store writes the collection to the stream S. It does +this by writeing the current Count, Limit and Delta +to the stream, and then writing each item to the stream. +

+

+The contents of the stream are then suitable for instantiating another +collection with Load. +

+

+For an example, see . +

+
+ +Errors returned are those by . + + + + + +
+ + + +Put one item on the stream + +PutItem writes Item to stream S. This method is used +internaly by the TCollection object, and should not be called +directly. + + +Errors are those returned by . + + +Store +GetItem + + + + +Abstract sorted collection. + +

+TSortedCollection is an abstract class, implementing a sorted +collection. You should never use an instance of TSortedCollection +directly, instead you should declare a descendent type, and override the +Compare method. +

+

+Because the collection is ordered, TSortedCollection overrides some +TCollection methods, to provide faster routines for lookup. +

+

+The Compare method decides how elements +in the collection should be ordered. Since TCollection has no way +of knowing how to order pointers, you must override the compare method. +

+

+Additionally, TCollection provides a means to filter out duplicates. +if you set Duplicates to False (the default) then duplicates +will not be allowed. +

+

+The example below defines a descendent of TSortedCollection which +is used in the examples. +

+
+ +
+ + +If True duplicate strings are allowed in the collection. + + + +Instantiates a new instance of a TSortedCollection + +

+Init calls the inherited constuctor (see ) and +sets the Duplicates flag to false. +

+

+You should not call this method directly, since TSortedCollection is a +abstract class. Instead, the descendent classes should call it via the +inherited keyword. +

+
+ +None. + + + + + +
+ + +Instantiates a new instance of a TSortedCollection and +loads it from stream. + +

+Load calls the inherited constuctor (see ) and +reads the Duplicates flag from the stream.. +

+

+You should not call this method directly, since TSortedCollection is a +abstract class. Instead, the descendent classes should call it via the +inherited keyword. +

+

+For an example, see . +

+
+ +None. + + + + + +
+ + + +Return the key of an item + +

+KeyOf returns the key associated with Item. +TSortedCollection returns the item itself as the key, descendent +objects can override this method to calculate a (unique) key based on the +item passed (such as hash values). +

+

+Keys are used to sort the objects, they are used to search and sort +the items in the collection. If descendent types override this method then +it allows possibly for faster search/sort methods based on keys rather than +on the objects themselves. +

+
+ +None. + + + + + +
+ + +Return index of an item in the collection. + +

+IndexOf returns the index of Item in the collection. It searches +for the object based on it's key. If duplicates are allowed, then it returns +the index of last object that matches Item. +

+

+In case Item is not found in the collection, -1 is returned. +

+

+For an example, see +

+
+ +None. + + + + + +
+ + + +Compare two items in the collection. + +

+Compare is an abstract method that should be overridden by descendent +objects in order to compare two items in the collection. This method is used +in the Search method and in the +Insert method to determine the ordering of +the objects. +

+

+The function should compare the two keys of items and return the following +function results: +

+
+
Result < 0
If Key1 is logically before Key2 (Key1<Key2)
+
Result = 0
If Key1 and Key2 are equal. (Key1=Key2)
+
Result > 0
If Key1 is logically after Key2 (Key1>Key2)
+
+
+ +An 'abstract run-time error' will be generated if you call +TSortedCollection.Compare directly. + + + + + + +
+ + + +Search for item with given key. + +

+Search looks for the item with key Key and returns the position +of the item (if present) in the collection in Index. +

+

+Instead of a linear search as TCollection does, TSortedCollection +uses a binary search based on the keys of the objects. It uses the +Compare function to implement this +search. +

+

+If the item is found, Search returns True, otherwise False +is returned. +

+
+ +None. + + + + + +
+ + + +Insert new item in collection. + +

+Insert inserts an item in the collection at the correct position, such +that the collection is ordered at all times. You should never use +Atinsert, since then the collection ordering +is not guaranteed. +

+

+If Item is already present in the collection, and Duplicates is +False, the item will not be inserted. +

+
+ +None. + + + + + +
+ + + + +Write the collection to the stream. + +

+Store writes the collection to the stream S. It does this by +calling the inherited , and then writing the +Duplicates flag to the stream. +

+

+After a Store, the collection can be loaded from the stream with the +constructor Load +

+

+For an example, see . +

+
+ +Errors can be those of . + + + + +
+ + + +Collection of pascal strings. + +

+The TStringCollection object manages a sorted collection of pascal +strings. +To this end, it overrides the Compare +method of TSortedCollection, and it introduces methods to read/write +strings from a stream. +

+
+
+ + +Get string from the stream. + +

+GetItem reads a string from the stream S and returns a pointer +to it. It doesn't insert the string in the collection. +

+

+This method is primarily introduced to be able to load and store the +collection from and to a stream. +

+
+ +The errors returned are those of . + + + + +
+ + +Compare two strings in the collection. + +

+TStringCollection overrides the Compare function so it compares +the two keys as if they were pointers to strings. The compare is done case +sensitive. It returns the following results: +

+
+
-1
if the first string is alphabetically earlier than the second string.
+
0
if the two strings are equal.
+
1
if the first string is alphabetically later than the second string.
+
+
+ +None. + + + + + +
+ + + + +Dispose a string in the collection from memory. + +TStringCollection overrides FreeItem so that the string pointed +to by Item is disposed from memory. + + +None. + + + + + + + +Write a string to the stream. + +

+PutItem writes the string pointed to by Item to the stream +S. +

+

+This method is primarily used in the Load and Store methods, +and should not be used directly. +

+
+ +Errors are those of . + + + + +
+ + + +Collection of null-terminated strings + +

+The TStrCollection object manages a sorted collection +of null-terminated strings (pchar strings). +To this end, it overrides the Compare +method of TSortedCollection, and it introduces methods to read/write +strings from a stream. +

+
+
+ + +Read a null-terminated string from the stream. + +

+GetItem reads a null-terminated string from the stream S +and returns a pointer to it. It doesn't insert the string in the +collection. +

+

+This method is primarily introduced to be able to load and store the +collection from and to a stream. +

+
+ +The errors returned are those of . + + + + +
+ + +Compare two strings in the collection. + +

+TStrCollection overrides the Compare function so it compares +the two keys as if they were pointers to strings. The compare is done case +sensitive. It returns +

+
+
-1
if the first string is alphabetically earlier than the second string.
+
0
if the two strings are equal.
+
1
if the first string is alphabetically later than the second string.
+
+
+ +None. + + + + + +
+ + +Free null-terminated string from the collection. + +TStrCollection overrides FreeItem so that the string pointed +to by Item is disposed from memory. + + +None. + + + + + + + +Write a null-terminated string to the stream. + +

+PutItem writes the string pointed to by Item to the stream +S. +

+

+This method is primarily used in the Load and Store methods, +and should not be used directly. +

+
+ +Errors are those of . + + + + +
+ + +Unsorted string collection + +

+The TUnSortedStrCollection object manages an unsorted list of strings. +To this end, it overrides the method to add +strings at the end of the collection, rather than in the alphabetically +correct position. +

+

+Take care, the Search and +IndexOf methods will not work on an unsorted +string collection. +

+
+
+ + +Insert a new string in the collection. + +Insert inserts a string at the end of the collection, instead +of on it's alphabetical place, resulting in an unsorted collection of +strings. + + +None. + + + + + + + + + + +Collection of resource names + +

+A TResourceCollection manages a collection of resource names. +It stores the position and the size of a resource, as well as the name of +the resource. It stores these items in records that look like this: +

+ +TYPE + TResourceItem = packed RECORD + Posn: LongInt; + Size: LongInt; + Key : String; + End; + PResourceItem = ^TResourceItem; + +

+It overrides some methods of TStringCollection in order to accomplish +this. +

+ +Remark that the TResourceCollection manages the names of the +resources and their assiciated positions and sizes, it doesn't manage +the resources themselves. + +
+
+ + +Return the key of an item in the collection. + +KeyOf returns the key of an item in the collection. For resources, the +key is a pointer to the string with the resource name. + + +None. + + + + + + + +Read an item from the stream. + +

+GetItem reads a resource item from the stream S. It reads the +position, size and name from the stream, in that order. It DOES NOT read the +resource itself from the stream. +

+

+The resulting item is not inserted in the collection. This call is manly for +internal use by the method. +

+
+ +Errors returned are those by + + + + + +
+ + +Release memory occupied by item. + +

+FreeItem releases the memory occupied by Item. It de-allocates +the name, and then the resourceitem record. +

+

+It does NOT remove the item from the collection. +

+
+ +None. + + + + +
+ + +Write an item to the stream. + +

+PutItem writes Item to the stream S. It does this by +writing the position and size and name of the resource item to the stream. +

+

+This method is used primarily by the Store +method. +

+
+ +Errors returned are those by . + + + + +
+ + + +Resource file + + represents the resources in a binary file image. + + + + +Actual file stream + +contains the (file) stream that has the executable image and +the resources. It can be initialized by the Init +constructor call. + + + + +Have resources changed ? + +Modified is set to True if one of the resources has been changed. +It is set by the SwitchTo, +Delete and Put +methods. Calling Flush will clear the +Modified flag. + + + + +Instantiate a new instance. + +

+Init instantiates a new instance of a TResourceFile object. +If AStream is not nil then it is considered as a stream describing an +executable image on disk. +

+

+Init will try to position the stream on the start of the resources section, +and read all resources from the stream. +

+
+ +None. + + + + +
+ + +Destroy the instance and remove it from memory. + +Done cleans up the instance of the TResourceFile Object. +If Stream was specified at initialization, then Stream is +disposed of too. + + +None. + + + + + + + +Number of resources in the file + +Count returns the number of resources. If no resources were +read, zero is returned. + + +None. + + + + + + + +Return the key of the item at a certain position. + +KeyAt returns the key (the name) of the I-th resource. + + +In case I is invalid, TCollection.Error will be executed. + + + + + + + +Return a resource by key name. + +Get returns a pointer to a instance of a resource identified by +Key. If Key cannot be found in the list of resources, then +Nil is returned. + + +Errors returned may be those by TStream.Get + + + + + + +Write resources to a new stream. + +

+SwitchTo switches to a new stream to hold the resources in. +AStream will be the new stream after the call to SwitchTo. +

+

+If Pack is true, then all the known resources will be copied from +the current stream to the new stream (AStream). If Pack is +False, then only the current resource is copied. +

+

+The return value is the value of the original stream: Stream. +

+

+The Modified flag is set as a consequence of this call. +

+
+ +Errors returned can be those of and +. + + + + +
+ + +Writes the resources to the stream. + +If the Modified flag is set to True, then Flush +writes the resources to the stream Stream. It sets the Modified +flag to true after that. + + +Errors can be those by and . + + + + + + + +Delete a resource from the file + +Delete deletes the resource identified by Key from the +collection. It sets the Modified flag to true. + + +None. + + + + + + + +Set a resource by key name. + +Put sets the resource identified by Key to Item. +If no such resource exists, a new one is created. The item is written +to the stream. + + +Errors returned may be those by and TStream.Seek + + +Get + + + + +Collection of strings + +

+A TStringList object can be used to read a collection of strings +stored in a stream. If you register this object with the +function, you cannot register the TStrListMaker object. +

+
+
+ + +Load stringlist from stream. + +The Load constructor reads the TStringList object from the +stream S. It also reads the descriptions of the strings from the +stream. The string descriptions are stored as an array of +TstrIndexrec records, where each record describes a string on the +stream. These records are kept in memory. + + +If an error occurs, a stream error is triggered. + + + + + + + +Clean up the instance + +The Done destructor frees the memory occupied by the string +descriptions, and destroys the object. + + +None. + + +Load + + + + + +Return a string by key name + +Get reads the string with key Key from the list of strings on the +stream, and returns this string. If there is no string with such a key, an +empty string is returned. + + +If no string with key Key is found, an empty string is returned. +A stream error may result if the stream doesn't contain the needed strings. + + + + + + + +Generate a stream with strings, readable by + +

+The TStrListMaker object can be used to generate a stream with +strings, which can be read with the TStringList object. +If you register this object with the +function, you cannot register the TStringList object. +

+
+
+ + +Instantiate a new instance of TStrListMaker + +

+The Init constructor creates a new instance of the TstrListMaker +object. It allocates AStrSize bytes on the heap to hold all the +strings you wish to store. It also allocates enough room for +AIndexSize key description entries (of the type TStrIndexrec). +

+

+AStrSize must be large enough to contain all the strings you wish to +store. If not enough memory is allocated, other memory will be overwritten. +The same is true for AIndexSize : maximally AIndexSize strings +can be written to the stream. +

+
+ +None. + + + + + +
+ + +Clean up the instance and free all related memory. + +The Done destructor de-allocates the memory for the index description +records and the string data, and then destroys the object. + + +None. + + + + + + + + +Add a new string to the list with associated key. + +Put adds they string S with key Key to the collection of +strings. This action doesn't write the string to a stream. To write the +strings to the stream, see the Store method. + + +None. + + + + + + + +Write the strings to the stream. + +Store writes the collection of strings to the stream S. +The collection can then be read with the TStringList object. + + +A stream error may occur when writing the strings to the stream. + + + + + + + + +Value for invalid handle. Initial value for file stream handles or when the stream is closed. + + + +
+
+
\ No newline at end of file diff --git a/docs/sockets.xml b/docs/sockets.xml new file mode 100644 index 0000000000..b957160552 --- /dev/null +++ b/docs/sockets.xml @@ -0,0 +1,1453 @@ + + + + + + +TCP/IP Sockets functionality unit + +This document describes the SOCKETS unit for Free Pascal. +it was written for linux by Michael Van Canneyt, and ported to Windows +by Florian Klaempfl. + + + +Type of socket: stream (connection) type socket (TCP) + + +Type of socket: datagram (conn.less) socket (UDP) + + +Type of socket: raw socket + + +Type of socket: reliably-delivered message + + +Type of socket: sequential packet socket + + +Type of socket: Packet + + + +Socket domain: Not specified + + +Socket domain: Unix domain sockets + + +Socket domain: Internet IP Protocol + + +Socket domain: Amateur Radio AX.25 + + +Socket domain: Novell IPX + + +Socket domain: Appletalk DDP + + +Socket domain: Amateur radio NetROM + + +Socket domain: Multiprotocol bridge + + +Socket domain: Reserved for Werner's ATM + + +Socket domain: Reserved for X.25 project + + +Socket domain: IP version 6 + + +Socket domain: Maximum value + + +Protocol family: Unspecified + + +Protocol family: Internet IP Protocol + + +Protocol family: Amateur Radio AX.25 + + +Protocol family: Novell IPX + + +Protocol family: Appletalk DDP + + +Protocol family: Unix domain sockets + + +Protocol family:Amateur radio NetROM + + +Protocol family: Multiprotocol bridge + + +Protocol family: Reserved for Werner's ATM + + +Protocol family: Reserved for X.25 project + + +Protocol family: IP version 6 + + +Protocol family: Maximum value + + + +General socket adress record + +TUnixSockAddr is used to store a general socket addres for the +, and calls. + + + +Address family + + +Addres data + + + +Unix socket address record. + +TUnixSockAddr is used to store a UNIX socket addres for the +, and calls. + + + + +Address family + + +File name + + + +Internet socket address record + +TUnixSockAddr is used to store a INET socket addres for the +, and calls. + + + + +Address family + + +Port number + + +IP address + + +Pad data. Do not use. + + + +Type returned by the call. + + + +Address family: ? + + + + +Address family: ? + + + + +Address family: ? + + + + +Address family: ? + + + + +Address family: ? + + + + +Address family: ? + + + + +Address family: ? + + + + +Address family: ? + + + + +Address family: ? + + + + +Addresss family: Linux SNA project + + + + +Address family: Reserved for DECnet project. + + + + +Address family: ? + + + + +Address family: ? + + + + +Address family: ? + + + + +Address family: Alias to emulate 4.4BSD. + + + + +Address family: ? + + + + +Address family: ? + + + + +Address family: ? + + + + +Address family: ? + + + + +Address family: ? + + + + +Address family: ? + + + + +Address family: ? + + + + +Address family: ? + + + + +Address family: ? + + + + +Address family: key management API. + + + + +Address family: ? + + + + +Address family: ? + + + + +Address family: ? + + + + +Address family: ? + + + + +Maximum socket address length for call. + + + + + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol Family: Linux SNA project + + + + +Protocol Family: DECNET project + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol family: Key management API + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Protocol Family: ? + + + + +Socket option level: Socket level + + + + +Socket option level: debug + + + + +Socket option: Reuse address + + + + +Socket option: Type + + + + +Socket option: Error + + + + +Socket option: Don't route + + + + +Socket option: Broadcast + + + + +Socket option: Send buffer + + + + +Socket option: receive buffer + + + + +Socket option: keep alive + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Socket option: ? + + + + +Shutdown read part of full duplex socket + + + + +Shutdown write part of full duplex socket + + + + +Shutdown read and write part of full duplex socket + + + + +Address family type + + + + +Protocol family: Unix socket + + + + +Protocol family: Unix socket (alias) + + + + +Address family: Unix socket + + + + +Address family: Unix socket (alias) + + + + +Receive flags: receive out-of-band data. + + + + +Receive flags: peek at data, don't remove from buffer. + + + + +Send flags: don't use gateway + + + + +Receive flags: ? + + + + +Receive flags: Control Data was discarded (buffer too small) + + + + +Receive flags: ? + + + + +Receive flags: packet Data was discarded (buffer too small) + + + + +Receive flags: Non-blocking operation request. + + + + +Receive flags: End of record + + + + +Receive flags: Wait till operation completed. + + + + +Receive flags: ? + + + + +Receive flags: ? + + + + +Send flags: Conform connection + + + + +Receive flags: ? + + + + +Receive flags: ? + + + + +Receive flags: Suppress SIG_PIPE signal. + + + + +Receive flags: ? + + + + +Input socket in socket pair. + + + + +Output socket in socket pair + + + + +General inet socket address. + + + + +Actual address + + + + +General socket address: Address family + + + + +General socket address: Address data + + + + +Pointer to + + + + +Pointer to + + + + +Alias for + + + + +Pointer to + + + + +Record for IPV6 socket address. + + + + +Address family + + + + +Port + + + + +Flow information. + + + + +IPV6 address + + + + + + + + + +Alias for + + + + +Pointer to + + + + +Array of sockets, used in call. + + + + +Contains the error code for the last socket operation. + +SocketError contains the error code for the last socket +operation. It can be examined to return the last socket error. + + + + + +Alias for the call + + + + +Alias for the call + + + + +Alias for the call + + + + +Alias for the call + + + + +Alias for the call + + + + +Alias for the call + + + + +Alias for the call + + + + +Alias for the call + + + + +Alias for the call + + + + +Alias for the call + + + + +Alias for the call + + + + +Alias for the call + + + + +Alias for the call + + + + +Alias for the call + + + + +Alias for the call + + + + +Closes a socket handle. + +CloseSocket closes a socket handle. It returns 0 if the socket +was closed succesfully, -1 if it failed. + + +On error, -1 is returned. + + + + + + + + +Send data through an unconnected socket to an address. + +SendTo sends data from buffer Buf with length +Buflen through socket Sock with options +Flags. The data is sent to address Addr, which has +length AddrLen + + +On error, -1 is returned. + + + + + + + + + + +Receive data from an unconnected socket + +RecvFrom receives data in buffer Buf with maximum +length BufLen from socket Sock. +Receipt is controlled by options in Flags. Addr will +be filled with the address from the sender, and will have length +The function returns the number of bytes received, or -1 on error. +AddrLen. + + +On error, -1 is returned. + + + + + + + + + +Accept a connection from a socket. + +

+FPAccept accepts a connection from a socket Sock, which was +listening for a connection. If a connection is accepted, a file descriptor +is returned. On error -1 is returned. The returned socket may NOT +be used to accept more connections. The original socket remains open. +

+

+The Accept call fills the address of the connecting entity in +Addr, and sets its length in Addrlen. Addr should +be pointing to enough space, and Addrlen should be set to the +amount of space available, prior to the call. +

+

+The alternate forms of the command, with the +Text or File parameters are equivalent +to subsequently calling the regular function and the + or functions. +These functions return True if successful, False otherwise. +

+
+ +

+On error, -1 is returned, and errors are reported in +SocketError, and include the following: +

+
+
SYS_EBADF
The socket descriptor is invalid.
+
SYS_ENOTSOCK
The descriptor is not a socket.
+
SYS_EOPNOTSUPP
The socket type doesn't support the Listen operation.
+
SYS_EFAULT
Addr points outside your address space.
+
SYS_EWOULDBLOCK
The requested operation would block the process.
+
+
+ + + + + + +
+ + +Bind a socket to an address. + +

+Bind binds the socket Sock to address Addr. Addr +has length Addrlen. +The function returns True if the call was succesful, False if +not. +

+

+The form of the Bind command with the +is equivalent to subsequently calling and the +regular Bind function. +The function returns True if successfull, False otherwise. +

+
+ +

+Errors are returned in SocketError and include the following: +

+
+
SYS_EBADF
The socket descriptor is invalid.
+
SYS_EINVAL
The socket is already bound to an address,
+
SYS_EACCESS
Address is protected and you don't have permission to open it.
+
+

+More arrors can be found in the Unix man pages. +

+
+ + + +
+ + +Open a connection to a server socket. + +

+Connect opens a connection to a peer, whose address is described by +Addr. AddrLen contains the length of the address. +The type of Addr depends on the kind of connection you're trying to +make, but is generally one of TSockAddr or TUnixSockAddr. +

+

+The forms of the command with the Text or +File arguments are equivalent to subsequently calling the regular Connect +function and the or functions. +These functions return True if successfull, False otherwise. +

+

+The Connect function returns a file descriptor if the call +was successfull, -1 in case of error. +

+
+ +On error, -1 is returned and errors are reported in +SocketError. + + + + + + + + +
+ + +Return the name (address) of the connected peer. + +

+GetPeerName returns the name of the entity connected to the +specified socket Sock. The Socket must be connected for this call to +work. +

+

+Addr should point to enough space to store the name, the +amount of space pointed to should be set in Addrlen. +When the function returns succesfully, Addr will be filled with the +name, and Addrlen will be set to the length of Addr. +

+
+ +

+Errors are reported in SocketError, and include the following: +

+
+
SYS_EBADF
The socket descriptor is invalid.
+
SYS_ENOBUFS
The system doesn't have enough buffers to perform the operation.
+
SYS_ENOTSOCK
The descriptor is not a socket.
+
SYS_EFAULT
Addr points outside your address space.
+
SYS_ENOTCONN
The socket isn't connected.
+
+
+ + + + +
+ + +Return name of socket. + +GetSockName returns the current name of the specified socket +Sock. Addr should point to enough space to store the name, the +amount of space pointed to should be set in Addrlen. +When the function returns succesfully, Addr will be filled with the +name, and Addrlen will be set to the length of Addr. + + +

+Errors are reported in SocketError, and include the following: +

+
+
SYS_EBADF
The socket descriptor is invalid.
+
SYS_ENOBUFS
The system doesn't have enough buffers to perform the operation.
+
SYS_ENOTSOCK
The descriptor is not a socket.
+
SYS_EFAULT
Addr points outside your address space.
+
+
+ + + +
+ + +Get current socket options + +

+GetSocketOptions gets the connection options for socket Sock. +The socket may be obtained from different levels, indicated by Level, +which can be one of the following: +

+
+
SOL_SOCKET
From the socket itself.
+
XXX
set Level to XXX, the protocol number of the protocol +which should interprete the option.
+
+

+For more information on this call, refer to the unix manual page \seem{getsockopt}{2}. +

+
+ +

+Errors are reported in SocketError, and include the following: +

+
+
SYS_EBADF
The socket descriptor is invalid.
+
SYS_ENOTSOCK
The descriptor is not a socket.
+
SYS_EFAULT
OptVal points outside your address space.
+
+
+ + + +
+ + +Listen for connections on socket. + +

+Listen listens for up to MaxConnect connections from socket +Sock. The socket Sock must be of type SOCK_STREAM or +Sock_SEQPACKET. +

+

+The function returns True if a connection was accepted, False +if an error occurred. +

+
+ +

+Errors are reported in SocketError, and include the following: +

+
+
SYS_EBADF
The socket descriptor is invalid.
+
SYS_ENOTSOCK
The descriptor is not a socket.
+
SYS_EOPNOTSUPP
The socket type doesn't support the Listen operation.
+
+
+ + + + + +
+ + +Receive data on socket + +

+Recv reads at most Addrlen bytes from socket Sock into +address Addr. The socket must be in a connected state. +Flags can be one of the following: +

+
+
1
Process out-of band data.
+
4
Bypass routing, use a direct interface.
+
??
Wait for full request or report an error.
+
+

+The functions returns the number of bytes actually read from the socket, or +-1 if a detectable error occurred. +

+
+ +

+Errors are reported in SocketError, and include the following: +

+
+
SYS_EBADF
The socket descriptor is invalid.
+
SYS_ENOTCONN
The socket isn't connected.
+
SYS_ENOTSOCK
The descriptor is not a socket.
+
SYS_EFAULT
The address is outside your address space.
+
SYS_EMSGSIZE
The message cannot be sent atomically.
+
SYS_EWOULDBLOCK
The requested operation would block the process.
+
SYS_ENOBUFS
The system doesn't have enough free buffers available.
+
+
+ + + +
+ + +Send data through socket + +

+Send sends AddrLen bytes starting from address Addr +to socket Sock. Sock must be in a connected state. +The function returns the number of bytes sent, or -1 if a detectable +error occurred. +

+

+Flags can be one of the following: +

+
+
1
Process out-of band data.
+
4
Bypass routing, use a direct interface.
+
+
+ +

+Errors are reported in SocketError, and include the following: +

+
+
SYS_EBADF
The socket descriptor is invalid.
+
SYS_ENOTSOCK
The descriptor is not a socket.
+
SYS_EFAULT
The address is outside your address space.
+
SYS_EMSGSIZE
The message cannot be sent atomically.
+
SYS_EWOULDBLOCK
The requested operation would block the process.
+
SYS_ENOBUFS
The system doesn't have enough free buffers available.
+
+
+ + + +
+ + +Set socket options. + +

+SetSocketOptions sets the connection options for socket Sock. +The socket may be manipulated at different levels, indicated by Level, +which can be one of the following: +

+
+
SOL_SOCKET
To manipulate the socket itself.
+
XXX
set Level to XXX, the protocol number of the protocol +which should interprete the option.
+
+

+For more information on this call, refer to the unix manual page +setsockopt +

+
+ +

+Errors are reported in SocketError, and include the following: +

+
+
SYS_EBADF
The socket descriptor is invalid.
+
SYS_ENOTSOCK
The descriptor is not a socket.
+
SYS_EFAULT
OptVal points outside your address space.
+
+
+ + + +
+ + +Close one end of full duplex connection. + +

+ShutDown closes one end of a full duplex socket connection, described +by Sock. The parameter How determines how the connection +will be shut down, and can be one of the following: +

+
+
0
Further receives are disallowed.
+
1
Further sends are disallowed.
+
2
Sending nor receiving are allowed.
+
+

+On succes, the function returns 0, on error -1 is returned. +

+
+ +

+SocketError is used to report errors, and includes the following: +

+
+
SYS_EBADF
The socket descriptor is invalid.
+
SYS_ENOTCONN
The socket isn't connected.
+
SYS_ENOTSOCK
The descriptor is not a socket.
+
+
+ + + + +
+ + +Convert socket to untyped file descriptors + +Sock2File transforms a socket Sock into 2 Pascal file +descriptors of type File, one for reading from the socket +(SockIn), one for writing to the socket (SockOut). + + +None. + + + + + + + + +Convert socket to text file descriptors + +Sock2Text transforms a socket Sock into 2 Pascal file +descriptors of type Text, one for reading from the socket +(SockIn), one for writing to the socket (SockOut). + + +None. + + + + + + + + +Create new socket + +

+Socket creates a new socket in domain Domain, from type +SocketType using protocol Protocol. +The Domain, Socket type and Protocol can be specified using predefined +constants (see the section on constants for available constants) +If succesfull, the function returns a socket descriptor, which can be passed +to a subsequent call. If unsuccesfull, the function returns -1. +

+

+for an example, see . +

+
+ +

+Errors are returned in SocketError, and include the follwing: +

+
+
SYS_EPROTONOSUPPORT
The protocol type or the specified protocol is not +supported within this domain.
+
SYS_EMFILE
The per-process descriptor table is full.
+
SYS_ENFILE
The system file table is full.
+
SYS_EACCESS
Permission to create a socket of the specified type +and/or protocol is denied.
+
SYS_ENOBUFS
Insufficient buffer space is available. The socket +cannot be created until sufficient resources are freed.
+
+
+ +, \seem{socket}{2} + +
+ + + +Create socket pair + +SocketPair creates 2 sockets in domain Domain, from type +SocketType and using protocol Protocol. +The pair is returned in Pair, and they are indistinguishable. +The function returns -1 upon error and 0 upon success. + + +Errors are reported in SocketError, and are the same as in + + + + + + + +Convert path to + +Str2UnixSockAddr transforms a Unix socket address in a string to a +TUnixSockAddr structure which can be passed to the call. + + +None. + + + + + + + + +
+
+
\ No newline at end of file diff --git a/docs/video.xml b/docs/video.xml new file mode 100644 index 0000000000..67ba835ebd --- /dev/null +++ b/docs/video.xml @@ -0,0 +1,1001 @@ + + + + + +Screen handling unit + + +

+The Video unit implements a screen access layer which is system +independent. It can be used to write on the screen in a system-independent +way, which should be optimal on all platforms for which the unit is +implemented. +

+

+The working of the Video is simple: After calling , +the array VideoBuf contains a representation of the video screen of +size ScreenWidth*ScreenHeight, going from left to right and top to +bottom when walking the array elements: VideoBuf[0] contains the +character and color code of the top-left character on the screen. +VideoBuf[ScreenWidth] contains the data for the character in the +first column of the second row on the screen, and so on. +

+

+To write to the 'screen', the text to be written should be written to the +VideoBuf array. Calling will then cp the text to +the screen in the most optimal way. (an example can be found further on). +

+

+The color attribute is a combination of the foreground and background color, +plus the blink bit. The bits describe the various color combinations: +

+
+
bits 0-3
+
The foreground color. Can be set using all color constants. +
+
bits 4-6
+
The background color. Can be set using a subset of the +color constants. +
+
bit 7
+
The blinking bit. If this bit is set, the character will appear +blinking. +
+
+

+Each possible color has a constant associated with it, see the constants +section for a list of constants. +

+

+The foreground and background color can be combined to a color attribute +with the following code: +

+ +Attr:=ForeGroundColor + (BackGroundColor shl 4); + +

+The color attribute can be logically or-ed with the blink attribute to +produce a blinking character: +

+ + Atrr:=Attr or blink; + +

+But not all drivers may support this. +

+

+The contents of the VideoBuf array may be modified: This is 'writing' +to the screen. As soon as everything that needs to be written in the array +is in the VideoBuf array, calling UpdateScreen will copy the +contents of the array screen to the screen, in a manner that is as efficient +as possible. +

+

+The updating of the screen can be prohibited to optimize performance; To +this end, the function can be used: This will +increment an internal counter. As long as the counter differs from zero, +calling will not do anything. The counter can be +lowered with . When it reaches zero, the next call +to will actually update the screen. This is useful when +having nested procedures that do a lot of screen writing. +

+

+The video unit also presents an interface for custom screen drivers, thus +it is possible to override the default screen driver with a custom screen +driver, see the call. The current video driver can +be retrieved using the call. +

+ +The video unit should not be used together with the crt unit. +Doing so will result in very strange behaviour, possibly program crashes. + +
+ + +Black color attribute + + + +Blue color attribute + + + +Green color attribute + + + +Cyan color attribute + + + +Red color attribute + + + +Magenta color attribute + + + +Brown color attribute + + + +Light gray color attribute + + + +Dark gray color attribute + + + +Light Blue color attribute + + + +Light green color attribute + + + +Light cyan color attribute + + + +Light red color attribute + + + +Light magenta color attribute + + + +Yellow color attribute + + + +White color attribute + + + +Blink attribute + + + +Video driver supports underline attribute + + + +Video driver supports blink attribute + + + +Video driver supports color + + + +Video driver supports changing screen font. + + + +Video driver supports changing mode + + + +Video driver supports changing cursor shape. + + + +Hide cursor + + + +Underline cursor + + + +Block cursor + + + +Half block cursor + + + +No errors occurred + + + +Base value for video errors + + + +No error + + + +Video driver initialization error. + + + +Unsupported video function + + + +Invalid video mode + + + + +Current screen Width + + + + +Current screen height + + + +Only use low ascii characters + + + +Disable transformation of control characters on unix terminals + + + +Maximum screen buffer width. + + + +Error code returned by the last operation. + + + +Pointer to extended error information. + + + +Error handler routine + +The ErrorHandler variable can be set to a custom-error handling +function. It is set by default to the function. + + + + + +The TVideoMode record describes a videomode. Its fields are +self-explaining: Col,Row describe the number of columns and +rows on the screen for this mode. Color is True if this mode +supports colors, or False if not. + + + + +Pointer to record. + + + +Video mode selection callback prototype. + + + +One cell (=screen position) in the video buffer + +TVideoCell describes one character on the screen. One of the bytes +contains the color attribute with which the character is drawn on the screen, +and the other byte contains the ASCII code of the character to be drawn. The +exact position of the different bytes in the record is operating system specific. +On most little-endian systems, the high byte represents the color attribute, +while the low-byte represents the ASCII code of the character to be drawn. + + + + +Pointer type to + + + +Screen array type + +The TVideoBuf type represents the screen. + + + + +Pointer type to + + + +Type used to report and respond to error conditions + + + +retry the operation + + + +abort and return error code + + + +abort without returning an errorcode. + + + +Error handler prototype + +

+The TErrorHandler function is used to register an own error +handling function. It should be used when installing a custom error +handling function, and must return one of the above values. +

+

+Code should contain the error code for the error condition, +and the Info parameter may contain any data type specific to +the error code passed to the function. +

+
+
+ + +Video driver record + +

+TVideoDriver record can be used to install a custom video +driver, with the call. +

+

+An explanation of all fields can be found there. +

+
+
+ + +Indicate whether current screen supports colors + +ScreenColor indicates whether the current screen supports colors. + + + + +Current write cursor X position. + +Current horizontal position in the screen where items will be written. + + + + +Current write cursor Y position. + +Current vertical position in the screen where items will be written. + + + + +Current screen image. + +VideoBuf forms the heart of the Video unit: This +variable represents the physical screen. Writing to this +array and calling will write the actual characters +to the screen. + + + + +Last written screen image. + +

+The OldVideoBuf contains the state of the video screen after the last +screen update. The function uses this array to decide +which characters on screen should be updated, and which not. +

+

+Note that the OldVideoBuf array may be ignored by some drivers, so +it should not be used. The Array is in the interface section of the video +unit mainly so drivers that need it can make use of it. +

+
+
+ + +Size of the screen image. +Current size of the video buffer pointed to by + + + +Clear the video screen. + +ClearScreen clears the entire screen, and calls +after that. This is done by writing spaces to all character cells of the +video buffer in the default color (lightgray on black, color attribute \$07). + + +None. + + + + + + + + + + +Default error handling routine. + +DefaultErrorHandler is the default error handler used by the video +driver. It simply sets the error code AErrorCode and AErrorInfo +in the global variables ErrorCode and ErrorInfo and returns +errContinue. + + +None. + + + + + + +Disable video driver. + +

+DoneVideo disables the Video driver if the video driver is active. If +the videodriver was already disabled or not yet initialized, it does +nothing. Disabling the driver means it will clean up any allocated +resources, possibly restore the screen in the state it was before +InitVideo was called. Particularly, the VideoBuf and +OldVideoBuf arrays are no longer valid after a call to +DoneVideo. +

+

+The DoneVideo should always be called if InitVideo was called. +Failing to do so may leave the screen in an unusable state after the program +exits. +

+

+For an example, see most other functions. +

+
+ +Normally none. If the driver reports an error, this is done through the +ErrorCode variable. + + + + +
+ + +Get current driver capabilities. + +

+GetCapabilities returns the capabilities of the current driver. +It is an or-ed combination of the following constants: +

+
+
cpUnderLine
+
cpBlink
+
cpColor
+
cpChangeFont
+
cpChangeMode
+
cpChangeCursor
+
+

+Note that the video driver should not yet be initialized to use this +function. It is a property of the driver. +

+
+ +None. + + + + + + +
+ + + +Get screen cursor type + +

+GetCursorType returns the current cursor type. It is one of the +following values: +

+
+
crHidden
+
crUnderLine
+
crBlock
+
crHalfBlock
+
+

+Note that not all drivers support all types of cursors. +

+
+ +None. + + + + + + +
+ + + +Get the screen lock update count. + +GetLockScreenCount returns the current lock level. When the lock +level is zero, a call to will actually update the +screen. + + +None. + + + + + + + + + + +Return current video mode + + + + + + + +Get a copy of the current video driver. + +GetVideoMode returns the settings of the currently active video mode. +The row,col fields indicate the dimensions of the current video mode, +and Color is true if the current video supports colors. + + +None. + + + + + + + + + + +Get the number of video modes supported by the driver. + +

+GetVideoModeCount returns the number of video modes that the current +driver supports. If the driver does not support switching of modes, then 1 +is returned. +

+

+This function can be used in conjunction with the +function to retrieve data for the supported video modes. +

+
+ +None. + + + + + + +
+ + + +Get the specifications for a video mode + +

+GetVideoModeData returns the characteristics of the Index-th +video mode in Data. Index is zero based, and has a maximum value of +GetVideoModeCount-1. If the current driver does not support setting of +modes (GetVideoModeCount=1) and Index is zero, the current mode +is returned. +

+

+The function returns True if the mode data was retrieved succesfully, +False otherwise. +

+

+For an example, see . +

+
+ +In case Index has a wrong value, False is returned. + + + + + + +
+ + + +Initialize video driver. + +

+InitVideo Initializes the video subsystem. If the video system was +already initialized, it does nothing. +After the driver has been initialized, the VideoBuf and OldVideoBuf +pointers are initialized, based on the ScreenWidth and +ScreenHeight variables. When this is done, the screen is cleared. +

+

+For an example, see most other functions. +

+
+ +if the driver fails to initialize, the ErrorCode variable is set. + + + + +
+ + + +Prevent further screen updates. + +

+LockScreenUpdate increments the screen update lock count with one. +As long as the screen update lock count is not zero, +will not actually update the screen. +

+

+This function can be used to optimize screen updating: If a lot of writing +on the screen needs to be done (by possibly unknown functions), calling +LockScreenUpdate before the drawing, and +after the drawing, followed by a call, all writing will +be shown on screen at once. +

+

+For an example, see . +

+
+ +None. + + + + + + +
+ + + +Set write cursor position. + +

+SetCursorPos positions the cursor on the given position: Column +NewCursorX and row NewCursorY. The origin of the screen is the +upper left corner, and has coordinates (0,0). +

+

+The current position is stored in the CursorX and CursorY +variables. +

+
+ +None. + + + + + +
+ + +Set cursor type + +

+SetCursorType sets the cursor to the type specified in NewType. +

+
+
crHidden
+
crUnderLine
+
crBlock
+
crHalfBlock
+
+
+ +None. + + + + +
+ + +Install a new video driver. + +

+SetVideoDriver sets the videodriver to be used to Driver. If +the current videodriver is initialized (after a call to InitVideo) +then it does nothing and returns False. +

+

+A new driver can only be installed if the previous driver was not yet +activated (i.e. before a call to ) or after it was +deactivated (i.e after a call to DoneVideo). +

+

+For more information about installing a videodriver, see . +

+

+For an example, see the section on writing a custom video driver. +

+
+ +If the current driver is initialized, then False is returned. + + + + +
+ + +Record type descrbing a video mode. + + + +Number of columns for display + + + +Number of rows for display + + + +Color support + + + +Set current video mode. + +

+SetVideoMode sets the video mode to the mode specified in Mode: +

+

+If the call was succesful, then the screen will have Col columns and +Row rows, and will be displaying in color if Color is +True. +

+

+The function returns True if the mode was set succesfully, False +otherwise. +

+

+Note that the video mode may not always be set. E.g. a console on Linux +or a telnet session cannot always set the mode. It is important to check +the error value returned by this function if it was not succesful. +

+

+The mode can be set when the video driver has not yet been initialized +(i.e. before was called) In that case, the video mode will +be stored, and after the driver was initialized, an attempt will be made to +set the requested mode. Changing the video driver before the call to +InitVideo will clear the stored video mode. +

+

+To know which modes are valid, use the and + functions. To retrieve the current video mode, +use the procedure. +

+
+ +If the specified mode cannot be set, then errVioNoSuchMode may be set +in ErrorCode + + + + + + +
+ + +Unlock screen update. + +

+UnlockScreenUpdate decrements the screen update lock count with one if +it is larger than zero. When the lock count reaches zero, the + will actually update the screen. No screen update will +be performed as long as the screen update lock count is nonzero. This +mechanism can be used to increase screen performance in case a lot of +writing is done. +

+

+It is important to make sure that each call to is +matched by exactly one call to UnlockScreenUpdate +

+

+For an example, see . +

+
+ +None. + + + + + + +
+ + + +Update physical screen with internal screen image. + +

+UpdateScreen synchronizes the actual screen with the contents +of the VideoBuf internal buffer. The parameter Force +specifies whether the whole screen has to be redrawn (Force=True) +or only parts that have changed since the last update of the screen. +

+

+The Video unit keeps an internal copy of the screen as it last +wrote it to the screen (in the OldVideoBuf array). The current +contents of VideoBuf are examined to see what locations on the +screen need to be updated. On slow terminals (e.g. a linux telnet +session) this mechanism can speed up the screen redraw considerably. +

+

+For an example, see most other functions. +

+
+ +None. + + + + +
+ + + +Writing a custom video driver + +

+Writing a custom video driver is not difficult, and generally means +implementing a couple of functions, which whould be registered with +the function. The various functions that can be +implemented are located in the record: +

+ +TVideoDriver = Record + InitDriver : Procedure; + DoneDriver : Procedure; + UpdateScreen : Procedure(Force : Boolean); + ClearScreen : Procedure; + SetVideoMode : Function (Const Mode : TVideoMode) : Boolean; + GetVideoModeCount : Function : Word; + GetVideoModeData : Function(Index : Word; Var Data : TVideoMode) : Boolean; + SetCursorPos : procedure (NewCursorX, NewCursorY: Word); + GetCursorType : function : Word; + SetCursorType : procedure (NewType: Word); + GetCapabilities : Function : Word; +end; + +

+Not all of these functions must be implemented. In fact, the only absolutely +necessary function to write a functioning driver is the UpdateScreen +function. The general calls in the Video unit will check which +functionality is implemented by the driver. +

+

+The functionality of these calls is the same as the functionality of the +calls in the video unit, so the expected behaviour can be found in the +previous section. Some of the calls, however, need some additional remarks. +

+
+
InitDriver
+
Called by InitVideo, this function should initialize +any data structures needed for the functionality of the driver, maybe do some +screen initializations. The function is guaranteed to be called only once; It +can only be called again after a call to DoneVideo. The variables +ScreenWidth and ScreenHeight should be initialized correctly +after a call to this function, as the InitVideo call will initialize +the VideoBuf and OldVideoBuf arrays based on their values. +
+
DoneDriver
+
This should clean up any structures that have been +initialized in the InitDriver function. It should possibly also +restore the screen as it was before the driver was initialized. The VideoBuf +and OldVideoBuf arrays will be disposed of by the general DoneVideo +call. +
+
UpdateScreen
+
This is the only required function of the driver. It +should update the screen based on the VideoBuf array's contents. It +can optimize this process by comparing the values with values in the +OldVideoBuf array. After updating the screen, the UpdateScreen +procedure should update the OldVideoBuf by itself. If the Force +parameter is True, the whole screen should be updated, not just the +changed values. +
+
ClearScreen
+
If there is a faster way to clear the screen than to +write spaces in all character cells, then it can be implemented here. If the +driver does not implement this function, then the general routines will +write spaces in all video cells, and will call UpdateScreen(True). +
+
SetVideoMode
+
Should set the desired video mode, if available. It +should return True if the mode was set, False if not. +
+
GetVideoModeCount
+
Should return the number of supported video modes. +If no modes are supported, this function should not be implemented; the +general routines will return 1. (for the current mode) +
+
GetVideoModeData
+
Should return the data for the Index-th mode; +Index is zero based. The function should return true if the data was +returned correctly, false if Index contains an invalid index. +If this is not implemented, then the general routine will return the current +video mode when Index equals 0. +
+
GetCapabilities
+
If this function is not implemented, zero (i.e. +no capabilities) will be returned by the general function. +
+
+

+The following unit shows how to override a video driver, with a driver +that writes debug information to a file. The unit can be used in any of +the demonstration programs, by simply including it in the uses +clause. Setting DetailedVideoLogging to +True will create a more detailed log (but will also slow down +functioning) +

+
+ +
+ + +Examples utility unit + +The examples in this section make use of the unit vidutil, which +contains the TextOut function. This function writes a text to the +screen at a given location. It looks as follows: + + + + + +
+
+