开发者

Putting a 'terminal' in my application?

开发者 https://www.devze.com 2022-12-18 20:07 出处:网络
Are there any frameworks for say, putting a d开发者_如何学Goisplay like in Terminal.app in MY app, and then displaying text on it like usual output to STDOUT? Complete with scrollback and etc.?You may

Are there any frameworks for say, putting a d开发者_如何学Goisplay like in Terminal.app in MY app, and then displaying text on it like usual output to STDOUT? Complete with scrollback and etc.?


You may want to look at iTerm, an open-source terminal emulator written in Cocoa. If you really want terminal emulation, you might be able to lift from that framework.


This thread has a couple suggestions. The first is very UNIX'y - you use pipe() to map stdout to a new location. Then you'd need another process or a thread that reads that pipe and displays it into an NSTextView. The other approach that I liked as it seems cleaner and less resource intensive is to replace the File_writer_t _write proc in the stdout() FILE pointer with the hook that you want, which write the output into an NSTextView.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号