Readline Implementation in Rust

Overview

RustyLine

Build Status dependency status Docs

Readline implementation in Rust that is based on Antirez' Linenoise

Supported Platforms

  • Unix (tested on FreeBSD, Linux and macOS)
  • Windows
    • cmd.exe
    • Powershell

Note:

  • Powershell ISE is not supported, check issue #56
  • Mintty (Cygwin/MinGW) is not supported
  • Highlighting / Colors are not supported on Windows < Windows 10 except with ConEmu and ColorMode::Forced.

Example

use rustyline::error::ReadlineError;
use rustyline::Editor;

fn main() {
    // `()` can be used when no completer is required
    let mut rl = Editor::<()>::new();
    if rl.load_history("history.txt").is_err() {
        println!("No previous history.");
    }
    loop {
        let readline = rl.readline(">> ");
        match readline {
            Ok(line) => {
                rl.add_history_entry(line.as_str());
                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();
}

crates.io

You can use this package in your project by adding the following to your Cargo.toml:

[dependencies]
rustyline = "7.1.0"

Features

  • Unicode (UTF-8) (linenoise supports only ASCII)
  • Word completion (linenoise supports only line completion)
  • Filename completion
  • History search (Searching for Commands in the History)
  • Kill ring (Killing Commands)
  • Multi line support (line wrapping)
  • Word commands
  • Hints

Actions

For all modes:

Keystroke Action
Home Move cursor to the beginning of line
End Move cursor to end of line
Left Move cursor one character left
Right Move cursor one character right
Ctrl-C Interrupt/Cancel edition
Ctrl-D, Del (if line is not empty) Delete character under cursor
Ctrl-D (if line is empty) End of File
Ctrl-J, Ctrl-M, Enter Finish the line entry
Ctrl-R Reverse Search history (Ctrl-S forward, Ctrl-G cancel)
Ctrl-T Transpose previous character with current character
Ctrl-U Delete from start of line to cursor
Ctrl-V Insert any special character without performing its associated action (#65)
Ctrl-W Delete word leading up to cursor (using white space as a word boundary)
Ctrl-Y Paste from Yank buffer
Ctrl-Z Suspend (Unix only)
Ctrl-_ Undo

Emacs mode (default mode)

Keystroke Action
Ctrl-A, Home Move cursor to the beginning of line
Ctrl-B, Left Move cursor one character left
Ctrl-E, End Move cursor to end of line
Ctrl-F, Right Move cursor one character right
Ctrl-H, Backspace Delete character before cursor
Ctrl-I, Tab Next completion
Ctrl-K Delete from cursor to end of line
Ctrl-L Clear screen
Ctrl-N, Down Next match from history
Ctrl-P, Up Previous match from history
Ctrl-X Ctrl-U Undo
Ctrl-Y Paste from Yank buffer (Meta-Y to paste next yank instead)
Meta-< Move to first entry in history
Meta-> Move to last entry in history
Meta-B, Alt-Left Move cursor to previous word
Meta-C Capitalize the current word
Meta-D Delete forwards one word
Meta-F, Alt-Right Move cursor to next word
Meta-L Lower-case the next word
Meta-T Transpose words
Meta-U Upper-case the next word
Meta-Y See Ctrl-Y
Meta-Backspace Kill from the start of the current word, or, if between words, to the start of the previous word
Meta-0, 1, ..., - Specify the digit to the argument. starts a negative argument.

Readline Emacs Editing Mode Cheat Sheet

vi command mode

Keystroke Action
$, End Move cursor to end of line
. Redo the last text modification
; Redo the last character finding command
, Redo the last character finding command in opposite direction
0, Home Move cursor to the beginning of line
^ Move to the first non-blank character of line
a Insert after cursor
A Insert at the end of line
b Move one word or token left
B Move one non-blank word left
c Change text of a movement command
C Change text to the end of line (equivalent to c$)
d Delete text of a movement command
D, Ctrl-K Delete to the end of the line
e Move to the end of the current word
E Move to the end of the current non-blank word
f Move right to the next occurrence of char
F Move left to the previous occurrence of char
h, Ctrl-H, Backspace Move one character left
l, Space Move one character right
Ctrl-L Clear screen
i Insert before cursor
I Insert at the beginning of line
+, j, Ctrl-N Move forward one command in history
-, k, Ctrl-P Move backward one command in history
p Insert the yanked text at the cursor (paste)
P Insert the yanked text before the cursor
r Replaces a single character under the cursor (without leaving command mode)
s Delete a single character under the cursor and enter input mode
S Change current line (equivalent to 0c$)
t Move right to the next occurrence of char, then one char backward
T Move left to the previous occurrence of char, then one char forward
u Undo
w Move one word or token right
W Move one non-blank word right
x Delete a single character under the cursor
X Delete a character before the cursor
y Yank a movement into buffer (copy)

vi insert mode

Keystroke Action
Ctrl-H, Backspace Delete character before cursor
Ctrl-I, Tab Next completion
Esc Switch to command mode

Readline vi Editing Mode Cheat Sheet

Terminal codes (ANSI/VT100)

Wine

$ cargo run --example example --target 'x86_64-pc-windows-gnu'
...
Error: Io(Error { repr: Os { code: 6, message: "Invalid handle." } })
$ wineconsole --backend=curses target/x86_64-pc-windows-gnu/debug/examples/example.exe
...

Terminal checks

$ # current settings of all terminal attributes:
$ stty -a
$ # key bindings:
$ bind -p
$ # print out a terminfo description:
$ infocmp

Similar projects

Library Lang OS Term Unicode History Completion Keymap Kill Ring Undo Colors Hint/Auto suggest
go-prompt Go Ux/win ANSI Yes Yes any Emacs/prog No No Yes Yes
Haskeline Haskell Ux/Win Any Yes Yes any Emacs/vi/conf Yes Yes ? ?
linefeed Rust Ux/Win Any Yes any Emacs/conf Yes No ? No
linenoise C Ux ANSI No Yes only line Emacs No No Ux Yes
linenoise-ng C Ux/Win ANSI Yes Yes only line Emacs Yes No ? ?
Liner Rust Ux ANSI No inc search only word Emacs/vi/prog No Yes Ux History based
prompt_toolkit Python Ux/Win ANSI Yes Yes any Emacs/vi/conf Yes Yes Ux/Win Yes
rb-readline Ruby Ux/Win ANSI Yes Yes only word Emacs/vi/conf Yes Yes ? No
replxx C/C++ Ux/Win ANSI Yes Yes only line Emacs Yes No Ux/Win Yes
Rustyline Rust Ux/Win ANSI Yes Yes any Emacs/vi/bind Yes Yes Ux/Win 10+ Yes
termwiz Rust Ux/Win Any ? Yes any Emacs No No Ux/Win No

Multi line support

This is a very simple feature that simply causes lines that are longer than the current terminal width to be displayed on the next visual line instead of horizontally scrolling as more characters are typed. Currently this feature is always enabled and there is no configuration option to disable it.

This feature does not allow the end user to hit a special key sequence and enter a mode where hitting the return key will cause a literal newline to be added to the input buffer.

The way to achieve multi-line editing is to implement the Validator trait.

Comments
  • Support Partial Completion

    Support Partial Completion

    This commit adds the ability to complete the current line with the word of the hint. When the cursor is at the end of the current line and CTRL + right arrow has been pressed, the next word of the hint will be added to the editor's line.

    Closes #413

    enhancement 
    opened by schrieveslaach 20
  • Implement CTRL-V support on Windows

    Implement CTRL-V support on Windows

    This commit implements CTRL-V support on Windows. See #519 where this issue was raised.

    Implementation notes

    On Windows, we have 3 key changes:

    • There are new Windows-only dependencies on the clipboard-win and error-code crates.
    • tty/windows.rs implements read_pasted_text by calling the clipboard-win crate. Errors are mapped to a new Windows-only error variant.
    • When CTRL-V is pressed, QuotedInsert will perform a yank using the text from the clipboard (inserting the text and moving the cursor).

    Testing

    I made a new package:

    cargo new testpaste
    cd testpaste
    cargo add rustyline
    # edit Cargo.toml; make rustyline use my git fork
    # edit src/lib.rs to be the contents of https://github.com/kkawakam/rustyline#example
    

    As noted in #519, running this example in Windows Terminal works (CTRL-V pastes text from the system clipboard) while using Powershell or cmd.exe does not work (CTRL-V does nothing, while rightclick pastes text from the system clipboard).

    After this change, CTRL-V works in all 3 shells. Mouse rightclick continues to work.

    Other

    See #520 for why I reverted the change to use fd-lock.

    opened by marcbowes 18
  • The last line of text printed by the program disappears if it doesn't end with a newline

    The last line of text printed by the program disappears if it doesn't end with a newline

    Sample program:

    use rustyline::{Editor,error::ReadlineError};
    
    fn main() {
        let mut e: Editor<()> = Editor::new();
    
        loop {
            let rl = e.readline("$ ");
            match rl {
                Ok(_) => {
                    print!("text\nwithout\nnewline");
                }
                Err(ReadlineError::Interrupted) | Err(ReadlineError::Eof) => break,
                Err(err) => panic!(err),
            }
        }
    }
    

    Expected output:

    $ some text here
    text
    without
    newline$ some other
    

    Actual output:

    $ some text here
    text
    without
    $ some other
    
    enhancement 
    opened by tudurom 17
  • Bracketed paste on Windows?

    Bracketed paste on Windows?

    Microsoft Terminal now supports bracketed paste.

    Can enable_bracketed_paste support be added to Windows targets as well? Right now, support is only for Unix environments.

    enhancement 
    opened by schungx 16
  • External print

    External print

    See #229

    cargo run --example external_print
    

    To do:

    • ~~Windows platform (only one printer supported, and when the printer is dropped we still wait)~~
    • Check interaction with history search, completion, ...
    opened by gwenn 16
  • fd-lock change breaks build on windows

    fd-lock change breaks build on windows

    56b925c271b56da77e7a78a64470e239bc1daa09 breaks the build on my Windows machine.

       Compiling dirs-next v2.0.0
    error[E0308]: mismatched types
      --> C:\Users\...\.cargo\registry\src\github.com-1ecc6299db9ec823\fd-lock-2.0.0\src\windows.rs:39:33
       |
    39 |         if unsafe { !UnlockFile(handle, 0, 0, 1, 0) } == 0 {
       |                                 ^^^^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
       |
       = note: expected raw pointer `*mut winapi::ctypes::c_void`
                  found raw pointer `*mut std::ffi::c_void`
    
    error[E0308]: mismatched types
      --> C:\Users\...\.cargo\registry\src\github.com-1ecc6299db9ec823\fd-lock-2.0.0\src\windows.rs:73:35
       |
    73 |         match unsafe { LockFileEx(handle, flags, 0, 1, 0, overlapped.raw()) } {
       |                                   ^^^^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
       |
       = note: expected raw pointer `*mut winapi::ctypes::c_void`
                  found raw pointer `*mut std::ffi::c_void`
    
    error[E0308]: mismatched types
      --> C:\Users\...\.cargo\registry\src\github.com-1ecc6299db9ec823\fd-lock-2.0.0\src\windows.rs:90:33
       |
    90 |         match unsafe { LockFile(handle, 0, 0, 1, 0) } {
       |                                 ^^^^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
       |
       = note: expected raw pointer `*mut winapi::ctypes::c_void`
                  found raw pointer `*mut std::ffi::c_void`
    
    opened by marcbowes 15
  • Rustyline crashes in linux if you hold enter

    Rustyline crashes in linux if you hold enter

    Repro:

    > cargo run --example example
    1> [now hold enter here]
    

    Once you hold enter, after a few seconds you'll see:

    1> 
    Line: 
    2> 
    Line: 
    3> 
    Line: 
    4> 
    Line: 
    5> 
    Line: 
    
    Error: Io(Kind(InvalidData))
    
    bug 
    opened by jntrnr 14
  • Keybinding to ASCII characters

    Keybinding to ASCII characters

    I'm trying to understand rustyline's keybindings better because I'm not sure what we have implemented in nushell is working.

    This backspaces a character at a time. It seems like it should backspace a word at a time.

        rl.bind_sequence(
            KeyPress::Char('\x08'), // The ASCII code for backspace is 08
            Cmd::Kill(Movement::BackwardWord(1, Word::Vi)),
            );
    

    This backspaces a word at a time. I think that is correct.

        rl.bind_sequence(
            KeyPress::Backspace,
            Cmd::Kill(Movement::BackwardWord(1, Word::Vi)),
            );
    

    This backspaces a character at a time. It seems like this should backspace a word at a time with ctrl+backspace.

        rl.bind_sequence(
            KeyPress::Ctrl('\x08'), // The ASCII code for backspace is 08
            Cmd::Kill(Movement::BackwardWord(1, Word::Vi)),
            );
    

    Any ideas why only the middle one seems to work?

    opened by fdncred 13
  • how to apply key bindings

    how to apply key bindings

    What's the secret sauce to get either of these to work in the custom_key_bindings example in Windows Terminal? Am I specifying the handler wrong?

        // rl.bind_sequence(
        //     KeyEvent {
        //         0: KeyCode::Char('H'),
        //         1: Modifiers::CTRL,
        //     },
        //     Cmd::Kill(Movement::BackwardChar(1)),
        // );
    
        rl.bind_sequence(KeyEvent::ctrl('h'), Cmd::Kill(Movement::BackwardChar(1)));
    
    bug 
    opened by fdncred 12
  • rustyline ignores user's terminal settings for VINTR and VSUSP on Unix

    rustyline ignores user's terminal settings for VINTR and VSUSP on Unix

    On Unix, users expect to configure the character they type to cause SIGINT to be sent to the foreground process group by typing, e.g. stty intr ^X where ^X is the key combination they wish to use.

    rustyline doesn't use signal handling, turns off ISIG, and hardwires Ctrl-C as the interrupt character. Likewise, the functionality of the VSUSP character (by default Ctrl-Z) appears hardwired as well.

    It may be better for it to query the terminal as to which character the user prefers to use and then implement the corresponding actions when it encounters these characters.

    PS: this behavior appears to be inherited from the original "guerrilla" linenoise library.

    enhancement 
    opened by godmar 12
  • With `EditMode::Vi`, insert mode should not have `keyseq_timeout` applied when receiving `KeyPress::Esc`

    With `EditMode::Vi`, insert mode should not have `keyseq_timeout` applied when receiving `KeyPress::Esc`

    When in insert mode, you have to wait for 500ms (or whatever timeout was given in the editor config). I would expect hitting the escape key to return to command mode immediately.

    opened by bobbygebert 11
  • How to access LineBuffer?

    How to access LineBuffer?

    Thanks for making rustyline! I've been enjoying it.

    I see the docs for LineBuffer but I can't seem to find a way to obtain one. Looking through the source, it seems none of its usages are exposed (that I can tell), but LineBuffer itself is exposed, which makes me think there's some way to access it...I just can't figure out what it is!

    opened by rtfeldman 1
  • How to test an app that uses rustyline?

    How to test an app that uses rustyline?

    I have been figuring out how to test the following basic CLI app that uses rustyline using std::process::Command but I could not figure out how to pull it off right.

    The following is the code for CLI app:

    use std::io::Write;
    
    use rustyline::error::ReadlineError;
    use rustyline::Editor;
    
    fn main() {
        let mut line_editor = Editor::<()>::new().unwrap();
        let mut counter = 0;
    
        loop {
            let readline = line_editor.readline("> ");
            match readline {
                Ok(line) => {
                    counter += 1;
                    println!("Line: {}", line);
                    line_editor.add_history_entry(line.clone());
    
                    if line == "clear" {
                        print!("{esc}[2J{esc}[1;1H", esc = 27 as char);
                        std::io::stdout().flush().unwrap();
                    }
                }
                Err(ReadlineError::Interrupted) => {
                    println!("Ctrl+C");
                    break;
                }
                Err(ReadlineError::Eof) => {
                    println!("Ctrl+D | Lines counted: {}", counter);
                    break;
                }
                Err(err) => {
                    println!("Error: {:?}", err);
                    break;
                }
            }
        }
    }
    

    And code for the test:

    #[test]
    fn clear_screen() -> Result<(), Box<dyn std::error::Error>> {
        let mut cmd = Command::cargo_bin("control-cli")?;
        let mut cmd_child = cmd.stdin(Stdio::piped()).spawn()?;
        let mut child_stdin = cmd_child.stdin.take().unwrap();
    
        child_stdin.write_all(b"history\n").unwrap();
    
        signal::kill(Pid::from_raw(cmd_child.id() as i32), Signal::SIGINT)?;
    
        let output = cmd.output()?;
    
        println!("{}", String::from_utf8_lossy(&output.stdout));
    
        Ok(())
    }
    

    When I run the test with cargo test -- --nocapture, I only get the following output:

    Ctrl+D | Lines counted: 0
    

    I was expecting something like:

    Line: history
    Ctrl+D | Lines counted: 1
    

    I believe #504 may be related to this problem. Nevertheless, how can I achieve the second output?

    opened by seanballais 2
  • Help, how to use multiline input prompt? Following the example code in `input_multiline.rs` but it does not compile

    Help, how to use multiline input prompt? Following the example code in `input_multiline.rs` but it does not compile

    I am using code from https://github.com/kkawakam/rustyline/blob/master/examples/input_multiline.rs and it does not compile on my system. I can't understand the error here:

    error[E0308]: mismatched types
       --> src\cli.rs:52:28
        |
    52  |         rl.set_helper(Some(h));
        |                       ---- ^ expected `()`, found struct `InputValidator`
        |                       |
        |                       arguments to this enum variant are incorrect
        |
    note: tuple variant defined here
       --> C:\Users\turtle\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\option.rs:526:5
        |
    526 |     Some(#[stable(feature = "rust1", since = "1.0.0")] T),
        |     ^^^^
    

    Here's my code:

        use rustyline::{error::ReadlineError, Editor};
        use rustyline::validate::MatchingBracketValidator;
        use rustyline::{Cmd, EventHandler, KeyCode, KeyEvent, Modifiers};
        use rustyline_derive::{Completer, Helper, Highlighter, Hinter, Validator};
    
        #[derive(Completer, Helper, Highlighter, Hinter, Validator)]
        struct InputValidator {
            #[rustyline(Validator)]
            brackets: MatchingBracketValidator,
        }
    
        #[allow(unreachable_code)]
        pub(crate) fn start_repl() -> std::io::Result<()> {
            let mut buf = String::new();
            let h = InputValidator {
                brackets: MatchingBracketValidator::new(),
            };
            let mut rl = Editor::<()>::new();
            rl.set_helper(Some(h));
            rl.bind_sequence(
                KeyEvent(KeyCode::Char('s'), Modifiers::CTRL),
                EventHandler::Simple(Cmd::Newline),
            );
            if rl.load_history("history.txt").is_err() {
                // println!("No previous history.");
            }
            loop {
                let line = rl.readline("> ");
                match line {
                    Ok(line) => {
                        rl.add_history_entry(line.as_str());
                        buf = line;
                    }
                    Err(ReadlineError::Interrupted) => {
                        println!("CTRL-C");
                        println!("Exiting");
                        std::process::exit(0);
                        break;
                    }
                    Err(ReadlineError::Eof) => {
                        println!("CTRL-D");
                        break;
                    }
                    Err(e) => {
                        eprintln!("Unexpected prompt error : {e:?}");
                        std::process::exit(1);
                    }
                }
                let input: &str = buf.trim();
                if input == "exit" || input == "quit" {
                    println!("Exiting");
                    std::process::exit(0);
                }
                buf.clear();
            }
            Ok(())
        }
    
    question 
    opened by weezy20 1
  • Highlighter::highlight_candidate() candidate argument should be Completer::Candidate

    Highlighter::highlight_candidate() candidate argument should be Completer::Candidate

    See FIXME comment here: https://github.com/kkawakam/rustyline/blob/4d48e58913dbc554e8381158d0dc27ec3d8a7559/src/highlight.rs#L45

    What's the reason this isn't fixed? Can it be fixed?

    I had to work around this and highlight the candidates in Completer::complete() instead.

    enhancement 
    opened by tobiasvl 1
  • Update custom key bindings example

    Update custom key bindings example

    In my testing selfinsert doesn't seem to work, it inserts one white-space character instead of an actual tab, changing it to insert makes it work perfectly.

    opened by sigmaSd 1
Releases(v10.0.0)
  • v10.0.0(Jul 17, 2022)

    What's Changed

    • Use a BufReader on unix platform #589
    • PreferTerm #599, #601
    • Guard cursor coordinates #602
    • External print #229, #235, #600, #627
    • Introduce signal-hook #606, #608
    • Replace buf_redux with BufReader from std #613
    • Remove SmallVec from Event enum #614
    • Make custom key bindings an optional Cargo feature #615
    • Use nix APIs for umask munging in history module #616
    • Derive Completer, Highlighter, Hinter, Validator from struct fields #621
    • Upgrade nix to 0.24, limit features #623
    • Do not validate if the command is 'NewLine' #640

    Full Changelog: https://github.com/kkawakam/rustyline/compare/v9.1.2...v10.0.0

    Source code(tar.gz)
    Source code(zip)
  • v9.1.2(Jan 1, 2022)

  • v9.1.1(Dec 11, 2021)

  • v9.1.0(Dec 4, 2021)

    What's Changed

    • Load terminal settings for VINTR, VQUIT, VSUSP on Unix #530 / #535
    • Fix interrupted interactive search #575 / #576
    • Upgrade dependencies #568
    • Migrate to 2021 edition #570

    Full Changelog: https://github.com/kkawakam/rustyline/compare/v9.0.0...v9.1.0

    Source code(tar.gz)
    Source code(zip)
  • v9.0.0(Aug 17, 2021)

    Breaking Changes

    • Fix prefix-based search #545
      • rename history::Direction to history::SearchDirection
      • History::search and History::starts_with return a SearchResult

    Changelog

    • Fix history persistence bugs #560 / #559
    • Keep the distinction between backspace and ctrl-h on windows #547 / #543
    • Keep the distinction between enter and ctrl-m on windows #547
    • Keep the distinction between tab and ctrl-i on windows #547
    • Case-insensitive history search #546 / #490
    • Run hinter again after hint is inserted with right arrow #555 / #556
    • Support multiline inputs in non TTY contexts #518
    • \0 is Ctrl-@ not Ctrl-space #538
    • Bind Ctrl-] to character-search in emacs mode #538
    • Bind Ctrl-X backspace to backward-kill-line in emacs mode #538
    • Implement Invoke for str #534
    • Upgrade to nix 0.22 #544
    • Upgrade fd-lock to version 3.0.0 #553
    Source code(tar.gz)
    Source code(zip)
  • v8.2.0(May 20, 2021)

  • v8.1.0(May 18, 2021)

    • Support Partial Completion (#413, #513)
    • Implement CTRL-V support on Windows (#519, #521)
    • Support ESC ESC sequences, and bind alt+left/alt+right (#517)
    • Implement Candidate for &'static str (#443, #512)
    • Fix KeyEvent::encode (#509, #511)
    • Fix line wrap predicate (#523)
    • Replace fs2 dependency by fd-lock (#505, #507, #522)
    Source code(tar.gz)
    Source code(zip)
  • v8.0.0(Mar 7, 2021)

    Breaking Changes

    • Fix WordAction variants (https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms)

    Changelog

    • Conditional binding (#492, #488, #436, #407, and partially #430, #269)
    • Bracketed paste can be disabled (#202)
    • Upgrade nix dependency to version 0.20
    • Upgrade skim optional dependency to version 0.9
    Source code(tar.gz)
    Source code(zip)
  • v7.1.0(Dec 15, 2020)

    Changelog

    • Fix Ctrl-Right binding (#465)
    • Migrated to dirs-next due to dirs no longer being maintained (#468)
    • Fix append_history (#469)
    • Fix issue: AltGr handled as Ctrl (#476)
    Source code(tar.gz)
    Source code(zip)
  • v7.0.0(Nov 22, 2020)

    Breaking Changes

    • Append histo (Should fix #400): a mutable reference is now needed to save history
    • Detach hint title from completion text (#414): Hinter trait has a new associated type (just add type Hint = String; to fix old implementations)
    • Flexible AcceptLine, fix bug in multi-line accept (#379)
    • Split KeyPress into separate Key and Modifier types. (#318 / #421)

    Changelog

    • Make possible to deactivate move_cursor_at_leftmost (#445 / #448)
    • Ctrl+Left, Ctrl+Right for word skip (#146)
    • Implement indentation commands (#452)
    • Implement Candidate for str (#447)
    • Ignore EINTR while polling (#454)
    • Fix input validation (#461)
    • Document Validator::validate_while_typing not being implemented (#460)
    • Upgrade dependencies and switch back to dirs (#456)
    Source code(tar.gz)
    Source code(zip)
  • v6.3.0(Sep 13, 2020)

    Changelog

    • Fix panic on Windows (#433)
    • Fix History::load (#409)
    • Vi: insert mode escape seq fallback to command mode (#416)
    • Improve History::save (#412)
    • Handle SIGWINCH while calling move_cursor_at_leftmost (May fix #402)
    • Update nix to 0.18 (#428)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.0(Jun 4, 2020)

    Changelog

    • vi: use j, k, + and - for history navigation (#374)
    • Migrate to dirs-next (#388)
    • Allow Windows to use case insensitive path completion (#389)
    • Fix completions with multiline prompt / input (#390)
    • Sort file completion candidates (#393)
    • Redefine DummyTerminal::is_unsupported under wasm (#354)
    • More sane behavior if terminal size is zero (#396)
    • Returns impl Iterator directly (#395)
    Source code(tar.gz)
    Source code(zip)
  • v6.1.2(Apr 23, 2020)

    Changelog

    • Fix clear_screen on Windows (#366)
    • Hide cursor while refreshing line on Windows (#256)
    • Fix line wrapping on Windows 10 (#351)
    • Make some enums non_exhaustive (#364)
    Source code(tar.gz)
    Source code(zip)
  • v6.1.1(Apr 12, 2020)

  • v6.1.0(Apr 2, 2020)

    Changelog

    • Bugfixes/consistency improvements for multiline stuff (#334)
      • Movement::{BeginningOfLine,EndOfLine,etc} now actually go to beginning/end of the line.
      • Movement::BeginningOfBuffer, etc was added to get the original functionality back.
      • Fix some off-by-one bugs in the line movement code.
      • Make it easier to test the multiline functionality by adding a matching bracket validator, and using it in the examples.
    • Add LineUp/LineDown movement commands (#317)
    • Add smart up and down commands (#329)
    • Add AcceptOrNewLine command (#330)
    • Make config builder clonable (#322)
    • Fix incorrect cfg-if dependency declaration. (#336)
    • Add skim as optional fuzzy completion option for unix (#323)
    • Add DIY hints content and hints promot behavior (#347)
    • Update nix to 0.17 (#320)
    • Upgrade utf8parse to 0.2 (#321)
    Source code(tar.gz)
    Source code(zip)
  • v6.0.0(Jan 5, 2020)

    Breaking Changes

    • Input validation (#311, #180, #79) In case you have implemented your own Helper, you will have to make it derive Validator.

    Changelog

    • Fix rendering bug when a linefeed is inserted at the end of the edited line (#193)
    Source code(tar.gz)
    Source code(zip)
  • v5.0.6(Jan 1, 2020)

  • v5.0.5(Dec 13, 2019)

  • v5.0.4(Oct 30, 2019)

  • v5.0.3(Sep 15, 2019)

  • v5.0.2(Aug 20, 2019)

    • Add CompleteBackward command (#257)
    • Allow edit line grow (#255)
    • Add constructor to Context visible for testing (#261)
    • Use nix::ioctl_read_bad! (#265)
    • Add an example to read password (#58)
    • Introduce derive macros for Completer, Helper, Highlighter and Hinter (#267)
    Source code(tar.gz)
    Source code(zip)
  • v5.0.1(Aug 1, 2019)

    • rustyline hangs when trying to put the prompt on the left side (#247)
    • Do not request cursor location when stdin is already ready (#246, #249)
    • Do not request cursor location when stdout is not a tty
    • Clippy: fix warnings
    Source code(tar.gz)
    Source code(zip)
  • v5.0.0(Jun 21, 2019)

    Breaking Changes

    • Fix highlight_prompt signature (#232)

    Changelog

    • Make sure prompt is at the leftmost edge of the screen (#216)
    • Make possible to detect changes (#230)
    • Improve undo action (#228)
    • Fix colors on Windows (#227)
    • Upgrade dirs dependency
    • Bump nix to 0.14 (#238)
    • Fix HistoryHinter (#239)
    Source code(tar.gz)
    Source code(zip)
  • v4.1.0(May 17, 2019)

    • Fix nightly build (#217)
    • Make implementing Helper easier (#213)
    • Introduce FilenameCompleter::complete_path (#211)
    • Replace deprecated ATOMIC_BOOL_INIT (#221)
    Source code(tar.gz)
    Source code(zip)
  • v4.0.0(Apr 24, 2019)

    Breaking Changes

    • Introduce Context which gives history access for completion/suggestion.
    • Update nix dependency to 0.13

    Changelog

    • Suggestion based on history: HistoryHinter
    • Support bracketed paste mode on unix
    • Editor::dimensions returns terminal size (#204)
    • Feature toggle dirs to legacy support (#195)
    • Fix bug in HistoryHinter when ctx.history_index() is 0 (#186)
    • Fix \t rendering width (#65)
    Source code(tar.gz)
    Source code(zip)
  • v3.0.0(Dec 9, 2018)

    Breaking Changes

    • fix highlight_char signature
    • remove highlight_dynamic_prompt deprecated method

    Changelog

    • Add support for matching delimiter blinking (#111)
    • Ensure Editor is Send and Sync. (#160)
    • Complete hints with the right key
    • Allow customisation of the output stream
    • Ignore all IO errors during file completion
    • Fix spelling in documentation
    • Apply clippy::pedantic suggestions
    • Fix hint display logic
    • Simplify surrogate pair handling on windows
    • Rust 2018 edition
    Source code(tar.gz)
    Source code(zip)
  • v2.1.0(Sep 9, 2018)

    • Fix refresh bug (https://github.com/kkawakam/rustyline/issues/149)
    • Improve key press handling:
      • BackTab (Shift-Tab) on both unix and windows
      • F1...F5 on linux console
      • Ctrl-Space on windows
    Source code(tar.gz)
    Source code(zip)
  • v2.0.1(Sep 6, 2018)

    • Use into() instead of casting to c_ulong because of different types in some targets
    • Windows: handle shift+arrow
    • Fix https://github.com/kkawakam/rustyline/issues/137
    • Mark highlight_dynamic_prompt as deprecated (My bad).
    Source code(tar.gz)
    Source code(zip)
  • v2.0.0(Aug 26, 2018)

    Breaking Changes

    • add_history_line could take a Into (#77) rl.add_history_entry(&line); => rl.add_history_entry(line.as_ref());, see impact on example.
    • Introduce Config struct, see first and final impacts on example.
    • Replace set_completer by set_helper, see impact on example.
    • Replace get_history_const by history and get_history by history_mut.
    • Introduce Candidate trait, see impact on example.

    Changelog

    • Page completions
    • Doc (#80)
    • Add an Iterator (#82)
    • Make History iterable
    • Fix completion (#95)
    • Handle single ESC key (#66)
    • Fix autocomplete cancel
    • Fix insecure history file creation
    • Fix Ctrl-Z (#20)
    • Vi mode support (#94)
    • Add get_history_const() function
    • Numeric arguments (RepeatCount)
    • Move cursor by grapheme not by char (#107)
    • Undos (#60)
    • Make possible to customize key bindings (#115) https://github.com/kkawakam/rustyline/commit/0a909f7e104f0ac5f18b05ee03742a54b9c490b0#diff-9cbba383e150da18cf46e47c7a49189fR30
    • Optimize cursor movement (#59)
    • Vi overwrite mode
    • Support additional keys (Function keys, Control+Arrow key, Shift+Arrow key, Insert key)
    • Support initial input (readline_with_initial)
    • Add auto_add_history config flag
    • Hints support (#67)
    • Fix multi-line prompts clearing too many lines
    • Dynamic prompt (arg: ?)
    • Enable ansi colors on windows (windows 10 only)
    • Fix compilation error on FreeBSD (#129)
    • File completion: handle quoted path
    • Upgrade dependencies
    • Fix windows file completion (#106, #113, #136)
    • Highlight support (#111, #114)
    • Modify Editor Config (#137)
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Aug 21, 2016)

    Breaking Changes

    You will need to explicitly parametrizing the Editor if there is no completer.

    Before you would do the following (if you did not specify a completer):

    let mut rl = Editor::new();
    

    Now you will have to do the following (if you did not specify a completer):

    let mut rl = Editor::<()>::new();
    

    Changelog

    • Fix compilation against musl #41
    • Fix mult-line prompts #45
    • History if configurable to ignore spaces and/or duplicate entries #51
    • Parametrize the editor by the Completer type #52
    • Clear only the lines/rows drawn used by the editor #53
    • Windows support #42 #54 #69

    Thank you to @gwenn for his work

    Source code(tar.gz)
    Source code(zip)
Owner
Katsu Kawakami
Work account @kkawakam-transferwise
Katsu Kawakami
A readline replacement written in Rust

A readline replacement written in Rust Basic example // Create a default reedline object to handle user input use reedline::{DefaultPrompt, Reedline,

JT 292 Jan 9, 2023
A minimal readline with multiline and async support

RustyLine Async A minimal readline with multiline and async support. Inspired by rustyline , async-readline & termion-async-input.

Zyansheep 16 Dec 15, 2022
A SIMD implementation of Keccak256 for aarch64, forked from Remco Bloeman's Goldilocks K12 implementation.

keccak256-aarch64 Warning This crate was forked from real cryptographers (Goldilocks by Remco Bloeman), by not a real cryptographer. Do not use this k

null 6 Oct 24, 2023
Rust implementation of the termbox library

Rustbox Rustbox is a Rust implementation of termbox. Currently, this is just a wrapper of the C library by nsf, though my plan is to convert it to be

Greg Chapple 462 Dec 19, 2022
A very fast implementation of tldr in Rust

A very fast implementation of tldr in Rust: Simplified, example based and community-driven man pages.

Danilo Bargen 2.9k Dec 31, 2022
A compact implementation of connect four written in rust.

connect-four A compact implementation of connect four written in rust. Run the game At the moment there no pre-built binaries - but you can build it l

Maximilian Schulke 12 Jul 31, 2022
Baby's first Rust CLI project. Basic implementation of grep. Written in about 100 SLOC.

minigrep Coding project from Chapter 12 of the The Rust Programming Language book. Usage Compile and run as so minigrep QUERY FILENAME QUERY being the

Anis 2 Oct 2, 2021
An implementation of Verifiable Delay Functions in Rust

Verifiable Delay Function (VDF) Implementation in Rust What is a VDF? A Verifiable Delay Function (VDF) is a function that requires substantial time t

null 147 Dec 12, 2022
A Decimal Implementation written in pure Rust suitable for financial calculations.

Decimal   A Decimal implementation written in pure Rust suitable for financial calculations that require significant integral and fractional digits wi

Paul Mason 702 Jan 5, 2023
Rust implementation of custom numeric base conversion.

base_custom Use any characters as your own numeric base and convert to and from decimal. This can be taken advantage of in various ways: Mathematics:

Daniel P. Clark 5 Dec 28, 2021
Red-blue graph problem solver - Rust implementation

Red-blue graph problem solver - Rust implementation The problem is the following: In a directed graph, each node is colored either red or blue. Furthe

Thomas Prévost 2 Jan 17, 2022
A better customization password dictionary generator implementation by Rust.

abcdict A better customization password dictionary generator implementation by Rust. Features Cli Faster Customize Rules Build & Installation $> cargo

b23r0 6 Jun 2, 2022
An Rust implementation of the Modified Merkle Patricia Tree described by ETH Yellow Paper

Merkle Patricia Tree的Rust实现 博客文章:https://dere.press/2022/01/24/eth-trie/ 本实现参考下列项目: https://ethereum.github.io/yellowpaper/paper.pdf https://github.co

M4tsuri 3 Dec 13, 2022
Rust implementation of Python command line progress bar tool tqdm.

tqdm Rust implementation of Python command line progress bar tool tqdm. From original documentation: tqdm derives from the Arabic word taqaddum (تقدّم

Yiheng Du 8 Dec 7, 2022
A cross platform, rust implementation for the Tegra X1 bootROM exploit

Switcheroo A CLI and GUI for the RCM BootRom exploit (Fusée Gelée exploit for Nintendo Switch) Only works on unpatched Switches: https://ismyswitchpat

Ethan Budd 35 Nov 5, 2022
An NTP implementation in Rust, supported by Internet Security Research Group's Prossimo project.

NTPD-rs NTPD-rs is an implementation of NTP completely written in Rust, with a focus on exposing a minimal attack surface. The project is currently in

Prossimo (ISRG) 302 Jan 4, 2023
Rust implementation of PowerSession, with new features and enhancements

PowerSession Record a Session in PowerShell. PowerShell version of asciinema based on Windows Pseudo Console(ConPTY) This is a new Rust implemented ve

Watfaq Technologies Pty Ltd 43 Dec 26, 2022
Jump Point Search Implementation for Path Finding, in Rust

jps : Jump Point Search in Rust. Jump Point Search Algorithm Implementation in Rust. Current implementation status JPS Implementation 3D case ✅ Lifeti

null 3 Dec 15, 2022
A Write Ahead Log (WAL) implementation in Rust

Okay WAL A write-ahead log (WAL) implementation for Rust. There's The Great Wall, and then there's this: an okay WAL. This crate exposes a WAL that su

Khonsu Labs 5 Oct 28, 2022