Need to be careful to do that platform-dependent enablement of tab completion with parse_and_bind, like in Input_completer in utils.py.
I think if I set delimiters correctly (i.e. whitespace), then the "text" input to the completer should just be the current (partial) word? In this situation I don't have any need to look back in the buffer.
When state is "0", generate an array of matches and return the first one. For subsequent values of state return the next in the array, until when there are no more matches then return None.
My reflex is to use Tab to find/complete command names in that interactive edit. Let's make it work!
The Completion section of https://docs.python.org/3/library/readline.html is relevant. Examples of varying complexity:
https://github.com/modelop/hadrian/blob/master/titus/titus/inspector/defs.py https://github.com/gabfl/vault/blob/main/src/modules/autocomplete.py https://github.com/OWASP/QRLJacking/blob/master/QRLJacker/core/utils.py
Basically it looks like: