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
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§
- Linenoise
State - 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
lenelements 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
--keycodesoption. - 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.