| 1 |
#include "clConsoleOSXTerminal.h" |
| 2 |
#include "file_logger.h" |
| 3 |
#include "fileutils.h" |
| 4 |
|
| 5 |
clConsoleOSXTerminal::clConsoleOSXTerminal() { SetTerminalApp("Terminal"); } |
| 6 |
|
| 7 |
clConsoleOSXTerminal::~clConsoleOSXTerminal() {} |
| 8 |
|
| 9 |
bool clConsoleOSXTerminal::Start() |
| 10 |
{ |
| 11 |
wxString commandToExecute = PrepareCommand(); |
| 12 |
int rc = system(commandToExecute.mb_str(wxConvUTF8).data()); |
| 13 |
wxUnusedVar(rc); |
| 14 |
return true; |
| 15 |
} |
| 16 |
|
| 17 |
bool clConsoleOSXTerminal::StartForDebugger() |
| 18 |
{ |
| 19 |
SetRealPts(""); |
| 20 |
SetTty(""); |
| 21 |
SetPid(wxNOT_FOUND); |
| 22 |
FileUtils::OSXOpenDebuggerTerminalAndGetTTY(GetWorkingDirectory(), GetTerminalApp(), m_tty, m_pid); |
| 23 |
SetRealPts(m_tty); |
| 24 |
return true; |
| 25 |
} |
| 26 |
wxString clConsoleOSXTerminal::PrepareCommand() |
| 27 |
{ |
| 28 |
wxString commandToExecute; |
| 29 |
// osascript -e 'tell app "Terminal" to do script "echo hello"' |
| 30 |
wxFileName scriptPath = PrepareExecScript(); |
| 31 |
|
| 32 |
if(IsTerminalNeeded()) { |
| 33 |
commandToExecute << "open -n -a " << GetTerminalApp(); |
| 34 |
} |
| 35 |
|
| 36 |
if(!GetCommand().IsEmpty()) { |
| 37 |
commandToExecute << " " << scriptPath.GetFullPath(); |
| 38 |
} |
| 39 |
clDEBUG() << commandToExecute; |
| 40 |
return commandToExecute; |
| 41 |
} |