-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IPC between texedit and tecomp with piped+async subprocesses
IO redirection from tecomp for texedit to recieve its output while it's run in the background
- Loading branch information
Showing
14 changed files
with
421 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
vendor/ | ||
tests/ | ||
examples/ | ||
deps/ | ||
docs/ | ||
build/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) 2024 Jack Bennett. | ||
* All Rights Reserved. | ||
* | ||
* See the LICENCE file for more information. | ||
*/ | ||
|
||
#include "tecomp_proc.hpp" | ||
|
||
#include "util/except.hpp" | ||
#include "util/resources.hpp" | ||
|
||
namespace te { | ||
TECompProcess::TECompProcess(ProcessManager &mgr) : _mgr{mgr}, _id{1} { | ||
_cmd = util::res::RelToExec("tecomp"); | ||
if (!util::res::ValidateExecutable(_cmd.ToStdString())) { | ||
throw util::except::MissingComponentException("tecomp"); | ||
} | ||
} | ||
|
||
void TECompProcess::Start() { | ||
const char *const argv[] = { | ||
_cmd.ToUTF8(), | ||
"watch", "examples", "examples/HelloWorld.tex", | ||
0 | ||
}; | ||
|
||
_mgr.ExecutePipedAsync(_id, argv); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2024 Jack Bennett. | ||
* All Rights Reserved. | ||
* | ||
* See the LICENCE file for more information. | ||
*/ | ||
|
||
#pragma once | ||
#ifndef __texedit__tecomp_proc_hpp__ | ||
#define __texedit__tecomp_proc_hpp__ | ||
|
||
#include <wx/wx.h> | ||
|
||
#include "process/process_mgr.hpp" | ||
|
||
namespace te { | ||
class TECompProcess { | ||
public: | ||
TECompProcess(ProcessManager &mgr); | ||
|
||
void Start(); | ||
|
||
inline int GetID() { return _id; } | ||
|
||
private: | ||
ProcessManager &_mgr; | ||
wxString _cmd; | ||
|
||
int _id; | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2024 Jack Bennett. | ||
* All Rights Reserved. | ||
* | ||
* See the LICENCE file for more information. | ||
*/ | ||
|
||
#include "process.hpp" | ||
|
||
#include "process_mgr.hpp" | ||
|
||
#include <wx/txtstrm.h> | ||
#include <iostream> | ||
|
||
namespace te { | ||
Process::Process(wxEvtHandler *parent, ProcessManager *mgr) : wxProcess(parent), _mgr{mgr} { | ||
} | ||
|
||
void Process::OnTerminate(int pid, int status) { | ||
_mgr->HandleProcessTerminated(this, pid, status); | ||
} | ||
|
||
PipedProcess::PipedProcess(wxEvtHandler *parent, ProcessManager *mgr) : Process(parent, mgr) { | ||
Redirect(); | ||
} | ||
|
||
wxString PipedProcess::ReadLineStdout() { | ||
wxString r{""}; | ||
|
||
if (IsInputAvailable()) { | ||
wxTextInputStream tis(*GetInputStream()); | ||
r << _cmd << " (stdout): " << tis.ReadLine() << "\n"; | ||
} | ||
if (IsErrorAvailable()) { | ||
wxTextInputStream tis(*GetErrorStream()); | ||
r << _cmd << " (stderr): " << tis.ReadLine() << "\n"; | ||
} | ||
|
||
return r; | ||
} | ||
|
||
void PipedProcess::OnTerminate(int pid, int status) { | ||
_mgr->HandlePipedProcessTerminated(this, pid, status); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2024 Jack Bennett. | ||
* All Rights Reserved. | ||
* | ||
* See the LICENCE file for more information. | ||
*/ | ||
|
||
#pragma once | ||
#ifndef __texedit__process_mgr_hpp__ | ||
#define __texedit__process_mgr_hpp__ | ||
|
||
#include <wx/process.h> | ||
|
||
#include <vector> | ||
|
||
namespace te { | ||
class ProcessManager; | ||
|
||
class Process : public wxProcess { | ||
public: | ||
Process(wxEvtHandler *parent, ProcessManager *mgr); | ||
|
||
virtual void OnTerminate(int pid, int status) override; | ||
|
||
inline void SetCmd(const wxString &cmd) { _cmd = cmd; } | ||
inline wxString GetCmd() { return _cmd; } | ||
|
||
protected: | ||
ProcessManager *_mgr; | ||
wxString _cmd{}; | ||
}; | ||
|
||
class PipedProcess : public Process { | ||
public: | ||
PipedProcess(wxEvtHandler *parent, ProcessManager *mgr); | ||
|
||
wxString ReadLineStdout(); | ||
|
||
virtual void OnTerminate(int pid, int status) override; | ||
}; | ||
} | ||
|
||
#endif |
Oops, something went wrong.