home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol069 / termio.pas < prev    next >
Pascal/Delphi Source File  |  1984-04-29  |  3KB  |  122 lines

  1. {+++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2. {+ TERMINAL IO DRIVERS SOURCE PROGRAM - UNMODIFIED   +}
  3. {+ YOU MUST MODIFY THIS PROGRAM FOR YOUR APPLICATION +}
  4. {+ AND RENAME THE MODIFIED PROGRAM "TERMIO.LIB"      +}
  5. {+++++++++++++++++++++++++++++++++++++++++++++++++++++}
  6.  
  7.     {+ CONSTANT DEFINITIONS +}
  8. CONST
  9.   alphalen = 10;
  10.  
  11.     {+ TYPE DEFINITIONS +}
  12. TYPE
  13.   byte = 0..255;
  14.   alpha = array [0..alphalen] of byte;
  15.  
  16.     {+ VARIABLE DEFINITIONS +}
  17. VAR
  18.       { first 5 bytes for some misc terminal values }
  19.    DELMIS,        { delay after other functions }
  20.    DELCUS,        { delay after moving cursor }
  21.    X_OFF,        { offset to add to column }
  22.    Y_OFF,        { offset to add to row }
  23.    XY         : BYTE;    { flag for column/row or row/column }
  24.      { string sequences }
  25.    CLRSCR,        { CLEAR SCREEN }
  26.    CUR,         { CURSOR ADDRESSING LEADIN STRING }
  27.    eraeos,        { CLEAR TO END OF SCREEN }
  28.    eraeol,        { CLEAR TO END OF LINE }
  29.    HOME,        { HOME UP CURSOR }
  30.    LockKbd,        { LOCK KEYBOARD }
  31.    UnlockKbd,        { UNLOCK KEYBOARD }
  32.    LINDEL,       { delete screen line containing cursor }
  33.    LININS,       { insert a blank line on screen }
  34.    INVON,       { turn on highlighting - inverse video }
  35.    INVOFF,       { turn off highlighting }
  36.    CRSON,       { SET CURSOR ON AND BLINKING }
  37.    CRSOFF : ALPHA; { SET CURSOR DISPLAY OFF }
  38.  
  39.  
  40. procedure writes( strng: alpha );
  41. { writes writes a string of type alpha to the console
  42.   device. }
  43. var    ix: byte;
  44. begin
  45.   for ix:=1 to strng[0] do
  46.     write( chr(strng[ix]) );
  47. end{ of writes };
  48.  
  49.  
  50. Procedure Clear_Screen;
  51. var    ix: byte;
  52. begin
  53.   writes( CLRSCR );
  54.   for ix:=0 to DELMIS do {};
  55. end;
  56.  
  57.  
  58. Procedure gotoxy(x_coord, y_coord: byte);
  59. var    ix: byte;
  60.     x_pos, y_pos: byte;
  61. begin
  62.   X_POS := x_coord + X_OFF;
  63.   Y_POS := y_coord + Y_OFF;
  64.   IF ( XY=2 ) AND ( X_POS<31 ) THEN
  65.     X_POS := X_POS + 96;
  66.   writes( CUR );
  67.   IF ( XY=1 ) OR ( XY=2 ) THEN
  68.     write( CHR(X_POS), CHR(Y_POS) )
  69.   ELSE
  70.     write( CHR(Y_POS), CHR(X_POS) );
  71.   for ix:=0 TO DELCUS do {};
  72. end;
  73.  
  74.  
  75. FUNCTION INITTERM: BOOLEAN;
  76. { RETURNS TRUE IF TERMINAL DATA FILE FOUND  }
  77. {      FALSE IF DATA FILE NOT FOUND!     }
  78. TYPE    BFILE = FILE OF BYTE;
  79. VAR    bx     : byte;
  80.     termio : BFILE;
  81.  
  82.    procedure gets( var fb: BFILE; var strng: alpha );
  83.    { gets a string of type alpha from the
  84.      specified file of type BFILE. }
  85.    var       ix: byte;
  86.    begin
  87.      read( fb, strng[0] );       { first byte is always length }
  88.      for ix:=1 to strng[0] do
  89.        read( fb, strng[ix] )
  90.    end{ of gets };
  91.  
  92. begin
  93.   { OPEN file TERMIO.FIL for READ assign TERMIO }
  94.   reset('TERMIO.FIL', termio);
  95.   if eof(termio) then { file does not exist }
  96.      INITTERM := FALSE
  97.   else begin
  98.     INITTERM := TRUE;
  99.     { first 5 bytes in this sequence }
  100.     { strings must be read back in same sequence as were written }
  101.     read( termio,
  102.           BX,     { length byte }
  103.           DELMIS, DELCUS, X_OFF, Y_OFF, XY );
  104.     gets( termio, CLRSCR );
  105.     gets( termio, CUR );
  106.     gets( termio, eraeos );
  107.     gets( termio, eraeol );
  108.     gets( termio, HOME );
  109.     gets( termio, LockKbd );
  110.     gets( termio, UnlockKbd );
  111.     gets( termio, LINDEL );
  112.     gets( termio, LININS );
  113.     gets( termio, INVON );
  114.     gets( termio, INVOFF );
  115.     gets( termio, CRSON );
  116.     gets( termio, CRSOFF );
  117.   end{else}
  118. end{ of INITTERM }{ CLOSE(termio); };
  119.  
  120.  
  121.  
  122.