Crate linenoise_rs

Crate linenoise_rs 

Source
Expand description

linenoise – Guerilla line editing library against the idea that a line editing lib needs to be 20,000 lines of C code.

Does a number of crazy assumptions that happen to be true in 99.9999% of the UNIX computers around these days.

Copyright (c) 2025 parazyd Copyright (c) 2010-2023, Salvatore Sanfilippo Copyright (c) 2010-2013, Pieter Noordhuis

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

References:

  • http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
  • http://www.3waylabs.com/nw/WWW/products/wizcon/vt220.html

Structs§

LinenoiseState
Multiplexing support

Functions§

linenoise
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 conditions.
linenoise_clear_screen
Clear the screen. Used to handle Ctrl+L
linenoise_history_add
This is the API call to add a new entry to the linenoise history.
linenoise_history_load
Load the history from the specified file. If the file does not exist then no operation is performed.
linenoise_history_save
Save the history to the specified file.
linenoise_history_set_max_len
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.
linenoise_mask_mode_disable
Disable mask mode.
linenoise_mask_mode_enable
Enable mask mode. When it is enabled, instead of the input that the user is typing, the terminal will just display a corresponding number of asterisks, like “***”. This is useful for passwords and other secrets that should not be displayed.
linenoise_print_key_codes
This special mode is used by linenoise in order to print scan codes on screen for debugging/development purposes. It is implemented by the linenoise example program using the --keycodes option.
linenoise_set_completion_callback
Register a callback function to be called for tab-completion.
linenoise_set_hints_callback
Registers a hints function to be called to show hints to the user at the right of the prompt.
linenoise_set_multi_line
Toggle multi line mode.

Type Aliases§

CompletionCallback
HintsCallback