aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/libptyqt/iptyprocess.h
blob: 3d974908c86b7949aff8fb1a93a42ece63dc31e6 (plain)
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
#ifndef IPTYPROCESS_H
#define IPTYPROCESS_H

#include <QDebug>
#include <QString>
#include <QThread>

#define CONPTY_MINIMAL_WINDOWS_VERSION 18309

class IPtyProcess
{
public:
    enum PtyType { UnixPty = 0, WinPty = 1, ConPty = 2, AutoPty = 3 };

    IPtyProcess() = default;
    IPtyProcess(const IPtyProcess &) = delete;
    IPtyProcess &operator=(const IPtyProcess &) = delete;

    virtual ~IPtyProcess() {}

    virtual bool startProcess(const QString &executable,
                              const QStringList &arguments,
                              const QString &workingDir,
                              QStringList environment,
                              qint16 cols,
                              qint16 rows)
        = 0;
    virtual bool resize(qint16 cols, qint16 rows) = 0;
    virtual bool kill() = 0;
    virtual PtyType type() = 0;
    virtual QString dumpDebugInfo() = 0;
    virtual QIODevice *notifier() = 0;
    virtual QByteArray readAll() = 0;
    virtual qint64 write(const QByteArray &byteArray) = 0;
    virtual bool isAvailable() = 0;
    virtual void moveToThread(QThread *targetThread) = 0;
    qint64 pid() { return m_pid; }
    QPair<qint16, qint16> size() { return m_size; }
    const QString lastError() { return m_lastError; }
    int exitCode() { return m_exitCode; }
    bool toggleTrace()
    {
        m_trace = !m_trace;
        return m_trace;
    }

protected:
    QString m_shellPath;
    QString m_lastError;
    qint64 m_pid{0};
    int m_exitCode{0};
    QPair<qint16, qint16> m_size; //cols / rows
    bool m_trace{false};
};

#endif // IPTYPROCESS_H