redox_liner

Crates.ioredox_liner
lib.rsredox_liner
version0.5.3
sourcesrc
created_at2019-11-29 16:48:08.253623
updated_at2024-07-19 19:17:56.713947
descriptionA library offering readline-like functionality.
homepagehttps://gitlab.redox-os.org/redox-os/liner
repositoryhttps://gitlab.redox-os.org/redox-os/liner
max_upload_size
id185338
size252,205
Michael Murphy (mmstick)

documentation

README

liner

A Rust library offering readline-like functionality.

CONTRIBUTING.md

crates.io 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.

Commit count: 0

cargo fmt