Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support non-controlling terminals #156

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

goertzenator
Copy link

This patch adds useTermHandles to support terminals other than the controlling terminal. For example, opening and serving a serial port might look like...

main :: IO ()
main = do
  behavior <- useTermHandles (Just "vt100")
    <$> openFile "/dev/ttyUSB0" ReadMode
    <*> openFile "/dev/ttyUSB0" WriteMode
  runInputTBehavior behavior defaultSettings loop
    where
      loop :: InputT IO ()
      loop = do ...

This also has applications for pseudo terminals as per issue #147.

Testing:

  • I was unable to run the tests on my machine.
  • I am running this code on a hardware serial port and it seems to work fine.

@goertzenator
Copy link
Author

Some comments on a Windows implementation:

This PR does not implement useTermHandles for Windows. I tried briefly to port the changes into the Windows backend, but more rework is required there than I was comfortable with so I abandoned the effort. I think it would be useful to do that at some point; being able to support serial ports and the new ConPTY under Windows would be a good thing.

I would urge that this PR be merged despite the lack of Windows support. It would be useful to me and likely others. What I do seek though is the input of a Windows expert to determine if the new API useTermHandles is going to be suitable for Windows. That at least should be made portable so that a Window implementation can later be merged.

@NorfairKing
Copy link

+1 Just subscribing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants