package miaou-core
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=60a3b9f181f24572a06a9492532bfdda
sha512=fcc35a275066be2900e6201782faf47503076fa4640f08cf78067835a6f447b74613009e55b2ac799adb7ca46f1bffa261fc5971753f2cc3c6bef327511c7ef6
doc/miaou-core.core/Miaou_core/Prompt/index.html
Module Miaou_core.PromptSource
Reusable prompt helpers built on top of Modal_manager.
These helpers wrap the boilerplate of building a small modal page and pushing it onto the modal stack. They mirror the patterns seen in the existing example modal modules (textbox_modal, select_modal, password_textbox_modal) so app code can ask for a yes/no answer, a free-form text value, or a list selection in one call.
All three helpers are non-blocking: they push a modal and return immediately. The result is delivered asynchronously through on_result when the user commits or cancels.
Typical usage:
Prompt.confirm
~title:"Delete file?"
~message:"This cannot be undone."
~on_result:(fun answered_yes ->
if answered_yes then delete_file () else ())
()Ask a yes / no question.
Pushes a centred modal with message as the body. The modal commits on Enter (calling on_result true) and cancels on Esc (calling on_result false).
val input :
?placeholder:string ->
?initial:string ->
title:string ->
on_result:(string option -> unit) ->
unit ->
unitAsk the user to type a free-form string.
Pushes a centred modal containing a single-line textbox. On commit (Enter) the callback receives Some text; on cancel (Esc) the callback receives None.
val select :
title:string ->
items:'a list ->
to_string:('a -> string) ->
on_result:('a option -> unit) ->
unit ->
unitAsk the user to pick one item from a list.
Pushes a centred modal containing a Miaou_widgets_input.Select_widget populated from items. On commit (Enter) the callback receives Some item; on cancel (Esc) the callback receives None.
Pure helpers (testable without a TUI runtime)
These helpers implement the small bits of result-mapping logic used internally. They are exposed so unit tests can verify the behaviour without spinning up a modal stack.
confirm_outcome `Commit is true and confirm_outcome `Cancel is false.
Pure result mapping for input.
input_result outcome ~text:
`CommityieldsSome text.`CancelyieldsNone.