Capturing the shell output in SwiftUI #308
-
Hi, using the LocalProcessTerminalView view I can access to the terminal to send a byte array to the shell rendered in the terminal (I use zsh). But how can I capture the stdout of that shell inside my Swift app? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 5 replies
-
Hello, Mhm I see that the method you would need is public, but not open, making the simplest solution hard (the An option is for me to make this open, but the other option is to manually assign the delegate on the process class and intercept all those calls and forward those to the view. |
Beta Was this translation helpful? Give feedback.
-
Hi Miguel, thanks, I managed to capture the chars on that method. As for now i'm going to handle this manually unless you know an easier way to obtain this. What I need to do basically is wait for some output matching a regexp before calling the send function to write something else in the terminal in response. |
Beta Was this translation helpful? Give feedback.
-
So you could override without needing a new release? That’s perfect |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
thanks, let me add the “open” there, so you don’t need to modify my code, and instead you subclass this and modify there |
Beta Was this translation helpful? Give feedback.
-
Ok, it should be a lot easier now. What you need to do is create a subclass of Like this:
|
Beta Was this translation helpful? Give feedback.
Ok, it should be a lot easier now.
What you need to do is create a subclass of
LocalProcessTerminalView
and override thedataReceived
method.Like this: