Editline is a compact line editing library that provides essential command line editing and history functionality. It's designed to be compatible with the FSF readline library but is smaller, has no dependencies, and is easily integrable into your projects, making it ideal for embedded systems.
Editline is a lightweight command-line editing library designed as a small alternative to the GNU readline() function for UNIX systems. With a size of under 30k and no dependencies on external libraries like ncurses, Editline offers a streamlined solution for developers, particularly in the embedded systems space. Its low footprint and liberal licensing make it an appealing choice for various applications.
Key Features
- Command Line Editing: Editline provides robust command line editing capabilities, enabling users to input commands easily and efficiently.
- History Functions: The library supports command history, allowing users to recall previously entered commands, enhancing user experience.
- Compatibility: It features call compatibility with the FSF readline library, maintaining familiar functionality while reducing footprint.
Usage Example
Editline can be incorporated smoothly into your projects. Here's a brief example of how to create a simple command line interface (CLI):
#include <stdio.h>
#include <stdlib.h>
#include <editline.h>
int main(void) {
char *p;
while ((p = readline("CLI> ")) != NULL) {
puts(p);
free(p);
}
return 0;
}
Compile this example using the appropriate Makefile configuration to link against Editline.
API Reference
Editline provides a variety of global variables and functions, including:
el_no_echo
: Disables echoing input characters.readline(const char *prompt)
: The main function to read a line from the user with a customizable prompt.add_history(const char *line)
: Saves a line to the history for easy recall.read_history(const char *filename)
: Loads history from a file, enabling persistent command history.
Source and Maintenance
Editline is actively developed and maintained on GitHub, making it accessible for contributions and improvements. Originally created by Rich Salz and Simmule Turner in 1992 and derived from the Minix source tree, this library has evolved with contributions from various forks and projects.
For further details, documentation, examples, and the complete API reference, please visit the Editline GitHub Repository.
Editline is not intended for Windows environments; however, it is ideally suited for UNIX-like systems. Dive into the world of efficient command line interaction with Editline!