Skip to content

Upgrade from 0.5 to 0.6

Zrzka edited this page Nov 15, 2019 · 1 revision

Namespace refactor

Some namespaces have been changed. All types of could be used directly by use crossterm::*; instead of having to go to a specific module for importing a type.

old

crossterm::input::{TerminalInput, ...};
crossterm::style::style;
crossterm::cursor::*;
crossterm::teriminal::{Terminal, ...};

new

crossterm::{TerminalInput, style, TerminalColor, StyledObject, Terminal, ...}

Removed unclear methods

let screen = Screen::new();

// the below methods are not available anymore
cursor::from_screen(&screen);
input::from_screen(&screen);
terminal::from_screen(&screen);
color::from_screen(&screen);

Instead of this you should make use of Crossterm type

let screen = Screen::new();
let crossterm = Crossterm::from_screen(screen);
let cursor = crossterm.cursor();
....

Or you can use the from_output(); this takes in the output stored in Screen

let screen = Screen::new();
let cursor = TerminalCursor::from_output(&screen.stdout);
let input = TerminalInput::from_output(&screen.stdout);

Wait until takes in a self now.

old

TerminalInput::wait_until(KeyEvent::OnKeyPress(b'x'));

new

let terminal_input = TerminalInput::new();
terminal_input.wait_until(KeyEvent::OnKeyPress(b'x'));