package grenier

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

Module TropeSource

Buffer management

Sourcetype 'a t

Type of semi-persistent buffers

Sourceval create : unit -> 'a t

Create a new lineage of buffers

Sourceval clear : 'a t -> 'a t

Clear contents of a buffer

Sourceval is_empty : 'a t -> bool

true iff is buffer empty ?

Sourceval remove : ?left_of:unit -> 'a t -> at:int -> len:int -> 'a t

Shift contents of the buffer by removing len units starting at at. Valid iff at >= 0 && len >= 0. Cursors exactly at position at are removed iff called with ~left_of:().

Sourceval insert : ?left_of:unit -> 'a t -> at:int -> len:int -> 'a t

Shift contents of the buffer by inserting len units starting at at. Valid iff at >= 0 && len >= 0. Cursors exactly at position at are shifted iff called with ~left_of:().

Cursor management

Sourcetype cursor

Type of cursors

Sourceval member : 'a t -> cursor -> bool

Is a cursor member of a buffer ?

Sourceval find : 'a t -> cursor -> 'a

Find value associated to a cursor, or raise Not_found

Sourceval compare : cursor -> cursor -> int

Compare the position of two cursors

Sourceval position : 'a t -> cursor -> int

Get the physical position of a cursor in a revision of a buffer

Creation and removal of cursors

Sourceval put_cursor : 'a t -> at:int -> 'a -> 'a t * cursor

Create a new cursors at position at Valid iff at >= 0.

Sourceval put_left : 'a t -> cursor -> 'a -> 'a t

Insert or update a cursor. Cursor is inserted at the left-most valid position.

Sourceval put_right : 'a t -> cursor -> 'a -> 'a t

Insert or update a cursor. Cursor is inserted at the right-most valid position before buffer end.

Sourceval rem_cursor : 'a t -> cursor -> 'a t

rem_cursor t c removes a cursor from the buffer. Valid iff member t c.

Sourceval cursor_after : cursor -> cursor

cursor_after c creates a cursor that is immediately after c.

Sourceval cursor_before : cursor -> cursor

cursor_before c creates a cursor that is immediately before c.

Sourceval cursor_at_origin : 'a t -> cursor

cursor_at_origin t creates a cursor that is minimal for t (before all other cursors in t)

Modification of buffers

Sourceval remove_between : 'a t -> cursor -> cursor -> 'a t

Remove anything between two cursors. remove_between t a b is valid iff member t a && member t b && compare a b <= 0

Sourceval remove_before : 'a t -> cursor -> int -> 'a t

remove_before t c len removes len units before c. Valid iff member t c && len >= 0.

Sourceval remove_after : 'a t -> cursor -> int -> 'a t

remove_after t c len removes len units after c. Valid iff member t c && len >= 0.

Sourceval insert_before : 'a t -> cursor -> int -> 'a t

insert_before t c len inserts len units before c. Valid iff member t c && len >= 0.

Sourceval insert_after : 'a t -> cursor -> int -> 'a t

insert_before t c len inserts len units after c. Valid iff member t c && len >= 0.

Looking up cursors in the buffer

Sourceval find_before : 'a t -> int -> (cursor * 'a) option

find_before t at finds the last cursor c in t satisfying position t c <= at

Sourceval find_after : 'a t -> int -> (cursor * 'a) option

find_after t at finds the first cursor c in t satisfying position t c >= at

Sourceval seek_before : 'a t -> cursor -> (cursor * 'a) option

seek_before t c finds the last cursor c' in t satisfying compare c' c < 0

Sourceval seek_after : 'a t -> cursor -> (cursor * 'a) option

seek_after t c finds the first cursor c' in t satisfying compare c' c > 0

Sourceval to_list : 'a t -> (int * cursor * 'a) list
OCaml

Innovation. Community. Security.