module Zed_edit:sig..end
type 'a t
'a is the type of custom data
attached to the engine in order to extend it.type clipboard = {
|
clipboard_get : |
(* |
Returns the current contents of the clipboard.
| *) |
|
clipboard_set : |
(* |
Sets the contents of the clipboard.
| *) |
val new_clipboard : unit -> clipboardnew_clipboard () creates a new clipboard using a reference.val create : ?editable:(int -> int -> bool) ->
?move:(int -> int -> int) ->
?clipboard:clipboard ->
?match_word:(Zed_rope.t -> int -> int option) ->
?locale:string option React.signal -> ?undo_size:int -> unit -> 'a tcreate ?editable ?move ?clipboard () creates a new edition
engine in the initial state.
editable is used to determine whether the text at given
position is editable or not. It takes as argument the position
and the length of the text to remove.
move is unused.
clipboard is the clipboard to use for this engine. If none is
defined, a new one using a reference is created.
match_word is used to recognize words. It must returns the end
of the matched word if any.
locale is the locale of this buffer. It is used for case
mapping.
undo_size is the size of the undo buffer. It is the number of
state zed will remember. It defaults to 1000.
val match_by_regexp : Zed_re.t -> Zed_rope.t -> int -> int optionmatch_by_regexp re creates a word-matching function using a
regular expression.val get_data : 'a t -> 'aget_data edit returns the custom data attached to the
engine. It raises Not_found if no data is attached to the
engine.val set_data : 'a t -> 'a -> unitset_data edit data attach data to the engine.val clear_data : 'a t -> unitclear_data edit removes the custom data of engine.val text : 'a t -> Zed_rope.ttext edit returns the signal holding the current contents of
the buffer.val lines : 'a t -> Zed_lines.tlines edit returns the set of line position of text edit.val get_line : 'a t -> int -> Zed_rope.tget_line edit n returns the rope corresponding to the nth line
without the newline character.val changes : 'a t -> (int * int * int) React.eventchanges edit returns an event which occurs with values of the
form (start, added, removed) when the contents of the engine
changes. start is the start of modifications, added is the
number of characters added and removed is the number of
characters removed.val update : 'a t -> Zed_cursor.t list -> unit React.eventupdate edit cursors returns an event which occurs each the
rendering of the engine should be updated.val erase_mode : 'a t -> bool React.signalerase_mode edit returns the ``erase'' mode of the buffer. In
this mode character inserted in the buffer erase existing
ones.val get_erase_mode : 'a t -> boolerase_mode edit returns the current erase mode of the
buffer.val set_erase_mode : 'a t -> bool -> unitset_erase_mode edit state sets the status of the erase mode
for the given engine.val mark : 'a t -> Zed_cursor.tmark edit returns the cursor used to for the mark in the given
engine.val selection : 'a t -> bool React.signalselection edit returns the signal holding the current
selection state. If true, text is being selectionned.val get_selection : 'a t -> boolselection edit returns the current selection state.val set_selection : 'a t -> bool -> unitset_selection edit state sets the selection state.val new_cursor : 'a t -> Zed_cursor.tnew_cursor edit creates a new cursor for the given edition
engine. The cursor initially points to the beginning of the
buffer.exception Cannot_edit
type 'a context
val context : ?check:bool -> 'a t -> Zed_cursor.t -> 'a contextcontext ?check edit cursor creates a new context with given
parameters. cursor is the cursor that will be used for all
modification of the text. If check is true (the default)
then all modification of the text will be checked with the
editable function of the engine.val edit : 'a context -> 'a tedit ctx returns the edition engine used by the given
context.val cursor : 'a context -> Zed_cursor.tcursor ctx returns the cursor used by this context.val check : 'a context -> boolcheck ctx returns whether the context has been created with
the check flag.val with_check : bool -> 'a context -> 'a contextwith_check check ctx retuns ctx with the check flag set to
check.val goto : 'a context -> ?set_wanted_column:bool -> int -> unitgoto ctx ?set_column position moves the cursor to the given
position. It raises Zed_cursor.Out_of_bounds if the position
is outside the bounds of the text. If set_wanted_column is
true, the wanted column of the cursor is set to the new
column.val move : 'a context -> ?set_wanted_column:bool -> int -> unitmove ctx ?set_wanted_column delta moves the cursor by the
given number of characters. It raises
Zed_cursor.Out_of_bounds if the current plus delta is
outside the bounds of the text.val move_line : 'a context -> int -> unitmove_line ctx ?set_wanted_column delta moves the cursor by the
given number of lines.val position : 'a context -> intposition ctx returns the position of the cursor.val line : 'a context -> intline ctx returns the line of the cursor.val column : 'a context -> intcolumn ctx returns the column of the cursor.val at_bol : 'a context -> boolat_bol ctx returns true iff the cursor is at the beginning
of the current line.val at_eol : 'a context -> boolat_eol ctx returns true iff the cursor is at the end of the
current line.val at_bot : 'a context -> boolat_bot ctx returns true iff the cursor is at the beginning
of the text.val at_eot : 'a context -> boolat_eot ctx returns true iff the cursor is at the end of the
text.val insert : 'a context -> Zed_rope.t -> unitinsert ctx rope inserts the given rope at current position.val insert_no_erase : 'a context -> Zed_rope.t -> unitinsert ctx rope inserts the given rope at current position but
do not erase text if the buffer is currently in erase mode.val remove_next : 'a context -> int -> unitremove_next ctx n removes n characters at current
position. If there is less than n characters at current
position, it removes everything until the end of the text.val remove_prev : 'a context -> int -> unitremove_prev ctx n removes n characters before current
position. If there is less than n characters before current
position, it removes everything until the beginning of the
text.val remove : 'a context -> int -> unitZed_edit.remove_nextval replace : 'a context -> int -> Zed_rope.t -> unitreplace ctx n rope does the same as:
remove ctx n;
insert_no_erase ctx rope
but in one atomic operation.
val newline : 'a context -> unitval next_char : 'a context -> unitnext_char ctx moves the cursor to the next character. It does
nothing if the cursor is at the end of the text.val prev_char : 'a context -> unitprev_char ctx moves the cursor to the previous character. It
does nothing if the cursor is at the beginning of the text.val next_line : 'a context -> unitnext_line ctx moves the cursor to the next line. If the cursor
is on the last line, it is moved to the end of the buffer.val prev_line : 'a context -> unitprev_line ctx moves the cursor to the previous line. If the
cursor is on the first line, it is moved to the beginning of the
buffer.val goto_bol : 'a context -> unitgoto_bol ctx moves the cursor to the beginning of the current
line.val goto_eol : 'a context -> unitgoto_eol ctx moves the cursor to the end of the current
line.val goto_bot : 'a context -> unitgoto_bot ctx moves the cursor to the beginning of the text.val goto_eot : 'a context -> unitgoto_eot ctx moves the cursor to the end of the text.val delete_next_char : 'a context -> unitdelete_next_char ctx deletes the character after the cursor,
if any.val delete_prev_char : 'a context -> unitdelete_prev_char ctx delete the character before the
cursor.val delete_next_line : 'a context -> unitdelete_next_line ctx delete everything until the end of the
current line.val delete_prev_line : 'a context -> unitdelete_next_line ctx delete everything until the beginning of
the current line.val kill_next_line : 'a context -> unitkill_next_line ctx delete everything until the end of the
current line and save it to the clipboard.val kill_prev_line : 'a context -> unitkill_next_line ctx delete everything until the beginning of
the current line and save it to the clipboard.val switch_erase_mode : 'a context -> unitswitch_erase_mode ctx switch the current erase mode.val set_mark : 'a context -> unitset_mark ctx sets the mark at current position.val goto_mark : 'a context -> unitgoto_mark ctx moves the cursor to the mark.val copy : 'a context -> unitcopy ctx copies the current selectionned region to the
clipboard.val kill : 'a context -> unitkill ctx copies the current selectionned region to the
clipboard and remove it.val yank : 'a context -> unityank ctx inserts the contents of the clipboard at current
position.val capitalize_word : 'a context -> unitcapitalize_word ctx capitalizes the first word after the
cursor.val lowercase_word : 'a context -> unitlowercase_word ctx converts the first word after the cursor to
lowercase.val uppercase_word : 'a context -> unituppercase_word ctx converts the first word after the cursor to
uppercase.val next_word : 'a context -> unitnext_word ctx moves the cursor to the end of the next word.val prev_word : 'a context -> unitprev_word ctx moves the cursor to the beginning of the
previous word.val delete_next_word : 'a context -> unitdelete_next_word ctx deletes the word after the cursor.val delete_prev_word : 'a context -> unitdelete_prev_word ctx deletes the word before the cursor.val kill_next_word : 'a context -> unitkill_next_word ctx deletes the word after the cursor and save
it to the clipboard.val kill_prev_word : 'a context -> unitkill_prev_word ctx deletes the word before the cursor and save
it to the clipboard.val undo : 'a context -> unitundo ctx reverts the last performed action.type action =
| |
Insert of |
| |
Newline |
| |
Next_char |
| |
Prev_char |
| |
Next_line |
| |
Prev_line |
| |
Goto_bol |
| |
Goto_eol |
| |
Goto_bot |
| |
Goto_eot |
| |
Delete_next_char |
| |
Delete_prev_char |
| |
Delete_next_line |
| |
Delete_prev_line |
| |
Kill_next_line |
| |
Kill_prev_line |
| |
Switch_erase_mode |
| |
Set_mark |
| |
Goto_mark |
| |
Copy |
| |
Kill |
| |
Yank |
| |
Capitalize_word |
| |
Lowercase_word |
| |
Uppercase_word |
| |
Next_word |
| |
Prev_word |
| |
Delete_next_word |
| |
Delete_prev_word |
| |
Kill_next_word |
| |
Kill_prev_word |
| |
Undo |
val get_action : action -> 'a context -> unitget_action action returns the function associated to the given
action.val actions : (action * string) listInsert.val doc_of_action : action -> stringdoc_of_action action returns a short description of the
action.val action_of_name : string -> actionaction_of_name str converts the given action name into an
action. Action name are the same as function name but with '_'
replaced by '-'. It raises Not_found if the name does not
correspond to an action.
Insert ch is represented by "insert(<char>)" where <char> is:
val name_of_action : action -> stringname_of_action act returns the name of the given action.