namespace reformat, 2018 style, warnings (#209)
This commit is contained in:
parent
43aa1c222e
commit
fa4654ac80
@ -1,12 +1,8 @@
|
|||||||
extern crate crossterm_screen;
|
|
||||||
|
|
||||||
use crossterm_screen::AlternateScreen;
|
use crossterm_screen::AlternateScreen;
|
||||||
|
|
||||||
use std::io::{stdout, Write};
|
|
||||||
use std::{thread, time};
|
|
||||||
|
|
||||||
/// print wait screen on alternate screen, then switch back.
|
/// 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.
|
// move to the alternate screen, 'false' determines if the alternate screen should be in raw mode.
|
||||||
if let Ok(alternate) = AlternateScreen::to_alternate(false) {
|
if let Ok(alternate) = AlternateScreen::to_alternate(false) {
|
||||||
// do some stuff on the alternate screen.
|
// do some stuff on the alternate screen.
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
extern crate crossterm_screen;
|
use std::io::stdout;
|
||||||
|
|
||||||
use crossterm_screen::{IntoRawMode, RawScreen};
|
use crossterm_screen::{IntoRawMode, RawScreen};
|
||||||
|
|
||||||
use std::io::{stdout, Write};
|
#[allow(unused_variables)]
|
||||||
use std::{thread, time};
|
fn main() {
|
||||||
|
|
||||||
pub fn raw_modes() {
|
|
||||||
// create a Screen instance that operates on the default output: io::stdout(). By passing in 'true', we make this screen 'raw'
|
// 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 = RawScreen::into_raw_mode();
|
||||||
let screen = stdout().into_raw_mode();
|
let screen = stdout().into_raw_mode();
|
||||||
|
@ -1,15 +1,6 @@
|
|||||||
//! A module which provides some functionalities to work with the terminal screen.
|
//! 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.
|
//! Like allowing you to switch between the main and alternate screen or putting the terminal into raw mode.
|
||||||
#[macro_use]
|
pub use self::screen::{AlternateScreen, IntoRawMode, RawScreen};
|
||||||
extern crate crossterm_utils;
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
extern crate winapi;
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
extern crate crossterm_winapi;
|
|
||||||
|
|
||||||
mod screen;
|
mod screen;
|
||||||
mod sys;
|
mod sys;
|
||||||
|
|
||||||
pub use self::screen::{AlternateScreen, IntoRawMode, RawScreen};
|
|
||||||
|
@ -5,15 +5,16 @@
|
|||||||
//! For an example of this behavior, consider when vim is launched from bash.
|
//! 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.
|
//! Vim uses the entirety of the screen to edit the file, then returning to bash leaves the original buffer unchanged.
|
||||||
|
|
||||||
#[cfg(windows)]
|
use std::io;
|
||||||
use crate::sys::winapi::ToAlternateScreenCommand;
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use crossterm_utils::supports_ansi;
|
use crossterm_utils::supports_ansi;
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
use crate::sys::winapi::ToAlternateScreenCommand;
|
||||||
use crate::sys::{self, IAlternateScreenCommand};
|
use crate::sys::{self, IAlternateScreenCommand};
|
||||||
|
|
||||||
use super::RawScreen;
|
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.
|
/// 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.
|
/// Check also the Screen type for switching to alternate mode.
|
||||||
|
@ -14,9 +14,10 @@
|
|||||||
//!
|
//!
|
||||||
//! With these modes you can easier design the terminal screen.
|
//! With these modes you can easier design the terminal screen.
|
||||||
|
|
||||||
use crate::sys;
|
|
||||||
use std::io::{self, Stdout, Write};
|
use std::io::{self, Stdout, Write};
|
||||||
|
|
||||||
|
use crate::sys;
|
||||||
|
|
||||||
/// A wrapper for the raw terminal state, which can be used to write to.
|
/// 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`.
|
/// Please note that if this type drops, the raw screen will be undone. To prevent this behaviour call `disable_drop`.
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
|
use std::io::Write;
|
||||||
|
|
||||||
|
use crossterm_utils::{csi, write_cout, Result};
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
pub mod unix;
|
pub mod unix;
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub mod winapi;
|
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.
|
/// This command is used for switching to the alternate screen and back to the main screen.
|
||||||
pub struct ToAlternateScreenCommand;
|
pub struct ToAlternateScreenCommand;
|
||||||
|
|
||||||
|
@ -1,17 +1,22 @@
|
|||||||
use super::IAlternateScreenCommand;
|
|
||||||
use crossterm_utils::Result;
|
|
||||||
use crossterm_winapi::{ConsoleMode, Handle, ScreenBuffer};
|
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use winapi::shared::minwindef::DWORD;
|
use winapi::shared::minwindef::DWORD;
|
||||||
use winapi::um::wincon;
|
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.
|
/// 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.
|
/// For more info check: https://docs.microsoft.com/en-us/windows/console/high-level-console-modes.
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct RawModeCommand {
|
pub struct RawModeCommand {
|
||||||
mask: DWORD,
|
mask: DWORD,
|
||||||
}
|
}
|
||||||
use self::wincon::{ENABLE_LINE_INPUT, ENABLE_WRAP_AT_EOL_OUTPUT};
|
|
||||||
impl RawModeCommand {
|
impl RawModeCommand {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
RawModeCommand {
|
RawModeCommand {
|
||||||
|
Loading…
Reference in New Issue
Block a user