home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / RADOOR30.ZIP / BBSEDIT.ZIP / BBSEDIT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-04-12  |  6.9 KB  |  269 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. Unit BBSedit;
  17. Interface
  18. Uses KeyDefs,
  19.      LowLevel,
  20.      UserHook,
  21.      Fossil,
  22.      GlobInfo,
  23.      RA;
  24.  
  25.  
  26. {
  27.   MenuKeys: Position  Meaning
  28.                1      Abort         Make sure the keys are in this order!!
  29.                2      List
  30.                3      Continue
  31.                4      Save
  32. }
  33.  
  34. Const StatLine    : String[100] = '';
  35.       MenuLine    : String[100] = '';
  36.       MenuKeys    : String[6]   = '';
  37.       YourChoice  : String[20]  = '';
  38.       Counter     : String[20]  = '';
  39.  
  40. Type  LineType  = String[80];
  41.       BodyArray = Array[0..255] Of LineType;
  42.       BodyType  = ^BodyArray;
  43.  
  44. Procedure LineEditor(Var Foss     : FossilObject;
  45.                          Body     : BodyType;
  46.                      Var Lines    : Byte;
  47.                          MaxLines : Byte);
  48.  
  49.  
  50. Implementation
  51.  
  52.  
  53. Procedure LineEditor(Var Foss     : FossilObject;
  54.                          Body     : BodyType;
  55.                      Var Lines    : Byte;
  56.                          MaxLines : Byte);
  57.  
  58. Var StopEdit : Boolean;
  59.     CurrLine : Byte;
  60.     Key      : Char;
  61.  
  62. Procedure List(Start : Byte;More : Boolean);
  63. Var Count  : Byte;
  64.     TCount : String[20];
  65.     CPos   : Byte;
  66.  
  67. Begin
  68. With Foss Do
  69.  Begin
  70.  ClrScrF;
  71.  WriteLnF(StatLine);
  72.  WriteLnF('');
  73.  
  74.  If CurrLine=0
  75.     Then Exit;
  76.  
  77.  For Count := Start To CurrLine-1 Do
  78.   Begin
  79.   TCount:=Counter;
  80.   CPos:=Pos('@',TCount);
  81.   Delete(TCount,CPos,1);
  82.   Insert(S(Count,3),TCount,CPos);
  83.   WriteLnF(TCount+Body^[Count]);
  84.   If More And ((Count Mod (GlobalInfo.ScreenLength-4))=(GlobalInfo.ScreenLength-5))
  85.      Then Begin
  86.           WriteLnF('');
  87.           PressENTER;
  88.           ClrScrF;
  89.           WriteLnF(StatLine);
  90.           WriteLnF('');
  91.           End;
  92.   End; {For}
  93.  End; {With}
  94. End;
  95.  
  96.  
  97.  
  98. Function WrapLine(Var Line : LineType):LineType;
  99. Var LinePtr : Byte;
  100.     DelChars: Byte;
  101. Begin
  102. LinePtr:=Length(Line);
  103. While (LinePtr>0) And (Not (Line[LinePtr] In [' ',#9])) Do
  104.  Dec(LinePtr);
  105. If LinePtr=0
  106.    Then Begin
  107.         WrapLine:='';
  108.         Exit;
  109.         End;
  110.  
  111. For DelChars:=1 To (Length(Line)-LinePtr+1) Do
  112.   Foss.WriteF(#8' '#8);
  113. WrapLine:=Copy(Line,LinePtr+1,Length(Line)-LinePtr);
  114. Line:=Copy(Line,1,LinePtr-1);
  115. End;
  116.  
  117.  
  118.  
  119. Procedure EditText;
  120.  
  121. Var TempLine : String[80];
  122.     Gotcha   : Boolean;
  123.     Key      : Char;
  124.     Stop     : Boolean;
  125.     TCount   : String[20];
  126.     CPos     : Byte;
  127.  
  128.  
  129. Begin
  130. With Foss Do
  131.  Begin
  132.  Stop:=False;
  133.  TCount:=Counter;
  134.  CPos:=Pos('@',TCount);
  135.  Delete(TCount,CPos,1);
  136.  Insert(S(CurrLine,3),TCount,CPos);
  137.  WriteF(#13+TCount);
  138.  
  139.  Repeat
  140.   Gotcha:=False;
  141.   Repeat
  142.   If KeyPressedF
  143.      Then Begin
  144.           Key:=ReadKeyF;
  145.           If Key<>#$FF         { The SysOp Keys! }
  146.              Then Gotcha:=True;
  147.           End;
  148.   Until Gotcha Or Emergency;
  149.  
  150.  Case Key Of
  151.   CR  : Begin
  152.         If (Body^[CurrLine]<>'') And
  153.            (CurrLine<MaxLines)
  154.            Then Begin
  155.                 Inc(CurrLine);
  156.                 WriteF(#13#10);
  157.                 TCount:=Counter;
  158.                 CPos:=Pos('@',TCount);
  159.                 Delete(TCount,CPos,1);
  160.                 Insert(S(CurrLine,3),TCount,CPos);
  161.                 WriteF(TCount);
  162.                 End
  163.            Else Stop:=True;
  164.         End;
  165.   BS  : Begin
  166.         If Body^[CurrLine]<>''
  167.            Then Begin
  168.                 Dec(Body^[CurrLine][0]);
  169.                 WriteF(#8' '#8);
  170.                 End;
  171.         End;
  172.   Else  Begin
  173.         If Key>=#32
  174.            Then Begin
  175.                 WriteF(Key);
  176.                 Body^[CurrLine]:=Body^[CurrLine]+Key;
  177.                 If Length(Body^[CurrLine])=65
  178.                    Then Begin
  179.                         Inc(CurrLine);
  180.                         If CurrLine<MaxLines
  181.                            Then Begin
  182.                                 Body^[CurrLine]:=WrapLine(Body^[CurrLine-1]);
  183.                                 WriteF(#13#10);
  184.                                 TCount:=Counter;
  185.                                 CPos:=Pos('@',TCount);
  186.                                 Delete(TCount,CPos,1);
  187.                                 Insert(S(CurrLine,3),TCount,CPos);
  188.                                 WriteF(TCount);
  189.                                 WriteF(Body^[CurrLine]);
  190.                                 End
  191.                            Else Begin
  192.                                 WriteF(#7);
  193.                                 Stop:=True;
  194.                                 End;
  195.                         End;
  196.                 End;
  197.         End;
  198.  End; {Case}
  199.  Until Emergency Or Stop;
  200.  End; {With FOSS}
  201. End;
  202.  
  203.  
  204. Begin
  205. CurrLine:=Lines;
  206. StopEdit:=False;
  207. With Foss Do
  208.  Begin
  209.  If CurrLine>0
  210.     Then Begin
  211.          If CurrLine>10
  212.              Then List(CurrLine-10,False)
  213.              Else List(0,False);
  214.         End
  215.     Else Begin
  216.          ClrScrF;
  217.          WriteLnF(StatLine);
  218.          WriteLnF('');
  219.          End;
  220.  End;
  221.  
  222.  
  223.  
  224. EditText;
  225.  
  226. Repeat  { Do menu }
  227.  With Foss Do
  228.   Begin
  229.   WriteF(#13);
  230.   WriteLnF('^1'+MakeString(79,'─')+'^0');
  231.   WriteLnF(MenuLine);
  232.   WriteF(YourChoice);
  233.   Key:=Upcase(Foss.AskKey(MenuKeys,MenuKeys[1]));
  234.   End; {With}
  235.  
  236.   Case Pos(Key,MenuKeys) Of
  237.     1  : Begin
  238.          StopEdit:=True;
  239.          Body^[0]:='';
  240.          Lines:=0;
  241.          End;
  242.     2  : List(0,True);
  243.     3  : Begin
  244.          If CurrLine>10
  245.             Then List(CurrLine-10,False)
  246.             Else List(0,False);
  247.          EditText;
  248.          End;
  249.     4  : Begin
  250.          StopEdit:=True;
  251.          If CurrLine>0
  252.             Then Lines:=CurrLine-1;
  253.          End;
  254.   End; {Case}
  255.  
  256. Until StopEdit Or Foss.Emergency;
  257. End;
  258.  
  259. Begin
  260.  
  261. { Default strings for the editor. }
  262.  
  263. StatLine:=Center('-=( Type your text now, use an empty line to finish )=-');
  264. MenuLine   := '   [L]ist      [C]ontinue      [S]ave       [A]bort';
  265. YourChoice := '   Your choice: ';
  266. MenuKeys   := 'ALCS';
  267. Counter    := '@]';
  268. End.
  269.