Fix rustyline patch.

This commit is contained in:
Stephen Chung 2022-04-11 16:32:23 +08:00
parent 63359f3f81
commit 06608affc5
3 changed files with 13 additions and 17 deletions

View File

@ -1,13 +1,14 @@
Rhai Release Notes
==================
Version 1.7.0
Version 1.6.1
=============
Bug fixes
---------
* Functions with `Dynamic` parameters now work in qualified calls from `import`ed modules.
* `rhai-repl` now compiles with the new patch version of `rustyline`.
Script-breaking changes
-----------------------
@ -18,7 +19,7 @@ Script-breaking changes
Enhancements
------------
* Strings are not directly iterable (via `for .. in`) yielding individual characters.
* Strings are now directly iterable (via `for .. in`) yielding individual characters.
Version 1.6.0

View File

@ -3,7 +3,7 @@ members = [".", "codegen"]
[package]
name = "rhai"
version = "1.7.0"
version = "1.6.1"
rust-version = "1.57"
edition = "2018"
authors = ["Jonathan Turner", "Lukáš Hozda", "Stephen Chung", "jhwgh1968"]

View File

@ -3,7 +3,6 @@ use rhai::{Dynamic, Engine, EvalAltResult, Module, Scope, AST, INT};
use rustyline::config::Builder;
use rustyline::error::ReadlineError;
use rustyline::{Cmd, Editor, Event, EventHandler, KeyCode, KeyEvent, Modifiers, Movement};
use smallvec::smallvec;
use std::{env, fs::File, io::Read, path::Path, process::exit};
@ -223,40 +222,40 @@ fn setup_editor() -> Editor<()> {
// On Windows, Esc clears the input buffer
#[cfg(target_family = "windows")]
rl.bind_sequence(
Event::KeySeq(smallvec![KeyEvent(KeyCode::Esc, Modifiers::empty())]),
Event::KeySeq(vec![KeyEvent(KeyCode::Esc, Modifiers::empty())]),
EventHandler::Simple(Cmd::Kill(Movement::WholeBuffer)),
);
// On Windows, Ctrl-Z is undo
#[cfg(target_family = "windows")]
rl.bind_sequence(
Event::KeySeq(smallvec![KeyEvent::ctrl('z')]),
Event::KeySeq(vec![KeyEvent::ctrl('z')]),
EventHandler::Simple(Cmd::Undo(1)),
);
// Map Ctrl-Enter to insert a new line - bypass need for `\` continuation
rl.bind_sequence(
Event::KeySeq(smallvec![KeyEvent(KeyCode::Char('J'), Modifiers::CTRL)]),
Event::KeySeq(vec![KeyEvent(KeyCode::Char('J'), Modifiers::CTRL)]),
EventHandler::Simple(Cmd::Newline),
);
rl.bind_sequence(
Event::KeySeq(smallvec![KeyEvent(KeyCode::Enter, Modifiers::CTRL)]),
Event::KeySeq(vec![KeyEvent(KeyCode::Enter, Modifiers::CTRL)]),
EventHandler::Simple(Cmd::Newline),
);
// Map Ctrl-Home and Ctrl-End for beginning/end of input
rl.bind_sequence(
Event::KeySeq(smallvec![KeyEvent(KeyCode::Home, Modifiers::CTRL)]),
Event::KeySeq(vec![KeyEvent(KeyCode::Home, Modifiers::CTRL)]),
EventHandler::Simple(Cmd::Move(Movement::BeginningOfBuffer)),
);
rl.bind_sequence(
Event::KeySeq(smallvec![KeyEvent(KeyCode::End, Modifiers::CTRL)]),
Event::KeySeq(vec![KeyEvent(KeyCode::End, Modifiers::CTRL)]),
EventHandler::Simple(Cmd::Move(Movement::EndOfBuffer)),
);
// Map Ctrl-Up and Ctrl-Down to skip up/down the history, even through multi-line histories
rl.bind_sequence(
Event::KeySeq(smallvec![KeyEvent(KeyCode::Down, Modifiers::CTRL)]),
Event::KeySeq(vec![KeyEvent(KeyCode::Down, Modifiers::CTRL)]),
EventHandler::Simple(Cmd::NextHistory),
);
rl.bind_sequence(
Event::KeySeq(smallvec![KeyEvent(KeyCode::Up, Modifiers::CTRL)]),
Event::KeySeq(vec![KeyEvent(KeyCode::Up, Modifiers::CTRL)]),
EventHandler::Simple(Cmd::PreviousHistory),
);
@ -371,11 +370,7 @@ fn main() {
input.clear();
loop {
let prompt = if input.is_empty() {
"rhai-repl> "
} else {
" > "
};
let prompt = if input.is_empty() { "repl> " } else { " > " };
match rl.readline(prompt) {
// Line continuation