start text box with cursor at the end of prefilled

This commit is contained in:
Dustin Carlino 2018-12-23 09:05:39 -08:00
parent 551a8ef63a
commit 8202698daa

View File

@ -13,10 +13,11 @@ pub struct TextBox {
impl TextBox {
pub fn new(prompt: &str, prefilled: Option<String>) -> TextBox {
let line = prefilled.unwrap_or_else(String::new);
TextBox {
prompt: prompt.to_string(),
line: prefilled.unwrap_or_else(String::new),
cursor_x: 0,
cursor_x: line.len(),
line,
shift_pressed: false,
}
}