forked from extern/nushell
imp: bump rustyline to 8.0.0 (#3167)
* imp: bump rustyline to 8.0.0 * fix: rustyline 8 keybindings * fix: commands count/length test Co-authored-by: alexhk <alexhk@protonmail.com>
This commit is contained in:
parent
2ace20fade
commit
56adc7c3c6
106
Cargo.lock
generated
106
Cargo.lock
generated
@ -1164,7 +1164,7 @@ version = "3.1.8"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c15b8ec3b5755a188c141c1f6a98e76de31b936209bf066b647979e2a84764a9"
|
checksum = "c15b8ec3b5755a188c141c1f6a98e76de31b936209bf066b647979e2a84764a9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nix 0.20.0",
|
"nix",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -1326,16 +1326,6 @@ dependencies = [
|
|||||||
"dirs-sys",
|
"dirs-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dirs-next"
|
|
||||||
version = "1.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "cf36e65a80337bea855cd4ef9b8401ffce06a7baedf2e85ec467b1ac3f6e82b6"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if 1.0.0",
|
|
||||||
"dirs-sys-next",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs-next"
|
name = "dirs-next"
|
||||||
version = "2.0.0"
|
version = "2.0.0"
|
||||||
@ -1514,6 +1504,12 @@ dependencies = [
|
|||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "endian-type"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "env_logger"
|
name = "env_logger"
|
||||||
version = "0.7.1"
|
version = "0.7.1"
|
||||||
@ -2995,6 +2991,15 @@ version = "1.0.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
|
checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nibble_vec"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43"
|
||||||
|
dependencies = [
|
||||||
|
"smallvec 1.6.1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nipper"
|
name = "nipper"
|
||||||
version = "0.1.8"
|
version = "0.1.8"
|
||||||
@ -3008,30 +3013,6 @@ dependencies = [
|
|||||||
"tendril",
|
"tendril",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nix"
|
|
||||||
version = "0.18.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "83450fe6a6142ddd95fb064b746083fc4ef1705fe81f64a64e1d4b39f54a1055"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"cc",
|
|
||||||
"cfg-if 0.1.10",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nix"
|
|
||||||
version = "0.19.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b2ccba0cfe4fdf15982d1674c69b1fd80bad427d293849982668dfe454bd61f2"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"cc",
|
|
||||||
"cfg-if 1.0.0",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nix"
|
name = "nix"
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
@ -3151,7 +3132,7 @@ dependencies = [
|
|||||||
"ctrlc",
|
"ctrlc",
|
||||||
"derive-new",
|
"derive-new",
|
||||||
"directories-next",
|
"directories-next",
|
||||||
"dirs-next 2.0.0",
|
"dirs-next",
|
||||||
"dtparse",
|
"dtparse",
|
||||||
"dunce",
|
"dunce",
|
||||||
"eml-parser",
|
"eml-parser",
|
||||||
@ -3202,7 +3183,7 @@ dependencies = [
|
|||||||
"roxmltree",
|
"roxmltree",
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
"rust-embed",
|
"rust-embed",
|
||||||
"rustyline 6.3.0",
|
"rustyline",
|
||||||
"serde 1.0.124",
|
"serde 1.0.124",
|
||||||
"serde_bytes",
|
"serde_bytes",
|
||||||
"serde_ini",
|
"serde_ini",
|
||||||
@ -3253,7 +3234,7 @@ dependencies = [
|
|||||||
"ctrlc",
|
"ctrlc",
|
||||||
"derive-new",
|
"derive-new",
|
||||||
"directories-next",
|
"directories-next",
|
||||||
"dirs-next 2.0.0",
|
"dirs-next",
|
||||||
"dtparse",
|
"dtparse",
|
||||||
"dunce",
|
"dunce",
|
||||||
"eml-parser",
|
"eml-parser",
|
||||||
@ -3304,7 +3285,7 @@ dependencies = [
|
|||||||
"roxmltree",
|
"roxmltree",
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
"rust-embed",
|
"rust-embed",
|
||||||
"rustyline 7.1.0",
|
"rustyline",
|
||||||
"serde 1.0.124",
|
"serde 1.0.124",
|
||||||
"serde_bytes",
|
"serde_bytes",
|
||||||
"serde_ini",
|
"serde_ini",
|
||||||
@ -3342,7 +3323,7 @@ dependencies = [
|
|||||||
"chrono",
|
"chrono",
|
||||||
"derive-new",
|
"derive-new",
|
||||||
"directories-next",
|
"directories-next",
|
||||||
"dirs-next 2.0.0",
|
"dirs-next",
|
||||||
"getset",
|
"getset",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"log 0.4.14",
|
"log 0.4.14",
|
||||||
@ -3371,7 +3352,7 @@ dependencies = [
|
|||||||
"bytes 0.5.6",
|
"bytes 0.5.6",
|
||||||
"codespan-reporting",
|
"codespan-reporting",
|
||||||
"derive-new",
|
"derive-new",
|
||||||
"dirs-next 2.0.0",
|
"dirs-next",
|
||||||
"dunce",
|
"dunce",
|
||||||
"encoding_rs",
|
"encoding_rs",
|
||||||
"filesize",
|
"filesize",
|
||||||
@ -4533,6 +4514,16 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "radix_trie"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd"
|
||||||
|
dependencies = [
|
||||||
|
"endian-type",
|
||||||
|
"nibble_vec",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand"
|
name = "rand"
|
||||||
version = "0.3.23"
|
version = "0.3.23"
|
||||||
@ -4987,38 +4978,21 @@ checksum = "cb5d2a036dc6d2d8fd16fde3498b04306e29bd193bf306a57427019b823d5acd"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustyline"
|
name = "rustyline"
|
||||||
version = "6.3.0"
|
version = "8.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6f0d5e7b0219a3eadd5439498525d4765c59b7c993ef0c12244865cd2d988413"
|
checksum = "b9e1b597fcd1eeb1d6b25b493538e5aa19629eb08932184b85fef931ba87e893"
|
||||||
dependencies = [
|
|
||||||
"cfg-if 0.1.10",
|
|
||||||
"dirs-next 1.0.2",
|
|
||||||
"libc",
|
|
||||||
"log 0.4.14",
|
|
||||||
"memchr",
|
|
||||||
"nix 0.18.0",
|
|
||||||
"scopeguard",
|
|
||||||
"unicode-segmentation",
|
|
||||||
"unicode-width",
|
|
||||||
"utf8parse 0.2.0",
|
|
||||||
"winapi 0.3.9",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustyline"
|
|
||||||
version = "7.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8227301bfc717136f0ecbd3d064ba8199e44497a0bdd46bb01ede4387cfd2cec"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"dirs-next 2.0.0",
|
"dirs-next",
|
||||||
"fs2",
|
"fs2",
|
||||||
"libc",
|
"libc",
|
||||||
"log 0.4.14",
|
"log 0.4.14",
|
||||||
"memchr",
|
"memchr",
|
||||||
"nix 0.19.1",
|
"nix",
|
||||||
|
"radix_trie",
|
||||||
"scopeguard",
|
"scopeguard",
|
||||||
|
"smallvec 1.6.1",
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
"utf8parse 0.2.0",
|
"utf8parse 0.2.0",
|
||||||
@ -5424,7 +5398,7 @@ version = "2.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "83bdb7831b2d85ddf4a7b148aa19d0587eddbe8671a436b7bd1182eaad0f2829"
|
checksum = "83bdb7831b2d85ddf4a7b148aa19d0587eddbe8671a436b7bd1182eaad0f2829"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs-next 2.0.0",
|
"dirs-next",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -5851,7 +5825,7 @@ version = "0.7.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f"
|
checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs-next 2.0.0",
|
"dirs-next",
|
||||||
"rustversion",
|
"rustversion",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
@ -77,7 +77,7 @@ rayon = "1.5.0"
|
|||||||
regex = "1.4.3"
|
regex = "1.4.3"
|
||||||
roxmltree = "0.14.0"
|
roxmltree = "0.14.0"
|
||||||
rust-embed = "5.9.0"
|
rust-embed = "5.9.0"
|
||||||
rustyline = { version = "6.3.0", optional = true }
|
rustyline = { version = "8.0.0", optional = true }
|
||||||
serde = { version = "1.0.123", features = ["derive"] }
|
serde = { version = "1.0.123", features = ["derive"] }
|
||||||
serde_bytes = "0.11.5"
|
serde_bytes = "0.11.5"
|
||||||
serde_ini = "0.2.0"
|
serde_ini = "0.2.0"
|
||||||
|
@ -1,38 +1,64 @@
|
|||||||
|
use rustyline::{KeyCode, Modifiers};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
fn convert_keypress(keypress: KeyPress) -> rustyline::KeyPress {
|
pub fn convert_keyevent(key_event: KeyEvent) -> rustyline::KeyEvent {
|
||||||
match keypress {
|
match key_event {
|
||||||
KeyPress::UnknownEscSeq => rustyline::KeyPress::UnknownEscSeq,
|
KeyEvent::UnknownEscSeq => convert_to_rl_keyevent(rustyline::KeyCode::UnknownEscSeq, None),
|
||||||
KeyPress::Backspace => rustyline::KeyPress::Backspace,
|
KeyEvent::Backspace => convert_to_rl_keyevent(rustyline::KeyCode::Backspace, None),
|
||||||
KeyPress::BackTab => rustyline::KeyPress::BackTab,
|
KeyEvent::BackTab => convert_to_rl_keyevent(rustyline::KeyCode::BackTab, None),
|
||||||
KeyPress::BracketedPasteStart => rustyline::KeyPress::BracketedPasteStart,
|
KeyEvent::BracketedPasteStart => {
|
||||||
KeyPress::BracketedPasteEnd => rustyline::KeyPress::BracketedPasteEnd,
|
convert_to_rl_keyevent(rustyline::KeyCode::BracketedPasteStart, None)
|
||||||
KeyPress::Char(c) => rustyline::KeyPress::Char(c),
|
}
|
||||||
KeyPress::ControlDown => rustyline::KeyPress::ControlDown,
|
KeyEvent::BracketedPasteEnd => {
|
||||||
KeyPress::ControlLeft => rustyline::KeyPress::ControlLeft,
|
convert_to_rl_keyevent(rustyline::KeyCode::BracketedPasteEnd, None)
|
||||||
KeyPress::ControlRight => rustyline::KeyPress::ControlRight,
|
}
|
||||||
KeyPress::ControlUp => rustyline::KeyPress::ControlUp,
|
KeyEvent::Char(c) => convert_to_rl_keyevent(rustyline::KeyCode::Char(c), None),
|
||||||
KeyPress::Ctrl(c) => rustyline::KeyPress::Ctrl(c),
|
KeyEvent::ControlDown => {
|
||||||
KeyPress::Delete => rustyline::KeyPress::Delete,
|
convert_to_rl_keyevent(rustyline::KeyCode::Down, Some(Modifiers::CTRL))
|
||||||
KeyPress::Down => rustyline::KeyPress::Down,
|
}
|
||||||
KeyPress::End => rustyline::KeyPress::End,
|
KeyEvent::ControlLeft => {
|
||||||
KeyPress::Enter => rustyline::KeyPress::Enter,
|
convert_to_rl_keyevent(rustyline::KeyCode::Left, Some(Modifiers::CTRL))
|
||||||
KeyPress::Esc => rustyline::KeyPress::Esc,
|
}
|
||||||
KeyPress::F(u) => rustyline::KeyPress::F(u),
|
KeyEvent::ControlRight => {
|
||||||
KeyPress::Home => rustyline::KeyPress::Home,
|
convert_to_rl_keyevent(rustyline::KeyCode::Right, Some(Modifiers::CTRL))
|
||||||
KeyPress::Insert => rustyline::KeyPress::Insert,
|
}
|
||||||
KeyPress::Left => rustyline::KeyPress::Left,
|
KeyEvent::ControlUp => {
|
||||||
KeyPress::Meta(c) => rustyline::KeyPress::Meta(c),
|
convert_to_rl_keyevent(rustyline::KeyCode::Up, Some(Modifiers::CTRL))
|
||||||
KeyPress::Null => rustyline::KeyPress::Null,
|
}
|
||||||
KeyPress::PageDown => rustyline::KeyPress::PageDown,
|
KeyEvent::Ctrl(c) => rustyline::KeyEvent::ctrl(c),
|
||||||
KeyPress::PageUp => rustyline::KeyPress::PageUp,
|
KeyEvent::Delete => convert_to_rl_keyevent(rustyline::KeyCode::Delete, None),
|
||||||
KeyPress::Right => rustyline::KeyPress::Right,
|
KeyEvent::Down => convert_to_rl_keyevent(rustyline::KeyCode::Down, None),
|
||||||
KeyPress::ShiftDown => rustyline::KeyPress::ShiftDown,
|
KeyEvent::End => convert_to_rl_keyevent(rustyline::KeyCode::End, None),
|
||||||
KeyPress::ShiftLeft => rustyline::KeyPress::ShiftLeft,
|
KeyEvent::Enter => convert_to_rl_keyevent(rustyline::KeyCode::Enter, None),
|
||||||
KeyPress::ShiftRight => rustyline::KeyPress::ShiftRight,
|
KeyEvent::Esc => convert_to_rl_keyevent(rustyline::KeyCode::Esc, None),
|
||||||
KeyPress::ShiftUp => rustyline::KeyPress::ShiftUp,
|
KeyEvent::F(u) => convert_to_rl_keyevent(rustyline::KeyCode::F(u), None),
|
||||||
KeyPress::Tab => rustyline::KeyPress::Tab,
|
KeyEvent::Home => convert_to_rl_keyevent(rustyline::KeyCode::Home, None),
|
||||||
KeyPress::Up => rustyline::KeyPress::Up,
|
KeyEvent::Insert => convert_to_rl_keyevent(rustyline::KeyCode::Insert, None),
|
||||||
|
KeyEvent::Left => convert_to_rl_keyevent(rustyline::KeyCode::Left, None),
|
||||||
|
KeyEvent::Meta(c) => rustyline::KeyEvent::new(c, Modifiers::NONE),
|
||||||
|
KeyEvent::Null => convert_to_rl_keyevent(rustyline::KeyCode::Null, None),
|
||||||
|
KeyEvent::PageDown => convert_to_rl_keyevent(rustyline::KeyCode::PageDown, None),
|
||||||
|
KeyEvent::PageUp => convert_to_rl_keyevent(rustyline::KeyCode::PageUp, None),
|
||||||
|
KeyEvent::Right => convert_to_rl_keyevent(rustyline::KeyCode::Right, None),
|
||||||
|
KeyEvent::ShiftDown => {
|
||||||
|
convert_to_rl_keyevent(rustyline::KeyCode::Down, Some(Modifiers::SHIFT))
|
||||||
|
}
|
||||||
|
KeyEvent::ShiftLeft => {
|
||||||
|
convert_to_rl_keyevent(rustyline::KeyCode::Left, Some(Modifiers::SHIFT))
|
||||||
|
}
|
||||||
|
KeyEvent::ShiftRight => {
|
||||||
|
convert_to_rl_keyevent(rustyline::KeyCode::Right, Some(Modifiers::SHIFT))
|
||||||
|
}
|
||||||
|
KeyEvent::ShiftUp => convert_to_rl_keyevent(rustyline::KeyCode::Up, Some(Modifiers::SHIFT)),
|
||||||
|
KeyEvent::Tab => convert_to_rl_keyevent(rustyline::KeyCode::Tab, None),
|
||||||
|
KeyEvent::Up => convert_to_rl_keyevent(rustyline::KeyCode::Up, None),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn convert_to_rl_keyevent(key_event: KeyCode, modifier: Option<Modifiers>) -> rustyline::KeyEvent {
|
||||||
|
rustyline::KeyEvent {
|
||||||
|
0: key_event,
|
||||||
|
1: modifier.unwrap_or(Modifiers::NONE),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +123,9 @@ fn convert_cmd(cmd: Cmd) -> rustyline::Cmd {
|
|||||||
match cmd {
|
match cmd {
|
||||||
Cmd::Abort => rustyline::Cmd::Abort,
|
Cmd::Abort => rustyline::Cmd::Abort,
|
||||||
Cmd::AcceptLine => rustyline::Cmd::AcceptLine,
|
Cmd::AcceptLine => rustyline::Cmd::AcceptLine,
|
||||||
Cmd::AcceptOrInsertLine => rustyline::Cmd::AcceptOrInsertLine,
|
Cmd::AcceptOrInsertLine => rustyline::Cmd::AcceptOrInsertLine {
|
||||||
|
accept_in_the_middle: false,
|
||||||
|
},
|
||||||
Cmd::BeginningOfHistory => rustyline::Cmd::BeginningOfHistory,
|
Cmd::BeginningOfHistory => rustyline::Cmd::BeginningOfHistory,
|
||||||
Cmd::CapitalizeWord => rustyline::Cmd::CapitalizeWord,
|
Cmd::CapitalizeWord => rustyline::Cmd::CapitalizeWord,
|
||||||
Cmd::ClearScreen => rustyline::Cmd::ClearScreen,
|
Cmd::ClearScreen => rustyline::Cmd::ClearScreen,
|
||||||
@ -140,18 +168,18 @@ fn convert_cmd(cmd: Cmd) -> rustyline::Cmd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convert_keybinding(keybinding: Keybinding) -> (rustyline::KeyPress, rustyline::Cmd) {
|
fn convert_keybinding(keybinding: Keybinding) -> (rustyline::KeyEvent, rustyline::Cmd) {
|
||||||
(
|
(
|
||||||
convert_keypress(keybinding.key),
|
convert_keyevent(keybinding.key),
|
||||||
convert_cmd(keybinding.binding),
|
convert_cmd(keybinding.binding),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub enum KeyPress {
|
pub enum KeyEvent {
|
||||||
/// Unsupported escape sequence (on unix platform)
|
/// Unsupported escape sequence (on unix platform)
|
||||||
UnknownEscSeq,
|
UnknownEscSeq,
|
||||||
/// ⌫ or `KeyPress::Ctrl('H')`
|
/// ⌫ or `KeyEvent::Ctrl('H')`
|
||||||
Backspace,
|
Backspace,
|
||||||
/// ⇤ (usually Shift-Tab)
|
/// ⇤ (usually Shift-Tab)
|
||||||
BackTab,
|
BackTab,
|
||||||
@ -177,9 +205,9 @@ pub enum KeyPress {
|
|||||||
Down,
|
Down,
|
||||||
/// ⇲
|
/// ⇲
|
||||||
End,
|
End,
|
||||||
/// ↵ or `KeyPress::Ctrl('M')`
|
/// ↵ or `KeyEvent::Ctrl('M')`
|
||||||
Enter,
|
Enter,
|
||||||
/// Escape or `KeyPress::Ctrl('[')`
|
/// Escape or `KeyEvent::Ctrl('[')`
|
||||||
Esc,
|
Esc,
|
||||||
/// Function key
|
/// Function key
|
||||||
F(u8),
|
F(u8),
|
||||||
@ -191,7 +219,7 @@ pub enum KeyPress {
|
|||||||
Left,
|
Left,
|
||||||
/// Escape-char or Alt-char
|
/// Escape-char or Alt-char
|
||||||
Meta(char),
|
Meta(char),
|
||||||
/// `KeyPress::Char('\0')`
|
/// `KeyEvent::Char('\0')`
|
||||||
Null,
|
Null,
|
||||||
/// ⇟
|
/// ⇟
|
||||||
PageDown,
|
PageDown,
|
||||||
@ -207,7 +235,7 @@ pub enum KeyPress {
|
|||||||
ShiftRight,
|
ShiftRight,
|
||||||
/// Shift-↑
|
/// Shift-↑
|
||||||
ShiftUp,
|
ShiftUp,
|
||||||
/// ⇥ or `KeyPress::Ctrl('I')`
|
/// ⇥ or `KeyEvent::Ctrl('I')`
|
||||||
Tab,
|
Tab,
|
||||||
/// ↑ arrow key
|
/// ↑ arrow key
|
||||||
Up,
|
Up,
|
||||||
@ -399,7 +427,7 @@ pub type RepeatCount = usize;
|
|||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub struct Keybinding {
|
pub struct Keybinding {
|
||||||
key: KeyPress,
|
key: KeyEvent,
|
||||||
binding: Cmd,
|
binding: Cmd,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,9 @@ use crate::prelude::*;
|
|||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use nu_engine::script::LineResult;
|
use nu_engine::script::LineResult;
|
||||||
|
|
||||||
|
#[cfg(feature = "rustyline-support")]
|
||||||
|
use crate::keybinding::{convert_keyevent, KeyEvent};
|
||||||
|
|
||||||
#[cfg(feature = "rustyline-support")]
|
#[cfg(feature = "rustyline-support")]
|
||||||
use crate::shell::Helper;
|
use crate::shell::Helper;
|
||||||
|
|
||||||
@ -16,7 +19,7 @@ use rustyline::{
|
|||||||
config::Configurer,
|
config::Configurer,
|
||||||
config::{ColorMode, CompletionType, Config},
|
config::{ColorMode, CompletionType, Config},
|
||||||
error::ReadlineError,
|
error::ReadlineError,
|
||||||
At, Cmd, Editor, KeyPress, Movement, Word,
|
At, Cmd, Editor, Movement, Word,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "rustyline-support")]
|
#[cfg(feature = "rustyline-support")]
|
||||||
@ -40,22 +43,27 @@ pub fn default_rustyline_editor_configuration() -> Editor<Helper> {
|
|||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
const DEFAULT_COMPLETION_MODE: CompletionType = CompletionType::List;
|
const DEFAULT_COMPLETION_MODE: CompletionType = CompletionType::List;
|
||||||
|
|
||||||
let config = Config::builder().color_mode(ColorMode::Forced).build();
|
let config = Config::builder()
|
||||||
|
.check_cursor_position(true)
|
||||||
|
.color_mode(ColorMode::Forced)
|
||||||
|
.build();
|
||||||
let mut rl: Editor<_> = Editor::with_config(config);
|
let mut rl: Editor<_> = Editor::with_config(config);
|
||||||
|
|
||||||
// add key bindings to move over a whole word with Ctrl+ArrowLeft and Ctrl+ArrowRight
|
// add key bindings to move over a whole word with Ctrl+ArrowLeft and Ctrl+ArrowRight
|
||||||
rl.bind_sequence(
|
rl.bind_sequence(
|
||||||
KeyPress::ControlLeft,
|
convert_keyevent(KeyEvent::ControlLeft),
|
||||||
Cmd::Move(Movement::BackwardWord(1, Word::Vi)),
|
Cmd::Move(Movement::BackwardWord(1, Word::Vi)),
|
||||||
);
|
);
|
||||||
rl.bind_sequence(
|
rl.bind_sequence(
|
||||||
KeyPress::ControlRight,
|
convert_keyevent(KeyEvent::ControlRight),
|
||||||
Cmd::Move(Movement::ForwardWord(1, At::AfterEnd, Word::Vi)),
|
Cmd::Move(Movement::ForwardWord(1, At::AfterEnd, Word::Vi)),
|
||||||
);
|
);
|
||||||
|
|
||||||
// workaround for multiline-paste hang in rustyline (see https://github.com/kkawakam/rustyline/issues/202)
|
// workaround for multiline-paste hang in rustyline (see https://github.com/kkawakam/rustyline/issues/202)
|
||||||
rl.bind_sequence(KeyPress::BracketedPasteStart, rustyline::Cmd::Noop);
|
rl.bind_sequence(
|
||||||
|
convert_keyevent(KeyEvent::BracketedPasteStart),
|
||||||
|
rustyline::Cmd::Noop,
|
||||||
|
);
|
||||||
// Let's set the defaults up front and then override them later if the user indicates
|
// Let's set the defaults up front and then override them later if the user indicates
|
||||||
// defaults taken from here https://github.com/kkawakam/rustyline/blob/2fe886c9576c1ea13ca0e5808053ad491a6fe049/src/config.rs#L150-L167
|
// defaults taken from here https://github.com/kkawakam/rustyline/blob/2fe886c9576c1ea13ca0e5808053ad491a6fe049/src/config.rs#L150-L167
|
||||||
rl.set_max_history_size(100);
|
rl.set_max_history_size(100);
|
||||||
|
@ -57,6 +57,7 @@ impl rustyline::completion::Completer for Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl rustyline::hint::Hinter for Helper {
|
impl rustyline::hint::Hinter for Helper {
|
||||||
|
type Hint = String;
|
||||||
fn hint(&self, line: &str, pos: usize, ctx: &rustyline::Context<'_>) -> Option<String> {
|
fn hint(&self, line: &str, pos: usize, ctx: &rustyline::Context<'_>) -> Option<String> {
|
||||||
self.hinter.as_ref().and_then(|h| h.hint(line, pos, &ctx))
|
self.hinter.as_ref().and_then(|h| h.hint(line, pos, &ctx))
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ rayon = "1.5.0"
|
|||||||
regex = "1.4.3"
|
regex = "1.4.3"
|
||||||
roxmltree = "0.14.0"
|
roxmltree = "0.14.0"
|
||||||
rust-embed = "5.9.0"
|
rust-embed = "5.9.0"
|
||||||
rustyline = { version = "7.1.0", optional = true }
|
rustyline = { version = "8.0.0", optional = true }
|
||||||
serde = { version = "1.0.123", features = ["derive"] }
|
serde = { version = "1.0.123", features = ["derive"] }
|
||||||
serde_bytes = "0.11.5"
|
serde_bytes = "0.11.5"
|
||||||
serde_ini = "0.2.0"
|
serde_ini = "0.2.0"
|
||||||
|
@ -245,7 +245,7 @@ fn open_dir_is_ls() {
|
|||||||
cwd: dirs.test(), pipeline(
|
cwd: dirs.test(), pipeline(
|
||||||
r#"
|
r#"
|
||||||
open .
|
open .
|
||||||
| count
|
| length
|
||||||
"#
|
"#
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@
|
|||||||
Enter:
|
Enter:
|
||||||
binding:
|
binding:
|
||||||
AcceptLine:
|
AcceptLine:
|
||||||
|
|
||||||
# Next match from history
|
# Next match from history
|
||||||
- key:
|
- key:
|
||||||
Down: #Down Arrow Key
|
Down: #Down Arrow Key
|
||||||
@ -150,7 +150,7 @@
|
|||||||
binding:
|
binding:
|
||||||
Undo: 1
|
Undo: 1
|
||||||
|
|
||||||
# KeyPress::UnknownEscSeq => Cmd::Noop,
|
# KeyEvent::UnknownEscSeq => Cmd::Noop,
|
||||||
- key:
|
- key:
|
||||||
UnknownEscSeq:
|
UnknownEscSeq:
|
||||||
binding:
|
binding:
|
||||||
@ -161,7 +161,7 @@
|
|||||||
##########################################################
|
##########################################################
|
||||||
# /// Unsupported escape sequence (on unix platform)
|
# /// Unsupported escape sequence (on unix platform)
|
||||||
# UnknownEscSeq,
|
# UnknownEscSeq,
|
||||||
# /// ⌫ or `KeyPress::Ctrl('H')`
|
# /// ⌫ or `KeyEvent::Ctrl('H')`
|
||||||
# Backspace,
|
# Backspace,
|
||||||
# /// ⇤ (usually Shift-Tab)
|
# /// ⇤ (usually Shift-Tab)
|
||||||
# BackTab,
|
# BackTab,
|
||||||
@ -187,9 +187,9 @@
|
|||||||
# Down,
|
# Down,
|
||||||
# /// ⇲
|
# /// ⇲
|
||||||
# End,
|
# End,
|
||||||
# /// ↵ or `KeyPress::Ctrl('M')`
|
# /// ↵ or `KeyEvent::Ctrl('M')`
|
||||||
# Enter,
|
# Enter,
|
||||||
# /// Escape or `KeyPress::Ctrl('[')`
|
# /// Escape or `KeyEvent::Ctrl('[')`
|
||||||
# Esc,
|
# Esc,
|
||||||
# /// Function key
|
# /// Function key
|
||||||
# F(u8),
|
# F(u8),
|
||||||
@ -201,7 +201,7 @@
|
|||||||
# Left,
|
# Left,
|
||||||
# /// Escape-char or Alt-char
|
# /// Escape-char or Alt-char
|
||||||
# Meta(char),
|
# Meta(char),
|
||||||
# /// `KeyPress::Char('\0')`
|
# /// `KeyEvent::Char('\0')`
|
||||||
# Null,
|
# Null,
|
||||||
# /// ⇟
|
# /// ⇟
|
||||||
# PageDown,
|
# PageDown,
|
||||||
@ -217,7 +217,7 @@
|
|||||||
# ShiftRight,
|
# ShiftRight,
|
||||||
# /// Shift-↑
|
# /// Shift-↑
|
||||||
# ShiftUp,
|
# ShiftUp,
|
||||||
# /// ⇥ or `KeyPress::Ctrl('I')`
|
# /// ⇥ or `KeyEvent::Ctrl('I')`
|
||||||
# Tab,
|
# Tab,
|
||||||
# /// ↑ arrow key
|
# /// ↑ arrow key
|
||||||
# Up,
|
# Up,
|
||||||
@ -330,7 +330,7 @@
|
|||||||
# BeforeEnd,
|
# BeforeEnd,
|
||||||
# /// After end of word.
|
# /// After end of word.
|
||||||
# AfterEnd,
|
# AfterEnd,
|
||||||
|
|
||||||
##########################################################
|
##########################################################
|
||||||
# Possible options for Anchor
|
# Possible options for Anchor
|
||||||
##########################################################
|
##########################################################
|
||||||
@ -381,4 +381,4 @@
|
|||||||
# /// beginning-of-buffer
|
# /// beginning-of-buffer
|
||||||
# BeginningOfBuffer,
|
# BeginningOfBuffer,
|
||||||
# /// end-of-buffer
|
# /// end-of-buffer
|
||||||
# EndOfBuffer,
|
# EndOfBuffer,
|
||||||
|
Loading…
Reference in New Issue
Block a user