home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / 1991 / 03 / grdlagen / crtdemo.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1990-12-07  |  3.2 KB  |  103 lines

  1. (* ------------------------------------------------------ *)
  2. (*                      CRTDEMO.PAS                       *)
  3. (* Dieses Programm demonstriert den Gebrauch des Objekts  *)
  4. (* "VSMCrt", eine (objektorientierte) Neuimplementation   *)
  5. (* der Unit Crt von Turbo Pascal, anhand des ebenfalls    *)
  6. (* neuimplementierten Demoprogramm "CrtDemo", das ja auch *)
  7. (* zum Lieferumfang von Turbo Pascal gehört.              *)
  8. (*                                                        *)
  9. (*         (c) 1991 Raimond Reichert & toolbox            *)
  10. (* ------------------------------------------------------ *)
  11. PROGRAM CrtDemo;
  12.  
  13. USES CrtVar;
  14.  
  15. VAR
  16.   LastCol, LastRow : BYTE;
  17.   Ch               : CHAR;
  18.   Finished         : BOOLEAN;
  19.  
  20.  
  21.   PROCEDURE Initialize;
  22.   BEGIN
  23.     WITH Crt^ DO BEGIN
  24.       SetCheckBreak(Off);
  25.       LastCol := GetWinMaxX;
  26.       LastRow := GetWinMaxY;
  27.       GotoXY(1, LastRow);
  28.       SetTextBackground(Black);
  29.       SetTextColor(White);
  30.       Write(' Ins-InsLine  ' +  'Del-DelLine  '+
  31.              #27#24#25#26'-Cursor  '+
  32.              'Alt-W-Window  '+   'Alt-R-Random  '+
  33.              'Esc-Exit');
  34.       Dec(LastRow);
  35.       Randomize;
  36.     END;
  37.   END;
  38.  
  39.   PROCEDURE MakeWindow;
  40.   VAR
  41.     x1, y1, Width, Height : BYTE;
  42.   BEGIN
  43.     WITH Crt^ DO BEGIN
  44.       Width  := Random(LastCol - 2) + 2;
  45.       Height := Random(LastRow - 2) + 2;
  46.       x1     := Random(LastCol - Width) + 1;
  47.       y1     := Random(LastRow - Height) + 1;
  48.       Window(x1, y1, x1+Width, y1+Height);
  49.       SetTextBackground(White);
  50.       SetTextColor(Black);
  51.       ClrScr;
  52.       Window(Succ(x1), Succ(y1),
  53.             Pred(x1+Width), Pred(y1+Height));
  54.       SetTextBackground(Black);
  55.       SetTextColor(White);
  56.       ClrScr;
  57.     END;
  58.   END;
  59.  
  60.   PROCEDURE RandomText;
  61.   BEGIN
  62.     REPEAT
  63.       Crt^.Write(Chr(Random(256-32)+32));
  64.     UNTIL Crt^.KeyPressed;
  65.   END;
  66.  
  67. BEGIN
  68.   Crt := New(VSMCrtPtr, Init(0, 0));
  69.   Crt^.ClrScr;
  70.   Initialize;
  71.   MakeWindow;
  72.   Finished := FALSE;
  73.   WITH Crt^ DO
  74.     REPEAT
  75.       Ch := ReadKey;
  76.       CASE Ch OF
  77.          #0 : BEGIN
  78.                 Ch := ReadKey;
  79.                 CASE Ch OF
  80.                   #17: MakeWindow;                { Alt-W  }
  81.                   #19: RandomText;                { Alt-R  }
  82.                   #45: Finished := TRUE;          { Alt-X  }
  83.                   #72: GotoXY(WhereX, WhereY-1);  { Up     }
  84.                   #75: GotoXY(WhereX-1, WhereY);  { Left   }
  85.                   #77: GotoXY(WhereX+1, WhereY);  { Right  }
  86.                   #80: GotoXY(WhereX, WhereY+1);  { Down   }
  87.                   #82: InsLine;                   { Ins    }
  88.                   #83: DelLine;                   { Del    }
  89.                 END;
  90.               END;
  91.          #3 : Finished := TRUE;                   { Ctrl-C }
  92.         #13 : WriteLn('');                        { Enter  }
  93.         #27 : Finished := TRUE;                   { Esc    }
  94.       ELSE
  95.         Write(Ch);
  96.       END;
  97.     UNTIL Finished;
  98.   Crt^.ClrScr;
  99.   Crt^.Done;             { <-- aufräumen nicht vergessen ! }
  100. END.
  101. (* ------------------------------------------------------ *)
  102. (*                 Ende von CRTDEMO.PAS                   *)
  103.