package miaou-core
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=60a3b9f181f24572a06a9492532bfdda
sha512=fcc35a275066be2900e6201782faf47503076fa4640f08cf78067835a6f447b74613009e55b2ac799adb7ca46f1bffa261fc5971753f2cc3c6bef327511c7ef6
doc/miaou-core.driver-common/Miaou_driver_common/Terminal_raw/index.html
Module Miaou_driver_common.Terminal_rawSource
Raw terminal operations shared between drivers.
Provides low-level terminal control: raw mode, mouse tracking, size detection, signal handling, and cleanup. Based on lambda-term driver's tested implementation.
Usage:
let term = Terminal_raw.setup () in
at_exit (fun () -> Terminal_raw.cleanup term);
Terminal_raw.enter_raw term;
Terminal_raw.enable_mouse term;
(* ... main loop ... *)
Terminal_raw.cleanup termTerminal state handle.
Get the input file descriptor (stdin).
Enable SGR mouse tracking (1002h + 1006h). Writes to /dev/tty for consistency with other terminal operations.
Disable mouse tracking. Idempotent, safe to call multiple times. Uses multiple methods (tty, stdout, stderr) to ensure delivery.
Full cleanup: clear screen, show cursor, restore settings, disable mouse. Safe to call multiple times (idempotent for terminal restore).
Detect terminal size. Uses cache; call invalidate_size_cache on resize. Falls back to environment variables or (24, 80) if detection fails.
val install_signals :
t ->
on_resize:(unit -> unit) ->
on_exit:(unit -> unit) ->
bool Atomic.tInstall signal handlers for resize and exit.
val install_signals' :
t ->
on_resize:(unit -> unit) ->
on_exit:(unit -> unit) ->
?handle_sigint:bool ->
unit ->
bool Atomic.tLike install_signals but with optional control over which signals are handled.
Set screen content to dump on exit for debugging. The content will be printed to stdout after exiting alternate screen mode, preserving the TUI output in terminal scrollback.
Choose whether enter_raw switches to the alternate screen.
By default the terminal enters the alt-screen on enter_raw and leaves it on cleanup, restoring the prior shell content. Calling set_alt_screen t false before enter_raw switches to inline mode: the TUI renders directly over the current terminal contents and the final frame stays in the scrollback after the program exits. A trailing newline is appended on cleanup so the next shell prompt starts on a fresh line.
Inline mode trades the standard "take over the screen" experience for one where the rendered output is preserved as part of the user's terminal history — useful for short-running CLI helpers, debugging, and any tool you want to read after it exits.
Must be called before enter_raw to take effect.