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

Add Enter/LeaveAlternateScreen commands #7

Merged
merged 2 commits into from
Oct 2, 2019

Conversation

zrzka
Copy link
Contributor

@zrzka zrzka commented Oct 2, 2019

  • Internal refactoring (no breaking changes)
    • Just to follow the -cursor, etc. code style/structure
  • New commands introduced EnterAlternateScreen, LeaveAlternateScreen
  • Tested
    • Tested on macOS -> AnsiAlternateScreen
    • Didn't test on Windows -> WinApiAlternateScreen -> @TimonPost please test on Windows

Tested with ...

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

use crossterm_screen::{
    execute, AlternateScreen, EnterAlternateScreen, LeaveAlternateScreen, Result,
};

macro_rules! pause {
    () => {
        sleep(Duration::from_secs(2));
    };
}

fn test_commands() -> Result<()> {
    execute!(stdout(), EnterAlternateScreen)?;
    println!("test_commands: Alternate");
    pause!();
    execute!(stdout(), LeaveAlternateScreen)?;
    println!("test_commands: Left alternate");
    Ok(())
}

fn test_struct() -> Result<()> {
    let _alternate = AlternateScreen::to_alternate(false)?;
    println!("test_struct: Alternate");
    pause!();
    Ok(())
}

fn test_struct_raw() -> Result<()> {
    let _alternate = AlternateScreen::to_alternate(true)?;
    println!("test_struct_raw: Alternate");
    println!("Type something, shouldn't be echoed");
    pause!();
    Ok(())
}

fn main() -> Result<()> {
    println!("Main");
    pause!();
    test_commands()?;
    println!("Back on main after test_commands");
    pause!();
    test_struct()?;
    println!("Back on main after test_struct");
    pause!();
    test_struct_raw()?;
    println!("Back on main after test_struct_raw");
    Ok(())
}

@zrzka zrzka requested a review from TimonPost as a code owner October 2, 2019 11:49
@zrzka zrzka force-pushed the zrzka/alternate-commands-and-refactoring branch from 7a1f664 to 6f51e00 Compare October 2, 2019 11:54
Signed-off-by: Robert Vojta <rvojta@me.com>
@zrzka zrzka force-pushed the zrzka/alternate-commands-and-refactoring branch from 6f51e00 to ed95e0f Compare October 2, 2019 12:03
@zrzka zrzka changed the title [WIP] Add Enter/LeaveAlternateScreen commands Add Enter/LeaveAlternateScreen commands Oct 2, 2019
@zrzka
Copy link
Contributor Author

zrzka commented Oct 2, 2019

@TimonPost please, test this properly on Windows. I didn't install all the tools on my Windows 10 inside VMware yet.

@Canop just FYI ^ (first comment)

Copy link
Member

@TimonPost TimonPost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is Screen, if you removed it, can you add it to the changelog as well?

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor Author

@zrzka zrzka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which Screen? Didn't remove it, just comments about non existent Screen.

@TimonPost
Copy link
Member

I tested it on windows, and it works. I Meen the Screen type, I can't find it. I think you have renamed it to AlternateScreen instead.

@zrzka
Copy link
Contributor Author

zrzka commented Oct 2, 2019

Thanks for the Windows tests!

Check the diff. I didn't rename anything. There wasn't the Screen type. This doesn't even exist in the old versions, for example 0.2.5 https://docs.rs/crossterm_screen/0.2.5/crossterm_screen/.

Signed-off-by: Robert Vojta <rvojta@me.com>
@zrzka
Copy link
Contributor Author

zrzka commented Oct 2, 2019

The Screen type was available in the 0.1.0 (https://docs.rs/crossterm_screen/0.1.0/crossterm_screen/) and removed in the 0.2.0 (https://docs.rs/crossterm_screen/0.2.0/crossterm_screen/).

@TimonPost
Copy link
Member

TimonPost commented Oct 2, 2019

Yea I went for a search, I forgot that I've already eliminated it because it wasn't needed anymore. Sorry for the confusion. My dependencies in my brain were not updated yet.

@zrzka zrzka merged commit 929fb44 into master Oct 2, 2019
@zrzka zrzka deleted the zrzka/alternate-commands-and-refactoring branch October 2, 2019 15:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants