japhb / Terminal-Widgets

Simple Raku widgets for full-screen TUIs
Artistic License 2.0
2 stars 3 forks source link

Example of a custom composed widget #15

Open patrickbkr opened 2 months ago

patrickbkr commented 2 months ago

I'm trying to implement a custom widget (The source view widget of the debugger I'm working on. I'm calling it SourceWidget). That widget should be a composition of a SpanBuffer (the line numbers), a divider and another SpanBuffer (the source text). As that widget will be specific to my use-case, it won't make sense to add it to T::W. I am missing an example of how to build a custom widget that's composed of others. Questions that have come to my mind trying to do so:

I'm lacking in understanding of the overall T::W architecture. I think an example could help.

japhb commented 1 month ago

In IRC you mentioned a few days ago that you were working on building your own widget, but it doesn't look composed (it looks like you went the bespoke route instead). I think this is a generally useful request, and would in fact probably make a great example, but is it still a priority request for you?

patrickbkr commented 1 month ago

There are many open ends I'm chasing. I'm just picking the ones where I'm not blocked. My current plan is:

As a temporary workaround for the "custom" part (i.e. How do I create a widget without modifying the T-W sources?), I can just add the widget to my local clone of T-W and move it out later.

As a temporary workaround for the "composed" part (i.e. How do I combine two SpanBuffers and a Divider into a new SourceView widget?), I can use a single SpanBuffer and output the line numbers at the start of each line and enforce line wrapping.

So in summary, it's not the highest priority at the moment, but at some point it will turn into a blocker.