Skip to content

Capturing the shell output in SwiftUI #308

Closed Answered by migueldeicaza
alealealedocebo asked this question in Q&A
Discussion options

You must be logged in to vote

Ok, it should be a lot easier now.

What you need to do is create a subclass of LocalProcessTerminalView and override the dataReceived method.

Like this:

class MyCapturingTerminalView: LocalProcessTerminalView {
    public override init (frame: CGRect)
    {
        super.init (frame: frame)
    }
    
    public required init? (coder: NSCoder)
    {
        super.init (coder: coder)
    }

    override func dataReceived(slice: ArraySlice<UInt8>) {
        super.dataReceived (slice: slice) 
        print ("Received: \(slice.count) bytes")
    }
}

Replies: 6 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@alealealedocebo
Comment options

Comment options

You must be logged in to vote
4 replies
@alealealedocebo
Comment options

@alealealedocebo
Comment options

@migueldeicaza
Comment options

@alealealedocebo
Comment options

Answer selected by migueldeicaza
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants