diff --git a/src/lib.rs b/src/lib.rs index 1ff5d25..34e59d1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,7 +12,7 @@ pub mod shell { use termion::event::Key; use termion::input::TermRead; use termion::raw::IntoRawMode; - use termion::color; + use termion::{color, cursor, cursor::DetectCursorPos}; use unicode_segmentation::UnicodeSegmentation; mod history; @@ -292,6 +292,20 @@ pub mod shell { write!(stdout, "{}", mycommand); }, + Key::Left => { + //La taille du prompt est incorrecte à cause des couleurs ! + let pr_length = prompt.chars().count(); + let curs_pos = stdout.cursor_pos().unwrap().0; + if usize::from(curs_pos) > pr_length { + write!(stdout, "1{:?}/2{}-{}", curs_pos, pr_length, cursor::Left(10)); + stdout.flush(); + } + }, + + Key::Right => { + print!("{}", cursor::Right(1)); + } + _ => (), }