From ba0d9505db1a980af49afee0b6956f11bdef3c55 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Nov 2023 11:02:45 +0000 Subject: [PATCH] Update crossterm requirement from 0.12 to 0.27 Updates the requirements on [crossterm](https://github.com/crossterm-rs/crossterm) to permit the latest version. - [Release notes](https://github.com/crossterm-rs/crossterm/releases) - [Changelog](https://github.com/crossterm-rs/crossterm/blob/master/CHANGELOG.md) - [Commits](https://github.com/crossterm-rs/crossterm/compare/0.12.0...0.27.0) --- updated-dependencies: - dependency-name: crossterm dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- interactive-test/Cargo.toml | 2 +- interactive-test/src/main.rs | 23 ++++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/interactive-test/Cargo.toml b/interactive-test/Cargo.toml index d03df70..b98dc81 100644 --- a/interactive-test/Cargo.toml +++ b/interactive-test/Cargo.toml @@ -12,4 +12,4 @@ publish = false [dependencies] anes = { path = "../anes" } -crossterm = "0.12" +crossterm = "0.27" diff --git a/interactive-test/src/main.rs b/interactive-test/src/main.rs index b85e827..e81d90c 100644 --- a/interactive-test/src/main.rs +++ b/interactive-test/src/main.rs @@ -1,8 +1,9 @@ -use std::io::{self, Write}; - use anes::{execute, queue}; - -pub use crossterm::Result; +use crossterm::{ + event::{self, Event, KeyCode, KeyEvent}, + terminal::enable_raw_mode, +}; +use std::io::{self, Result, Write}; #[macro_use] mod macros; @@ -30,7 +31,7 @@ where { execute!(w, anes::SwitchBufferToAlternate)?; - let _raw = crossterm::RawScreen::into_raw_mode()?; + enable_raw_mode()?; loop { queue!( @@ -64,11 +65,19 @@ where } pub fn read_char() -> Result { - crossterm::input().read_char() + loop { + if let Event::Key(KeyEvent { + code: KeyCode::Char(c), + .. + }) = event::read()? + { + return Ok(c); + } + } } pub fn buffer_size() -> Result<(u16, u16)> { - crossterm::terminal().size() + crossterm::terminal::size() } fn main() -> Result<()> {