tui-rs icon indicating copy to clipboard operation
tui-rs copied to clipboard

How to build UI like use HTML tag?

Open kaixinbaba opened this issue 2 years ago • 1 comments

Problem

Does Rust have the opportunity to use macros to build the structure of the TUI app, just like JSX in React

use crate::MyComponent1;
use crate::MyComponent2;
use crate::MyComponent3;

struct MyComponent2 {
    someAttr: SomeType,
}

struct MyComponent3 {}

impl MyComponent3 {
    pub fn keyHandler(event: KeyEvent) {
        ...
    }
}

struct Root {}

impl Root {
    pub fn update() {
        tui!(
            <MyComponent1>
                <MyComponent2 attr="someAttr">Hello Rust</MyComponent2>
                <MyComponent3 onKey="keyHandler">Hello TUI</MyComponent3>
            </MyComponent1>
        )
    }
}

These are my simple and immature ideas

kaixinbaba avatar Apr 18 '22 02:04 kaixinbaba

that would be interesting

peepo5 avatar Apr 24 '22 18:04 peepo5