A great Crossterm material for begginers
⚓ Rust 📅 2026-06-11 👤 surdeus 👁️ 1Well I was looking for a good crossterm study material, And I found this stream from tsoding.
It's not a tutorial, He is just tinkering with the library, which is something i really like to do, but he is a professional and knows were to look in the documentation, so it was a fun experience walking through the crossterm docs with him.
If you are a complete beginner like me, He experiments a lot of other stuff in rust which really made me learn something. The fact that it's not a tutorial really makes it fun.
Recommend me other materials if you know pls:>
btw I watched the first hour and this is what i coded A long:
use std::io::{Write, stdout};
use crossterm::terminal::{self, Clear, ClearType};
use crossterm::cursor::{MoveTo};
use crossterm::QueueableCommand;
use crossterm::event::{read, poll, Event, KeyCode, KeyModifiers};
use std::time::Duration;
use std::thread;
fn main()
{
let mut stdout = stdout();
let _ = terminal::enable_raw_mode();
let (mut width, mut height) = terminal::size().unwrap();
let barch = "&";
let mut bar = barch.repeat(width as usize);
let mut buffer = String::new();
let mut quit = false;
while !quit
{
while poll(Duration::ZERO).unwrap()
{
match read().unwrap()
{
Event::Resize(new_height, new_width) => { width = new_width; height = new_height; bar = "_".repeat(height as usize); },
Event::Key(event) =>
{
match event.code
{
KeyCode::Char(x) =>
{
if x == 'c' && event.modifiers.contains(KeyModifiers::SHIFT)
{
quit = true;
}
else
{
buffer.push(x);
}
},
_ => {},
}
},
_ => {},
}
}
stdout.queue(Clear(ClearType::All)).unwrap();
stdout.queue(MoveTo(0, height-2)).unwrap();
stdout.write(bar.as_bytes()).unwrap();
stdout.queue(MoveTo(0, height-1)).unwrap();
stdout.write(buffer.as_bytes());
stdout.flush().unwrap();
thread::sleep(Duration::from_millis(33));
}
}
1 post - 1 participant
🏷️ Rust_feed