VincentFoulon80 / console_engine

A simple terminal framework to draw things and manage user input
https://crates.io/crates/console_engine
MIT License
220 stars 7 forks source link

Update crossterm to 0.26.1 (fixed examples and add proper key release) #23

Closed lesleyrs closed 1 year ago

lesleyrs commented 1 year ago

I didn't implement window focus or paste because I'm not sure how, it just returns () now so it doesn't panic.

There's also a new KeyEventState which I didn't use because I think it requires kitty keyboard protocol in order to work. Which windows terminal/conhost doesn't support so maybe leave it for now.

Lastly I noticed that in --example shapes holding down S or F which checks for key press not hold does the action a second time after a few frames. But this happens in crossterm 0.24 as well so it's unrelated to this.

Closes https://github.com/VincentFoulon80/console_engine/issues/16 you could make a new issues for window focus, paste and the double key press? Fixes https://github.com/VincentFoulon80/console_engine/issues/22

This change now allows for smooth movement using console engine like I was trying to get in my issue 👍 .

lesleyrs commented 1 year ago

Some more info here https://github.com/crossterm-rs/crossterm/issues/772#issuecomment-1498380935

lesleyrs commented 1 year ago

Just added a smooth scrolling example that showcases it compared to normal scroll, however there's 1 issue with my idea:

If you press another key without releasing the original one, then let go of it later, you can get a delayed release event which stops the scrolling for a little.

For some reason even if I check if the original key is still being pressed, the code still gets triggered. But this is good enough for now.

It would be really amazing to get it to work perfect natively in terminal imo, the only other crates I've seen that do this get input from outside the terminal which is less cool.

VincentFoulon80 commented 1 year ago

We can figure that out later if you're willing to get it to work perfectly 😉

Do you think your branch is ready to merge, or is there something else you'd like to add ?

lesleyrs commented 1 year ago

I think key release events are windows only so I'll add a comment to the example right now, you can version bump yourself after this.

That's it.