Skip to content
This repository has been archived by the owner on Oct 22, 2019. It is now read-only.

Refactoring and docs #5

Merged
merged 10 commits into from
Oct 1, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix examples
Signed-off-by: Robert Vojta <rvojta@me.com>
  • Loading branch information
zrzka committed Oct 1, 2019
commit 2ed0161a2aed98f6d6c118f6b5ab7fcc9935e4d1
28 changes: 24 additions & 4 deletions src/screen/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,22 @@ use crate::sys;
///
/// Basic usage:
///
/// ```rust
/// use crossterm_screen::{RawScreen, Result};
/// ```no_run
/// use crossterm_screen::RawScreen;
/// use crossterm_utils::Result;
///
/// fn main() -> Result<()> {
/// let _raw = RawScreen::into_raw_mode()?;
/// // Do something in the raw mode
/// Ok(())
/// } // `_raw` is dropped here <- raw mode is disabled
/// ```
///
/// Do not disable the raw mode implicitly:
///
/// ```rust
/// use crossterm_screen::{RawScreen, Result};
/// ```no_run
/// use crossterm_screen::RawScreen;
/// use crossterm_utils::Result;
///
/// fn main() -> Result<()> {
/// let mut raw = RawScreen::into_raw_mode()?;
Expand Down Expand Up @@ -103,6 +106,23 @@ impl RawScreen {
/// TTYs has their state controlled by the writer, not the reader. You use the writer to
/// clear the screen, move the cursor and so on, so naturally you use the writer to change
/// the mode as well.
///
/// # Examples
///
/// ```no_run
/// use std::io::stdout;
/// use crossterm_screen::IntoRawMode;
/// use crossterm_utils::Result;
///
/// fn main() -> Result<()> {
/// let stdout = stdout();
/// let _raw = stdout.into_raw_mode()?;
///
/// // Do something in the raw mode
///
/// Ok(())
/// } // `_raw` dropped here <- raw mode disabled
/// ```
pub trait IntoRawMode: Write + Sized {
/// Enables raw mode.
fn into_raw_mode(self) -> Result<RawScreen>;
Expand Down