inuit

Make interactive text-based user-interfaces in OCaml
IN THIS PACKAGE
Module Inuit_base . Patch
type operation =
| Remove of int
| Insert of string
| Replace of int * string
| Propertize of int
type 'flags t = private {
offset : int;(*

Starting at offset'th unicode sequence

*)
operation : operation;
text_len : int;
flags : 'flags list;(*

A list of backend defined flags.

*)
}

A flags Patch.t represents the replacement of a piece of text by another, possibly annotated by values of type flags.

val utf8_length : ?offset:int -> string -> int

utf8_length str is the number of unicode sequences in str.

str is assumed to be a valid utf-8 string, result is undefined otherwise.

val utf8_offset : string -> ?offset:int -> int -> int

utf8_offset str ?offset index returns the offset as a number of bytes of the indexth unicode sequences in str.

If offset is provided, search starts from this byte. Otherwise it defaults to 0. If index is 0, 0 is returned. If index is one more than the number of sequences in str, String.length str is returned. If index is even more than that, exception Not_found is thrown.

str is assumed to be a valid utf-8 string, result is undefined otherwise.

val make : offset:int -> 'flags list -> operation -> 'flags t

Produces a patch, ensuring that new_len = utf8_length text. TODO: validate utf-8 string.

val with_flags : 'flags list -> 'flags t -> 'flags t

Replace the flags in a patch by a new list

val removed : _ t -> int
val inserted : _ t -> int
val inserted_text : _ t -> string