cursor is very like an
Inuit_region.t with a default set of flags. This is a convenient type to expose to higher-level code.
Since it is just a wrapper, you can refer to
Inuit_region.t for the documentation of most functions.
The set of flags for buffers with the capability to mark areas as clickable and to receive clicks.
val null : _ cursor
A dummy cursor that is always closed. Useful as a placeholder.
val text : 'flags cursor -> ?flags:'flags list -> string -> unit
text cursor ?flags str append the text
str at the right of
cursor while moving it to right. If
flags is not provided, default set of flags is applied.
val clear : 'flags cursor -> unit
clear cursor erase the content of the region containing the cursor. New content can still be added, using
text for instance.
val kill : 'flags cursor -> unit
Erase the content and close the cursor. No content can be added anymore.
sub cursor creates an empty sub-cursor at the right end of
cursor. Clearing the sub-cursor will not affect other content, but clearing
cursor will kill the sub-cursor.
val observe : 'flags cursor -> ( 'flags cursor -> [ `Local | `Remote ] -> 'flags Inuit_base.patch -> 'flags list * ( unit -> unit ) option ) -> 'flags cursor
Create a sub-cursor and associate an observer call-back. See
Inuit_region.observe for more information.
val is_closed : 'flags cursor -> bool
A cursor is closed if it has no observers, all changes will be ignored. This can happen when using
clear on a parent cursor, and when the root socket is closed.
A cursor is nothing but a region with a default set of flags. The following functions allow to manipulate this set.
Add a flag,
mem_flag flag (add_flag flag c) = true.
Remove a flag,
mem_flag flag (rem_flag flag c) = false.
val mem_flag : 'flags -> 'flags cursor -> bool
Check if a flag is in the set of flags of the cursor.
val get_flags : 'flags cursor -> 'flags list
Direct access to the list of flags.
Replace the set of flags with a new one.
val get_indent : 'flags cursor -> int
Get indentation level of cursor
Add the argument to indentation level, clamp negative values to 0.
shift_ident t n = with_indent t (max 0 (get_indent t + n))
Create a sub-cursor that can be clicked. The call-back provided as argument is invoked during a click.
Append formatted text to the cursor
A mix of
clickable: append formatted text that can be clicked. The callback is provided last, for instance:
link cursor "Click to visit %s" "https://github.com" (fun _ -> ...)
Make a cursor from a region.