3 releases

0.5.3 Jul 19, 2024
0.5.2 Nov 4, 2023
0.5.1 Nov 29, 2019

#68 in Text editors

Download history 191/week @ 2024-11-15 190/week @ 2024-11-22 191/week @ 2024-11-29 203/week @ 2024-12-06 290/week @ 2024-12-13 234/week @ 2024-12-20 233/week @ 2024-12-27 254/week @ 2025-01-03 318/week @ 2025-01-10 299/week @ 2025-01-17 226/week @ 2025-01-24 274/week @ 2025-01-31 288/week @ 2025-02-07 340/week @ 2025-02-14 318/week @ 2025-02-21 271/week @ 2025-02-28

1,258 downloads per month
Used in 4 crates (3 directly)

MIT license

235KB
6K SLoC

liner

A Rust library offering readline-like functionality.

CONTRIBUTING.md

Build Status Docs

Features

  • 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.3"
...

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

~2.5MB
~40K SLoC