Skip to content

Conversation

altsem
Copy link
Owner

@altsem altsem commented Sep 29, 2025

This is another attempt at introducing a ui that is more easy to work with.

It is now composable via functions, and simplifies the UI code to just:

    layout.clear();

    layout.stacked(OPTS, |layout| {
        screen::layout_screen(
            layout,
            frame.area().as_size(),
            state.screens.last().unwrap(),
        );

        layout.vertical(OPTS.align_end(), |layout| {
            menu::layout_menu(layout, state);
            layout_command_log(layout, state);
            layout_prompt(layout, state);
        });
    });

    layout.compute([frame.area().width, frame.area().height]);

    for span in layout.iter() {
        let area = Rect {
            x: span.pos[0],
            y: span.pos[1],
            width: span.size[0],
            height: span.size[1],
        };

        frame.render_widget(span.data, area);
    }
  • The styling, particularly in the screen-module needs fixing.

  • Spans do wrap to new lines, breaking the editor (it assumes 1 item = 1 line)

  • Spans are truncated if too long, we should word/char-wrap instead. Perhaps feeding every single char to "layout" could work.

  • There's a lot of allocations going on, one way to amend this could be to look at removing the 'static lifetime from app.layout_tree. Since it is only used once per frame and cleared after.

  • The tui_prompt dependency should be easier to get rid of now. Eventually, we may get rid of Ratatui as well.

This is another attempt at introducing a ui that is more easy to work
with.

It is now composable via functions, and simplifies the UI code to just:
```rust
    layout.clear();

    layout.stacked(OPTS, |layout| {
        screen::layout_screen(
            layout,
            frame.area().as_size(),
            state.screens.last().unwrap(),
        );

        layout.vertical(OPTS.align_end(), |layout| {
            menu::layout_menu(layout, state);
            layout_command_log(layout, state);
            layout_prompt(layout, state);
        });
    });

    layout.compute([frame.area().width, frame.area().height]);

    for span in layout.iter() {
        let area = Rect {
            x: span.pos[0],
            y: span.pos[1],
            width: span.size[0],
            height: span.size[1],
        };

        frame.render_widget(span.data, area);
    }
```

- [ ] The styling, particularly in the `screen`-module needs fixing.

- [ ] Spans do wrap to new lines, breaking the editor (it assumes 1 item = 1 line)

- [ ] Spans are truncated if too long, we should word/char-wrap instead.
      Perhaps feeding every single char to "layout" could work.

- [ ] There's a lot of allocations going on, one way to amend this could
      be to look at removing the 'static lifetime from `app.layout_tree`.
      Since it is only used once per frame and cleared after.

- [ ] The tui_prompt dependency should be easier to get rid of now.
      Eventually, we may get rid of Ratatui as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant