home *** CD-ROM | disk | FTP | other *** search
- (* ------------------------------------------------------ *)
- (* CRTDEMO.PAS *)
- (* Dieses Programm demonstriert den Gebrauch des Objekts *)
- (* "VSMCrt", eine (objektorientierte) Neuimplementation *)
- (* der Unit Crt von Turbo Pascal, anhand des ebenfalls *)
- (* neuimplementierten Demoprogramm "CrtDemo", das ja auch *)
- (* zum Lieferumfang von Turbo Pascal gehört. *)
- (* *)
- (* (c) 1991 Raimond Reichert & toolbox *)
- (* ------------------------------------------------------ *)
- PROGRAM CrtDemo;
-
- USES CrtVar;
-
- VAR
- LastCol, LastRow : BYTE;
- Ch : CHAR;
- Finished : BOOLEAN;
-
-
- PROCEDURE Initialize;
- BEGIN
- WITH Crt^ DO BEGIN
- SetCheckBreak(Off);
- LastCol := GetWinMaxX;
- LastRow := GetWinMaxY;
- GotoXY(1, LastRow);
- SetTextBackground(Black);
- SetTextColor(White);
- Write(' Ins-InsLine ' + 'Del-DelLine '+
- #27#24#25#26'-Cursor '+
- 'Alt-W-Window '+ 'Alt-R-Random '+
- 'Esc-Exit');
- Dec(LastRow);
- Randomize;
- END;
- END;
-
- PROCEDURE MakeWindow;
- VAR
- x1, y1, Width, Height : BYTE;
- BEGIN
- WITH Crt^ DO BEGIN
- Width := Random(LastCol - 2) + 2;
- Height := Random(LastRow - 2) + 2;
- x1 := Random(LastCol - Width) + 1;
- y1 := Random(LastRow - Height) + 1;
- Window(x1, y1, x1+Width, y1+Height);
- SetTextBackground(White);
- SetTextColor(Black);
- ClrScr;
- Window(Succ(x1), Succ(y1),
- Pred(x1+Width), Pred(y1+Height));
- SetTextBackground(Black);
- SetTextColor(White);
- ClrScr;
- END;
- END;
-
- PROCEDURE RandomText;
- BEGIN
- REPEAT
- Crt^.Write(Chr(Random(256-32)+32));
- UNTIL Crt^.KeyPressed;
- END;
-
- BEGIN
- Crt := New(VSMCrtPtr, Init(0, 0));
- Crt^.ClrScr;
- Initialize;
- MakeWindow;
- Finished := FALSE;
- WITH Crt^ DO
- REPEAT
- Ch := ReadKey;
- CASE Ch OF
- #0 : BEGIN
- Ch := ReadKey;
- CASE Ch OF
- #17: MakeWindow; { Alt-W }
- #19: RandomText; { Alt-R }
- #45: Finished := TRUE; { Alt-X }
- #72: GotoXY(WhereX, WhereY-1); { Up }
- #75: GotoXY(WhereX-1, WhereY); { Left }
- #77: GotoXY(WhereX+1, WhereY); { Right }
- #80: GotoXY(WhereX, WhereY+1); { Down }
- #82: InsLine; { Ins }
- #83: DelLine; { Del }
- END;
- END;
- #3 : Finished := TRUE; { Ctrl-C }
- #13 : WriteLn(''); { Enter }
- #27 : Finished := TRUE; { Esc }
- ELSE
- Write(Ch);
- END;
- UNTIL Finished;
- Crt^.ClrScr;
- Crt^.Done; { <-- aufräumen nicht vergessen ! }
- END.
- (* ------------------------------------------------------ *)
- (* Ende von CRTDEMO.PAS *)