lukewilliamboswell / roc-tui

An experimental TUI platform for Roc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terminal UI for Roc (WIP)

This is a tui platform for Roc built on top of the excellent tui-rs.

My goal for making this platform is to learn more about Roc dev; to explore ideas for the Roc editor, and how to do Action-State in Roc.

I welcome any feedback or assistance!

Note that to close the app it is currently hardcoded in the platform to the 'ESC' key. This will be configurable when I add support for effects.

Here is the hello.roc example.

# Model
Model : { text : Str }

init = \_ -> { text: "Hello world!" }

# Handle Events
update : Model, Event -> Model
update = \model, _ -> model

# Render UI
render : Model -> List Elem
render = \model -> 
    text = [[Elem.styled model.text { fg: Green }]]
    
    [ Elem.layout [ Elem.paragraph { text } ] {} ]

Here is a demonstration of examples/todo.roc.

and, here is a demonstration of examples/popup.roc.

If your feeling brave you can use a URL release of this platform. For more information how to do this see the Roc Tutorial.

Things I'm working on, or thinking about

  • Block widget
  • Paragraph widget
  • Responsive layouts
  • Styling
  • Scrolling for paragraphs
  • Optional Records for better API
  • List widget
  • Add support for Popup/Modals
  • Support for effects (e.g. close app)
  • Support more widgets. Currently blocked on #4554
    • Canvas widget
    • Tabs
    • Table
    • Charts
    • Sparkline
  • More examples
  • Support Tasks such as opening a File similar to CLI, needs investigation. Better to wait for improved roc glue support and packages
  • Better error handling, don't mess up terminal if Roc panics somehow
  • Support for mouse input
  • Write some tests

Process to add functionality

  1. Review the tui-rs docs and examples to understand the behaviour.
  2. Add feature to the Platform API *.roc files
  3. Generate platform/glue.rs with roc glue platform/main.roc platform/src/glue.rs note the comments in platform/main.roc
  4. Use cargo build from the platform folder to fix any errors
  5. Wire functionality into the platform host Rust code
  6. Update hello.roc and other examples
  7. Rebuild release with roc build --bundle .tar.br platform/main.roc

Platform Docs

roc docs platform/main.roc
cd ./generated-docs
simple-http-server --nocache --index

About

An experimental TUI platform for Roc

License:Universal Permissive License v1.0


Languages

Language:Rust 100.0%Language:C 0.0%