Questions tagged [crossterm]
a Rust crate dedicate to cross-platform terminal application building.
crossterm
14
questions
0
votes
0
answers
36
views
Unable to poll for events using crossterm when spawned as a NodeJS child process: "Failed to initialize input reader"
I want to start a Rust terminal user interface I've made using crossterm which needs to handle keyboard input as a NodeJS child process. This works fine when I directly run the Rust program, but ...
0
votes
0
answers
51
views
How can I print text without jumping and move the cursor without text moving?
I've been trying to implement a simple terminal text editor using the crossterm crate and I'm able to create the screen and implement the cursor movements for basic h,j,k,l keys and I'm able to print ...
0
votes
1
answer
282
views
Detecting mouse click events on Blocks when using Ratatui
The ratatui library for building terminal apps has a widget for rendering rectangles on screen called Block. https://docs.rs/ratatui/latest/ratatui/widgets/block/struct.Block.html.
I would like to ...
3
votes
1
answer
228
views
Crossterm not clearing screen properly
I have a main method that looks like this:
use std::io::stdout;
use crossterm as ct;
use crossterm::terminal as ct_terminal;
pub mod tui;
fn main() -> () {
let user_result: usize = tui::...
-1
votes
1
answer
55
views
How would one go about emulating the behaviour of io::stdin().read_line?
This is a mostly abstract question. I'm asking for a basic description of an implementation, not 'fix my code pls'.
I'm using crossterm, working on a project that would ideally have a command line ...
0
votes
0
answers
151
views
How can I capture the same keyboard event from different threads using crossterm in rust?
I have a loop which spawns a set of threads. Each thread is listening to a different key. I want to do something in each thread based on the character pressed event.
This is the function I am using. (...
1
vote
0
answers
59
views
Handling key event doesn't register until other key event is triggered, using Crossterm
I just started Rust and wanted to make a simple and easy project that could help me learn more about the language.
I'm making an interactive Todo app in the terminal using Crossterm. Everything was ...
0
votes
1
answer
758
views
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. ...
0
votes
0
answers
131
views
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:...
2
votes
1
answer
2k
views
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: https://...
1
vote
1
answer
743
views
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 ...
0
votes
1
answer
658
views
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(&...
0
votes
0
answers
1k
views
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 ...
0
votes
1
answer
416
views
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 ...