peterbrittain / asciimatics

A cross platform package to do curses-like operations, plus higher level APIs and widgets to create text UIs and ASCII art animations
Apache License 2.0
3.61k stars 238 forks source link

Add proposed ReadBox widget #371

Closed cltrudeau closed 11 months ago

cltrudeau commented 1 year ago

Important: this isn't the real PR, a real PR would include tests and stuff. I haven't run the test suite or any other good practices, this is just to get the ReadBox in front of you to see if you want it committed.

ReadBox is a read-only TextBox-like widget. Differences are subtle from TextBox(readonly=True), but I remember when adding features to TextBox that to get the cursor behaviour I wanted for a README-style reader didn't work well with the TextBox implementation.

If the difference is too subtle and not worth the extra code being maintained, reject the PR. If you like it, I'll add some tests and move the example into forms.py.

peterbrittain commented 1 year ago

Ooh... I like this! What you have here is a readonly listbox with optional line wrapping (and horizontal scrolling when you don't). I need to think about this some more, but I'd like to see if we can fit this code into the listbox classes.

peterbrittain commented 1 year ago

Of course, it's not quite that because it follows the TextBox value model, but the visual style reminds me more of a list.

cltrudeau commented 1 year ago

Well, it is is here if you want it. Let me know when you decide what to do with it.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

peterbrittain commented 11 months ago

Hi. I'm catching up on the project here and so trying to close out items before republishing.

On this one, I'm still not sure what to do... It acts a lot like a readonly TextBox apart from the the value model. On the other hand, the value model is like a ListBox and you've added the ability to wrap or scroll horizontally (plus autoscrolling). I think it would be great to add some, or all, of these features to ListBox... What do you think?

cltrudeau commented 11 months ago

Hey Peter,

It is your project. I had to write the code for myself either way. Happy to add tests and whatever if you would like the widget in the project, won't be offended if you think it has too much overlap. If you want it, let me know and I'll add stuff to the PR (or create a new one, I think I mucked the other one by including other changes).

If you don't want it, feel free to close this.

peterbrittain commented 11 months ago

Thanks. I appreciate your understanding.

There are features here that I really want to add to asciimatics (most notably horizontal scrolling to the various list boxes), but I think this class overlaps too much with the existing classes to justify taking it all.

At least this way you don't have to write those pesky unit tests! :-)