17 releases (5 breaking)

Uses old Rust 2015

0.5.2 Jun 17, 2016
0.5.0 May 25, 2016
0.4.1 Dec 27, 2015
0.1.2 Jul 29, 2015
0.0.4 Mar 26, 2015

#1013 in Text processing

Download history 1/week @ 2023-12-01 1/week @ 2024-01-05 2/week @ 2024-01-12 4/week @ 2024-02-09 8/week @ 2024-02-16 23/week @ 2024-02-23 21/week @ 2024-03-01 20/week @ 2024-03-08 13/week @ 2024-03-15

78 downloads per month
Used in 3 crates (2 directly)

GPL license

2.5MB
31K SLoC

C 24K SLoC // 0.2% comments Rust 4K SLoC // 0.1% comments M4 3K SLoC // 0.2% comments Shell 172 SLoC // 0.2% comments Forge Config 3 SLoC

readline-sys

Version

Crates.io Build Status

Native bindings to libreadline.

Features

  • thin wrappers around readline and add_history
  • write history line to file: add_history_persist
  • load history from file: preload_history
  • library version: version

API Documentation

Rustdocs

Usage

Add rl-sys as a dependency in Cargo.toml

[dependencies]
rl-sys = "~0.5.2"

A simple implementation of cat using rl_sys::readline

extern crate rl_sys;

use rl_sys::readline;
use rl_sys::history::listmgmt;

fn main() {
    loop {
        let input: String = match readline::readline("") {
            Ok(Some(s)) => s,
            Ok(None) => break,  // user entered ctrl-d
            Err(e) => {
                println!("{}", e);
                continue;
            }
        };
        println!("{}", input);

        // Enables up/down arrow scrolling through history
        listmgmt::add(&input).unwrap();
    }
}

Check out the more comprehensive shell example in the examples directory.

Development

To work on this crate, remember to git clone --recursive or git submodule init && git submodule update.

License

Distributed under the GNU General Public License.

Dependencies