diff --git a/crossterm_terminal/src/sys/unix.rs b/crossterm_terminal/src/sys/unix.rs index 1aff943..fdc3e5e 100644 --- a/crossterm_terminal/src/sys/unix.rs +++ b/crossterm_terminal/src/sys/unix.rs @@ -16,7 +16,7 @@ pub fn get_terminal_size() -> (u16, u16) { let r = unsafe { ioctl(STDOUT_FILENO, TIOCGWINSZ.into(), &mut size) }; if r == 0 { - (size.ws_co, size.ws_row) + (size.ws_col, size.ws_row) } else { (0, 0) } diff --git a/crossterm_terminal/src/terminal/terminal.rs b/crossterm_terminal/src/terminal/terminal.rs index 0101492..8096a06 100644 --- a/crossterm_terminal/src/terminal/terminal.rs +++ b/crossterm_terminal/src/terminal/terminal.rs @@ -52,18 +52,20 @@ impl Terminal { /// /// # Example /// ```rust + /// # use crossterm_terminal as crossterm; + /// # use crossterm_terminal::terminal; /// let mut term = terminal(); /// /// // clear all cells in terminal. - /// term.clear(terminal::ClearType::All); + /// term.clear(crossterm::ClearType::All); /// // clear all cells from the cursor position downwards in terminal. - /// term.clear(terminal::ClearType::FromCursorDown); + /// term.clear(crossterm::ClearType::FromCursorDown); /// // clear all cells from the cursor position upwards in terminal. - /// term.clear(terminal::ClearType::FromCursorUp); + /// term.clear(crossterm::ClearType::FromCursorUp); /// // clear current line cells in terminal. - /// term.clear(terminal::ClearType::CurrentLine); + /// term.clear(crossterm::ClearType::CurrentLine); /// // clear all cells from cursor position until new line in terminal. - /// term.clear(terminal::ClearType::UntilNewLine); + /// term.clear(crossterm::ClearType::UntilNewLine); /// ``` pub fn clear(&self, clear_type: ClearType) -> Result<()> { self.terminal.clear(clear_type) @@ -96,6 +98,7 @@ impl Terminal { /// Set the terminal size. Note that not all terminals can be set to a very small scale. /// /// ```rust + /// # use crossterm_terminal::terminal; /// let mut term = terminal(); /// /// // Set of the size to X: 10 and Y: 10 @@ -108,6 +111,7 @@ impl Terminal { /// Exit the current process. /// /// ```rust + /// # use crossterm_terminal::terminal; /// let mut term = terminal(); /// /// let size = term.exit(); @@ -119,6 +123,7 @@ impl Terminal { /// Write any displayable content to the current terminal screen. /// /// ```rust + /// # use crossterm_terminal::terminal; /// let mut term = terminal(); /// /// let size = term.write("Some text \n Some text on new line"); diff --git a/crossterm_terminal/src/terminal/test.rs b/crossterm_terminal/src/terminal/test.rs index ca75d88..13e5467 100644 --- a/crossterm_terminal/src/terminal/test.rs +++ b/crossterm_terminal/src/terminal/test.rs @@ -1,5 +1,3 @@ -use super::{AnsiTerminal, ITerminal, WinApiTerminal}; - /* ======================== WinApi =========================== */ #[cfg(windows)] mod winapi_tests { @@ -21,6 +19,7 @@ mod winapi_tests { /* ======================== ANSI =========================== */ #[test] fn resize_ansi() { + use super::*; use std::{thread, time}; if try_enable_ansi() { let terminal = AnsiTerminal::new(); diff --git a/src/crossterm.rs b/src/crossterm.rs index 156b87c..0b15d8f 100644 --- a/src/crossterm.rs +++ b/src/crossterm.rs @@ -5,15 +5,16 @@ use std::fmt::Display; /// To get a cursor instance to perform cursor related actions, you can do the following: /// /// ```rust +/// # use crossterm::*; /// let crossterm = Crossterm::new(); /// let cursor = crossterm.cursor(); -// let color = crossterm.color(); -// let terminal = crossterm.terminal(); -// let terminal = crossterm.input(); -// let style = crossterm -// .style(format!("{} {}", 0, "Black text on green background")) -// .with(Color::Black) -// .on(Color::Green); +/// let color = crossterm.color(); +/// let terminal = crossterm.terminal(); +/// let terminal = crossterm.input(); +/// let style = crossterm +/// .style(format!("{} {}", 0, "Black text on green background")) +/// .with(Color::Black) +/// .on(Color::Green); /// ``` /// /// # Remark @@ -30,6 +31,7 @@ impl Crossterm { /// Get a `TerminalCursor` implementation whereon cursor related actions can be performed. /// /// ```rust + /// # use crossterm::*; /// let crossterm = Crossterm::new(); /// let cursor = crossterm.cursor(); /// ``` @@ -41,6 +43,7 @@ impl Crossterm { /// Get a `TerminalInput` implementation whereon terminal related actions can be performed. /// /// ```rust + /// # use crossterm::*; /// let crossterm = Crossterm::new(); /// let input = crossterm.input(); /// ``` @@ -52,6 +55,7 @@ impl Crossterm { /// Get a `Terminal` implementation whereon terminal related actions can be performed. /// /// ```rust + /// # use crossterm::*; /// let crossterm = Crossterm::new(); /// let mut terminal = crossterm.terminal(); /// ``` @@ -63,6 +67,7 @@ impl Crossterm { /// Get a `TerminalColor` implementation whereon color related actions can be performed. /// /// ```rust + /// # use crossterm::*; /// let crossterm = Crossterm::new(); /// let mut terminal = crossterm.color(); /// ``` @@ -75,6 +80,7 @@ impl Crossterm { /// /// # Example /// ```rust + /// # use crossterm::*; /// let crossterm = Crossterm::new(); /// /// // get an styled object which could be painted to the terminal.