package inquire

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Unicode ropes

type t

Type of unicode ropes.

type rope = t

Alias.

exception Out_of_bounds

Exception raised when trying to access a character which is outside the bounds of a rope.

Construction
val empty : unit -> rope

The empty rope.

val make : int -> Zed_char.t -> rope

make length char creates a rope of length length containing only char.

val singleton : Zed_char.t -> rope

singleton ch creates a rope of length 1 containing only ch.

Informations
val length : rope -> int

Returns the length of the given rope.

val size : rope -> int

Returns the size of the given rope.

val is_empty : rope -> bool

is_empty rope returns whether str is the empty rope or not.

Random access
val get : rope -> int -> Zed_char.t

get rope idx returns the glyph at index idx in rope.

val get_raw : rope -> int -> Uchar.t

get_raw rope idx returns the character at raw index idx in rope.

Rope manipulation
val append : rope -> rope -> rope

Concatenates the two given ropes.

val concat : rope -> rope list -> rope

concat sep l concatenates all strings of l separating them by sep.

val sub : rope -> int -> int -> rope

sub rope ofs len Returns the sub-rope of rope starting at ofs and of length len.

val break : rope -> int -> rope * rope

break rope pos returns the sub-ropes before and after pos in rope. It is more efficient than creating two sub-ropes with sub.

val before : rope -> int -> rope

before rope pos returns the sub-rope before pos in rope.

val after : rope -> int -> rope

after rope pos returns the sub-string after pos in rope.

val insert : rope -> int -> rope -> rope

insert rope pos sub inserts sub in rope at position pos.

val insert_uChar : rope -> int -> Uchar.t -> rope

insert rope pos char inserts char in rope at position pos. If char is a combing mark, it's merged to the character at position pos-1

val remove : rope -> int -> int -> rope

remove rope pos len removes the len characters at position pos in rope

val replace : rope -> int -> int -> rope -> rope

replace rope pos len repl replaces the len characters at position pos in rope by repl.

val lchop : rope -> rope

lchop rope returns rope without is first character. Returns empty if rope is empty.

val rchop : rope -> rope

rchop rope returns rope without is last character. Returns empty if rope is empty.

Iteration, folding and mapping
val iter : (Zed_char.t -> unit) -> rope -> unit

iter f rope applies f on all characters of rope starting from the left.

val rev_iter : (Zed_char.t -> unit) -> rope -> unit

rev_iter f rope applies f an all characters of rope starting from the right.

val fold : (Zed_char.t -> 'a -> 'a) -> rope -> 'a -> 'a

fold f rope acc applies f on all characters of rope starting from the left, accumulating a value.

val rev_fold : (Zed_char.t -> 'a -> 'a) -> rope -> 'a -> 'a

rev_fold f rope acc applies f on all characters of rope starting from the right, accumulating a value.

val map : (Zed_char.t -> Zed_char.t) -> rope -> rope

map f rope maps all characters of rope with f.

val rev_map : (Zed_char.t -> Zed_char.t) -> rope -> rope

rev_map f str maps all characters of rope with f in reverse order.

Iteration and folding on leafs

Note: for all of the following functions, the leaves must absolutely not be modified.

val iter_leaf : (Zed_string.t -> unit) -> rope -> unit

iter_leaf f rope applies f on all leaves of rope starting from the left.

val rev_iter_leaf : (Zed_string.t -> unit) -> rope -> unit

iter_leaf f rope applies f on all leaves of rope starting from the right.

val fold_leaf : (Zed_string.t -> 'a -> 'a) -> rope -> 'a -> 'a

fold f rope acc applies f on all leaves of rope starting from the left, accumulating a value.

val rev_fold_leaf : (Zed_string.t -> 'a -> 'a) -> rope -> 'a -> 'a

rev_fold f rope acc applies f on all leaves of rope starting from the right, accumulating a value.

val compare : rope -> rope -> int

Compares two ropes (in code point order).

val equal : rope -> rope -> bool

equal r1 r2 retuns true if r1 is equal to r2.

Zippers
module Zip : sig ... end
module Zip_raw : sig ... end
Buffers
module String_buffer = Buffer
module Buffer : sig ... end
val init : int -> (int -> Zed_char.t) -> rope
val init_from_uChars : int -> (int -> Uchar.t) -> rope
val of_string : Zed_string.t -> rope
val to_string : rope -> Zed_string.t
val lowercase : ?locale:string -> t -> t
val uppercase : ?locale:string -> t -> t
OCaml

Innovation. Community. Security.