ratatui / templates

Templates for bootstrapping a Rust TUI application with Ratatui
https://ratatui.rs/templates
MIT License
255 stars 36 forks source link

feat(component): Add a mean for components to access raw key events #81

Open louis-thevenet opened 1 month ago

louis-thevenet commented 1 month ago

Description

This adds an is_editing method to components for whether they should receive all key inputs or just the regular actions.

Why

Currently, there is no way for a component to take user input.

louis-thevenet commented 1 month ago

Sure! I'm building a markdown tasks parser and manager. I wanted to add a search bar and therefore needed to get user input. Here is how it turned out =)

https://github.com/user-attachments/assets/a8c7cf3e-4efc-4443-a32e-5e25395ad8c8

orhun commented 1 month ago

that looks pretty! looking forward to the new releases, I want to package it for Arch 🐻

joshka commented 1 month ago

I defer to @kdheepak for whether this is the right idea. I'm not too familiar with this template.

kdheepak commented 1 month ago

I think this is a good reference PR! Thanks for making it. I'm not sure if we should merge it though, because the component template is already more complex than I'd like for a template and severely under-documented.

louis-thevenet commented 1 month ago

Your review was correct, I think this new version is cleaner. It allows a component to set specific actions to be escaped in editing mode.

I think this is a good reference PR! Thanks for making it. I'm not sure if we should merge it though, because the component template is already more complex than I'd like for a template and severely under-documented.

I agree with you, I'm happy with the template and did not have to change it a lot beside this "can't access raw keys" issue. But it was not a "ready to jump in" template for me, especially for a first Ratatui app, it took me some time to get comfortable with it.