Allow more positions for not overwriting chunk

This commit is contained in:
Martin Lariz 2020-07-30 09:33:46 -07:00 committed by Ferran Basora
parent ac5bb4908e
commit 6ec79a1296

View File

@ -127,12 +127,21 @@ impl<'a> View<'a> {
if let Some(ref hint) = mat.hint { if let Some(ref hint) = mat.hint {
let extra_position = if self.position == "left" { let extra_position = if self.position == "left" {
0 0
} else if self.position == "off_left" {
0 - mat.hint.clone().unwrap().len()
} else if self.position == "off_right" {
text.len()
} else { } else {
text.len() - mat.hint.clone().unwrap().len() text.len() - mat.hint.clone().unwrap().len()
}; };
let text = self.make_hint_text(hint.as_str()); let text = self.make_hint_text(hint.as_str());
let final_position = if (offset as i32 + extra_position as i32) < 0 {
0
} else {
offset + extra_position as u16
};
print!( print!(
"{goto}{background}{foregroud}{text}{resetf}{resetb}", "{goto}{background}{foregroud}{text}{resetf}{resetb}",
goto = cursor::Goto(offset + extra_position as u16 + 1, mat.y as u16 + 1), goto = cursor::Goto(offset + extra_position as u16 + 1, mat.y as u16 + 1),