forked from standardml/cmlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoord.sig
executable file
·39 lines (30 loc) · 1.25 KB
/
coord.sig
1
2
3
4
5
6
7
8
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
(* A coordinate is a point location within a text document.
* Coordinates use a text-editor convention of counting from 1, not 0. *)
(* Adapted from Chris Okasaki, Robert Harper, and Tom Murphy VII's position
* library. *)
signature COORD =
sig
type coord
type t = coord
(* Positions are positions within a file; a filename must be given *)
val init : string -> coord
(* Advance to the next position over a regular character or a newline *)
val nextchar : coord -> coord
val nextline : coord -> coord
(* Filename originally passed to init *)
val file : coord -> string
(* Absolute position, which could be input to "M-x goto-char" in emacs *)
val abs : coord -> int
(* Line and character coordinates *)
val line : coord -> int
val char : coord -> int
(* Comparision and equality are only defined on coordinates that come
* from the same call to "init" (morally placing them within the same
* document). *)
val leftmost : coord -> coord -> coord
val rightmost : coord -> coord -> coord
val eq : (coord * coord) -> bool
val compare : (coord * coord) -> order
val hash : coord -> word
val toString : coord -> string
end