Questions tagged [crossterm]

a Rust crate dedicate to cross-platform terminal application building.

Crossterm is a rather low level Rust crate, dealing with rendering on terminal and receiving typical terminal events.

https://github.com/crossterm-rs/crossterm

9 questions
1
vote
1 answer

Detecting key release with crossterm with rust

I'm trying to detect key releasing instead of pressing using crossterm. I'm using the basic example named event-stream-tokio. I need tokio runtime for the project. Link to the example code:…
Mithrandir
  • 46
  • 5
1
vote
1 answer

Sleep in Future::poll

I am trying to create a future polling for inputs from the crossterm crate, which does not provide an asynchronous API, as far as I know. At first I tried to do something like the following : use crossterm::event::poll as crossterm_poll; use…
Quessours
  • 47
  • 5
0
votes
0 answers

crossterm gives the "Not a terminal" error when enabling rawmode and pressing any key

I am trying to detect user input by using crossterm, when Ctrl R is pressed it should go back to the main function. If I press any key, (not just the Ctrl R , it simply exits. The following error message appears: thread 'main' panicked at 'called…
Mart
  • 11
  • 3
0
votes
1 answer

Rust Tokio select macro conditional sleep branch

I have an async select macro loop that handles user inputs and event intervals within a CLI game that I am writing. I would like to be able to conditionally set a sleep countdown within it as well. I have tried declaring an Option that's…
Chambers
  • 21
  • 3
0
votes
0 answers

How to implement a generic function to apply `crossterm` style to any type which can be converted into a string

I would like to implement a generic function to apply style red and attribute bold to any type which can be converted into a string. This function works, but only for &str arguments: use crossterm::style::Stylize; fn red(str: &str) -> <&str as…
lucatrv
  • 725
  • 8
  • 14
0
votes
0 answers

MoveTo in Crossterm is clearing my output

When using the crossterm library with this code: fn draw_box(stdout: &mut Stdout, x: u16, y: u16) -> Result<()> { let size = 5; let outline = (x..x + size) .map(|i| (i, y)) .chain((y + 1..y + size - 1).map(|i| (x + size - 1,…
dvreed77
  • 2,217
  • 2
  • 27
  • 42
0
votes
1 answer

Is it possible to print in the same line from right to left in Crossterm

I try to print a couple of words from right to left but my last word overwrite previous and erase line to the end. I got in my output just Second word, What I'm doing wrong ? Thank you. fn render(&self, stdout: &mut Stdout) { stdout …
mrLanu
  • 3
  • 2
0
votes
0 answers

Rust crossterm match a range of values

I am using crossterm to get user input. I'm trying to parse any character press. In the match block here, I am matching specific code/modifier combos, but I would like to match any char. I'm not sure what the syntax is. //importing in execute!…
Peter Kapteyn
  • 354
  • 1
  • 13
0
votes
1 answer

How can I deserialize chars in a TOML config file into crossterm::event::KeyCode?

I have a .toml config file containing some key bindings expressed as chars, I need to deserialize that file to a struct where each field is a crossterm::event::KeyCode. I'm using toml crate to parse the string. What I thought is that maybe there is…
PrinceOfBorgo
  • 508
  • 5
  • 14