Closed gdude2002 closed 9 years ago
Looking for input from @Adam01, @rakiru if possible
This is Python - surely someone's already done this for us?
I've been looking, trust me. The only viable thing is curses and that's not even available on windows.
I've used curses of some sort on windows in python. It might've been in cygwin or something though, I guess.
Edit: Ok, there are python curses builds for windows, but they don't support unicode characters, so that's a dead-end (although does cmd even support unicode characters?).
Edit 2: Powershell probably does though I think, so yeah, that's not an option.
@rakiru Just C libraries in general would be nice to avoid anyway since almost everything we do related to logging is pure-python.
So let's assume pure-python. Where do we go from there?
Well, both IRC and Mumble partially rely on C libraries already, but I do agree that we should go with pure Python if possible. I'd say have a go writing a PoC of your first suggestion. The main problem I see is handling backspace etc., if you're having to print the input after any other output.
I'd also probably suggest that we make sure that anything someone might want to use sys.stdout for is possible to do from our stuff, and simply don't support directly using it. That may be easier said than done though, since it may be a library that tries to do that, rather than a plugin.
/randommumblings
I don't think backspace would be a problem, but I'm wondering how exactly to get it. I think that readline might be a good library to work with, though.
Actually, never mind, that isn't even close to the readline I was expecting. Hmm..
that isn't even close to the readline I was expecting
What were you expecting, then? Because this seems to be the standard solution for what it seems you're trying to do.
@dequis something like https://github.com/qmx/jreadline
It's got all those features, it just happens to have an obtuse api designed in 1970.
@dequis mind sharing a few pointers, then?
You probably want to use emacs editing mode (the default, so skip the suggestion about set editing-mode vi
), and if tab completion isn't needed, readline.parse_and_bind('')
(empty config) + raw_input()
is enough. Yep
Other config entries here: http://tiswww.case.edu/php/chet/readline/readline.html#SEC10
Logging and taking input simultaneously might be an issue:
Otherwise: http://urwid.org/ - decent pythonic wrapper over curses.
I'm going to drop this one and remove the console for now as it causes too many problems in a lot of edge cases.
I may revisit this in the future, though.
It's about time we looked at this. A working console with input is always a very useful thing to have - so, how should we implement one? A couple ideas I've had..
:
, at which point the we pause the output and add a line at the bottom for the input, unfreezing it when the input is submitted.Any ideas, thoughts, etc would be appreciated, especially relating to implementation detail.