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:
2024-10-05 00:57:12 +01:00
parent 014c2ef7d1
commit 599252e5ed

View File

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