Crate rl_sys [] [src]

This library provides native bindings for the GNU readline library.

The GNU Readline library provides a set of functions for use by applications that allow users to edit command lines as they are typed in. Both Emacs and vi editing modes are available. The Readline library includes additional functions to maintain a list of previously-entered command lines, to recall and perhaps reedit those lines, and perform csh-like history expansion on previous commands.

Examples

use rl_sys::readline;
use rl_sys::history::{listmgmt, mgmt};

loop {
    let input = match readline::readline("$ ") {
        Ok(Some(s)) => match &*s {
            "clear" => {
                listmgmt::clear();
                continue;
            }
            _ => s
        },
        Ok(None) => break,  // EOF encountered
        Err(e) => {
            println!("{}", e);
            continue;
        }
    };
    println!("{}", input);

    // Add input to history.
    match listmgmt::add(&input) {
        Ok(_) => {},
        Err(e) => { println!("{:?}", e); },
    }
}

mgmt::cleanup();

Modules

history

GNU Readline History API

readline

GNU Readline API

Structs

HistoryError

Represents an error that has occurred within the History API.

ReadlineError

Represents an error that has occurred within the Readline API.

Functions

version

Generate a version string.