TextBuf.def 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. DEFINITION MODULE TextBuf ;
  2. (* Shared TP3-style text buffer: an array of characters in which lines
  3. are terminated by CR ($0D). Used by the shell (load/save) and by the
  4. editor. The buffer never stores a trailing ^Z. *)
  5. CONST
  6. TextLimit = 62903 ;
  7. PROCEDURE Clear ;
  8. (* reset the buffer to empty *)
  9. PROCEDURE Length () : CARDINAL ;
  10. (* number of characters currently stored *)
  11. PROCEDURE CharAt (i : CARDINAL) : CHAR ;
  12. (* character at offset i; 0 <= i < Length *)
  13. PROCEDURE InsertCh (i : CARDINAL ; ch : CHAR) ;
  14. (* insert one character at offset i, shifting text right.
  15. Does nothing if the buffer is full. *)
  16. PROCEDURE InsertStr (i : CARDINAL ; VAR s : ARRAY OF CHAR ; n : CARDINAL) : BOOLEAN ;
  17. (* insert the first n characters of s at offset i, in one right-shift.
  18. Returns FALSE, and changes nothing, if they do not all fit - so a caller
  19. pasting a whole file in cannot get a silently truncated buffer the way a
  20. loop of InsertCh would (InsertCh drops the overflow character and says
  21. nothing). *)
  22. PROCEDURE OverwriteCh (i : CARDINAL ; ch : CHAR) ;
  23. (* replace the character at offset i (no insertion) *)
  24. PROCEDURE DeleteAt (i : CARDINAL) ;
  25. (* delete one character at offset i, shifting text left *)
  26. PROCEDURE DeleteFromTo (i, n : CARDINAL) ;
  27. (* delete n characters starting at offset i *)
  28. END TextBuf.