Replies: 6 comments 2 replies
-
Hi there See any of the examples in the readme file to get started, plus you need to add the dependency to you build. I'll make the readme file a bit clearer. There is no dropdown widget and so on here yet unfortunately. I'd love to have it though. It does have events, but maybe not at the level you probably would expect them. You write a top-level loop which handles it |
Beta Was this translation helpful? Give feedback.
-
Thank you! Let me just add two comments. It would help if the library were published to sonatype, then at least it would be very easy to check out the examples and start playing with it. Second, I'm looking at Elm and I think the Elm architecture will fit here. It's a very straightforward thing where an interactive program is a pure value of type The view can use Cassowary constraints, widgets, etc., and the Elm architecture makes it declarative; there are no threads or race conditions to think about. I would be interested in about 1 year to create a project implementing Elm architecture for text-based UIs. |
Beta Was this translation helpful? Give feedback.
-
I think this is interesting. We need to find a way to componentize the widgets, including callbacks. So a user can easily compose components without getting lost in individual coordinates and complicated state management. It needs to be structured enough that we can get tab navigation for instance "for free". This is the main thing I want to accomplish in the short term. Note that some amount of imperative code is OK in my book to fulfill these requirements, especially if it makes it easier to use the library for beginners. I'm sure you can discuss details of elm and react architecture for a while, but for my purposes here let's just talk loosely about a components as pure rendering function + state management (including callbacks). The elm architecture is definitely a possible direction, though the scope of implementing it look like a full rewrite of the rendering and widgets layers. Maybe any componentization of the library would end up there actually. I wanted to drop a few links as possible inspiration apart from elm proper, I'm sure there are tons more.
challenges
where to go from hereIf you're interested in working on this I'd be very happy to see a proof of concept, where we for instance create an elm-like architecture, some widget like a checkbox which is controllable by both mouse and keyboard, and a user program which renders a bunch of checkboxes to test layouting and user interaction. I hope that such a prototype can be easy on type parameters and "advanced" features. Ideally at a level where it could be ported to java, although not a hard requirement. It's a big plus if it works both for scala 2 and 3. |
Beta Was this translation helpful? Give feedback.
-
First off, I did not mean to say that Elm is the only way to go. I see Elm as a high-level interface that can be slapped on top of any UI library that has callbacks, mutable DOM, or whatever. First, a UI library must somehow, most likely imperatively, draw the views, manage layouts, and catch user events. Then, independently of that, one needs to implement a runloop and some higher-level "widgets". The Elm architecture is one possibility among many. The UI library should be Elm-agnostic and should concentrate on good maintainability of the low-level code. An Elm runner will be implemented entirely through the public API of a UI library. So, Elm-related considerations are not needed while you are still working out the low-level details of the UI library: how to implement overlapping widgets, how to minimize redrawing, how to detect which widget got clicked or has focus, and so on. The UI library needs to be able to draw a given layout with widgets, handle focus, and catch events from widgets. To do that, the UI library may use any mechanism - callbacks, mutable global variables, virtual DOM or just a big screen buffer, whatever works. The UI library may implement its own runloop but it is not necessary at that level. I leave it entirely to your judgment (certainly you have more experience than I) to decide what to do with tui-scala in terms of low-level implementation. I am not familiar with the "immediate mode GUI" and I will need to read up on that. I wanted to make a proof of concept with the code I showed above in my previous comment. I created a small project, imported tui-scala and pasted my code and some example code from the tui-scala repo. I hoped to figure out how to draw the widgets and how to catch events from them. But I couldn't figure out anything. The code of the widgets is too imperative and it is not clear how to use tui-scala, and there is no documentation or tutorial or explanation about what "widgets" do, what is going on when you call So, getting anything done will require a few continuous weeks of going through your entire code, until I understand how it works. But I have perhaps one half-hour per week to look at this project. That is why this discussion thread has the title "how to get started using tui". |
Beta Was this translation helpful? Give feedback.
-
Here is an example from the https://github.com/JD557/interim/blob/master/examples/release/intro.md def application(inputState: InputState) = ??? // Our application code
while(true) {
val input: InputState = backend.grabInput() // Grab input from the backend
val (renderOps, _) = application(input) // Generate render ops
backend.render(renderOps) // Send render operations to the backend
} It is clear from this example how to implement any high-level GUI architecture, such as Elm or "immediate UI" or anything else, using just the public API of a "backend". The "backend" just needs to be able to grab user events and to render a given view in some way. |
Beta Was this translation helpful? Give feedback.
-
I just found https://gitlab.com/AutumnMeowMeow/jexer/-/wikis/high-level-design |
Beta Was this translation helpful? Give feedback.
-
Hello,
I'm intrigued by text-based UI but I couldn't find any documentation about tui-rs or tui-scala. How can I get started? Say, I want to write a Scala app that sends commands to a Web server using a text-based UI. As input I need drop-down choice boxes, tick boxes, and free input fields, say.
I'm also confused by the statement that "this library does not implement any events". How can a UI library work without implementing events? Is there a runloop, is there a declarative description of the logic, or how does it work?
Beta Was this translation helpful? Give feedback.
All reactions