Use new version of rustyline.
This commit is contained in:
parent
8cf6f424a5
commit
5e7db6e105
@ -55,15 +55,16 @@ The REPL bin tool, `rhai-rpl`, has been enhanced.
|
||||
|
||||
### Line editor
|
||||
|
||||
* `rhai-repl` now uses [`rustyline`](https://crates.io/crates/rustyline) as a line editor with history.
|
||||
* Shift-Enter can now be used to enter multiple lines without having to attach the `\` continuation character the end of each line.
|
||||
* `rhai-repl` now uses a modified version of [`rustyline`](https://crates.io/crates/rustyline) as a line editor with history.
|
||||
* Ctrl-Enter can now be used to enter multiple lines without having to attach the `\` continuation character the end of each line.
|
||||
* Bracketed paste is supported, even on Windows (version 10 or above), so pasting code directly into `rhai-repl` is made much more convenient.
|
||||
|
||||
### New commands
|
||||
|
||||
* `strict` to turn on/off _Strict Variables Mode_.
|
||||
* `optimize` to turn on/off script optimization.
|
||||
* `history` to print lines history.
|
||||
* `!!`, `!`_num_ and `!`_text_ to recall a history line.
|
||||
* `!!`, `!`_num_, `!`_text_ and `!?`_text_ to recall a history line.
|
||||
* `keys` to print all key bindings.
|
||||
|
||||
|
||||
|
@ -29,7 +29,9 @@ serde = { version = "1.0", default-features = false, features = ["derive", "allo
|
||||
serde_json = { version = "1.0", default-features = false, features = ["alloc"], optional = true }
|
||||
unicode-xid = { version = "0.2", default-features = false, optional = true }
|
||||
rust_decimal = { version = "1.16", default-features = false, features = ["maths"], optional = true }
|
||||
rustyline = { version = "9", optional = true }
|
||||
# notice that a custom modified version of `rustyline` is used which supports bracketed paste on Windows
|
||||
# this can be moved to the official version when bracketed paste is added
|
||||
rustyline = { version = "9", optional = true, git = "https://github.com/schungx/rustyline", branch = "bracketed_paste" }
|
||||
|
||||
[dev-dependencies]
|
||||
serde_bytes = "0.11"
|
||||
|
@ -62,8 +62,8 @@ fn print_help() {
|
||||
println!("ast => print the last AST (optimized)");
|
||||
println!("astu => print the last raw, un-optimized AST");
|
||||
println!();
|
||||
println!("press Shift-Enter to continue to the next line,");
|
||||
println!(r"or end a line with '\' (e.g. when pasting code).");
|
||||
println!("press Ctrl-Enter or end a line with `\\`");
|
||||
println!("to continue to the next line.");
|
||||
println!();
|
||||
}
|
||||
|
||||
@ -204,6 +204,7 @@ fn load_script_files(engine: &mut Engine) {
|
||||
|
||||
// Setup the Rustyline editor.
|
||||
fn setup_editor() -> Editor<()> {
|
||||
//env_logger::init();
|
||||
let config = Builder::new()
|
||||
.tab_stop(4)
|
||||
.indent_size(4)
|
||||
@ -225,23 +226,13 @@ fn setup_editor() -> Editor<()> {
|
||||
Event::KeySeq(smallvec![KeyEvent::ctrl('z')]),
|
||||
EventHandler::Simple(Cmd::Undo(1)),
|
||||
);
|
||||
// Map Shift-Return to insert a new line - bypass need for `\` continuation
|
||||
// Map Ctrl-Enter to insert a new line - bypass need for `\` continuation
|
||||
rl.bind_sequence(
|
||||
Event::KeySeq(smallvec![KeyEvent(
|
||||
KeyCode::Char('m'),
|
||||
Modifiers::CTRL_SHIFT
|
||||
)]),
|
||||
Event::KeySeq(smallvec![KeyEvent(KeyCode::Char('J'), Modifiers::CTRL)]),
|
||||
EventHandler::Simple(Cmd::Newline),
|
||||
);
|
||||
rl.bind_sequence(
|
||||
Event::KeySeq(smallvec![KeyEvent(
|
||||
KeyCode::Char('j'),
|
||||
Modifiers::CTRL_SHIFT
|
||||
)]),
|
||||
EventHandler::Simple(Cmd::Newline),
|
||||
);
|
||||
rl.bind_sequence(
|
||||
Event::KeySeq(smallvec![KeyEvent(KeyCode::Enter, Modifiers::SHIFT)]),
|
||||
Event::KeySeq(smallvec![KeyEvent(KeyCode::Enter, Modifiers::CTRL)]),
|
||||
EventHandler::Simple(Cmd::Newline),
|
||||
);
|
||||
// Map Ctrl-Home and Ctrl-End for beginning/end of input
|
||||
|
Loading…
Reference in New Issue
Block a user