package zed

  1. Overview
  2. Docs
Abstract engine for text edition in OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

3.1.0.tar.gz
sha256=c387b0496c34c7eb680999e751525992e3e636a803297480ef004498887625fd
md5=51e8676ba972e5ad727633c161e404b1

doc/zed/Zed_rope/index.html

Module Zed_ropeSource

Unicode ropes

Sourcetype t

Type of unicode ropes.

Sourcetype rope = t

Alias.

Sourceexception Out_of_bounds

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

Construction
Sourceval empty : unit -> rope

The empty rope.

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

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

Sourceval singleton : Zed_char.t -> rope

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

Informations
Sourceval length : rope -> int

Returns the length of the given rope.

Sourceval size : rope -> int

Returns the size of the given rope.

Sourceval is_empty : rope -> bool

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

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

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

Sourceval get_raw : rope -> int -> CamomileLibrary.UChar.t

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

Rope manipulation
Sourceval append : rope -> rope -> rope

Concatenates the two given ropes.

Sourceval concat : rope -> rope list -> rope

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

Sourceval sub : rope -> int -> int -> rope

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

Sourceval 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.

Sourceval before : rope -> int -> rope

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

Sourceval after : rope -> int -> rope

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

Sourceval insert : rope -> int -> rope -> rope

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

Sourceval insert_uChar : rope -> int -> CamomileLibrary.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

Sourceval remove : rope -> int -> int -> rope

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

Sourceval replace : rope -> int -> int -> rope -> rope

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

Sourceval lchop : rope -> rope

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

Sourceval rchop : rope -> rope

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

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

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

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

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

Sourceval 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.

Sourceval 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.

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

map f rope maps all characters of rope with f.

Sourceval 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.

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

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

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

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

Sourceval 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.

Sourceval 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.

Sourceval compare : rope -> rope -> int

Compares two ropes (in code point order).

Sourceval equal : rope -> rope -> bool

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

Zippers
Sourcemodule Zip : sig ... end
Sourcemodule Zip_raw : sig ... end
Buffers
Sourcemodule String_buffer = Buffer
Sourcemodule Buffer : sig ... end
Sourceval init : int -> (int -> Zed_char.t) -> rope
Sourceval init_from_uChars : int -> (int -> CamomileLibrary.UChar.t) -> rope
Sourceval of_string : Zed_string.t -> rope
Sourceval to_string : rope -> Zed_string.t
Camomile compatible interface
Sourcemodule Text : sig ... end
Sourcemodule Text_core : sig ... end
Sourcemodule Text_raw : sig ... end
OCaml

Innovation. Community. Security.