~larryprice/acolyterm/release-0.1

« back to all changes in this revision

Viewing changes to src/plugin/konsole/Pty.h

  • Committer: Larry Price
  • Date: 2016-06-15 14:47:59 UTC
  • Revision ID: larry.price@canonical.com-20160615144759-6wopn0gxwgta3x1n
Updating QMLTermWidget and removing unnecessary konsole codebase

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * This file is a part of QTerminal - http://gitorious.org/qterminal
3
 
 *
4
 
 * This file was un-linked from KDE and modified
5
 
 * by Maxim Bourmistrov <maxim@unixconn.com>
6
 
 *
7
 
 */
8
 
 
9
 
/*
10
 
    This file is part of Konsole, KDE's terminal emulator.
11
 
 
12
 
    Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
13
 
    Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
14
 
 
15
 
    This program is free software; you can redistribute it and/or modify
16
 
    it under the terms of the GNU General Public License as published by
17
 
    the Free Software Foundation; either version 2 of the License, or
18
 
    (at your option) any later version.
19
 
 
20
 
    This program is distributed in the hope that it will be useful,
21
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 
    GNU General Public License for more details.
24
 
 
25
 
    You should have received a copy of the GNU General Public License
26
 
    along with this program; if not, write to the Free Software
27
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28
 
    02110-1301  USA.
29
 
*/
30
 
 
31
 
#ifndef PTY_H
32
 
#define PTY_H
33
 
 
34
 
// Qt
35
 
#include <QtCore/QStringList>
36
 
#include <QtCore/QVector>
37
 
#include <QtCore/QList>
38
 
#include <QtCore/QSize>
39
 
 
40
 
// KDE
41
 
#include "kptyprocess.h"
42
 
 
43
 
 
44
 
/**
45
 
 * The Pty class is used to start the terminal process,
46
 
 * send data to it, receive data from it and manipulate
47
 
 * various properties of the pseudo-teletype interface
48
 
 * used to communicate with the process.
49
 
 *
50
 
 * To use this class, construct an instance and connect
51
 
 * to the sendData slot and receivedData signal to
52
 
 * send data to or receive data from the process.
53
 
 *
54
 
 * To start the terminal process, call the start() method
55
 
 * with the program name and appropriate arguments.
56
 
 */
57
 
class Pty: public KPtyProcess
58
 
{
59
 
Q_OBJECT
60
 
 
61
 
  public:
62
 
 
63
 
    /**
64
 
     * Constructs a new Pty.
65
 
     *
66
 
     * Connect to the sendData() slot and receivedData() signal to prepare
67
 
     * for sending and receiving data from the terminal process.
68
 
     *
69
 
     * To start the terminal process, call the run() method with the
70
 
     * name of the program to start and appropriate arguments.
71
 
     */
72
 
    explicit Pty(QObject* parent = 0);
73
 
 
74
 
    /**
75
 
     * Construct a process using an open pty master.
76
 
     * See KPtyProcess::KPtyProcess()
77
 
     */
78
 
    explicit Pty(int ptyMasterFd, QObject* parent = 0);
79
 
 
80
 
    ~Pty();
81
 
 
82
 
    /**
83
 
     * Starts the terminal process.
84
 
     *
85
 
     * Returns 0 if the process was started successfully or non-zero
86
 
     * otherwise.
87
 
     *
88
 
     * @param program Path to the program to start
89
 
     * @param arguments Arguments to pass to the program being started
90
 
     * @param environment A list of key=value pairs which will be added
91
 
     * to the environment for the new process.  At the very least this
92
 
     * should include an assignment for the TERM environment variable.
93
 
     * @param winid Specifies the value of the WINDOWID environment variable
94
 
     * in the process's environment.
95
 
     * @param addToUtmp Specifies whether a utmp entry should be created for
96
 
     * the pty used.  See K3Process::setUsePty()
97
 
     * @param dbusService Specifies the value of the KONSOLE_DBUS_SERVICE
98
 
     * environment variable in the process's environment.
99
 
     * @param dbusSession Specifies the value of the KONSOLE_DBUS_SESSION
100
 
     * environment variable in the process's environment.
101
 
     */
102
 
    int start( const QString& program,
103
 
               const QStringList& arguments,
104
 
               const QStringList& environment,
105
 
               ulong winid,
106
 
               bool addToUtmp
107
 
             );
108
 
 
109
 
    /** TODO: Document me */
110
 
    void setWriteable(bool writeable);
111
 
 
112
 
    /**
113
 
     * Enables or disables Xon/Xoff flow control.  The flow control setting
114
 
     * may be changed later by a terminal application, so flowControlEnabled()
115
 
     * may not equal the value of @p on in the previous call to setFlowControlEnabled()
116
 
     */
117
 
    void setFlowControlEnabled(bool on);
118
 
 
119
 
    /** Queries the terminal state and returns true if Xon/Xoff flow control is enabled. */
120
 
    bool flowControlEnabled() const;
121
 
 
122
 
    /**
123
 
     * Sets the size of the window (in lines and columns of characters)
124
 
     * used by this teletype.
125
 
     */
126
 
    void setWindowSize(int lines, int cols);
127
 
 
128
 
    /** Returns the size of the window used by this teletype.  See setWindowSize() */
129
 
    QSize windowSize() const;
130
 
 
131
 
    /** TODO Document me */
132
 
    void setErase(char erase);
133
 
 
134
 
    /** */
135
 
    char erase() const;
136
 
 
137
 
    /**
138
 
     * Returns the process id of the teletype's current foreground
139
 
     * process.  This is the process which is currently reading
140
 
     * input sent to the terminal via. sendData()
141
 
     *
142
 
     * If there is a problem reading the foreground process group,
143
 
     * 0 will be returned.
144
 
     */
145
 
    int foregroundProcessGroup() const;
146
 
 
147
 
  public slots:
148
 
 
149
 
    /**
150
 
     * Put the pty into UTF-8 mode on systems which support it.
151
 
     */
152
 
    void setUtf8Mode(bool on);
153
 
 
154
 
    /**
155
 
     * Suspend or resume processing of data from the standard
156
 
     * output of the terminal process.
157
 
     *
158
 
     * See K3Process::suspend() and K3Process::resume()
159
 
     *
160
 
     * @param lock If true, processing of output is suspended,
161
 
     * otherwise processing is resumed.
162
 
     */
163
 
    void lockPty(bool lock);
164
 
 
165
 
    /**
166
 
     * Sends data to the process currently controlling the
167
 
     * teletype ( whose id is returned by foregroundProcessGroup() )
168
 
     *
169
 
     * @param buffer Pointer to the data to send.
170
 
     * @param length Length of @p buffer.
171
 
     */
172
 
    void sendData(const char* buffer, int length);
173
 
 
174
 
  signals:
175
 
 
176
 
    /**
177
 
     * Emitted when a new block of data is received from
178
 
     * the teletype.
179
 
     *
180
 
     * @param buffer Pointer to the data received.
181
 
     * @param length Length of @p buffer
182
 
     */
183
 
    void receivedData(const char* buffer, int length);
184
 
 
185
 
  protected:
186
 
      void setupChildProcess();
187
 
 
188
 
  private slots:
189
 
    // called when data is received from the terminal process
190
 
    void dataReceived();
191
 
 
192
 
  private:
193
 
      void init();
194
 
 
195
 
    // takes a list of key=value pairs and adds them
196
 
    // to the environment for the process
197
 
    void addEnvironmentVariables(const QStringList& environment);
198
 
 
199
 
    int  _windowColumns;
200
 
    int  _windowLines;
201
 
    char _eraseChar;
202
 
    bool _xonXoff;
203
 
    bool _utf8;
204
 
};
205
 
 
206
 
#endif // PTY_H