package linenoise

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

OCaml bindings to linenoise.

type completions

Abstract type of completions, given to your completion callback

val add_completion : completions -> string -> unit

This function is used by the callback function registered by the user in order to add completion options given the input string when the user typed <tab>.

val set_completion_callback : (string -> completions -> unit) -> unit

Register the callback function that is called for upon tab-completion, aka when <TAB> is hit in the terminal

val linenoise : string -> string option

The high level function that is the main API of the linenoise library. This function checks if the terminal has basic capabilities, just checking for a blacklist of stupid terminals, and later either calls the line editing function or uses dummy fgets() so that you will be able to type something even in the most desperate of the conditions.

val history_add : string -> int

Add a string to the history

val history_set : max_length:int -> int

Set the maximum length for the history. This function can be called even if there is already some history, the function will make sure to retain just the latest 'len' elements if the new history length value is smaller than the amount of items already inside the history.

val history_save : filename:string -> int

Save the history in the specified file. On success 0 is returned otherwise -1 is returned.

val history_load : filename:string -> int

Load the history from the specified file. If the file does not exist zero is returned and no operation is performed. If the file exists and the operation succeeded 0 is returned, otherwise on error -1 is returned.

val clear_screen : unit -> unit

Clear the screen. Used to handle ctrl+l

val set_multiline : bool -> unit

Set if to use or not the multi line mode.

val print_keycodes : unit -> unit

This special mode is used by linenoise in order to print scan codes on screen for debugging / development purposes.

OCaml

Innovation. Community. Security.