commit | 2c7fdac1a26ed61bd5c4b865aa31a9b5eedfb6b1 | [log] [tgz] |
---|---|---|
author | Katsu Kawakami <kkawa1570@gmail.com> | Sun Feb 28 22:48:24 2016 -0500 |
committer | Katsu Kawakami <kkawa1570@gmail.com> | Sun Feb 28 22:48:24 2016 -0500 |
tree | f6389bfb70787c069bdcce6a4df6f311bd1531be | |
parent | d7d8044cc3b1bad7e9dabec5e24a8913063c6dad [diff] | |
parent | e0316e740cf08ec9a2c8881c564d16cbe787ed70 [diff] |
Merge pull request #23 from gwenn/ansi Fix calculated width of prompt with ansi formatting
Readline implementation in Rust that is based on Antirez' Linenoise
This project uses Cargo and Rust Nightly
cargo build --release
extern crate rustyline; use rustyline::error::ReadlineError; use rustyline::Editor; fn main() { let mut rl = Editor::new(); if let Err(_) = rl.load_history("history.txt") { println!("No previous history."); } loop { let readline = rl.readline(">> "); match readline { Ok(line) => { rl.add_history_entry(&line); println!("Line: {}", line); }, Err(ReadlineError::Interrupted) => { println!("CTRL-C"); break }, Err(ReadlineError::Eof) => { println!("CTRL-D"); break }, Err(err) => { println!("Error: {:?}", err); break } } } rl.save_history("history.txt").unwrap(); }
You can use this package in your project by adding the following to your Cargo.toml
:
[dependencies] rustyline = "0.2.0"