haskeline
haskeline copied to clipboard
How to get control characters
Hello,
I'd like to do something with \BS, but getInputChar
ignores non-printable characters.
How can I do it? Should I build a custom function which acts like getInputChar
returns non-printable ones?
I vote it should return all characters and not filter out non-printable characters.
I vote it should return all characters and not filter out non-printable characters.
+1
Here's another use case for allowing users of this library to respond to control characters: purescript/purescript#934.
I wonder if a better API would be to add a function which can transform InputT
actions to specify what should happen when a control character is entered. Something like this, perhaps:
type ControlHandler m = Char -> (String, String) -> InputT m (Maybe String)
handleControlChars :: (MonadException m) =>
ControlHandler m -> InputT m (Maybe String) -> InputT m (Maybe String)
The arguments to a ControlHandler
should be:
- the control character that was pressed - so, for example, pressing
^C
should give 'c' - what's on the line, in the form of a tuple, like with a CompletionFunc.
@judah if I were to put together a PR for this, would you take it?