1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// Copyright : (C) 2015 Eran Ifrah
// File name : TerminalEmulator.h
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifndef TERMINALEMULATOR_H
#define TERMINALEMULATOR_H
#include "asyncprocess.h"
#include "cl_command_event.h"
#include "codelite_exports.h"
#include <list>
#include <wx/event.h>
#include <wx/process.h>
#include <wx/string.h>
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_TERMINAL_COMMAND_EXIT, clCommandEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_TERMINAL_COMMAND_OUTPUT, clCommandEvent);
class MyProcess;
class WXDLLIMPEXP_CL TerminalEmulator : public wxEvtHandler
{
IProcess* m_process;
long m_pid;
friend class MyProcess;
std::list<wxProcess*> m_myProcesses;
protected:
void OnProcessTerminated(clProcessEvent& event);
void OnProcessOutput(clProcessEvent& event);
public:
TerminalEmulator();
virtual ~TerminalEmulator();
/**
* @brief terminate the running process
*/
void Terminate();
/**
* @brief is the process currently running?
*/
bool IsRunning() const;
/**
* @brief Execute a command in the OS terminal.
* @param command the command to execute
* @param waitOnExit when set to true, pause the terminal with the message
* @param command_args arguments to be appended to the command
* @param workingDirectory working directory for the new process
* "Hit any key to continue"
* @param title set the terminal title. If an empty string is provided, use the command as the title
*/
bool ExecuteConsole(const wxString& command, bool waitOnExit = false, const wxString& command_args = "",
const wxString& workingDirectory = "", const wxString& title = "");
/**
* @brief execute a command without attaching console
*/
bool ExecuteNoConsole(const wxString& command, const wxString& workingDirectory);
};
#endif // TERMINALEMULATOR_H
|