~ubuntu-branches/ubuntu/precise/konsole/precise-proposed

« back to all changes in this revision

Viewing changes to src/Pty.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-16 13:14:43 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: package-import@ubuntu.com-20111216131443-rhdplbmmuxntat3k
Tags: upstream-4.7.90
ImportĀ upstreamĀ versionĀ 4.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
    This file is part of Konsole, KDE's terminal emulator. 
3
 
    
 
2
    This file is part of Konsole, KDE's terminal emulator.
 
3
 
4
4
    Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
5
5
    Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
6
6
 
39
39
{
40
40
 
41
41
/**
42
 
 * The Pty class is used to start the terminal process, 
43
 
 * send data to it, receive data from it and manipulate 
 
42
 * The Pty class is used to start the terminal process,
 
43
 * send data to it, receive data from it and manipulate
44
44
 * various properties of the pseudo-teletype interface
45
45
 * used to communicate with the process.
46
46
 *
49
49
 * send data to or receive data from the process.
50
50
 *
51
51
 * To start the terminal process, call the start() method
52
 
 * with the program name and appropriate arguments. 
 
52
 * with the program name and appropriate arguments.
53
53
 */
54
54
class KONSOLEPRIVATE_EXPORT Pty: public KPtyProcess
55
55
{
56
56
Q_OBJECT
57
57
 
58
 
  public:
59
 
    
60
 
    /** 
 
58
public:
 
59
 
 
60
    /**
61
61
     * Constructs a new Pty.
62
62
     * 
63
63
     * Connect to the sendData() slot and receivedData() signal to prepare
64
64
     * for sending and receiving data from the terminal process.
65
65
     *
66
 
     * To start the terminal process, call the run() method with the 
 
66
     * To start the terminal process, call the run() method with the
67
67
     * name of the program to start and appropriate arguments.
68
68
     */
69
69
    explicit Pty(QObject* parent = 0);
70
70
 
71
 
    /** 
 
71
    /**
72
72
     * Construct a process using an open pty master.
73
73
     * See KPtyProcess::KPtyProcess()
74
74
     */
77
77
    ~Pty();
78
78
 
79
79
    /**
80
 
     * Starts the terminal process.  
 
80
     * Starts the terminal process.
81
81
     *
82
82
     * Returns 0 if the process was started successfully or non-zero
83
83
     * otherwise.
90
90
     * @param winid Specifies the value of the WINDOWID environment variable
91
91
     * in the process's environment.
92
92
     * @param addToUtmp Specifies whether a utmp entry should be created for
93
 
     * the pty used.  See K3Process::setUsePty() 
94
 
     * @param dbusService Specifies the value of the KONSOLE_DBUS_SERVICE 
 
93
     * the pty used.  See K3Process::setUsePty()
 
94
     * @param dbusService Specifies the value of the KONSOLE_DBUS_SERVICE
95
95
     * environment variable in the process's environment.
96
96
     * @param dbusSession Specifies the value of the KONSOLE_DBUS_SESSION
97
 
     * environment variable in the process's environment. 
 
97
     * environment variable in the process's environment.
98
98
     */
99
99
    int start( const QString& program, 
100
100
               const QStringList& arguments, 
105
105
               const QString& dbusSession
106
106
             );
107
107
 
108
 
    /** TODO: Document me */
 
108
    /** Control whether the pty device is writeable by group members. */
109
109
    void setWriteable(bool writeable);
110
110
 
111
 
    /** 
 
111
    /**
112
112
     * Enables or disables Xon/Xoff flow control.  The flow control setting
113
113
     * may be changed later by a terminal application, so flowControlEnabled()
114
114
     * may not equal the value of @p on in the previous call to setFlowControlEnabled()
118
118
    /** Queries the terminal state and returns true if Xon/Xoff flow control is enabled. */
119
119
    bool flowControlEnabled() const;
120
120
 
121
 
    /** 
122
 
     * Sets the size of the window (in lines and columns of characters) 
 
121
    /**
 
122
     * Sets the size of the window (in lines and columns of characters)
123
123
     * used by this teletype.
124
124
     */
125
125
    void setWindowSize(int lines, int cols);
126
 
    
 
126
 
127
127
    /** Returns the size of the window used by this teletype.  See setWindowSize() */
128
128
    QSize windowSize() const;
129
129
 
130
 
    /** TODO Document me */
131
 
    void setErase(char erase);
 
130
    /**
 
131
     * Sets the special character for erasing previous not-yet-erased character.
 
132
     * See termios(3) for detailed description.
 
133
     */
 
134
    void setEraseChar(char eraseChar);
132
135
 
133
136
    /** */
134
 
    char erase() const;
 
137
    char eraseChar() const;
 
138
 
 
139
    /**
 
140
     * Sets the initial working directory.
 
141
     */
 
142
    void setInitialWorkingDirectory(const QString& dir);
135
143
 
136
144
    /**
137
145
     * Returns the process id of the teletype's current foreground
142
150
     * 0 will be returned.
143
151
     */
144
152
    int foregroundProcessGroup() const;
145
 
   
146
 
  public slots:
 
153
 
 
154
public slots:
147
155
 
148
156
    /**
149
157
     * Put the pty into UTF-8 mode on systems which support it.
151
159
    void setUtf8Mode(bool on);
152
160
 
153
161
    /**
154
 
     * Suspend or resume processing of data from the standard 
 
162
     * Suspend or resume processing of data from the standard
155
163
     * output of the terminal process.
156
164
     *
157
165
     * See K3Process::suspend() and K3Process::resume()
160
168
     * otherwise processing is resumed.
161
169
     */
162
170
    void lockPty(bool lock);
163
 
    
164
 
    /** 
165
 
     * Sends data to the process currently controlling the 
 
171
 
 
172
    /**
 
173
     * Sends data to the process currently controlling the
166
174
     * teletype ( whose id is returned by foregroundProcessGroup() )
167
175
     *
168
176
     * @param buffer Pointer to the data to send.
170
178
     */
171
179
    void sendData(const char* buffer, int length);
172
180
 
173
 
  signals:
 
181
signals:
174
182
 
175
183
    /**
176
184
     * Emitted when a new block of data is received from
180
188
     * @param length Length of @p buffer
181
189
     */
182
190
    void receivedData(const char* buffer, int length);
183
 
   
184
 
  protected:
185
 
      void setupChildProcess();
186
 
 
187
 
  private slots:
188
 
    // called when data is received from the terminal process 
 
191
 
 
192
protected:
 
193
    void setupChildProcess();
 
194
 
 
195
private slots:
 
196
    // called when data is received from the terminal process
189
197
    void dataReceived(); 
190
 
    
191
 
  private:
192
 
      void init();
 
198
 
 
199
private:
 
200
 
 
201
    void init();
193
202
 
194
203
    // takes a list of key=value pairs and adds them
195
204
    // to the environment for the process