Skip to content

Commit

Permalink
namespace reformat, 2018 style, warnings (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
zrzka authored and TimonPost committed Sep 13, 2019
1 parent 43aa1c2 commit fa4654a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 32 deletions.
8 changes: 2 additions & 6 deletions crossterm_screen/examples/alternate_screen.rs
@@ -1,12 +1,8 @@
extern crate crossterm_screen;

use crossterm_screen::AlternateScreen;

use std::io::{stdout, Write};
use std::{thread, time};

/// print wait screen on alternate screen, then switch back.
pub fn print_wait_screen_on_alternate_window() {
#[allow(unused_variables)]
fn main() {
// move to the alternate screen, 'false' determines if the alternate screen should be in raw mode.
if let Ok(alternate) = AlternateScreen::to_alternate(false) {
// do some stuff on the alternate screen.
Expand Down
8 changes: 3 additions & 5 deletions crossterm_screen/examples/raw_mode.rs
@@ -1,11 +1,9 @@
extern crate crossterm_screen;
use std::io::stdout;

use crossterm_screen::{IntoRawMode, RawScreen};

use std::io::{stdout, Write};
use std::{thread, time};

pub fn raw_modes() {
#[allow(unused_variables)]
fn main() {
// create a Screen instance that operates on the default output: io::stdout(). By passing in 'true', we make this screen 'raw'
let screen = RawScreen::into_raw_mode();
let screen = stdout().into_raw_mode();
Expand Down
11 changes: 1 addition & 10 deletions crossterm_screen/src/lib.rs
@@ -1,15 +1,6 @@
//! A module which provides some functionalities to work with the terminal screen.
//! Like allowing you to switch between the main and alternate screen or putting the terminal into raw mode.
#[macro_use]
extern crate crossterm_utils;

#[cfg(windows)]
extern crate winapi;

#[cfg(windows)]
extern crate crossterm_winapi;
pub use self::screen::{AlternateScreen, IntoRawMode, RawScreen};

mod screen;
mod sys;

pub use self::screen::{AlternateScreen, IntoRawMode, RawScreen};
7 changes: 4 additions & 3 deletions crossterm_screen/src/screen/alternate.rs
Expand Up @@ -5,15 +5,16 @@
//! For an example of this behavior, consider when vim is launched from bash.
//! Vim uses the entirety of the screen to edit the file, then returning to bash leaves the original buffer unchanged.

#[cfg(windows)]
use crate::sys::winapi::ToAlternateScreenCommand;
use std::io;

#[cfg(windows)]
use crossterm_utils::supports_ansi;

#[cfg(windows)]
use crate::sys::winapi::ToAlternateScreenCommand;
use crate::sys::{self, IAlternateScreenCommand};

use super::RawScreen;
use std::io;

/// With this type you will be able to switch to the alternate screen and then back to the main screen.
/// Check also the Screen type for switching to alternate mode.
Expand Down
3 changes: 2 additions & 1 deletion crossterm_screen/src/screen/raw.rs
Expand Up @@ -14,9 +14,10 @@
//!
//! With these modes you can easier design the terminal screen.

use crate::sys;
use std::io::{self, Stdout, Write};

use crate::sys;

/// A wrapper for the raw terminal state, which can be used to write to.
///
/// Please note that if this type drops, the raw screen will be undone. To prevent this behaviour call `disable_drop`.
Expand Down
7 changes: 4 additions & 3 deletions crossterm_screen/src/sys/mod.rs
@@ -1,12 +1,13 @@
use std::io::Write;

use crossterm_utils::{csi, write_cout, Result};

#[cfg(unix)]
pub mod unix;

#[cfg(windows)]
pub mod winapi;

use crossterm_utils::Result;
use std::io::Write;

/// This command is used for switching to the alternate screen and back to the main screen.
pub struct ToAlternateScreenCommand;

Expand Down
13 changes: 9 additions & 4 deletions crossterm_screen/src/sys/winapi.rs
@@ -1,17 +1,22 @@
use super::IAlternateScreenCommand;
use crossterm_utils::Result;
use crossterm_winapi::{ConsoleMode, Handle, ScreenBuffer};
use std::io;

use winapi::shared::minwindef::DWORD;
use winapi::um::wincon;

use crossterm_utils::Result;
use crossterm_winapi::{ConsoleMode, Handle, ScreenBuffer};

use super::IAlternateScreenCommand;

use self::wincon::{ENABLE_LINE_INPUT, ENABLE_WRAP_AT_EOL_OUTPUT};

/// This command is used for enabling and disabling raw mode for Windows systems.
/// For more info check: https://docs.microsoft.com/en-us/windows/console/high-level-console-modes.
#[derive(Clone, Copy)]
pub struct RawModeCommand {
mask: DWORD,
}
use self::wincon::{ENABLE_LINE_INPUT, ENABLE_WRAP_AT_EOL_OUTPUT};

impl RawModeCommand {
pub fn new() -> Self {
RawModeCommand {
Expand Down

0 comments on commit fa4654a

Please sign in to comment.