Debian Codegraph @

CodeLite/TerminalEmulator.h

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