rr- / urwid_readline

readline text edit for urwid
MIT License
27 stars 11 forks source link

Add support for limit_chars argument for ReadlineEdit. #18

Closed zee-bit closed 3 years ago

zee-bit commented 3 years ago

There may be several use-cases, where you want to restrict the user input into a ReadlineEdit widget to not go beyond a particular limit, this PR makes it possible for clients to specify a max_char argument when initializing a ReadlineEdit widget so that the user can't input text beyond that limit. In particular zulip-terminal has such a use-case, where it needs ReadlineEdit widgets for stream and topic to only accept input up to 60 characters.

Relevant discussion:

rr- commented 3 years ago

Thanks, released as 0.13

neiljp commented 3 years ago

@rr- Thanks for the merge - I also think this could be good upstream depending on the activity there, though would still need integration here in terms of the other commands like paste?

rr- commented 3 years ago

Unfortunately I don't understand the question. BTW @neiljp I invited you as a collaborator. Later on we can think of a way to let you publish new versions through GitHub actions.

neiljp commented 3 years ago

@rr- I meant whether this feature belongs in urwid.Edit or similar, as a max-length could be a more fundamental property. However, I'm not sure how active upstream urwid is, or if they'd accept it - and urwid-readline would still need to handle situations like the paste case that is specific to this library.