Skip to content

mbarbin/mosaic

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mosaic

A delightful OCaml framework for building modern terminal user interfaces. Inspired by The Elm Architecture and Bubble Tea.

Status: Prototype - This is an early prototype exploring ideas for a modern OCaml TUI framework. It is not yet functional. APIs will change significantly.

Features

  • Elm Architecture - Simple, scalable app structure with model-view-update
  • Declarative UI - Build layouts with flexbox-style primitives
  • Cross-platform - Works on Unix/Linux, macOS, and Windows
  • Mouse & Keyboard - Full input handling with modifiers
  • Unicode Support - First-class support for Unicode throughout
  • Testable - Pure functions and effects make testing straightforward

Quick Start

open Mosaic

type model = int
type msg = Increment | Decrement | Quit

let init () = (0, Cmd.none)

let update msg model =
  match msg with
  | Increment -> (model + 1, Cmd.none)
  | Decrement -> (model - 1, Cmd.none)
  | Quit -> (model, Cmd.quit)

let view model =
  Ui.vbox [
    Ui.text "Counter Example";
    Ui.text (Printf.sprintf "Count: %d" model);
    Ui.text "";
    Ui.text "Press +/- to change, Ctrl+C to quit";
  ]

let subscriptions _ =
  Sub.batch [
    Sub.on_key ~ctrl:true (Char (Uchar.of_char 'C')) Quit;
    Sub.on_char '+' Increment;
    Sub.on_char '-' Decrement;
  ]

let () = Mosaic.run (Mosaic.app ~init ~update ~view ~subscriptions ())

Installation

opam install mosaic

License

ISC

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • OCaml 98.0%
  • C 1.9%
  • Dune 0.1%