2 releases

0.5.2 Nov 4, 2023
0.5.1 Nov 29, 2019

#82 in Text editors

Download history 207/week @ 2023-12-15 278/week @ 2023-12-22 159/week @ 2023-12-29 283/week @ 2024-01-05 322/week @ 2024-01-12 180/week @ 2024-01-19 190/week @ 2024-01-26 182/week @ 2024-02-02 326/week @ 2024-02-09 212/week @ 2024-02-16 246/week @ 2024-02-23 218/week @ 2024-03-01 267/week @ 2024-03-08 239/week @ 2024-03-15 249/week @ 2024-03-22 339/week @ 2024-03-29

1,113 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
~18K SLoC