From cf317d43a173ade413b02fc08fc264503e84b247 Mon Sep 17 00:00:00 2001 From: grbd Date: Fri, 11 Apr 2025 15:53:13 +0100 Subject: [PATCH 1/6] Change termion to crossterm for Windows compatibility --- examples/std/Cargo.toml | 2 +- examples/std/src/bin/std-async-tokio.rs | 6 +++--- examples/std/src/bin/std-sync.rs | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index e6935dd..1554e69 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml @@ -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..d024c5e 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 noline::builder::EditorBuilder; -use termion::raw::IntoRawMode; +use crossterm::terminal::{disable_raw_mode, enable_raw_mode}; 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..b3580dd 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 embedded_io::{ErrorType, Read as EmbRead, Write as EmbWrite}; +use crossterm::terminal::{disable_raw_mode, enable_raw_mode}; 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(); } From da5774c66d4c75f7178bb7da8b55dbf539617abf Mon Sep 17 00:00:00 2001 From: grbd Date: Fri, 11 Apr 2025 16:07:38 +0100 Subject: [PATCH 2/6] Fix minor warnings in build --- Cargo.toml | 1 + noline/src/sync_editor.rs | 2 ++ 2 files changed, 3 insertions(+) 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/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; From ee919c8304eabe7ff8a69245d53d963a40752554 Mon Sep 17 00:00:00 2001 From: grbd Date: Fri, 11 Apr 2025 16:09:53 +0100 Subject: [PATCH 3/6] Additional crossterm fix --- noline/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noline/Cargo.toml b/noline/Cargo.toml index 0535828..ea7f40c 100644 --- a/noline/Cargo.toml +++ b/noline/Cargo.toml @@ -26,7 +26,7 @@ alloc = [] [dev-dependencies] crossbeam = "0.8.1" -termion = "4.0.0" +crossterm = "0.29.0" [package.metadata.docs.rs] all-features = true From fb3f0ac5a38b0d009457d97def32d3b6c8205ed1 Mon Sep 17 00:00:00 2001 From: grbd Date: Fri, 11 Apr 2025 16:25:42 +0100 Subject: [PATCH 4/6] Updates to cargo depends --- examples/std/Cargo.toml | 2 +- noline/Cargo.toml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index 1554e69..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", diff --git a/noline/Cargo.toml b/noline/Cargo.toml index ea7f40c..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,7 +25,7 @@ std = ["embedded-io/std", "embedded-io-async/std"] alloc = [] [dev-dependencies] -crossbeam = "0.8.1" +crossbeam = "0.8.4" crossterm = "0.29.0" [package.metadata.docs.rs] From c1f1660dcfcf9f961e303f0a17cbf9bfe326e7c8 Mon Sep 17 00:00:00 2001 From: grbd Date: Fri, 11 Apr 2025 20:49:55 +0100 Subject: [PATCH 5/6] Format fixes --- examples/std/src/bin/std-async-tokio.rs | 4 ++-- examples/std/src/bin/std-sync.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/std/src/bin/std-async-tokio.rs b/examples/std/src/bin/std-async-tokio.rs index d024c5e..7fae3e1 100644 --- a/examples/std/src/bin/std-async-tokio.rs +++ b/examples/std/src/bin/std-async-tokio.rs @@ -1,5 +1,5 @@ -use noline::builder::EditorBuilder; use crossterm::terminal::{disable_raw_mode, enable_raw_mode}; +use noline::builder::EditorBuilder; use tokio::io; use tokio::io::{AsyncReadExt, AsyncWriteExt}; @@ -57,7 +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(); + 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 b3580dd..c74624b 100644 --- a/examples/std/src/bin/std-sync.rs +++ b/examples/std/src/bin/std-sync.rs @@ -1,6 +1,6 @@ -use noline::builder::EditorBuilder; -use embedded_io::{ErrorType, Read as EmbRead, Write as EmbWrite}; 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 { From 198156d3c2006b2b1c9ed5d04474c7a55df6d034 Mon Sep 17 00:00:00 2001 From: grbd Date: Sat, 12 Apr 2025 20:50:33 +0100 Subject: [PATCH 6/6] update to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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]