user1012032
user1012032

Reputation:

How to implement terminal in Mac OS X application?

So I have created an app(simple IDE) where you can write/edit ada code and save it to temp.adb file. To compile the file I should open terminal and navigate to the temp.adb directory. and execute

gnatmake temp.adb

If temp.adb has error the errors are shown in the terminal otherwise temp.adb executes within terminal. However I do not want the user to use the terminal and write commands separately. I just want the user to click on the "Build and run" button and it must compile the files and show the results within the app.

My question is if it is possible to show the compilation errors directly in the app? and also execute the temp.adb directly in the app? Where shall I read more about this? Any tips?
This is how the app looks like. The black view represents the console area. This is how the app looks like. The black view is a textfield which represents the console area.

Upvotes: 2

Views: 223

Answers (1)

DrummerB
DrummerB

Reputation: 40211

Use NSTask to run a shell (on OS X probably bash) with the appropriate arguments to compile and or run your code. Then use NSPipe to redirect stdout and stderr to your output text view.

I've done pretty much the same, but for shell scripts, it should work.

Upvotes: 2

Related Questions