2 releases

0.5.2 Nov 4, 2023
0.5.1 Nov 29, 2019

#89 in Text editors

Download history 193/week @ 2024-01-27 171/week @ 2024-02-03 345/week @ 2024-02-10 205/week @ 2024-02-17 263/week @ 2024-02-24 201/week @ 2024-03-02 265/week @ 2024-03-09 234/week @ 2024-03-16 245/week @ 2024-03-23 360/week @ 2024-03-30 173/week @ 2024-04-06 233/week @ 2024-04-13 187/week @ 2024-04-20 251/week @ 2024-04-27 203/week @ 2024-05-04 150/week @ 2024-05-11

825 downloads per month
Used in 4 crates (3 directly)

MIT license

240KB
6K SLoC

liner

A Rust library offering readline-like functionality.

CONTRIBUTING.md

Build Status Docs

Featues

  • Autosuggestions
  • Emacs and Vi keybindings
  • Multi-line editing
  • History
  • (Incomplete) basic and filename completions
  • Reverse search
  • Remappable keybindings

Basic Usage

In Cargo.toml:

[dependencies]
redox_liner = "0.5.2"
...

In src/main.rs:

extern crate liner;

use liner::{Context, Completer};

struct EmptyCompleter;

impl<W: std::io::Write> Completer<W> for EmptyCompleter {
    fn completions(&mut self, _start: &str) -> Vec<String> {
        Vec::new()
    }
}

fn main() {
    let mut con = Context::new();

    loop {
        let res = con.read_line("[prompt]$ ", &mut EmptyCompleter).unwrap();

        if res.is_empty() {
            break;
        }

        con.history.push(res.into());
    }
}

See src/main.rs for a more sophisticated example.

License

MIT licensed. See the LICENSE file.

Dependencies

~1MB
~19K SLoC