mirror of
https://github.com/nushell/nushell.git
synced 2024-12-26 00:50:03 +01:00
Merge pull request #704 from pka/fix-build-without-crossterm
Fix build without crossterm
This commit is contained in:
commit
8c240ca3fd
@ -359,7 +359,8 @@ pub async fn cli() -> Result<(), Box<dyn Error>> {
|
|||||||
|
|
||||||
// Register Ctrl-r for history fuzzy search
|
// Register Ctrl-r for history fuzzy search
|
||||||
// rustyline doesn't support custom commands, so we override Ctrl-D (EOF)
|
// rustyline doesn't support custom commands, so we override Ctrl-D (EOF)
|
||||||
#[cfg(not(windows))] // https://github.com/nushell/nushell/issues/689
|
// https://github.com/nushell/nushell/issues/689
|
||||||
|
#[cfg(all(not(windows), feature = "crossterm"))]
|
||||||
rl.bind_sequence(rustyline::KeyPress::Ctrl('R'), rustyline::Cmd::EndOfFile);
|
rl.bind_sequence(rustyline::KeyPress::Ctrl('R'), rustyline::Cmd::EndOfFile);
|
||||||
// Redefine Ctrl-D to same command as Ctrl-C
|
// Redefine Ctrl-D to same command as Ctrl-C
|
||||||
rl.bind_sequence(rustyline::KeyPress::Ctrl('D'), rustyline::Cmd::Interrupt);
|
rl.bind_sequence(rustyline::KeyPress::Ctrl('D'), rustyline::Cmd::Interrupt);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use ansi_term::{ANSIString, ANSIStrings, Colour, Style};
|
use ansi_term::{ANSIString, ANSIStrings, Colour, Style};
|
||||||
|
#[cfg(feature = "crossterm")]
|
||||||
use crossterm::{cursor, terminal, ClearType, InputEvent, KeyEvent, RawScreen};
|
use crossterm::{cursor, terminal, ClearType, InputEvent, KeyEvent, RawScreen};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use sublime_fuzzy::best_match;
|
use sublime_fuzzy::best_match;
|
||||||
@ -18,6 +19,8 @@ pub fn interactive_fuzzy_search(lines: &Vec<&str>, max_results: usize) -> Select
|
|||||||
Edit(String),
|
Edit(String),
|
||||||
}
|
}
|
||||||
let mut state = State::Selecting;
|
let mut state = State::Selecting;
|
||||||
|
#[cfg(feature = "crossterm")]
|
||||||
|
{
|
||||||
if let Ok(_raw) = RawScreen::into_raw_mode() {
|
if let Ok(_raw) = RawScreen::into_raw_mode() {
|
||||||
// User input for search
|
// User input for search
|
||||||
let mut searchinput = String::new();
|
let mut searchinput = String::new();
|
||||||
@ -87,7 +90,7 @@ pub fn interactive_fuzzy_search(lines: &Vec<&str>, max_results: usize) -> Select
|
|||||||
let _ = RawScreen::disable_raw_mode();
|
let _ = RawScreen::disable_raw_mode();
|
||||||
}
|
}
|
||||||
terminal().clear(ClearType::FromCursorDown).unwrap();
|
terminal().clear(ClearType::FromCursorDown).unwrap();
|
||||||
|
}
|
||||||
match state {
|
match state {
|
||||||
State::Selected(line) => SelectionResult::Selected(line),
|
State::Selected(line) => SelectionResult::Selected(line),
|
||||||
State::Edit(line) => SelectionResult::Edit(line),
|
State::Edit(line) => SelectionResult::Edit(line),
|
||||||
@ -132,6 +135,7 @@ pub fn fuzzy_search(searchstr: &str, lines: &Vec<&str>, max_results: usize) -> V
|
|||||||
results
|
results
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "crossterm")]
|
||||||
fn highlight(textmatch: &Match, normal: Style, highlighted: Style) -> Vec<ANSIString> {
|
fn highlight(textmatch: &Match, normal: Style, highlighted: Style) -> Vec<ANSIString> {
|
||||||
let text = &textmatch.text;
|
let text = &textmatch.text;
|
||||||
let mut ansi_strings = vec![];
|
let mut ansi_strings = vec![];
|
||||||
@ -147,6 +151,7 @@ fn highlight(textmatch: &Match, normal: Style, highlighted: Style) -> Vec<ANSISt
|
|||||||
ansi_strings
|
ansi_strings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "crossterm")]
|
||||||
fn paint_selection_list(lines: &Vec<Match>, selected: usize) {
|
fn paint_selection_list(lines: &Vec<Match>, selected: usize) {
|
||||||
let terminal = terminal();
|
let terminal = terminal();
|
||||||
let size = terminal.terminal_size();
|
let size = terminal.terminal_size();
|
||||||
|
Loading…
Reference in New Issue
Block a user