(Thank you for writing this series of articles. I've just started following it through and might file a bug or two as I find them)
Chapter: https://philippflenker.com/hecto-chapter-2/
In the Entering Raw Mode section, crossterm's enable_raw_mode is introduced and used.
The example code listing:
use std::io::{self, Read};
use crossterm::terminal::enable_raw_mode;
use crossterm::terminal::disable_raw_mode;
fn main() {
enable_raw_mode().unwrap();
for b in io::stdin().bytes() {
let c = b.unwrap() as char;
println!("{}", c);
if c == 'q' {
disable_raw_mode().unwrap();
break;
}
}
}
uses println!.
When I tried this, it did not print any output to the terminal. My env:
$ uname -a
Linux personal-workstation 6.1.0-41-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.158-1 (2025-11-09) x86_64 GNU/Linux
I was using crossterm version 0.29.0.
crossterm documentation calls out that println! does not work in raw mode because line termination is not processed, and that we should use write! instead.
Adding a io::stdout().flush() fixes the issue by flushing after each character.
(Thank you for writing this series of articles. I've just started following it through and might file a bug or two as I find them)
Chapter: https://philippflenker.com/hecto-chapter-2/
In the
Entering Raw Modesection,crossterm'senable_raw_modeis introduced and used.The example code listing:
uses
println!.When I tried this, it did not print any output to the terminal. My env:
$ uname -a Linux personal-workstation 6.1.0-41-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.158-1 (2025-11-09) x86_64 GNU/LinuxI was using
crosstermversion0.29.0.crosstermdocumentation calls out thatprintln!does not work in raw mode because line termination is not processed, and that we should usewrite!instead.Adding a
io::stdout().flush()fixes the issue by flushing after each character.