home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / RADOOR30.ZIP / USERHOOK.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1994-04-10  |  6.4 KB  |  213 lines

  1. {╔═════════════════════════════════════════════════════════════════════════╗
  2.  ║                                                                         ║
  3.  ║                   (c) CopyRight LiveSystems 1990, 1994                  ║
  4.  ║                                                                         ║
  5.  ║ Author    : Gerhard Hoogterp                                            ║
  6.  ║ FidoNet   : 2:282/100.5   2:283/7.33                                    ║
  7.  ║ BitNet    : GERHARD@LOIPON.WLINK.NL                                     ║
  8.  ║                                                                         ║
  9.  ║ SnailMail : Kremersmaten 108                                            ║
  10.  ║             7511 LC Enschede                                            ║
  11.  ║             The Netherlands                                             ║
  12.  ║                                                                         ║
  13.  ║        This module is part of the RADoor BBS doorwriters toolbox.       ║
  14.  ║                                                                         ║
  15.  ╚═════════════════════════════════════════════════════════════════════════╝}
  16. {---------------------------------------------------------------------------|
  17.  
  18.  Description
  19.  
  20.   This unit defines the procedures for handling the statusline and
  21.   the sysop keys. The statusline is a simple one-liner because I
  22.   prefer to see things the user sees them.. But if you prefer a two or
  23.   more lines, be my guest and change it here..;)
  24.  
  25. |-------------------------------------------------------------------------}
  26.  
  27. Unit UserHook;
  28. Interface
  29. Uses Dos,
  30.      Crt,
  31.      KeyDefs,   { Keyboard definitions       }
  32.      GlobInfo;  { Global information record  }
  33.  
  34. {---------------------------------------------------------------------------|
  35.   StatusLine handles a 4 levels statusline and is easy to maintain to
  36.              provide more info if needed. Just add an other level to the
  37.              statusline and the SysOpKeys procedure.
  38.  
  39.   SysOpKeys  accepts an extended keycode (as defined in the KeyDefs unit)
  40.              and does whatever it takes to accomplish the requested task.
  41.              Note that I use the Control-PgUp and Control-PgDn keys here
  42.              for incrementing and decrementing the users time. I didn't
  43.              have the urge to keep things RA compatible and this way I
  44.              avoid problems with the SmartReadKey function in the fossil
  45.              unit.
  46.  
  47.  SetStatLineStatus  Sets a default statusline.
  48. |-------------------------------------------------------------------------}
  49.  
  50. Procedure StatusLine;
  51. Procedure SysopKeys(Key : Char);
  52. Procedure SetStatLineStatus(Stat : Byte);
  53.  
  54. Implementation
  55. Uses RA;
  56.  
  57. { I know this isn't the most foolproof methode of hiding the cursor.. }
  58.  
  59. Procedure Cursor_On;
  60. Var regs : Registers;
  61. Begin
  62. Regs.Ah:=$01;
  63. Regs.Ch:=$06;
  64. Regs.Cl:=$07;
  65. Intr($10,Regs);
  66. End;
  67.  
  68. Procedure Cursor_Off;
  69. Var regs : Registers;
  70. Begin
  71. Regs.Ah:=$01;
  72. Regs.Ch:=$16;
  73. Regs.Cl:=$0;
  74. Intr($10,Regs);
  75. End;
  76.  
  77. Var OldMin         : Word;
  78.     StatLineStatus : Byte;
  79.  
  80. Procedure StatusLine;
  81. Var Mx,My,Mc : Byte;
  82. Begin
  83. If GlobalInfo.MinRemaining=OldMin
  84.    Then Exit;
  85.  
  86. Cursor_Off; { Gives a more quiet screen }
  87.  
  88. OldMin:=GlobalInfo.MinRemaining;
  89.  
  90. Mx:=CRT.WhereX;
  91. MY:=CRT.WhereY;
  92. MC:=CRT.TextAttr;
  93.  
  94. CRT.Window(1,1,80,25);
  95. CRT.GotoXy(1,25);
  96. CRT.TextAttr:=$70;
  97.  
  98. Case StatLineStatus Of
  99.    1 : Begin
  100.        With GlobalInfo Do
  101.         Begin
  102.         Write(' ',UserName,'':35-Length(UserName),
  103.               '  Sec: ',UserSecurity:5,
  104.               '  Time left: ',MinRemaining:3);
  105.         End;
  106.        End;
  107.    2 : Begin
  108.        With GlobalInfo Do
  109.         Begin
  110.         Write(' Sound ');
  111.         If LocalNoise
  112.            Then Write('[',#14,']')
  113.            Else Write('[-]');
  114.         Write('  Multiline ');
  115.         If MultiLine
  116.            Then Write('[*]')
  117.            Else Write('[-]');
  118.         Write('  DesqView ');
  119.         If DesqView
  120.            Then Write('[*]')
  121.            Else Write('[-]');
  122.         Write('  WarnSysop ');
  123.         If OnlineStatus=WarnOnLeaving
  124.            Then Write('[W]')
  125.            Else Write('[-]');
  126.         End; {With}
  127.        End;
  128.    3 : Write(' ALT: H - hangup, L - LockOut, W - WarnSysop');
  129.    4 : Write(' CTRL: PgUp/PgDn - Inc/Dec time');
  130.    5 : Begin
  131.        If GlobalInfo.IEMSI.Session
  132.           Then Write(' IEMSI: ',GlobalInfo.IEMSI.Software)
  133.           Else Begin
  134.                If GlobalInfo.BBSTag=1
  135.                   Then Write(' IEMSI: Not used')
  136.                   Else Write(' IEMSI: Not supported on this system.');
  137.                End;
  138.        End;
  139.    6 : Begin
  140.        With GlobalInfo Do
  141.         Write(' AKA: ',UserHandle,'':35-Length(UserHandle));
  142.        End;
  143.    7 : Begin
  144.        With GlobalInfo Do
  145.         Begin
  146.         Write(' Birthday: ',UserBirthday);
  147.         If UserAge>0
  148.            Then Write('  Age: ',UserAge:2)
  149.            Else Write('  Age: UnKnown');
  150.         End;
  151.        End;
  152.    9 : Write(' F1 - UserInfo, F2 - SystInfo, F3 - ALT-Keys, F4 - CTRL-keys');
  153.   10 : Write(' F5 - IEMSI  F6 - Handle  F7 - Age/Birthday');
  154. End; {Case}
  155.  
  156. If StatLineStatus<>99
  157.    Then Begin
  158.         Write('F9/F10 - Help':80-WhereX);
  159.         CRT.ClrEol;
  160.         CRT.Window(1,1,80,24);
  161.         End;
  162. CRT.TextAttr:=Mc;
  163. CRT.GotoXy(Mx,My);
  164. Cursor_On;
  165. End;
  166.  
  167. Procedure SysopKeys(Key : Char);
  168. Begin
  169. Case Key Of
  170.  SF1    : StatLineStatus:=99;
  171.  F1     : StatLineStatus:=1;
  172.  F2     : StatLineStatus:=2;
  173.  F3     : StatLineStatus:=3;
  174.  F4     : StatLineStatus:=4;
  175.  F5     : StatlineStatus:=5;
  176.  F6     : StatLineStatus:=6;
  177.  F7     : StatLineStatus:=7;
  178.  F9     : StatLineStatus:=9;
  179.  F10    : StatlineStatus:=10;
  180.  ALTS   : Begin
  181.           GlobalInfo.LocalNoise   := Not GlobalInfo.localNoise;
  182.           StatLineStatus:=2;
  183.           End;
  184.  ALTH   : GlobalInfo.OnlineStatus := HangUpLine;
  185.  ALTL   : GlobalInfo.OnlineStatus := LockOutUser;
  186.  ALTW   : Begin
  187.           If GlobalInfo.OnlineStatus = WarnOnLeaving
  188.              Then GlobalInfo.OnLineStatus := Normal
  189.              Else GlobalInfo.OnLineStatus := WarnOnLeaving;
  190.           StatLineStatus:=2;
  191.           End;
  192.  CPgUpK : Begin
  193.           Inc(GlobalInfo.MinRemaining);
  194.           StatLineStatus:=1;
  195.           End;
  196.  CPgDnK : Begin
  197.           Dec(GlobalInfo.MinRemaining);
  198.           StatLineStatus:=1;
  199.           End;
  200. End;
  201. OldMin:=61;
  202. End;
  203.  
  204. Procedure SetStatLineStatus(Stat : Byte);
  205. Begin
  206. StatLineStatus:=Stat;
  207. End;
  208.  
  209. Begin
  210. OldMin:=61;
  211. StatLineStatus:=1;
  212. End.
  213.