package inuit

  1. Overview
  2. Docs
type operation =
  1. | Remove of int
  2. | Insert of string
  3. | Replace of int * string
  4. | Propertize of int
type 'flags t = private {
  1. offset : int;
    (*

    Starting at offset'th unicode sequence

    *)
  2. operation : operation;
  3. text_len : int;
  4. 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