package inuit

  1. Overview
  2. Docs

Module Inuit_cursorSource

Sourcetype 'flags cursor

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

Sourcetype 'flags clickable = [> `Clickable | `Clicked ] as 'flags

The set of flags for buffers with the capability to mark areas as clickable and to receive clicks.

Sourceval null : _ cursor

A dummy cursor that is always closed. Useful as a placeholder.

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

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

Sourceval kill : 'flags cursor -> unit

Erase the content and close the cursor. No content can be added anymore.

Sourceval sub : 'flags cursor -> 'flags cursor

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.

Sourceval 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.observer and Inuit_region.observe for more information.

Sourceval is_closed : 'flags cursor -> bool

A cursor is closed if it has no observers, all changes will be ignored. This can happen when using kill, or clear on a parent cursor, and when the root socket is closed.

Sourceval region : 'flags cursor -> 'flags Inuit_region.t

The region affected by this cursor

Manipulating flags

A cursor is nothing but a region with a default set of flags. The following functions allow to manipulate this set.

Sourceval add_flag : 'flags -> 'flags cursor -> 'flags cursor

Add a flag, mem_flag flag (add_flag flag c) = true.

Sourceval rem_flag : 'flags -> 'flags cursor -> 'flags cursor

Remove a flag, mem_flag flag (rem_flag flag c) = false.

Sourceval mem_flag : 'flags -> 'flags cursor -> bool

Check if a flag is in the set of flags of the cursor.

Sourceval get_flags : 'flags cursor -> 'flags list

Direct access to the list of flags.

Sourceval with_flags : 'flags list -> 'flags cursor -> 'flags cursor

Replace the set of flags with a new one.

Manipulating indentation

Sourceval get_indent : 'flags cursor -> int

Get indentation level of cursor

Sourceval with_indent : 'flags cursor -> int -> 'flags cursor

Set indentation level of cursor

Sourceval shift_indent : 'flags cursor -> int -> 'flags 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))

Creating content (convenience functions)

Sourceval clickable : 'flags clickable cursor -> ('flags cursor -> unit) -> 'flags cursor

Create a sub-cursor that can be clicked. The call-back provided as argument is invoked during a click.

Sourceval printf : 'flags cursor -> ?flags:'flags list -> ('a, unit, string, unit) format4 -> 'a

Append formatted text to the cursor

A mix of printf and 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 _ -> ...)

Sourceval cursor_of_region : ?flags:'flags list -> ?indent:int -> 'flags Inuit_region.t -> 'flags cursor

Make a cursor from a region.

Sourceval make : unit -> 'flags cursor * 'flags Inuit_base.patch Inuit_base.socket

Inuit_region.make wrapper: return a root cursor and a pending socket. Socket must be connected prior to changing the cursor.

OCaml

Innovation. Community. Security.