package miaou-driver-matrix

  1. Overview
  2. Docs

Module Miaou_driver_matrix.Matrix_terminalSource

Terminal setup and management for the Matrix driver.

Handles raw mode, size detection, mouse tracking, and signal handling. Adapted from term_terminal_setup.ml and term_size_detection.ml for the matrix driver without lambda-term dependency.

Sourcetype t
Sourceval setup : unit -> t

Setup terminal and return handle. Must be called before any other ops.

Sourceval cleanup : t -> unit

Cleanup terminal state. Safe to call multiple times.

Sourceval enter_raw : t -> unit

Enter raw mode (disable line buffering and echo).

Sourceval leave_raw : t -> unit

Leave raw mode (restore original terminal state).

Sourceval size : t -> int * int

Get terminal size as (rows, cols). Uses cached value if available.

Sourceval invalidate_size_cache : t -> unit

Invalidate size cache. Called on SIGWINCH.

Sourceval enable_mouse : t -> unit

Enable mouse tracking (button events + SGR extended).

Sourceval disable_mouse : t -> unit

Disable mouse tracking.

Sourceval fd : t -> Unix.file_descr

Get the file descriptor for reading input.

Sourceval write : t -> string -> unit

Write string to terminal output.

Sourceval install_signals : t -> (unit -> unit) -> bool Atomic.t

Install signal handlers (SIGINT, SIGTERM, etc.). Returns atomic flag that will be set when exit signal received. The cleanup function will be called in the signal handler.

Sourceval install_signals' : t -> (unit -> unit) -> ?handle_sigint:bool -> unit -> bool Atomic.t

Like install_signals but with optional control over which signals are handled.

  • parameter handle_sigint

    If false, SIGINT (Ctrl+C) is not intercepted, allowing the app to receive it as a key event. Default: true

Sourceval resize_pending : t -> bool

Check if resize is pending (set by SIGWINCH).

Sourceval clear_resize_pending : t -> unit

Clear the resize pending flag.

Sourceval set_exit_screen_dump : t -> string -> unit

Set screen content to dump on exit for debugging. The content will be printed after exiting alternate screen mode.

Sourceval set_alt_screen : t -> bool -> unit

Configure whether enter_raw should switch to the alternate screen. Default is true (alt-screen on). When set to false before enter_raw, the driver runs in inline mode — the TUI renders over the current terminal contents and its final frame stays in scrollback after cleanup. See Miaou_driver_common.Terminal_raw.set_alt_screen.

Sourceval alt_screen_enabled : t -> bool

Whether the alternate screen is currently enabled.