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