package mosaic

  1. Overview
  2. Docs
Terminal UI framework for OCaml with The Elm Architecture

Install

dune-project
 Dependency

Authors

Maintainers

Sources

mosaic-0.1.0.tbz
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9

doc/mosaic.mlx/Mosaic_mlx/Cmd/index.html

Module Mosaic_mlx.CmdSource

Side-effects issued by the application.

Commands are values returned alongside a new model from app.init and app.update. The runtime executes them after each update cycle. Compose multiple commands with Cmd.batch.

Sourcetype 'msg t =
  1. | None
    (*

    No command. Equivalent to batch [].

    *)
  2. | Batch of 'msg t list
    (*

    Execute all commands in the list. Order is not guaranteed.

    *)
  3. | Perform of ('msg -> unit) -> unit
    (*

    Execute an arbitrary side-effecting function. The function receives a dispatch callback and may call it zero or more times, from any thread. See perform.

    *)
  4. | Quit
    (*

    Request orderly termination of the application.

    *)
  5. | Set_title of string
    (*

    Set the terminal window title to the given string.

    *)
  6. | Focus of string
    (*

    Move keyboard focus to the element identified by the given id. Has no effect if no element carries that id.

    *)
  7. | Static_commit of 'msg option Mosaic_ui.Vnode.t
    (*

    Render a vnode snapshot and write it to the static area with ANSI styling preserved. The row count is computed automatically from the rendered grid.

    *)
  8. | Static_clear
    (*

    Clear all previously written static content.

    *)

The type for commands.

Sourceval none : 'msg t

none is the empty command. Produces no side-effects.

Sourceval batch : 'msg t list -> 'msg t

batch cmds is a command that executes every command in cmds. Execution order among the commands is not specified.

Sourceval perform : (('msg -> unit) -> unit) -> 'msg t

perform f is a command that calls f dispatch asynchronously.

f may call dispatch msg any number of times; each call enqueues msg for the next update cycle. By default the runtime runs f on a fresh native thread so that long-running operations never block the UI loop. This behaviour can be overridden with the process_perform argument of run.

Sourceval quit : 'msg t

quit requests orderly application termination after the current update cycle completes.

Sourceval set_title : string -> 'msg t

set_title s sets the terminal window title to s.

Sourceval focus : string -> 'msg t

focus id moves keyboard focus to the element whose id attribute equals id. Has no effect when no matching element exists.

Sourceval static_commit : 'msg option Mosaic_ui.Vnode.t -> 'msg t

static_commit view renders view offscreen at the current terminal width and appends the styled result to static output.

Sourceval static_clear : 'msg t

static_clear removes all previously emitted static content.

Sourceval map : ('a -> 'b) -> 'a t -> 'b t

map f cmd is cmd with every dispatched message transformed by f. Use this to embed child-component commands in a parent command.