EdLineText.dcl 2.05 KB
Newer Older
Diederik van Arkel's avatar
Diederik van Arkel committed
1
2
3
4
5
6
/*
 * EdLineText.dcl: a type for dealing with line-oriented operations on texts
 */

definition module EdLineText

7
8
from StrictList	import :: StrictList
from EdPosition	import :: LineNr
Diederik van Arkel's avatar
Diederik van Arkel committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

:: 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

getLine				:: !LineNr !u:Text					-> !(!String, !u:Text)
getLineC			:: !LineNr !u:Text					-> !((!Int,!String), !u:Text)
getLines			:: LineNr LineNr Text				-> (StrictList String, Text)
//getLinesC			:: LineNr LineNr Text				-> (StrictList (Int,String), Text)

updateLine			:: !LineNr !String !.Text			-> (!Int,!.Text)
removeLine			:: !LineNr !Text					-> Text

removeLines			:: !LineNr !LineNr !Text				-> Text
insertLines			:: !LineNr !(StrictList String) !Text	-> Text
appendLines			:: !(StrictList String) !Text			-> !Text
appendLines`		:: !(StrictList String) !Text			-> !Text

// 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.