diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a664e5..b03a909 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - Bugfix: Missing CPR arguments causes panic +- Switched dependency termion to crossterm for setting the raw mode in the std examples for windows compatibility ## [0.5.0 - 2024-12-12] diff --git a/Cargo.toml b/Cargo.toml index 73b910a..087d0a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "2" members = [ "noline", diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index e6935dd..75b3281 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -tokio = { version = "1.38.0", features = [ +tokio = { version = "1.44.2", features = [ "full", "io-util", "sync", @@ -16,9 +16,9 @@ tokio = { version = "1.38.0", features = [ ] } noline = { path = "../../noline", features = ["std"] } heapless = "0.8.0" -termion = "4.0.0" embedded-io-async = "0.6.1" embedded-io = "0.6.1" +crossterm = "0.29.0" [[bin]] name = "std-sync" diff --git a/examples/std/src/bin/std-async-tokio.rs b/examples/std/src/bin/std-async-tokio.rs index be3ccf9..7fae3e1 100644 --- a/examples/std/src/bin/std-async-tokio.rs +++ b/examples/std/src/bin/std-async-tokio.rs @@ -1,6 +1,5 @@ -use embedded_io_async::Write; +use crossterm::terminal::{disable_raw_mode, enable_raw_mode}; use noline::builder::EditorBuilder; -use termion::raw::IntoRawMode; use tokio::io; use tokio::io::{AsyncReadExt, AsyncWriteExt}; @@ -43,7 +42,7 @@ impl embedded_io_async::Write for IOWrapper { #[tokio::main(flavor = "current_thread")] async fn main() { let term_task = tokio::spawn(async { - let _raw_term = std::io::stdout().into_raw_mode().unwrap(); + enable_raw_mode().unwrap(); let mut io = IOWrapper::new(); let prompt = "> "; @@ -58,6 +57,7 @@ async fn main() { let s = format!("Read: '{}'\n\r", line); io.stdout.write_all(s.as_bytes()).await.unwrap(); } + disable_raw_mode().unwrap(); }); match term_task.await { diff --git a/examples/std/src/bin/std-sync.rs b/examples/std/src/bin/std-sync.rs index 4accf5a..c74624b 100644 --- a/examples/std/src/bin/std-sync.rs +++ b/examples/std/src/bin/std-sync.rs @@ -1,8 +1,6 @@ -use noline::builder::EditorBuilder; -use std::io; -use termion::raw::IntoRawMode; - +use crossterm::terminal::{disable_raw_mode, enable_raw_mode}; use embedded_io::{ErrorType, Read as EmbRead, Write as EmbWrite}; +use noline::builder::EditorBuilder; use std::io::{Read, Stdin, Stdout, Write}; pub struct IOWrapper { @@ -45,7 +43,7 @@ impl EmbWrite for IOWrapper { } fn main() { - let _stdout = io::stdout().into_raw_mode().unwrap(); + enable_raw_mode().unwrap(); let prompt = "> "; let mut io = IOWrapper::new(); @@ -58,4 +56,5 @@ fn main() { while let Ok(line) = editor.readline(prompt, &mut io) { writeln!(io, "Read: '{}'", line).unwrap(); } + disable_raw_mode().unwrap(); } diff --git a/noline/Cargo.toml b/noline/Cargo.toml index 0535828..7be7a67 100644 --- a/noline/Cargo.toml +++ b/noline/Cargo.toml @@ -16,7 +16,7 @@ include = ["**/*.rs", "Cargo.toml"] [dependencies] embedded-io = "0.6.1" embedded-io-async = "0.6.1" -num_enum = { version = "0.7.2", default-features = false } +num_enum = { version = "0.7.3", default-features = false } [features] @@ -25,8 +25,8 @@ std = ["embedded-io/std", "embedded-io-async/std"] alloc = [] [dev-dependencies] -crossbeam = "0.8.1" -termion = "4.0.0" +crossbeam = "0.8.4" +crossterm = "0.29.0" [package.metadata.docs.rs] all-features = true diff --git a/noline/src/sync_editor.rs b/noline/src/sync_editor.rs index 1db66c3..6c8b331 100644 --- a/noline/src/sync_editor.rs +++ b/noline/src/sync_editor.rs @@ -4,6 +4,8 @@ //! traits. //! //! Use the [`crate::builder::EditorBuilder`] to build an editor. +#![allow(elided_named_lifetimes)] + use embedded_io::{Read, ReadExactError, Write}; use crate::error::NolineError;