Crate linenoise [] [src]

This is a library that interfaces with the linenoise library. Linenoise is a library implemented by Antirez, the Redis creator as a replacement for readline.

This library is just a binding to this library.

extern crate linenoise;
fn callback(input: &str) -> Vec<String> {
  let mut ret : Vec<&str>;
   if input.starts_with("s") {
    ret = vec!["suggestion", "suggestion2", "suggestion-three"];
  } else {
    ret = vec!["wot"];
  }

    return ret.iter().map(|s| s.to_string()).collect();
}

fn main() {
  linenoise::set_callback(callback);

    loop {
      let val = linenoise::input("hello > ");
        match val {
            None => { break }
            Some(input) => {
                println!("> {}", input);
                linenoise::history_add(input.as_slice());
                if input.as_slice() == "clear" {
                  linenoise::clear_screen();
                }
            }
        }
    }
}

Modules

ffi

Functions

add_completion

Add a completion to the current list of completions.

clear_screen

Clears the screen

history_add

Add this string to the history

history_line

Get a line from the history by (zero-based) index

history_load

Load the history on disk

history_save

Save the history on disk

history_set_max_len

Set max length history

input

Shows the prompt with your prompt as prefix Retuns the typed string or None is nothing or EOF

print_key_codes
set_callback

Sets the callback when tab is pressed

set_multiline

Type Definitions

CompletionCallback
Completions