mirror of
https://github.com/nushell/nushell.git
synced 2025-01-29 01:29:11 +01:00
Allow moving in text with Ctrl+ArrowLeft, Ctrl+ArrowRight (#1141)
* Allow moving in text with Ctrl+ArrowLeft, Ctrl+ArrowRight * Document changes * Format
This commit is contained in:
parent
f37f29b441
commit
8093612cac
15
src/cli.rs
15
src/cli.rs
@ -17,7 +17,10 @@ use nu_protocol::{Signature, UntaggedValue, Value};
|
||||
|
||||
use log::{debug, log_enabled, trace};
|
||||
use rustyline::error::ReadlineError;
|
||||
use rustyline::{self, config::Configurer, config::EditMode, ColorMode, Config, Editor};
|
||||
use rustyline::{
|
||||
self, config::Configurer, config::EditMode, At, Cmd, ColorMode, Config, Editor, KeyPress,
|
||||
Movement, Word,
|
||||
};
|
||||
use std::error::Error;
|
||||
use std::io::{BufRead, BufReader, Write};
|
||||
use std::iter::Iterator;
|
||||
@ -351,6 +354,16 @@ pub async fn cli() -> Result<(), Box<dyn Error>> {
|
||||
let config = Config::builder().color_mode(ColorMode::Forced).build();
|
||||
let mut rl: Editor<_> = Editor::with_config(config);
|
||||
|
||||
// add key bindings to move over a whole word with Ctrl+ArrowLeft and Ctrl+ArrowRight
|
||||
rl.bind_sequence(
|
||||
KeyPress::ControlLeft,
|
||||
Cmd::Move(Movement::BackwardWord(1, Word::Vi)),
|
||||
);
|
||||
rl.bind_sequence(
|
||||
KeyPress::ControlRight,
|
||||
Cmd::Move(Movement::ForwardWord(1, At::AfterEnd, Word::Vi)),
|
||||
);
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let _ = ansi_term::enable_ansi_support();
|
||||
|
Loading…
Reference in New Issue
Block a user