EdLineText.dcl 2.06 KB
Newer Older
Diederik van Arkel's avatar
Diederik van Arkel committed
1 2
definition module EdLineText

3 4
// a type for dealing with line-oriented operations on texts

5 6
from StrictList	import :: StrictList
from EdPosition	import :: LineNr
Diederik van Arkel's avatar
Diederik van Arkel committed
7
from syncol		import :: Info
Diederik van Arkel's avatar
Diederik van Arkel committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

:: Text
:: TextFragment
	:== StrictList String

newText				:: Text
emptyText			:: Text

textToStrings		:: !Text							-> StrictList String
stringsToText		:: (StrictList String)				-> Text
stringsToString		:: !(StrictList String)				-> String
stringToStrings		:: !String							-> (StrictList String)

StringToText s
	:== stringsToText (stringToStrings s)
 
textLength			:: !Text							-> Int
lastLineNr			:: !Text							-> LineNr
validateLineNr		:: !LineNr Text						-> LineNr

28
getLine				:: !LineNr !u:Text					-> (!String, !u:Text)
Diederik van Arkel's avatar
Diederik van Arkel committed
29
getLineC			:: !LineNr !u:Text					-> ((!Info,!String), !u:Text)
30
getLines			:: !LineNr !LineNr !Text			-> (!StrictList String, !Text)
Diederik van Arkel's avatar
Diederik van Arkel committed
31 32
//getLinesC			:: LineNr LineNr Text				-> (StrictList (Int,String), Text)

33
updateLine			:: !LineNr !String !.Text			-> (!Int,!Int,!.Text)
Diederik van Arkel's avatar
Diederik van Arkel committed
34 35 36 37
removeLine			:: !LineNr !Text					-> Text

removeLines			:: !LineNr !LineNr !Text				-> Text
insertLines			:: !LineNr !(StrictList String) !Text	-> Text
38 39
appendLines			:: !(StrictList String) !Text			-> Text
appendLines`		:: !(StrictList String) !Text			-> Text
Diederik van Arkel's avatar
Diederik van Arkel committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59

// newText:			creates a new text. A new text consists of one
//					empty line.

// textToStrings:	converts a text to a list of strings. 
// stringsToText:	converts a list of strings to a text. 

// textLength:		returns the number of lines in the text.
// lastLineNr:		returns the number of the last line in the text.
// validateLineNr:	makes sure that the line number is legal within the text.

// getLine:			returns the line indicated by the line number.
// getLinesFrom:	returns the lines including and below the line 
//					indicated by the line number.
// updateLine:		changes the line by the given string.
// removeLine:		removes the line with the given number.
// removeLines:		removes all lines with line numbers
//					between and including the given line numbers.
// insertLines:		inserts some lines before the line with the given number.