package mopsa
Module Core.LineEdit
Simple line-editing for interactive sessions in the terminal. Assumes an UTF-8 console with standard ANSI escape codes.
Entering raw mode
*********************
val org_stdin_attr : Unix.terminal_io optionExit raw mode after finishing line edition. Do not call print to the console when in raw mode.
FIFO character buffer
*************************
module FIFO : sig ... endCharacter input
*******************
val rabuf : FIFO.tWe may need to scan the input to get the answer for a get_position call. Hence, we keep a FIFO of inputs read while scanning.
Non blocking read_char. Fetch from the read-ahead buffer first.
Block until a char is available and return it. Fetch from the read-ahead buffer first.
Cursor manipulation
***********************
val pf : ('a, out_channel, unit) format -> 'aClear the screen / line up to the cursor position from the begining.
Return the cursur line and column (starting at 1). Return (0,0) in case of an error.
UTF-8 buffers
*****************
module UBuf : sig ... endBuffers backed by byte sequences that grow automatically. Support insertion and deletion at any position within the buffer. Include some support for UTF-8 encoding.
Line editing
****************
Line edition context, maintained between calls to read_line.
val create_ctx : unit -> ctxval backslash_eol : Str.regexpval read_line_tc : ctx -> stringMain line editing function, with support for cursor movement and history. You can print a prompt before calling this function. Return the string that was read. Throw Exit when Ctrl+C or Ctrl+D is typed.
val read_line : ctx -> stringLine edition, with fall-back to Stdlib.read_line if there is no terminal control.