add function to create a LineGap.t from a string (although, for performance reasons, it's best to use this function when string is shorter than 1024 chars)
This commit is contained in:
@@ -10,11 +10,14 @@ sig
|
|||||||
, rightLines: int vector list
|
, rightLines: int vector list
|
||||||
}
|
}
|
||||||
|
|
||||||
val delete: int * int * t -> t
|
|
||||||
val empty: t
|
val empty: t
|
||||||
val insert: int * string * t -> t
|
|
||||||
|
val fromString: string -> t
|
||||||
val toString: t -> string
|
val toString: t -> string
|
||||||
|
|
||||||
|
val delete: int * int * t -> t
|
||||||
|
val insert: int * string * t -> t
|
||||||
|
|
||||||
(* for testing *)
|
(* for testing *)
|
||||||
val verifyIndex: t -> unit
|
val verifyIndex: t -> unit
|
||||||
val verifyLines: t -> unit
|
val verifyLines: t -> unit
|
||||||
@@ -75,6 +78,15 @@ struct
|
|||||||
, rightLines = []
|
, rightLines = []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun fromString str =
|
||||||
|
{ idx = 0
|
||||||
|
, leftStrings = []
|
||||||
|
, rightStrings = [str]
|
||||||
|
, line = 0
|
||||||
|
, leftLines = []
|
||||||
|
, rightLines = [countLineBreaks str]
|
||||||
|
}
|
||||||
|
|
||||||
local
|
local
|
||||||
fun helpToString (acc, input) =
|
fun helpToString (acc, input) =
|
||||||
case input of
|
case input of
|
||||||
|
|||||||
Reference in New Issue
Block a user