home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
PASCAL
/
GRAPHTXT.ZIP
/
GRAPHTXT.DOC
< prev
next >
Wrap
Text File
|
1990-02-16
|
7KB
|
203 lines
GraphTxt.TPU for TP 5.5
=======================
Thank you for down loading graphtxt.zip! I found text
I/O to be somewhat burdensome using Turbo Pascal 5.5's
outtext() routines so I wrote this text file device
driver for the graphics' screen (see page 223, TP's
reference guide).
Simply include the graphtxt unit in your application's
"uses" clause. Then immediately after calling
InitGraph(), call InitGraphText. Now you can use
write[ln] and read[ln] just like you did with the crt
unit. You can even change the fonts and justification
with SetTextStyle() and SetTextJustify(). To return
to text mode call CloseGraphText immediately before
CloseGraph.
Run graphtxt.dem for a demonstration of the graphtxt
unit. Study the demo's source code to see how easy it
is to use. Below is a listing of the inteface section
of graphtxt.pas.
{
graphtxt.pas
2-16-1990
Enables read, readln, write, and writeln to be used
in graph modes. See graphtxt.dem.
Copyright 1990, John W. Small, All rights reserved
PSW / Power SoftWare
P.O. Box 10072
McLean, Virginia 22102 8072
(703) 759-3838
}
unit graphtxt;
interface
uses dos, crt, graph;
const
ColumnLeft : boolean = false;
InputWriteMode : integer = CopyPut;
InputRewrite : boolean = false;
InputDone : boolean = false;
OutputWriteMode : integer = CopyPut;
ClearTextBk : boolean = false;
TextBkPattern : integer = SolidFill;
TextBkColor : integer = 0; { 0 = current bkcolor }
CursorChar : string[1] = #124; { 0 = no readln cursor }
CursorOnMsec : word = 100;
CursorOffMsec : word = 100;
procedure InitGraphText; { Call InitGraph() first }
procedure CloseGraphText; { Call before CloseGraph() }
procedure AssignGraph(var F : Text);
Line Input
==========
Line input with read[ln] honors the same special
characters as the Crt unit (see page 136, TP reference
guide). Use crt.CheckEOF to enable CtrlZ check!
Crt.CheckBreak controls CtrlBreak operation. Crt's
special output characters (Bell, BackSpace, etc) are
not honored so that output is faster. They didn't
seem that important to me.
Column Justification
====================
Writeln operates on a column concept when the
justification is CenterText or RightText for horizonal
fonts and CenterText or TopText for vertical fonts.
The CR/LF puts the CP (current pointer) on the next line
aligned with the previous line instead of the left side
of the current viewport. With LeftText justify in
conjunction with a horizonal font, the CR/LF puts the
CP on the next line flush left with the current viewport.
If you want to writeln a column, left justified, then
set graphtxt.ColumnLeft to true! Then LeftText justify
works on the column concept too. The same is true with
a vertical font that is BottomText justified. Setting
graphtxt.ColumnLeft to false will cause writeln to put
the CP on the next line flush against the bottom of the
viewport. This is the most satisfactory arrangement
that I could come up with. You will recall that OutText
only advances the CP with (LeftText,TopText)
justification!
Write Mode for write[ln] and Stroked Fonts
==========================================
Graphtxt.OutputWriteMode only affects the stroked fonts.
Normally, if not always, you will want the text written
on the graphics screen with SetWriteMode(CopyPut). If
you want the output text to be XORPut onto the screen
then assign XORput to graphtxt.OutputWriteMode.
Character Background for write[ln] and read[ln]
===============================================
Assign true to graphtxt.ClearTextBk if you want the
background cleared before writing a character with
either write[ln] or read[ln]. Graphtxt.TextBkPattern
specifies the background fill pattern to be used in this
case. Its default is SolidFill. Graphtxt.TextBkColor
specifies the color of the background fill. If it is 0
(zero) then the current background color is used. Both
TextBkPattern and TextBkColor are used by the backspace
in read[ln] to rub out the character whenever
graphtxt.InputWriteMode is CopyPut or the DefaultFont
(non-stroked) is the current font.
Read[ln] features
=================
Graphtxt.InputWriteMode determines whether stroked font
characters echoed to the screen are CopyPut or XORPut.
The default is CopyPut. Sometimes you may want to use
XORPut in which case backspacing on input will erase
the character if the current font is stroked. This is
handy in paint programs where you only want the finished
line to be CopyPut. Set InputWriteMode to XORPut and
InputRewrite to true to accomplish this. InputRewrite
being set to true causes the input line to be rewritten
in the CopyPut mode after the user terminates the input
line with enter. On the other hand, backspacing will
"blacken" out the rubbed out character if InputWriteMode
is set to CopyPut or the DefaultFont is current. Wow!
You may want to reread this.
Graphtxt.CursorChar is really a string of one character.
(There were internal reasons for making it a string.)
This is the cursor that is displayed by read[ln]. I
chose the vertical bar "|" which is present in all the
supplied fonts. If you don't want a cursor displayed
then assign the zero character to the string, i.e.
CursorChar[1] := #0. CursorOnMsec and CursorOffMsec are
the parameters passed internally to crt.delay() to
determine the blink rate. 100 milliseconds appears to
be acceptable. If you think not then these are the
variables to monkey with.
It may seem odd for Graphtxt.InputDone to be placed in
the interface section of the graphtxt unit. It controls
the input loop for read[ln]. The reason it's there is
so that any interrupt routine you may have included in
your application can automatically terminate a read[ln]
in progress. I am writing a Paint program where I need
the mouse interrupt to be able to terminate the text
paint tool which happens to use readln and the
graphtxt.tpu. Perhaps you may need it too! By the way
the paint program is a demo for omouse.zip which I
should be uploading next week sometime. The program is
pretty primitive since it's only a demo for omouse.
Omouse stands for object mouse. The mouse object has
all 30 some methods (mouse functions) and some other
necessities like an automatic interrupt handler, etc,
which should make your mouse programming a snap.
Registration
============
If you find graphtxt useful and are using it in your
applications, a registration fee of $7 is requested.
Upon registration you will be sent source code and the
latest examples programs on a DOS formatted 5 1/4" disk.
Thanks again!
John W. Small
PSW / Power SoftWare
P.O. Box 10072
McLean, VA 22102 8072
(703) 759-3838