Skip to content
Snippets Groups Projects
Commit d24c6c11 authored by gwenn's avatar gwenn
Browse files

Fix refresh on windows

parent 7d3a26d4
No related branches found
No related tags found
No related merge requests found
......@@ -181,15 +181,33 @@ impl<'out, 'prompt> State<'out, 'prompt> {
// calculate the desired position of the cursor
let cursor = calculate_position(&self.line[..self.line.pos()], prompt_size, self.cols);
// position at the end of the prompt, clear to end of previous input
// position at the start of the prompt, clear to end of previous input
let mut info = unsafe { mem::zeroed() };
check!(kernel32::GetConsoleScreenBufferInfo(handle, &mut info));
info.dwCursorPosition.X = self.prompt_size.col as i16;
info.dwCursorPosition.Y -= (self.cursor.row - self.prompt_size.row) as i16;
info.dwCursorPosition.X = 0;
info.dwCursorPosition.Y -= self.cursor.row as i16;
check!(kernel32::SetConsoleCursorPosition(handle, info.dwCursorPosition));
let mut _count = 0;
check!(kernel32::FillConsoleOutputCharacterA(handle,
' ' as winapi::CHAR,
(info.dwSize.X * info.dwSize.Y) as winapi::DWORD, // FIXME
info.dwCursorPosition,
&mut _count));
let mut ab = String::new();
// display the prompt
ab.push_str(prompt);
// display the input line
ab.push_str(&self.line);
try!(write_and_flush(self.out, ab.as_bytes()));
// position the cursor
check!(kernel32::GetConsoleScreenBufferInfo(handle, &mut info));
info.dwCursorPosition.X = cursor.col as i16;
info.dwCursorPosition.Y -= (end_pos.row - cursor.row) as i16;
check!(kernel32::SetConsoleCursorPosition(handle, info.dwCursorPosition));
self.cursor = cursor;
unimplemented!()
Ok(())
}
fn update_columns(&mut self) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment