home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hacker Chronicles 2
/
HACKER2.BIN
/
148.GRAPHTEX.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-06-21
|
3KB
|
132 lines
UNIT GraphText;
INTERFACE
USES
{$IFDEF DOSCrt}
DOSCrt,
{$ELSE}
Crt,
{$ENDIF}
Graph,
TextOps;
PROCEDURE Text_To_Cart ( tx,ty : INTEGER;
VAR cx,cy : INTEGER);
PROCEDURE WriteText (s:STRING; x,y:INTEGER);
PROCEDURE ReadText (VAR s:STRING; x,y:INTEGER);
PROCEDURE ClearLine (x,y,delta_x : INTEGER);
FUNCTION char_width : INTEGER;
FUNCTION char_height : INTEGER;
(****************************************************************************)
IMPLEMENTATION
FUNCTION char_width : INTEGER;
BEGIN {char_width}
char_width:=succ(GetMaxX) div 80;
END; {char_width}
{----------------------------------------------------------------------------}
FUNCTION char_height : INTEGER;
BEGIN {char_height}
char_height:=succ(GetMaxY) div 25;
END; {char_height}
{----------------------------------------------------------------------------}
PROCEDURE Text_To_Cart ( tx,ty : INTEGER;
VAR cx,cy : INTEGER);
BEGIN {Text_To_Cart}
cx:=(tx-1)*char_width;
cy:=(ty-1)*char_height;
END; {Text_To_Cart}
{----------------------------------------------------------------------------}
PROCEDURE WriteText (s : STRING;
x : INTEGER;
y : INTEGER);
CONST
NormSize = 1;
BEGIN {WriteText}
GotoXY (x + length(s),y);
SetTextStyle (DefaultFont,HorizDir,NormSize);
SetTextJustify (LeftText,TopText);
Text_To_Cart (x,y,x,y);
OutTextXY (x,y,s);
MoveTo (x+TextWidth(s),y);
END; {WriteText}
{----------------------------------------------------------------------------}
PROCEDURE ReadText (VAR s : STRING;
x : INTEGER;
y : INTEGER);
VAR
i, j : INTEGER;
ch : CHAR;
blank : STRING;
BEGIN {ReadText}
i:=x;
s:='';
REPEAT
ch:=ReadKey;
CASE ch OF
BACKSPACE: IF i > x THEN BEGIN
DEC (i,1);
WriteText (' ',i,y);
s:=Copy (s,1,Length(s)-1);
END; {IF}
ESC: BEGIN
blank:='';
FOR j:=x TO i-1 DO blank:=blank+' ';
WriteText (blank,x,y);
s:='';
i:=x;
END;
ENTER: Exit;
ELSE BEGIN
s:=s+ch;
WriteText (ch,i,y);
INC (i,1);
END;
END; {CASE}
UNTIL FALSE;
END; {ReadText}
{----------------------------------------------------------------------------}
PROCEDURE ClearLine (x,y,delta_x : INTEGER);
VAR
x1,x2,y1,y2 : INTEGER;
old : ViewPortType;
BEGIN {ClearLine}
Text_To_Cart (x,y,x1,y1);
Text_To_Cart (x+delta_x,y+1,x2,y2);
GetViewSettings (old);
SetViewPort (x1,y1,x2,y2,ClipOff);
ClearViewPort;
WITH old DO SetViewPort (x1,y1,x2,y2,Clip);
END; {ClearLine}
(****************************************************************************)
BEGIN {Initialization}
END. {UNIT GraphText}