parent
61188e6353
commit
ad8b75f448
@ -1,3 +1,6 @@
|
||||
# Changes crossterm to 0.4.3
|
||||
- Fixed bug [issue 41](https://github.com/TimonPost/crossterm/issues/41)
|
||||
|
||||
# Changes crossterm to 0.4.2
|
||||
- Added functionality to make a styled object writable to screen [issue 33](https://github.com/TimonPost/crossterm/issues/33)
|
||||
- Added unit tests.
|
||||
|
@ -15,37 +15,6 @@ mod cursor;
|
||||
mod some_types;
|
||||
mod input;
|
||||
|
||||
use std::io::Write;
|
||||
|
||||
use crossterm::style::{style, Color, DisplayableObject};
|
||||
use crossterm::terminal::terminal;
|
||||
use crossterm::Screen;
|
||||
|
||||
use crossterm::output::TerminalOutput;
|
||||
use crossterm::cursor::TerminalCursor;
|
||||
|
||||
use crossterm::terminal::Terminal;
|
||||
use std::{thread,time};
|
||||
|
||||
fn main()
|
||||
{
|
||||
let screen = Screen::new(false);
|
||||
let terminal = Terminal::new(&screen.stdout);
|
||||
|
||||
// get terminal size
|
||||
let (x, y) = terminal.terminal_size();
|
||||
|
||||
// set size to 30, 50
|
||||
terminal.set_size(30,50);
|
||||
|
||||
// if we uncomment the line below the code will work perfectly fine and we will get the new dimensions.
|
||||
// if we comment this line the terminal dimensions gotten from terminal_size() are equal to the old dimensions.
|
||||
|
||||
// thread::sleep(time::Duration::from_millis(20));
|
||||
|
||||
// get new dimensions
|
||||
let (x_new, y_new) = terminal.terminal_size();
|
||||
|
||||
println!("old width: {} old height: {}", x, y);
|
||||
println!("new width: {} new height: {}", x_new, y_new);
|
||||
}
|
||||
|
@ -102,14 +102,16 @@ impl Screen
|
||||
///
|
||||
/// This function is useful if you want to build up some output and when you are ready you could flush the output to the screen.
|
||||
pub fn write_buf(&mut self, buf: &[u8]) -> Result<usize> {
|
||||
self.buffer.write(buf);
|
||||
self.buffer.write(buf)?;
|
||||
Ok(buf.len())
|
||||
}
|
||||
|
||||
/// Flush the internal buffer to the screen.
|
||||
pub fn flush_buf(&mut self) -> Result<()> {
|
||||
self.stdout.write_buf(&self.buffer);
|
||||
self.stdout.flush()
|
||||
self.stdout.write_buf(&self.buffer)?;
|
||||
self.stdout.flush()?;
|
||||
self.buffer.clear();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// This will disable the drop which will cause raw modes not to be undone on drop of `Screen`.
|
||||
|
Loading…
Reference in New Issue
Block a user