Giter Site home page Giter Site logo

ratatui-org / templates Goto Github PK

View Code? Open in Web Editor NEW
222.0 6.0 31.0 153 KB

Templates for bootstrapping a Rust TUI application with Ratatui

Home Page: https://ratatui.rs/templates

License: MIT License

Rust 100.00%
cargo-generate rust rust-template tui tui-rs tui-app template-project template-repository crossterm ratatui

templates's People

Contributors

joshka avatar karlheitmann avatar kdheepak avatar loadedice avatar mmitsuha avatar neumoneumo avatar orhun avatar pythops avatar stappersg avatar valentin271 avatar vinermy avatar vm910 avatar worlpaker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

templates's Issues

Async counter example text input broken

Hi,

Thanks for providing such a comprehensive template!

I tried to play around with the async counter example, but the text input doesn't work for me.

After some digging I found the issue and there is a quick semi-fix, but a somewhat more annoying issue remains, which also applies to the template and not just the counter example.

Quick Fix

The handle_key_events() function of the Home Component is never called. This is because the handle_events() function is overwritten with the handling of the mouse event. Changing the function name to handle_mouse_events() fixes the issue (with some minor other changes to make the compiler happy).

Remaining issue

Typing a lowercase q in the input field still makes the program quit, even in insert mode. This is because the key presses are passed through the key map and the resulting action is triggered regardless of component state. I think this is a bigger issue, as TUI applications usually quit on q and often require text input. So I think it's probably best to make the template easily compatible with such applications.

Maybe a possible solution would be to let component cancel actions, or to move the keybinding handling into the component (the keybindings are in the home section of the config, so maybe their logic should also be in the Home component so it can depend on the component state). The handling for the j,k,/,? keys is already inside the component so they can be handled better. But that raises the question about the case when multiple components need to handle the same key (e.g. two components with text inputs). Maybe full text input should be a first class citizen, that components can trigger, so it's handled outside of components all together?

These ideas are not very thought out and I'm not totally happy with them. I thought I'd first try to get some feedback as you likely have a better overview over how things are and should work.

I'm happy to help with a PR later

Cannot import tui::text::Line

Hello,

After creating a fresh project I am not able to import use tui::text::Line. It keeps telling me that "there is no Line in text", even though looking at the documentation there is.

image

It suggests the other widgets that are using Line, but these are not what I'm looking for, I want to use Line::from(). The following code shows what I'm trying to achieve:
image

I created a fresh new project, but still have the same issue. It seems that for some reason it is not able to locate the text::Line module.

Do you guys perhaps know why this is happening?(I'm a beginner at rust)

Full Code:

image

Check select! bug in async

I suspect that this is still a bug as the select can complete on either branch of the select in a non-deterministic fashion. The right way to handle (I think) is to not fail when the sender fails to send. The send failing can indicator that the receiver is closed. See https://docs.rs/tokio/latest/tokio/sync/mpsc/struct.Sender.html

I think there's probably a second bug with this in how cancelations are handled https://docs.rs/tokio/latest/tokio/sync/mpsc/struct.Sender.html#cancel-safety

Originally posted by @joshka in #48 (review)

error: when not focusing on the terminal

Great template for beginners. However, it panics and the program (terminal) freezes when not focused or when pressing ALT+TAB.

Error:

thread '<unnamed>' panicked at src\event.rs:51:34:
not implemented
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Keymaps that requires holding down "Shift" to trigger such as "!", "?" or "#" are not working

A keymap that requires holding down "Shift" to generate e.g. "!" or "?" characters will not trigger correctly.

For example, this will fail.

{
    "keybindings": {
        "StockWatch": {
            ...
            "<?>": "ToggleShowHelp", // Shift-/
            "<@>": "DummyAction1", // Shift-1
            "<#>": "DummyAction2",  // Shift-3
            ...
        },
    }
}

But this works:

{
    "keybindings": {
        "StockWatch": {
            ...
            "<Shift-?>": "ToggleShowHelp", 
            "<Shift-@>": "DummyAction1", 
            "<Shift-#>": "DummyAction2",  
            ...
        },
    }
}

Keep the async template minimalist

Currently the async template comes up with many dependencies and lot of code. Would be great to keep it minimalist like the simple template

More generalized way to set up Mode as part of the config

I'm trying to see if I one can overwrite the "global" setting of a specific keymap , so that a specific key that's mapped at the config.json can be ignored or changed at the component level based conditionally on the mode

For example, something like this?

{
    "keybindings": {
        "StockWatch": {
            "Insert":{
            },
            "Default":{
            "<q>":"Quit",
            "<j>": "ScheduleIncrement",
            "<l>": "ToggleShowHelp",
            "</>": "EnterInsert",
            "<Ctrl-d>": "Quit", // Another way to quit
            "<Ctrl-c>": "Quit", // Yet another way to quit
            "<Ctrl-z>": "Suspend", // Suspend the application
            }
        },
    }
}

Fix build checks / CI

The CI pipeline is failing probably due to the newly added async subtemplate. We need to look into fixing it.

Should `app.rs` only be responsible for app state?

Hi there!

Firstly, this repo is so cool, I wish I knew about it earlier rather than starting from the demo application in the tui-rs repo.

From the README.md it states that app.rs "holds the states and renders the widgets".

I feel like this is a fine pattern for simple projects but will easily leave app.rs and app struct being overwhelmed.

In the demo application from the ratatui repo they have split this responsibility into 2 files:

  • app.rs which is responsible for the application state and application logic.
  • ui.rs which is responsible for the rendering of widgets.

I think I found that pattern a bit easier to understand and the code is easier to navigate. In this particular example if both files were combined they'd be quite large. As this is a template I feel like it should try to get users off on the right foot. I've also noticed other users of tui/ratatui follow this pattern; although they may predate this repo and they're generally large applications.

If the maintainers/community agree that this responsibility should be split I'm more than happy to write up a PR for it. Alternatively if this is the pattern that the maintainers want to push, I can make a PR to tui-rs-revival to combine their ui.rs and app.rs for consistency if this is something they care about.

Also I'm pretty new to rust and contributing to open source stuff, so there is a reasonable chance I've overlooked something here and this isn't feasible.

Thanks!

License

Hello!

I created a small benchmarking tool using your template and modifying it to my need.

Since this repo does not have a license I only added comments like this line to cite your repo.
Is it ok with you?

Typo in doc comment

There is a typo in a doc comment in tui.rs in both the simple and simple-async templates. The doc comment for the draw method says

/// [`rendering`]: crate::ui:render

where it should be

/// [`rendering`]: crate::ui::render

(There should be two colons between ui and render.)

This leads to an error when Cargo builds the documentation,

warning: unresolved link to `crate::ui:render`
  --> src\tui.rs:52:24
   |
52 |     /// [`rendering`]: crate::ui:render
   |                        ^^^^^^^^^^^^^^^^ no item named `ui:render` in module `ratatui_simple_template`
   |
   = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.