No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jeremy Soller f3fb3b7546
0.5.3
2024-07-19 13:17:39 -06:00
examples Fix some warnings 2024-07-13 06:55:13 +03:00
src Apply most of clippy suggestions 2024-07-13 06:55:13 +03:00
.gitignore ignore vim swap files 2017-01-20 11:46:31 +13:00
.gitlab-ci.yml Combine CI build w/ test 2018-06-10 06:17:05 +00:00
.travis.yml add travis 2016-07-11 15:51:49 +12:00
Cargo.toml 0.5.3 2024-07-19 13:17:39 -06:00
CONTRIBUTING.md add CONTRIBUTING.md 2016-07-10 19:13:02 +12:00
hist Print the prompt up front 2019-06-30 16:57:50 -04:00
LICENSE update LICENSE 2017-06-11 12:43:48 +12:00
README.md 0.5.3 2024-07-19 13:17:39 -06:00

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.