{$IFNDEF OS2}
{$O+,F+}
{$ENDIF}

Unit UserEd;

{*********************************************************}
{*                     USERED.PAS                        *}
{*                                                       *}
{*  Copyright (c) Vlad Bakaev, 1995-98,                  *}
{*  Copyright (c) Konstantin Klyagin, 1995-98,           *}
{*                exspecially for Tornado BBS System     *}
{*                                                       *}
{*********************************************************}


Interface

Uses
{$IFNDEF WIN32}
  DOS,
  tWin,
  Iface,
  Iline,
{$ENDIF}
{$IFDEF OS2}
  {Crt,}
{$ENDIF}
  TGlob,
  OpCrt,
  tMisc,
  Parse,
  MainComm,
  Users,
  Resource;

Function EditUser (Var User : tUser): Boolean;

Implementation

Const
  BoolLength : Byte = 3;

Procedure ValidDataBox (X, Y : LongInt);
Var
  RX, RY        : Byte;

Begin
  RX := WhereX;
  RY := WhereY;
  HiddenCursor;
  CenterTempBox (Cnf. ColorScheme [cdFrame], Cnf. ColorScheme [cdButton],
                 1, ' Value must be in range|' + Long2Str (X) + ' - ' + ' ' +
                 Long2Str (Y) + '| ', ZoomSpeed, sm (smWarningWinTitle));
  NormalCursor;
  GotoXY (RX, RY);
End;

Function EditUser (Var User : tUser): Boolean;
Var
  T                     : SysInt;
  Temp, TempS           : String [80];
  FullBox, ConfirmBox   : PBoxRec;
  I, Keyb, OX, OY, RX,
  RY, Att               : Byte;
  CH                    : Char;
  DoStr, Changes, Ex    : Boolean;
  tEmu                  : tEmulation;

Label
  _Location, _Organization, _1st_address, _2nd_address, _3rd_address,
  _Password, _Home_phone, _Data_phone, _Birthdate, _MsgsPosted,
  _Lines, _Language, _Protocol, _Emulation, _EmulationMenu, _Comment,
  _Downloads, _DownloadsK, _TodayK, _Uploads, _UploadsK, _Pause,
  _HotKeys, _Finished_, _Flags, _Alias, _FSed, ConfirmEnd;

{some from APABSPCL.PAS by TurboPower}
Const
  XModem = 0;
  ZModem = 6;
  ProtocolTypeString : Array [0..11] Of String [10] = (
                       'Xmodem', 'XmodemCRC', 'Xmodem1K', 'Xmodem1KG',
                       'Ymodem', 'YmodemG', 'Zmodem', 'Zmodem8K', 'Kermit', 'Ascii',
                       'BPlus', 'None');

  EmuTypeString : Array [teANSI..teAvatar] Of String [6] = ('ANSI  ', 'TTY   ', 'AVATAR');

Function SpaceAdd (St: String; Num: Byte): String;
Begin
  While Length (St) < Num Do St := St + ' ';
  SpaceAdd := St;
End;

Begin
  Changes := False;
  OX := WhereX; OY := WhereY; HiddenCursor;
  BoolLength := Length (sm (smYes));
  If Length (sm (smNo)) > BoolLength Then BoolLength := Length (sm (smNo));

  InitWindow (FullBox, 1, 1, 80, 21, 4, Cnf. ColorScheme [cdFrame],
              '¹  User: ' + User. Name + '  Ì', Cnf. ColorScheme [cdTitle],
              ZoomSpeed, True);

  DrawWindow (FullBox);

  FastWrite (sm (smueLocation), FullBox^. Y1 + 2, 3, Cnf. ColorScheme [cdText]);
  FastWrite (User. Location, FullBox^. Y1 + 2, 17, Cnf. ColorScheme [cdInput]);
  FastWrite (sm (smueOrganization), FullBox^. Y1 + 3, 3, Cnf. ColorScheme [cdText]);
  FastWrite (User. Organization, FullBox^. Y1 + 3, 17, Cnf. ColorScheme [cdInput]);
  FastWrite (sm (smue1stAddress), FullBox^. Y1 + 4,  3, Cnf. ColorScheme [cdText]);
  FastWrite (User. Address1, FullBox^. Y1 + 4, 17, Cnf. ColorScheme [cdInput]);
  FastWrite (sm (smue2ndAddress), FullBox^. Y1 + 5, 3, Cnf. ColorScheme [cdText]);
  FastWrite (User. Address2, FullBox^. Y1 + 5, 17, Cnf. ColorScheme [cdInput]);
  FastWrite (sm (smue3rdAddress), FullBox^. Y1 + 6,  3, Cnf. ColorScheme [cdText]);
  FastWrite (User. Address3, FullBox^. Y1 + 6, 17, Cnf. ColorScheme [cdInput]);
  FastWrite (sm (smueComment), FullBox^. Y1 + 7, 3, Cnf. ColorScheme [cdText]);
  FastWrite (User. Comment, FullBox^. Y1 + 7, 17, Cnf. ColorScheme [cdInput]);
  FastWrite (sm (smueAlias), FullBox^. Y1 + 8, 3, Cnf. ColorScheme [cdText]);
  FastWrite (User. Alias, FullBox^. Y1 + 8, 17, Cnf. ColorScheme [cdInput]);
  FastWrite (sm (smuePassword), FullBox^. Y1 + 9,  3, Cnf. ColorScheme [cdText]);
  FastWrite (User. Password, FullBox^. Y1 + 9, 17, Cnf. ColorScheme [cdInput]);

  FastWrite (sm (smueHomePhone), FullBox^. Y1 + 10, 3, Cnf. ColorScheme [cdText]);
  FastWrite (User. HPhone, FullBox^. Y1 + 10, 17, Cnf. ColorScheme [cdInput]);
  FastWrite (sm (smueDataPhone), FullBox^. Y1 + 11,  3, Cnf. ColorScheme [cdText]);
  FastWrite (User. BPhone, FullBox^. Y1 + 11, 17, Cnf. ColorScheme [cdInput]);
  FastWrite (sm (smueBirthdate), FullBox^. Y1 + 12, 3, Cnf. ColorScheme [cdText]);
  FastWrite (ReFormatDate (Long2Date (User. BirthDate), DefaultDateMask, Cnf. DateMask), FullBox^. Y1 + 12, 17,
            Cnf. ColorScheme [cdInput]);
  FastWrite (sm (smueMsgsPosted), FullBox^. Y1 + 13,  3, Cnf. ColorScheme [cdText]); Str (User. MsgsPosted, TempS);
  FastWrite (TempS, FullBox^. Y1 + 13, 17, Cnf. ColorScheme [cdInput]);
  FastWrite (sm (smueProtocol), FullBox^. Y1 + 14, 3, Cnf. ColorScheme [cdText]);
  FastWrite (User. Protocol, FullBox^. Y1 + 14, 17, Cnf. ColorScheme [cdInput]);
  FastWrite (sm (smueLines), FullBox^. Y1 + 15, 3, Cnf. ColorScheme [cdText]); Str (User. Lines, TempS);
  FastWrite (TempS, FullBox^. Y1 + 15, 17, Cnf. ColorScheme [cdInput]);
  FastWrite (sm (smueLanguage), FullBox^. Y1 + 16, 3, Cnf. ColorScheme [cdText]);
  FastWrite (User. Lang, FullBox^. Y1 + 16, 17, Cnf. ColorScheme [cdInput]);
  FastWrite (sm (smueEmulation), FullBox^. Y1 + 17,  3, Cnf. ColorScheme [cdText]);
  FastWrite (SpaceAdd (EmuTypeString [User. Emu], 4), FullBox^. Y1 + 17, 17, Cnf. ColorScheme [cdInput]);
  FastWrite (sm (smueFlags), FullBox^. Y1 + 18, 3, Cnf. ColorScheme [cdText]);
  FastWrite (SpaceAdd (UpString (User. Flags), 8), FullBox^. Y1 + 18, 17, Cnf. ColorScheme [cdInput]);

  FastWrite (sm (smueDownloads), FullBox^. Y1 + 8, 37, Cnf. ColorScheme [cdText]); Str (User. Downloads, TempS);
  FastWrite (TempS, FullBox^. Y1 + 8, 51, Cnf. ColorScheme [cdInput]);
  FastWrite (sm (smueDownloadsK), FullBox^. Y1 + 9, 37, Cnf. ColorScheme [cdText]); Str (User. DownloadsK, TempS);
  FastWrite (TempS, FullBox^. Y1 + 9, 51, Cnf. ColorScheme [cdInput]);
  FastWrite (sm (smueTodayK), FullBox^. Y1 + 10, 37, Cnf. ColorScheme [cdText]); Str (User. TodayK, TempS);
  FastWrite (TempS, FullBox^. Y1 + 10, 51, Cnf. ColorScheme [cdInput]);
  FastWrite (sm (smueUploads), FullBox^. Y1 + 11, 37, Cnf. ColorScheme [cdText]); Str (User. Uploads, TempS);
  FastWrite (TempS, FullBox^. Y1 + 11, 51, Cnf. ColorScheme [cdInput]);
  FastWrite (sm (smueUploadsK), FullBox^. Y1 + 12, 37, Cnf. ColorScheme [cdText]); Str (User. UploadsK, TempS);
  FastWrite (TempS, FullBox^. Y1 + 12, 51, Cnf. ColorScheme [cdInput]);

  FastWrite (sm (smuePausing), FullBox^. Y1 + 13, 37, Cnf. ColorScheme [cdText]);
  If User. More
    Then FastWrite (sm (smYes), FullBox^. Y1 + 13, 51, Cnf. ColorScheme [cdInput])
    Else FastWrite (sm (smNo), FullBox^. Y1 + 13, 51, Cnf. ColorScheme [cdInput]);

  FastWrite (sm (smueHotKeys), FullBox^. Y1 + 14, 37, Cnf. ColorScheme [cdText]);
  If User. HotKeys
    Then FastWrite (sm (smYes), FullBox^. Y1 + 14, 51, Cnf. ColorScheme [cdInput])
    Else FastWrite (sm (smNo), FullBox^. Y1 + 14, 51, Cnf. ColorScheme [cdInput]);

  FastWrite (sm (smueFSeditor), FullBox^. Y1 + 15, 37, Cnf. ColorScheme [cdText]);
  If User. FSeditor
    Then FastWrite (sm (smYes), FullBox^. Y1 + 15, 51, Cnf. ColorScheme [cdInput])
    Else FastWrite (sm (smNo), FullBox^. Y1 + 15, 51, Cnf. ColorScheme [cdInput]);

  (*------ Static Data ------*)
  FastWrite (sm (smueLastDate), FullBox^. Y1 + 16, 37, Cnf. ColorScheme [cdText]);
  FastWrite (ReFormatDate (Long2Date (User. LastDate), DefaultDateMask, Cnf. DateMask), FullBox^. Y1 + 16, 51,
             Cnf. ColorScheme [cdText]);
  FastWrite (sm (smueFirstCall), FullBox^. Y1 + 17, 37, Cnf. ColorScheme [cdText]);
  FastWrite (ReFormatDate (Long2Date (User. FirstDate), DefaultDateMask, Cnf. DateMask), FullBox^. Y1 + 17, 51,
             Cnf. ColorScheme [cdText]);
  FastWrite (sm (smueCalls), FullBox^. Y1 + 18, 37, Cnf. ColorScheme [cdText]);
  FastWrite (Long2Str (User. NoCalls), FullBox^. Y1 + 18, 51, Cnf. ColorScheme [cdText]);
  (*-------------------------*)
  NormalCursor;

  _Location :

  User. Location := Input (17, FullBox^. Y1 + 2, User. Location, ' ', '', 50, 0, [#32..#255], True, Keyb,
                    Cnf. ColorScheme [cdInput], Changes);
  FastWrite (SpaceAdd (User. Location, 50), FullBox^. Y1 + 2, 17, Cnf. ColorScheme [cdInput]);
  If Keyb = 72 { Up       } Then Goto _FSed;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  _Organization :

  User. Organization := Input (17, FullBox^. Y1 + 3, User. Organization, ' ', '', 50, 0,
                               [#32..#255], True, Keyb, Cnf. ColorScheme [cdInput], Changes);
  FastWrite (SpaceAdd (User. Organization, 50), FullBox^. Y1 + 3, 17, Cnf. ColorScheme [cdInput]);
  If Keyb = 72 { Up       } Then Goto _Location;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  _1st_address :

  User. Address1 := Input (17, FullBox^. Y1 + 4, User. Address1, ' ', '', 50, 0,
                           [#32..#255], True, Keyb, Cnf. ColorScheme [cdInput], Changes);
  FastWrite (SpaceAdd (User. Address1, 50), FullBox^. Y1 + 4, 17, Cnf. ColorScheme [cdInput]);
  If Keyb = 72 { Up       } Then Goto _Organization ;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  _2nd_address:

  User. Address2 := Input (17, FullBox^. Y1 + 5, User. Address2, ' ', '', 50, 0,
  [#32..#255], True, Keyb, Cnf. ColorScheme [cdInput], Changes);
  FastWrite (SpaceAdd (User. Address2, 50), FullBox^. Y1 + 5, 17, Cnf. ColorScheme [cdInput]);
  If Keyb = 72 { Up       } Then Goto _1st_address;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  _3rd_address:

  User. Address3 := Input (17, FullBox^. Y1 + 6, User. Address3, ' ', '', 50, 0,
  [#32..#255], True, Keyb, Cnf. ColorScheme [cdInput], Changes);
  FastWrite (SpaceAdd (User. Address3, 50), FullBox^. Y1 + 6, 17, Cnf. ColorScheme [cdInput]);
  If Keyb = 72 { Up       } Then Goto _2nd_address ;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  _Comment:

  User. Comment := Input (17, FullBox^. Y1 + 7, User. Comment, ' ', '', 61, 0,
                   [#32..#255], True, Keyb, Cnf. ColorScheme [cdInput], Changes);
  FastWrite (SpaceAdd (User. Comment, 61), FullBox^. Y1 + 7, 17, Cnf. ColorScheme [cdInput]);
  If Keyb = 72 { Up       } Then Goto _3rd_address;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  _Alias:

  User. Alias := Input (17, FullBox^. Y1 + 8, User. Alias, ' ', '', 15, 0,
                 [#32..#255], True, Keyb, Cnf. ColorScheme [cdInput], Changes);
  FastWrite (SpaceAdd (User. Alias, 15), FullBox^. Y1 + 8, 17, Cnf. ColorScheme [cdInput]);
  If Keyb = 72 { Up       } Then Goto _Comment;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  _Password:

  User. Password := Input (17, FullBox^. Y1 + 9, User. Password, ' ', {'*'}'', 16, 0,
                    [#32..#255], True, Keyb, Cnf. ColorScheme [cdInput], Changes);
  FastWrite (SpaceAdd (User. Password, 15), FullBox^. Y1 + 9, 17, Cnf. ColorScheme [cdInput]);

  If Keyb = 72 { Up       } Then Goto _Alias ;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  _Home_phone:

  User. HPhone := Input (17, FullBox^. Y1 + 10, User. HPhone, ' ', '', 15, 0,
                  [#32..#255], True, Keyb, Cnf. ColorScheme [cdInput], Changes);
  FastWrite (SpaceAdd (User. HPhone, 15), FullBox^. Y1 + 10, 17, Cnf. ColorScheme [cdInput]);
  If Keyb = 72 { Up       } Then Goto _Password;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  _Data_phone:

  User. BPhone := Input (17, FullBox^. Y1 + 11, User. BPhone, ' ', '', 15, 0,
  [#32..#255], True, Keyb, Cnf. ColorScheme [cdInput], Changes);
  FastWrite (SpaceAdd (User. BPhone, 15), FullBox^. Y1 + 11, 17, Cnf. ColorScheme [cdInput]);
  If Keyb = 72 { Up       } Then Goto _Home_phone ;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  _Birthdate:

  TempS := Input (17, FullBox^. Y1 + 12, ReFormatDate (Long2Date (User. BirthDate),
                  DefaultDateMask, Cnf. DateMask), ' ', '', Length (Cnf. DateMask),
                  0, [#45, #48..#57], True, Keyb, Cnf. ColorScheme [cdInput], Changes);

  User. BirthDate := Date2Long (ReFormatDate (TempS, Cnf. DateMask, DefaultDateMask));
  FastWrite (SpaceAdd (TempS, 8), FullBox^. Y1 + 12, 17, Cnf. ColorScheme [cdInput]);

  If Keyb = 72 { Up       } Then Goto _Data_phone ;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  DoStr := True;

  _MsgsPosted:

  If DoStr Then Str (User. MsgsPosted, TempS);
  TempS := Input (17, FullBox^. Y1 + 13, TempS, ' ', '', 10, 0,
                 [#48..#57], True, Keyb, Cnf. ColorScheme
                 [cdInput], Changes);

  Val (TempS, User. MsgsPosted, T);
  Str (User. MsgsPosted, Temp);
  If Temp <> TempS Then
  Begin
    ValidDataBox (0, 2147483647);
    DoStr := False;
    Goto _MsgsPosted;
  End;

  DoStr := True;
  FastWrite (SpaceAdd (TempS, 10), FullBox^. Y1 + 13, 17, Cnf. ColorScheme [cdInput]);
  If Keyb = 72 { Up       } Then Goto _Birthdate ;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  _Protocol:

  TempS := Input (17, FullBox^. Y1 + 14, User. Protocol, ' ', '', 1, 0,
                 [#32..#255], False, Keyb, Cnf. ColorScheme
                 [cdInput], Changes);
  User. Protocol := TempS [1];

  FastWrite (User. Protocol, FullBox^. Y1 + 14, 17, Cnf. ColorScheme [cdInput]);
  If Keyb = 72  { Up       } Then Goto _MsgsPosted;
  If Keyb = 27  { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  _Lines:

  If DoStr Then Str (User. Lines, TempS);
  TempS := Input (17, FullBox^. Y1 + 15, TempS, ' ', '', 3, 0, [#48..#57], True, Keyb, Cnf. ColorScheme [cdInput], Changes);
  Val (TempS, User. Lines, T);
  Str (User. Lines, Temp);
  If Temp <> TempS Then
  Begin
    ValidDataBox (0, 255);
    DoStr := False;
    Goto _Lines;
  End;
  DoStr := True;
  FastWrite (SpaceAdd (TempS, 3), FullBox^. Y1 + 15, 17, Cnf. ColorScheme [cdInput]);
  If Keyb = 72 { Up       } Then Goto _Protocol;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  _Language:

  User. Lang := Input (17, FullBox^. Y1 + 16, User. Lang, ' ', '', 8, 0,
                [#32..#255], True, Keyb, Cnf. ColorScheme [cdInput],
                Changes);

  FastWrite (SpaceAdd (User. Lang, 8), FullBox^. Y1 + 16, 17,
             Cnf. ColorScheme [cdInput]);

  If Keyb = 72 { Up       } Then Goto _Lines ;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  _Emulation:

  GoToXY (17, FullBox^. Y1 + 17);
  FastWrite (EmuTypeString [User. Emu], FullBox^. Y1 + 17, 17, Cnf. ColorScheme [cdInput]);
  Ex := False;

  While not Ex do
  Begin
    If Not WaitForKey (CH) Then Ex := True;
    Case Ord (CH) Of
      {Tab}  9 : Ex := True;

      {Esc} 27 : Begin
                   Keyb := 27;
                   Ex := True;
                 End;

      {CR } 13,
      {Spc} 32 : GoTo _EmulationMenu;
      0 : Begin
            If Not WaitForKey (CH) Then Ex := True;
            Keyb := Ord (CH);
            Case Keyb Of
              { Up       }  72,
              { Down     }  80,
              { CtrlEnd  } 117,
              { CtrlHome } 119 : Ex := True;
              End;
            End;
      End;
  End;
  FastWrite (EmuTypeString [User. Emu], FullBox^. Y1 + 17, 17, Cnf. ColorScheme [cdInput]);
  NormalCursor;
  If Keyb =  27 { Esc      } Then Goto _Finished_;
  If Keyb =  72 { Up       } Then Goto _Language;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  GoTo _Flags;

  _EmulationMenu:

  RX := WhereX; RY := WhereY;
  HiddenCursor;
  InitWindow (ConfirmBox, 13, FullBox^. Y1 + 15, 26, FullBox^. Y1 + 19, 1,
              Cnf. ColorScheme [cdFrame], '', $00, ZoomSpeed, False);

  DrawWindow (ConfirmBox);
  For tEmu := teANSI To teAvatar Do
   FastWrite (EmuTypeString [tEmu], FullBox^. Y1 + 16 + Ord(tEmu), 17, Cnf. ColorScheme [cdText]);
  tEmu := User. Emu;
  Ex := False;
  Keyb := 0;
  While Not Ex Do
  Begin
    FastWrite ('  ' + EmuTypeString [tEmu]+ '  ', FullBox^. Y1 + 16 + Ord(tEmu), 15, Cnf. ColorScheme [cdInput]);
    If Not WaitForKey (CH) Then Ex := True;
    Case Ord (CH) Of
      {Esc} 27 : Ex := True;
      {CR } 13 :
                 Begin
                   If tEmu <> User. Emu Then Changes := True;
                   User. Emu := tEmu;
                   Ex := True;
                 End;
      {Tab}  9 :
                 Begin
                   If tEmu <> User. Emu Then Changes := True;
                   User. Emu := tEmu;
                   Ex := True;
                 End;
      0 :
          Begin
            If Not WaitForKey (CH) Then Ex := True;
            Keyb := Ord (CH);
            Case Keyb Of
              { Up       }  72 :
                                 Begin
                                   FastWrite ('  ' + EmuTypeString [tEmu] + '  ', FullBox^. Y1 + 16 + Ord(tEmu), 15,
                                              Cnf. ColorScheme [cdText]);
                                   If tEmu = teANSI then tEmu := teAvatar
                                    Else Dec(tEmu);
                                 End;
              { Down     }  80 :
                                 Begin
                                   FastWrite ('  ' + EmuTypeString [tEmu] + '  ', FullBox^. Y1 + 16 + Ord(tEmu), 15,
                                              Cnf. ColorScheme [cdText]);
                                   If tEmu = teAvatar then tEmu := teANSI
                                    Else Inc (tEmu);
                                 End;
              { Home     }  71 : If tEmu <> teANSI Then
                                 Begin
                                   FastWrite ('  ' + EmuTypeString [tEmu] + '  ', FullBox^. Y1 + 16 + Ord(tEmu), 15,
                                              Cnf. ColorScheme [cdText]);
                                   tEmu := teANSI;
                                 End;
              { End      }  79 : If tEmu <> teAvatar Then
                                 Begin
                                   FastWrite ('  ' + EmuTypeString [tEmu] + '  ', FullBox^. Y1 + 16 + Ord(tEmu), 15,
                                              Cnf. ColorScheme [cdText]);
                                   tEmu := teAvatar;
                                 End;


              { CtrlEnd  } 117,
              { CtrlHome } 119 :
                                 Begin
                                   If tEmu <> User. Emu Then Changes := True;
                                   User. Emu := tEmu;
                                   Ex := True;
                                 End;
            End;
          End;

    End;
  End;
  CloseWindow (ConfirmBox);
  GotoXY (RX, RY);
  NormalCursor;
  FastWrite (EmuTypeString [tEmu], FullBox^. Y1 + 17, 17, Cnf. ColorScheme [cdInput]);
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;
  GoTo _Emulation;

  DoStr := True;

  _Flags:

  User. Flags := UpString (Input (17, FullBox^. Y1 + 18, UpString (User. Flags), ' ', '',
                 8, 0, ['A'..'Z','a'..'z'], True, Keyb, Cnf. ColorScheme [cdInput],
                 Changes));

  FastWrite (SpaceAdd (User. Flags, 8), FullBox^. Y1 + 18, 17, Cnf. ColorScheme [cdInput]);
  If Keyb = 72 { Up       } Then Goto _Emulation;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  _Downloads:

  If DoStr Then Str (User. Downloads, TempS);
  TempS := Input (51, FullBox^. Y1 + 8, TempS, ' ', '', 10, 0, [#48..#57], True, Keyb, Cnf. ColorScheme [cdInput], Changes);
  Val (TempS, User. Downloads, T);
  Str (User. Downloads, Temp);
  If Temp <> TempS Then
  Begin
    ValidDataBox (0, 2147483647);
    DoStr := False;
    Goto _Downloads;
  End;
  DoStr := True;
  FastWrite (SpaceAdd (TempS, 10), FullBox^. Y1 + 8, 51, Cnf. ColorScheme [cdInput]);
  If Keyb = 72 { Up       } Then Goto _Flags;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  DoStr := True;

  _DownloadsK:

  If DoStr Then Str (User. DownloadsK, TempS);
  TempS := Input (51, FullBox^. Y1 + 9, TempS, ' ', '', 10, 0, [#48..#57], True, Keyb, Cnf. ColorScheme [cdInput], Changes);
  Val (TempS, User. DownloadsK, T);
  Str (User. DownloadsK, Temp);
  If Temp <> TempS Then
  Begin
    ValidDataBox (0, 2147483647);
    DoStr := False;
    Goto _DownloadsK;
  End;
  DoStr := True;
  FastWrite (SpaceAdd (TempS, 10), FullBox^. Y1 + 9, 51, Cnf. ColorScheme [cdInput]);
  If Keyb = 72 { Up       } Then Goto _Downloads;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  DoStr := True;

  _TodayK:

  If DoStr Then Str (User. TodayK, TempS);
  TempS := Input (51, FullBox^. Y1 + 10, TempS, ' ', '', 10, 0, [#48..#57], True, Keyb, Cnf. ColorScheme [cdInput], Changes);
  Val (TempS, User. TodayK, T);
  Str (User. TodayK, Temp);
  If Temp <> TempS Then
  Begin
    ValidDataBox (0, 2147483647);
    DoStr := False;
    Goto _TodayK;
  End;
  DoStr := True;
  FastWrite (SpaceAdd (TempS, 10), FullBox^. Y1 + 10, 51, Cnf. ColorScheme [cdInput]);
  If Keyb = 72 { Up       } Then Goto _DownloadsK;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  DoStr := True;

  _Uploads:

  If DoStr Then Str (User. Uploads, TempS);
  TempS := Input (51, FullBox^. Y1 + 11, TempS, ' ', '', 10, 0, [#48..#57], True, Keyb, Cnf. ColorScheme [cdInput], Changes);
  Val (TempS, User. Uploads, T);
  Str (User. Uploads, Temp);
  If Temp <> TempS Then
  Begin
    ValidDataBox (0, 2147483647);
    DoStr := False;
    Goto _Uploads;
  End;
  DoStr := True;
  FastWrite (SpaceAdd (TempS, 10), FullBox^. Y1 + 11, 51, Cnf. ColorScheme [cdInput]);
  If Keyb = 72 { Up       } Then Goto _TodayK;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  DoStr := True;

  _UploadsK:

  If DoStr Then Str (User. UploadsK, TempS);
  TempS := Input (51, FullBox^. Y1 + 12, TempS, ' ', '', 10, 0, [#48..#57], True, Keyb,
           Cnf. ColorScheme [cdInput], Changes);
  Val (TempS, User. UploadsK, T);
  Str (User. UploadsK, Temp);
  If Temp <> TempS Then
  Begin
    ValidDataBox (0, 2147483647);
    DoStr := False;
    Goto _UploadsK;
  End;
  DoStr := True;
  FastWrite (SpaceAdd (TempS, 10), FullBox^. Y1 + 12, 51, Cnf. ColorScheme [cdInput]);
  If Keyb = 72 { Up       } Then Goto _Uploads;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  _Pause:

  GoToXY (51, FullBox^. Y1 + 13);
  ex := False;
  While Not ex Do
  Begin
    Keyb := 0;
    If User. More Then FastWrite (PadCh (sm (smYes), ' ', BoolLength), FullBox^. Y1 + 13, 51, Cnf. ColorScheme [cdInput])
                  Else FastWrite (PadCh (sm (smNo), ' ', BoolLength), FullBox^. Y1 + 13, 51, Cnf. ColorScheme [cdInput]);

    If Not WaitForKey (CH) Then Ex := True;
    Keyb := Ord (CH);
    Case Keyb Of
      32, 13 : Begin
                 User. More := Not User. More;
                 Changes := True;
               End;
      27, 9  : Ex := True;
      0      : Begin
                 If Not WaitForKey (CH) Then Ex := True;
                 If CH In [#72, #80, #117, #119] Then Ex := True;
               End;
    End;
    If ex Then
      If User. More Then FastWrite (PadCh (sm (smYes), ' ', BoolLength), FullBox^. Y1 + 13, 51, Cnf. ColorScheme [cdInput])
                    Else FastWrite (PadCh (sm (smNo),  ' ', BoolLength), FullBox^. Y1 + 13, 51, Cnf. ColorScheme [cdInput]);
  End;

  If Keyb = 27 { Esc      } Then Goto _Finished_;
  NormalCursor;
  Keyb := Ord (CH);
  If Keyb =  72 { Up       } Then Goto _UploadsK ;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  _HotKeys:

  GoToXY (51, FullBox^. Y1 + 14);
  ex := False;
  While Not ex Do
  Begin
    Keyb := 0;
    If User. HotKeys Then FastWrite (PadCh (sm (smYes), ' ', BoolLength), FullBox^. Y1 + 14, 51, Cnf. ColorScheme [cdInput])
                     Else FastWrite (PadCh (sm (smNo), ' ', BoolLength), FullBox^. Y1 + 14, 51, Cnf. ColorScheme [cdInput]);

    If Not WaitForKey (CH) Then Ex := True;
    Keyb := Ord (CH);
    Case Keyb Of
      32, 13 : Begin
                 User. HotKeys := Not User. HotKeys;
                 Changes := True;
               End;
      27, 9  : Ex := True;
      0      : Begin
                 If Not WaitForKey (CH) Then Ex := True;
                 If CH In [#72, #80, #117, #119] Then Ex := True;
               End;
    End;
    If ex Then
      If User. HotKeys Then FastWrite (PadCh (sm (smYes), ' ', BoolLength), FullBox^. Y1 + 14, 51, Cnf. ColorScheme [cdInput])
                       Else FastWrite (PadCh (sm (smNo), ' ', BoolLength), FullBox^. Y1 + 14, 51, Cnf. ColorScheme [cdInput]);
  End;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  NormalCursor;
  Keyb := Ord (CH);
  If Keyb =  72 { Up       } Then Goto _Pause ;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  _FSed:

  GoToXY (51, FullBox^. Y1 + 15);
  ex := False;
  While Not ex Do
  Begin
    Keyb := 0;
    If User. FSeditor
      Then FastWrite (PadCh (sm (smYes), ' ', BoolLength), FullBox^. Y1 + 15, 51, Cnf. ColorScheme [cdInput])
      Else FastWrite (PadCh (sm (smNo), ' ', BoolLength), FullBox^. Y1 + 15, 51, Cnf. ColorScheme [cdInput]);

    If Not WaitForKey (CH) Then Ex := True;
    Keyb := Ord (CH);
    Case Keyb Of
      32, 13 : Begin
                 User. FSeditor := Not User. FSeditor;
                 Changes := True;
               End;
      27, 9  : Ex := True;
      0      : Begin
                 If Not WaitForKey (CH) Then Ex := True;
                 If CH In [#72, #80, #117, #119] Then Ex := True;
               End;
    End;
    If ex Then
      If User. FSeditor Then FastWrite (PadCh (sm (smYes), ' ', BoolLength), FullBox^. Y1 + 15, 51, Cnf. ColorScheme [cdInput])
                        Else FastWrite (PadCh (sm (smNo), ' ', BoolLength), FullBox^. Y1 + 15, 51, Cnf. ColorScheme [cdInput]);
  End;
  If Keyb = 27 { Esc      } Then Goto _Finished_;
  NormalCursor;
  Keyb := Ord (CH);
  If Keyb =  72 { Up       } Then Goto _HotKeys;
  If Keyb = 119 { CtrlHome } Then Goto _Location;
  If Keyb = 117 { CtrlEnd  } Then Goto _FSed;

  Goto _Location;

  _Finished_ :

  If Changes Then
  Begin
    HiddenCursor;

    i := SelectBox ('Yes|No', Cnf. ColorScheme [cdFrame],
    Cnf. ColorScheme [cdButton], Cnf. ColorScheme [cdTitle],
    ZoomSpeed, sm (smueSaveYN));

    If i = 0 Then GoTo _Location Else
    Ex :=
    {$IFNDEF WIN32}
          (i = 1)
    {$ELSE}
          True
    {$ENDIF};
    NormalCursor;
  End;

  CloseWindow (FullBox);
  GoToXY (OX, OY);
  EditUser := Ex;
  NormalCursor;
End;

End.
