Felche gauche en cours

This commit is contained in:
Justine 2022-12-25 17:27:59 +01:00
parent b64505106f
commit 19771dbd13

View File

@ -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));
}
_ => (),
}