{ =========================================================================== }
{ Cursor5x.pas - Restores cursor for any video card.        ver 5.X, 01-01-89 }
{ by  James H. LeMay, CIS 76011,217                                           }
{ for Eagle Performance Software                                              }
{     P.O. Box 122237                                                         }
{     Ft. Worth, TX 76121                                                     }
{     (817)-735-4833                                                          }
{                                                                             }
{ This program will let you restore your cursor automatically on whatever     }
{ system you have:                                                            }
{                                                                             }
{   Usage: Cursor                               << Underline cursor           }
{          Cursor [-bh?]                        << Block cursor or help       }
{          Cursor [TopScanLine BottomScanLine]  << Custom shape               }
{   No parameters makes an underline cursor.                                  }
{   -b makes a block cursor.                                                  }
{   Two decimal parameters shape the scan lines.                              }
{   Anything else just displays the usage.                                    }
{   The "-" and "/" are optional                                              }
{                                                                             }
{ For more information on cursor shapes for different video devices, get      }
{ QWIK5X.ARC.  QWIK.TPU is required to compile this program which is also in  }
{ QWIK5X.ARC.  This source code is public domain, but QWIK is shareware.      }
{ QWIK is initialized in the unit and detects your video system including:    }
{                                                                             }
{    IBM PC, XT, AT, PCjr, PC convertible, all PS/2 models, 3270 PC.          }
{    MDA, CGA, EGA, MCGA, VGA, 8214/A, all Hercules.                          }
{    And all compatibles.                                                     }
{    Operating in all text modes, column modes, and row modes.                }
{                                                                             }
{ QWIK turns on the cursor emulation mode for the VGA.                        }
{                                                                             }
{ EXAMPLES:                                                                   }
{   cursor -b                  << Restores block cursor                       }
{   cursor -h                  << Displays help                               }
{   cursor 0 13                << Makes a block-type cursor (MDA)             }
{                                                                             }
{                                                                             }
{ Revisions:                                                                  }
{   Version 1.1, 04-08-88                                                     }
{     . Accounted for CGA emulation on EGA with CheckCgaEmulation.            }
{   Version 4.2, 08-01-88                                                     }
{     . Revised program for QWIK42.TPU                                        }
{   Version 5.X, 01-01-89                                                     }
{     . Revised directives for TP5 and QWIK5X.TPU                             }
{ =========================================================================== }

program RestoreCursor;

{$M 1500, 0, 0}
{$A-,B-,D-,E-,F-,I-,L-,N-,O-,R-,S-,V-}

uses Qwik;  { QWIK.TPU is found in QWIK5X.ARC or a later version. }

var
  BottomScanLine,TopScanLine: byte;
  CursorMode:                 word absolute BottomScanLine;
  ParameterError:             boolean;
  Attr:                       integer;

procedure GetBlockCursor;
var P: string[10];
begin
  P := ParamStr(1);
  if (pos('b',P)>0) or (pos('B',P)>0) then
       CursorMode := CursorBlock
  else ParameterError:=true;  { Show command usage. }
end;

procedure GetCustomCursor;
var  Error1,Error2: integer;
begin
  val (ParamStr(1),TopScanLine   ,Error1);
  val (ParamStr(2),BottomScanLine,Error2);
  if Error1+Error2<>0 then
    ParameterError:=true;  { Show command usage. }
end;

begin
  ParameterError:=false;
  case ParamCount of
    0: CursorMode := CursorUnderline;
    1: GetBlockCursor;
    2: GetCustomCursor;
  else ParameterError := true;
  end;
  if ParameterError then
    begin
      ScrollAttr := QreadAttr (WhereR,WhereC);
      Attr       := ScrollAttr;
      EosToCursor;
      QwriteEos (Attr,'CURSOR 4.2 (c) 1988 Eagle Performance Software');QEosLn;
      QwriteEos (Attr,'Restores default cursor on any system.');        QEosLn;
      QwriteEos (Attr,'Usage: Cursor');                                 QEosLn;
      QwriteEos (Attr,'       Cursor [-bh?]');                          QEosLn;
      QwriteEos (Attr,'       Cursor [TopScanLine BottomScanLine]');    QEosLn;
      QwriteEos (Attr,'No parameters makes an underline cursor.');      QEosLn;
      QwriteEos (Attr,'-b makes a block cursor.');                      QEosLn;
      QwriteEos (Attr,'Two decimal parameters shape the scan lines.');  QEosLn;
      GotoEos;
    end
  else
    SetCursor (CursorMode);
end.
