~ubuntu-branches/ubuntu/saucy/konsole/saucy-proposed

« back to all changes in this revision

Viewing changes to src/Emulation.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-06-06 14:29:24 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20120606142924-1rekqv6j25lw2k41
Tags: 4:4.8.80-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#ifndef EMULATION_H
24
24
#define EMULATION_H
25
25
 
26
 
// System
27
 
#include <stdio.h>
28
 
 
29
26
// Qt
30
 
#include <QtGui/QKeyEvent>
 
27
#include <QtCore/QSize>
31
28
#include <QtCore/QTextCodec>
32
 
#include <QtCore/QTextStream>
33
29
#include <QtCore/QTimer>
34
30
 
35
31
// Konsole
36
32
#include "konsole_export.h"
37
33
 
 
34
class QKeyEvent;
 
35
 
38
36
namespace Konsole
39
37
{
40
 
 
41
38
class KeyboardTranslator;
42
39
class HistoryType;
43
40
class Screen;
50
47
 *
51
48
 * These are the values used by Emulation::stateChanged()
52
49
 */
53
 
enum 
54
 
 
50
enum {
55
51
    /** The emulation is currently receiving user input. */
56
 
    NOTIFYNORMAL=0, 
 
52
    NOTIFYNORMAL = 0,
57
53
    /**
58
54
     * The terminal program has triggered a bell event
59
55
     * to get the user's attention.
60
56
     */
61
 
    NOTIFYBELL=1, 
 
57
    NOTIFYBELL = 1,
62
58
    /**
63
59
     * The emulation is currently receiving data from its
64
60
     * terminal input.
65
61
     */
66
 
    NOTIFYACTIVITY=2,
 
62
    NOTIFYACTIVITY = 2,
67
63
 
68
 
    // unused here? 
69
 
    NOTIFYSILENCE=3 
 
64
    // unused here?
 
65
    NOTIFYSILENCE = 3
70
66
};
71
67
 
72
68
/**
120
116
 */
121
117
class KONSOLEPRIVATE_EXPORT Emulation : public QObject
122
118
{
123
 
Q_OBJECT
 
119
    Q_OBJECT
124
120
 
125
121
public:
126
 
 
127
 
   /** Constructs a new terminal emulation */
128
 
   Emulation();
129
 
  ~Emulation();
130
 
 
131
 
  /**
132
 
   * Creates a new window onto the output from this emulation.  The contents
133
 
   * of the window are then rendered by views which are set to use this window using the
134
 
   * TerminalDisplay::setScreenWindow() method.
135
 
   */
136
 
  ScreenWindow* createWindow();
137
 
 
138
 
  /** Returns the size of the screen image which the emulation produces */
139
 
  QSize imageSize() const;
140
 
 
141
 
  /**
142
 
   * Returns the total number of lines, including those stored in the history.
143
 
   */
144
 
  int lineCount() const;
145
 
 
146
 
  /**
147
 
   * Sets the history store used by this emulation.  When new lines
148
 
   * are added to the output, older lines at the top of the screen are transferred to a history
149
 
   * store.
150
 
   *
151
 
   * The number of lines which are kept and the storage location depend on the
152
 
   * type of store.
153
 
   */
154
 
  void setHistory(const HistoryType&);
155
 
  /** Returns the history store used by this emulation.  See setHistory() */
156
 
  const HistoryType& history() const;
157
 
  /** Clears the history scroll. */
158
 
  void clearHistory();
159
 
 
160
 
  /**
161
 
   * Copies the output history from @p startLine to @p endLine
162
 
   * into @p stream, using @p decoder to convert the terminal
163
 
   * characters into text.
164
 
   *
165
 
   * @param decoder A decoder which converts lines of terminal characters with
166
 
   * appearance attributes into output text.  PlainTextDecoder is the most commonly
167
 
   * used decoder.
168
 
   * @param startLine Index of first line to copy
169
 
   * @param endLine Index of last line to copy
170
 
   */
171
 
  virtual void writeToStream(TerminalCharacterDecoder* decoder,int startLine,int endLine);
172
 
 
173
 
  /** Returns the codec used to decode incoming characters.  See setCodec() */
174
 
  const QTextCodec* codec() const { return _codec; }
175
 
  /** Sets the codec used to decode incoming characters.  */
176
 
  void setCodec(const QTextCodec*);
177
 
 
178
 
  /**
179
 
   * Convenience method.
180
 
   * Returns true if the current codec used to decode incoming
181
 
   * characters is UTF-8
182
 
   */
183
 
  bool utf8() const
184
 
  { Q_ASSERT(_codec); return _codec->mibEnum() == 106; }
185
 
 
186
 
 
187
 
  /** Returns the special character used for erasing character. */
188
 
  virtual char eraseChar() const;
189
 
 
190
 
  /**
191
 
   * Sets the key bindings used to key events
192
 
   * ( received through sendKeyEvent() ) into character
193
 
   * streams to send to the terminal.
194
 
   */
195
 
  void setKeyBindings(const QString& name);
196
 
  /**
197
 
   * Returns the name of the emulation's current key bindings.
198
 
   * See setKeyBindings()
199
 
   */
200
 
  QString keyBindings() const;
201
 
 
202
 
  /**
203
 
   * Copies the current image into the history and clears the screen.
204
 
   */
205
 
  virtual void clearEntireScreen() =0;
206
 
 
207
 
  /** Resets the state of the terminal. */
208
 
  virtual void reset() =0;
209
 
 
210
 
  /**
211
 
   * Returns true if the active terminal program wants
212
 
   * mouse input events.
213
 
   *
214
 
   * The programUsesMouseChanged() signal is emitted when this
215
 
   * changes.
216
 
   */
217
 
  bool programUsesMouse() const;
 
122
    /** Constructs a new terminal emulation */
 
123
    Emulation();
 
124
    ~Emulation();
 
125
 
 
126
    /**
 
127
     * Creates a new window onto the output from this emulation.  The contents
 
128
     * of the window are then rendered by views which are set to use this window using the
 
129
     * TerminalDisplay::setScreenWindow() method.
 
130
     */
 
131
    ScreenWindow* createWindow();
 
132
 
 
133
    /** Returns the size of the screen image which the emulation produces */
 
134
    QSize imageSize() const;
 
135
 
 
136
    /**
 
137
     * Returns the total number of lines, including those stored in the history.
 
138
     */
 
139
    int lineCount() const;
 
140
 
 
141
    /**
 
142
     * Sets the history store used by this emulation.  When new lines
 
143
     * are added to the output, older lines at the top of the screen are transferred to a history
 
144
     * store.
 
145
     *
 
146
     * The number of lines which are kept and the storage location depend on the
 
147
     * type of store.
 
148
     */
 
149
    void setHistory(const HistoryType&);
 
150
    /** Returns the history store used by this emulation.  See setHistory() */
 
151
    const HistoryType& history() const;
 
152
    /** Clears the history scroll. */
 
153
    void clearHistory();
 
154
 
 
155
    /**
 
156
     * Copies the output history from @p startLine to @p endLine
 
157
     * into @p stream, using @p decoder to convert the terminal
 
158
     * characters into text.
 
159
     *
 
160
     * @param decoder A decoder which converts lines of terminal characters with
 
161
     * appearance attributes into output text.  PlainTextDecoder is the most commonly
 
162
     * used decoder.
 
163
     * @param startLine Index of first line to copy
 
164
     * @param endLine Index of last line to copy
 
165
     */
 
166
    virtual void writeToStream(TerminalCharacterDecoder* decoder, int startLine, int endLine);
 
167
 
 
168
    /** Returns the codec used to decode incoming characters.  See setCodec() */
 
169
    const QTextCodec* codec() const {
 
170
        return _codec;
 
171
    }
 
172
    /** Sets the codec used to decode incoming characters.  */
 
173
    void setCodec(const QTextCodec*);
 
174
 
 
175
    /**
 
176
     * Convenience method.
 
177
     * Returns true if the current codec used to decode incoming
 
178
     * characters is UTF-8
 
179
     */
 
180
    bool utf8() const {
 
181
        Q_ASSERT(_codec);
 
182
        return _codec->mibEnum() == 106;
 
183
    }
 
184
 
 
185
 
 
186
    /** Returns the special character used for erasing character. */
 
187
    virtual char eraseChar() const;
 
188
 
 
189
    /**
 
190
     * Sets the key bindings used to key events
 
191
     * ( received through sendKeyEvent() ) into character
 
192
     * streams to send to the terminal.
 
193
     */
 
194
    void setKeyBindings(const QString& name);
 
195
    /**
 
196
     * Returns the name of the emulation's current key bindings.
 
197
     * See setKeyBindings()
 
198
     */
 
199
    QString keyBindings() const;
 
200
 
 
201
    /**
 
202
     * Copies the current image into the history and clears the screen.
 
203
     */
 
204
    virtual void clearEntireScreen() = 0;
 
205
 
 
206
    /** Resets the state of the terminal. */
 
207
    virtual void reset() = 0;
 
208
 
 
209
    /**
 
210
     * Returns true if the active terminal program wants
 
211
     * mouse input events.
 
212
     *
 
213
     * The programUsesMouseChanged() signal is emitted when this
 
214
     * changes.
 
215
     */
 
216
    bool programUsesMouse() const;
218
217
 
219
218
public slots:
220
219
 
221
 
  /** Change the size of the emulation's image */
222
 
  virtual void setImageSize(int lines, int columns);
223
 
 
224
 
  /**
225
 
   * Interprets a sequence of characters and sends the result to the terminal.
226
 
   * This is equivalent to calling sendKeyEvent() for each character in @p text in succession.
227
 
   */
228
 
  virtual void sendText(const QString& text) = 0;
229
 
 
230
 
  /**
231
 
   * Interprets a key press event and emits the sendData() signal with
232
 
   * the resulting character stream.
233
 
   */
234
 
  virtual void sendKeyEvent(QKeyEvent*);
235
 
 
236
 
  /**
237
 
   * Converts information about a mouse event into an xterm-compatible escape
238
 
   * sequence and emits the character sequence via sendData()
239
 
   */
240
 
  virtual void sendMouseEvent(int buttons, int column, int line, int eventType);
241
 
 
242
 
  /**
243
 
   * Sends a string of characters to the foreground terminal process.
244
 
   *
245
 
   * @param string The characters to send.
246
 
   * @param length Length of @p string or if set to a negative value, @p string will
247
 
   * be treated as a null-terminated string and its length will be determined automatically.
248
 
   */
249
 
  virtual void sendString(const char* string, int length = -1) = 0;
250
 
 
251
 
  /**
252
 
   * Processes an incoming stream of characters.  receiveData() decodes the incoming
253
 
   * character buffer using the current codec(), and then calls receiveChar() for
254
 
   * each unicode character in the resulting buffer.
255
 
   *
256
 
   * receiveData() also starts a timer which causes the outputChanged() signal
257
 
   * to be emitted when it expires.  The timer allows multiple updates in quick
258
 
   * succession to be buffered into a single outputChanged() signal emission.
259
 
   *
260
 
   * @param buffer A string of characters received from the terminal program.
261
 
   * @param len The length of @p buffer
262
 
   */
263
 
  void receiveData(const char* buffer,int len);
 
220
    /** Change the size of the emulation's image */
 
221
    virtual void setImageSize(int lines, int columns);
 
222
 
 
223
    /**
 
224
     * Interprets a sequence of characters and sends the result to the terminal.
 
225
     * This is equivalent to calling sendKeyEvent() for each character in @p text in succession.
 
226
     */
 
227
    virtual void sendText(const QString& text) = 0;
 
228
 
 
229
    /**
 
230
     * Interprets a key press event and emits the sendData() signal with
 
231
     * the resulting character stream.
 
232
     */
 
233
    virtual void sendKeyEvent(QKeyEvent*);
 
234
 
 
235
    /**
 
236
     * Converts information about a mouse event into an xterm-compatible escape
 
237
     * sequence and emits the character sequence via sendData()
 
238
     */
 
239
    virtual void sendMouseEvent(int buttons, int column, int line, int eventType);
 
240
 
 
241
    /**
 
242
     * Sends a string of characters to the foreground terminal process.
 
243
     *
 
244
     * @param string The characters to send.
 
245
     * @param length Length of @p string or if set to a negative value, @p string will
 
246
     * be treated as a null-terminated string and its length will be determined automatically.
 
247
     */
 
248
    virtual void sendString(const char* string, int length = -1) = 0;
 
249
 
 
250
    /**
 
251
     * Processes an incoming stream of characters.  receiveData() decodes the incoming
 
252
     * character buffer using the current codec(), and then calls receiveChar() for
 
253
     * each unicode character in the resulting buffer.
 
254
     *
 
255
     * receiveData() also starts a timer which causes the outputChanged() signal
 
256
     * to be emitted when it expires.  The timer allows multiple updates in quick
 
257
     * succession to be buffered into a single outputChanged() signal emission.
 
258
     *
 
259
     * @param buffer A string of characters received from the terminal program.
 
260
     * @param len The length of @p buffer
 
261
     */
 
262
    void receiveData(const char* buffer, int len);
264
263
 
265
264
signals:
266
265
 
267
 
  /**
268
 
   * Emitted when a buffer of data is ready to send to the
269
 
   * standard input of the terminal.
270
 
   *
271
 
   * @param data The buffer of data ready to be sent
272
 
   * @param len The length of @p data in bytes
273
 
   */
274
 
  void sendData(const char* data,int len);
275
 
 
276
 
  /**
277
 
   * Requests that sending of input to the emulation
278
 
   * from the terminal process be suspended or resumed.
279
 
   *
280
 
   * @param suspend If true, requests that sending of
281
 
   * input from the terminal process' stdout be
282
 
   * suspended.  Otherwise requests that sending of
283
 
   * input be resumed.
284
 
   */
285
 
  void lockPtyRequest(bool suspend);
286
 
 
287
 
  /**
288
 
   * Requests that the pty used by the terminal process
289
 
   * be set to UTF 8 mode.
290
 
   *
291
 
   * Refer to the IUTF8 entry in termios(3) for more information.
292
 
   */
293
 
  void useUtf8Request(bool);
294
 
 
295
 
  /**
296
 
   * Emitted when the activity state of the emulation is set.
297
 
   *
298
 
   * @param state The new activity state, one of NOTIFYNORMAL, NOTIFYACTIVITY
299
 
   * or NOTIFYBELL
300
 
   */
301
 
  void stateSet(int state);
302
 
 
303
 
  /**
304
 
   * Emitted when the special sequence indicating the request for data
305
 
   * transmission through ZModem protocol is detected.
306
 
   */
307
 
  void zmodemDetected();
308
 
 
309
 
 
310
 
  /**
311
 
   * Requests that the color of the text used
312
 
   * to represent the tabs associated with this
313
 
   * emulation be changed.  This is a Konsole-specific
314
 
   * extension from pre-KDE 4 times.
315
 
   *
316
 
   * TODO: Document how the parameter works.
317
 
   */
318
 
  void changeTabTextColorRequest(int color);
319
 
 
320
 
  /**
321
 
   * This is emitted when the program running in the shell indicates whether or
322
 
   * not it is interested in mouse events.
323
 
   *
324
 
   * @param usesMouse This will be true if the program wants to be informed about
325
 
   * mouse events or false otherwise.
326
 
   */
327
 
  void programUsesMouseChanged(bool usesMouse);
328
 
 
329
 
  /**
330
 
   * Emitted when the contents of the screen image change.
331
 
   * The emulation buffers the updates from successive image changes,
332
 
   * and only emits outputChanged() at sensible intervals when
333
 
   * there is a lot of terminal activity.
334
 
   *
335
 
   * Normally there is no need for objects other than the screen windows
336
 
   * created with createWindow() to listen for this signal.
337
 
   *
338
 
   * ScreenWindow objects created using createWindow() will emit their
339
 
   * own outputChanged() signal in response to this signal.
340
 
   */
341
 
  void outputChanged();
342
 
 
343
 
  /**
344
 
   * Emitted when the program running in the terminal wishes to update the
345
 
   * session's title.  This also allows terminal programs to customize other
346
 
   * aspects of the terminal emulation display.
347
 
   *
348
 
   * This signal is emitted when the escape sequence "\033]ARG;VALUE\007"
349
 
   * is received in the input string, where ARG is a number specifying what
350
 
   * should change and VALUE is a string specifying the new value.
351
 
   *
352
 
   * TODO:  The name of this method is not very accurate since this method
353
 
   * is used to perform a whole range of tasks besides just setting
354
 
   * the user-title of the session.
355
 
   *
356
 
   * @param title Specifies what to change.
357
 
   * <ul>
358
 
   * <li>0 - Set window icon text and session title to @p newTitle</li>
359
 
   * <li>1 - Set window icon text to @p newTitle</li>
360
 
   * <li>2 - Set session title to @p newTitle</li>
361
 
   * <li>11 - Set the session's default background color to @p newTitle,
362
 
   *         where @p newTitle can be an HTML-style string ("#RRGGBB") or a named
363
 
   *         color (eg 'red', 'blue').
364
 
   *         See http://doc.trolltech.com/4.2/qcolor.html#setNamedColor for more
365
 
   *         details.
366
 
   * </li>
367
 
   * <li>31 - Supposedly treats @p newTitle as a URL and opens it (NOT IMPLEMENTED)</li>
368
 
   * <li>32 - Sets the icon associated with the session.  @p newTitle is the name
369
 
   *    of the icon to use, which can be the name of any icon in the current KDE icon
370
 
   *    theme (eg: 'konsole', 'kate', 'folder_home')</li>
371
 
   * </ul>
372
 
   * @param newTitle Specifies the new title
373
 
   */
374
 
 
375
 
  void titleChanged(int title,const QString& newTitle);
376
 
 
377
 
  /**
378
 
   * Emitted when the program running in the terminal changes the
379
 
   * screen size.
380
 
   */
381
 
  void imageSizeChanged(int lineCount , int columnCount);
382
 
 
383
 
  /**
384
 
   * Emitted when the setImageSize() is called on this emulation for
385
 
   * the first time.
386
 
   */
387
 
  void imageSizeInitialized();
388
 
 
389
 
  /**
390
 
   * Emitted when the terminal program requests to change various properties
391
 
   * of the terminal display.
392
 
   *
393
 
   * A profile change command occurs when a special escape sequence, followed
394
 
   * by a string containing a series of name and value pairs is received.
395
 
   * This string can be parsed using a ProfileCommandParser instance.
396
 
   *
397
 
   * @param text A string expected to contain a series of key and value pairs in
398
 
   * the form:  name=value;name2=value2 ...
399
 
   */
400
 
  void profileChangeCommandReceived(const QString& text);
401
 
 
402
 
  /**
403
 
   * Emitted when a flow control key combination ( Ctrl+S or Ctrl+Q ) is pressed.
404
 
   * @param suspendKeyPressed True if Ctrl+S was pressed to suspend output or Ctrl+Q to
405
 
   * resume output.
406
 
   */
407
 
  void flowControlKeyPressed(bool suspendKeyPressed);
408
 
 
409
 
  /**
410
 
   * Emitted when the active screen is switched, to indicate whether the primary
411
 
   * screen is in use.
412
 
   */
413
 
  void primaryScreenInUse(bool use);
414
 
 
415
 
  /**
416
 
   * Emitted when the text selection is changed
417
 
   */
418
 
  void selectedText(const QString & text);
419
 
 
 
266
    /**
 
267
     * Emitted when a buffer of data is ready to send to the
 
268
     * standard input of the terminal.
 
269
     *
 
270
     * @param data The buffer of data ready to be sent
 
271
     * @param len The length of @p data in bytes
 
272
     */
 
273
    void sendData(const char* data, int len);
 
274
 
 
275
    /**
 
276
     * Requests that the pty used by the terminal process
 
277
     * be set to UTF 8 mode.
 
278
     *
 
279
     * Refer to the IUTF8 entry in termios(3) for more information.
 
280
     */
 
281
    void useUtf8Request(bool);
 
282
 
 
283
    /**
 
284
     * Emitted when the activity state of the emulation is set.
 
285
     *
 
286
     * @param state The new activity state, one of NOTIFYNORMAL, NOTIFYACTIVITY
 
287
     * or NOTIFYBELL
 
288
     */
 
289
    void stateSet(int state);
 
290
 
 
291
    /**
 
292
     * Emitted when the special sequence indicating the request for data
 
293
     * transmission through ZModem protocol is detected.
 
294
     */
 
295
    void zmodemDetected();
 
296
 
 
297
 
 
298
    /**
 
299
     * Requests that the color of the text used
 
300
     * to represent the tabs associated with this
 
301
     * emulation be changed.  This is a Konsole-specific
 
302
     * extension from pre-KDE 4 times.
 
303
     *
 
304
     * TODO: Document how the parameter works.
 
305
     */
 
306
    void changeTabTextColorRequest(int color);
 
307
 
 
308
    /**
 
309
     * This is emitted when the program running in the shell indicates whether or
 
310
     * not it is interested in mouse events.
 
311
     *
 
312
     * @param usesMouse This will be true if the program wants to be informed about
 
313
     * mouse events or false otherwise.
 
314
     */
 
315
    void programUsesMouseChanged(bool usesMouse);
 
316
 
 
317
    /**
 
318
     * Emitted when the contents of the screen image change.
 
319
     * The emulation buffers the updates from successive image changes,
 
320
     * and only emits outputChanged() at sensible intervals when
 
321
     * there is a lot of terminal activity.
 
322
     *
 
323
     * Normally there is no need for objects other than the screen windows
 
324
     * created with createWindow() to listen for this signal.
 
325
     *
 
326
     * ScreenWindow objects created using createWindow() will emit their
 
327
     * own outputChanged() signal in response to this signal.
 
328
     */
 
329
    void outputChanged();
 
330
 
 
331
    /**
 
332
     * Emitted when the program running in the terminal wishes to update the
 
333
     * session's title.  This also allows terminal programs to customize other
 
334
     * aspects of the terminal emulation display.
 
335
     *
 
336
     * This signal is emitted when the escape sequence "\033]ARG;VALUE\007"
 
337
     * is received in the input string, where ARG is a number specifying what
 
338
     * should change and VALUE is a string specifying the new value.
 
339
     *
 
340
     * TODO:  The name of this method is not very accurate since this method
 
341
     * is used to perform a whole range of tasks besides just setting
 
342
     * the user-title of the session.
 
343
     *
 
344
     * @param title Specifies what to change.
 
345
     * <ul>
 
346
     * <li>0 - Set window icon text and session title to @p newTitle</li>
 
347
     * <li>1 - Set window icon text to @p newTitle</li>
 
348
     * <li>2 - Set session title to @p newTitle</li>
 
349
     * <li>11 - Set the session's default background color to @p newTitle,
 
350
     *         where @p newTitle can be an HTML-style string ("#RRGGBB") or a named
 
351
     *         color (eg 'red', 'blue').
 
352
     *         See http://doc.trolltech.com/4.2/qcolor.html#setNamedColor for more
 
353
     *         details.
 
354
     * </li>
 
355
     * <li>31 - Supposedly treats @p newTitle as a URL and opens it (NOT IMPLEMENTED)</li>
 
356
     * <li>32 - Sets the icon associated with the session.  @p newTitle is the name
 
357
     *    of the icon to use, which can be the name of any icon in the current KDE icon
 
358
     *    theme (eg: 'konsole', 'kate', 'folder_home')</li>
 
359
     * </ul>
 
360
     * @param newTitle Specifies the new title
 
361
     */
 
362
 
 
363
    void titleChanged(int title, const QString& newTitle);
 
364
 
 
365
    /**
 
366
     * Emitted when the terminal emualtor's size has changed
 
367
     */
 
368
    void imageSizeChanged(int lineCount , int columnCount);
 
369
 
 
370
    /**
 
371
     * Emitted when the setImageSize() is called on this emulation for
 
372
     * the first time.
 
373
     */
 
374
    void imageSizeInitialized();
 
375
 
 
376
    /**
 
377
     * Emitted after receiving the escape sequence which asks to change
 
378
     * the terminal emulator's size
 
379
     */
 
380
    void imageResizeRequest(const QSize& sizz);
 
381
 
 
382
    /**
 
383
     * Emitted when the terminal program requests to change various properties
 
384
     * of the terminal display.
 
385
     *
 
386
     * A profile change command occurs when a special escape sequence, followed
 
387
     * by a string containing a series of name and value pairs is received.
 
388
     * This string can be parsed using a ProfileCommandParser instance.
 
389
     *
 
390
     * @param text A string expected to contain a series of key and value pairs in
 
391
     * the form:  name=value;name2=value2 ...
 
392
     */
 
393
    void profileChangeCommandReceived(const QString& text);
 
394
 
 
395
    /**
 
396
     * Emitted when a flow control key combination ( Ctrl+S or Ctrl+Q ) is pressed.
 
397
     * @param suspendKeyPressed True if Ctrl+S was pressed to suspend output or Ctrl+Q to
 
398
     * resume output.
 
399
     */
 
400
    void flowControlKeyPressed(bool suspendKeyPressed);
 
401
 
 
402
    /**
 
403
     * Emitted when the active screen is switched, to indicate whether the primary
 
404
     * screen is in use.
 
405
     */
 
406
    void primaryScreenInUse(bool use);
 
407
 
 
408
    /**
 
409
     * Emitted when the text selection is changed
 
410
     */
 
411
    void selectionChanged(const QString& text);
420
412
 
421
413
protected:
422
 
  virtual void setMode(int mode) = 0;
423
 
  virtual void resetMode(int mode) = 0;
424
 
 
425
 
  /**
426
 
   * Processes an incoming character.  See receiveData()
427
 
   * @p ch A unicode character code.
428
 
   */
429
 
  virtual void receiveChar(int ch);
430
 
 
431
 
  /**
432
 
   * Sets the active screen.  The terminal has two screens, primary and alternate.
433
 
   * The primary screen is used by default.  When certain interactive programs such
434
 
   * as Vim are run, they trigger a switch to the alternate screen.
435
 
   *
436
 
   * @param index 0 to switch to the primary screen, or 1 to switch to the alternate screen
437
 
   */
438
 
  void setScreen(int index); 
439
 
 
440
 
  enum EmulationCodec
441
 
  {
442
 
      LocaleCodec = 0,
443
 
      Utf8Codec   = 1
444
 
  };
445
 
  void setCodec(EmulationCodec codec); // codec number, 0 = locale, 1=utf8
446
 
 
447
 
 
448
 
  QList<ScreenWindow*> _windows;
449
 
 
450
 
  Screen* _currentScreen;  // pointer to the screen which is currently active,
451
 
                            // this is one of the elements in the screen[] array
452
 
 
453
 
  Screen* _screen[2];      // 0 = primary screen ( used by most programs, including the shell
454
 
                            //                      scrollbars are enabled in this mode )
455
 
                            // 1 = alternate      ( used by vi , emacs etc.
456
 
                            //                      scrollbars are not enabled in this mode )
457
 
 
458
 
 
459
 
  //decodes an incoming C-style character stream into a unicode QString using
460
 
  //the current text codec.  (this allows for rendering of non-ASCII characters in text files etc.)
461
 
  const QTextCodec* _codec;
462
 
  QTextDecoder* _decoder;
463
 
  const KeyboardTranslator* _keyTranslator; // the keyboard layout
 
414
    virtual void setMode(int mode) = 0;
 
415
    virtual void resetMode(int mode) = 0;
 
416
 
 
417
    /**
 
418
     * Processes an incoming character.  See receiveData()
 
419
     * @p ch A unicode character code.
 
420
     */
 
421
    virtual void receiveChar(int ch);
 
422
 
 
423
    /**
 
424
     * Sets the active screen.  The terminal has two screens, primary and alternate.
 
425
     * The primary screen is used by default.  When certain interactive programs such
 
426
     * as Vim are run, they trigger a switch to the alternate screen.
 
427
     *
 
428
     * @param index 0 to switch to the primary screen, or 1 to switch to the alternate screen
 
429
     */
 
430
    void setScreen(int index);
 
431
 
 
432
    enum EmulationCodec {
 
433
        LocaleCodec = 0,
 
434
        Utf8Codec   = 1
 
435
    };
 
436
 
 
437
    void setCodec(EmulationCodec codec);
 
438
 
 
439
    QList<ScreenWindow*> _windows;
 
440
 
 
441
    Screen* _currentScreen;  // pointer to the screen which is currently active,
 
442
    // this is one of the elements in the screen[] array
 
443
 
 
444
    Screen* _screen[2];      // 0 = primary screen ( used by most programs, including the shell
 
445
    //                      scrollbars are enabled in this mode )
 
446
    // 1 = alternate      ( used by vi , emacs etc.
 
447
    //                      scrollbars are not enabled in this mode )
 
448
 
 
449
 
 
450
    //decodes an incoming C-style character stream into a unicode QString using
 
451
    //the current text codec.  (this allows for rendering of non-ASCII characters in text files etc.)
 
452
    const QTextCodec* _codec;
 
453
    QTextDecoder* _decoder;
 
454
    const KeyboardTranslator* _keyTranslator; // the keyboard layout
464
455
 
465
456
protected slots:
466
 
  /**
467
 
   * Schedules an update of attached views.
468
 
   * Repeated calls to bufferedUpdate() in close succession will result in only a single update,
469
 
   * much like the Qt buffered update of widgets.
470
 
   */
471
 
  void bufferedUpdate();
472
 
 
473
 
  // used to emit the primaryScreenInUse(bool) signal
474
 
  void checkScreenInUse();
475
 
 
476
 
  // used to emit the selectedText(QString) signal
477
 
  void checkSelectedText();
 
457
    /**
 
458
     * Schedules an update of attached views.
 
459
     * Repeated calls to bufferedUpdate() in close succession will result in only a single update,
 
460
     * much like the Qt buffered update of widgets.
 
461
     */
 
462
    void bufferedUpdate();
 
463
 
 
464
    // used to emit the primaryScreenInUse(bool) signal
 
465
    void checkScreenInUse();
 
466
 
 
467
    // used to emit the selectionChanged(QString) signal
 
468
    void checkSelectedText();
478
469
 
479
470
private slots:
480
 
 
481
 
  // triggered by timer, causes the emulation to send an updated screen image to each
482
 
  // view
483
 
  void showBulk(); 
484
 
 
485
 
  void usesMouseChanged(bool usesMouse);
 
471
    // triggered by timer, causes the emulation to send an updated screen image to each
 
472
    // view
 
473
    void showBulk();
 
474
 
 
475
    void usesMouseChanged(bool usesMouse);
486
476
 
487
477
private:
488
 
  bool _usesMouse;
489
 
  QTimer _bulkTimer1;
490
 
  QTimer _bulkTimer2;
491
 
  bool _imageSizeInitialized;
492
 
 
 
478
    bool _usesMouse;
 
479
    QTimer _bulkTimer1;
 
480
    QTimer _bulkTimer2;
 
481
    bool _imageSizeInitialized;
493
482
};
494
 
 
495
483
}
496
484
 
497
485
#endif // ifndef EMULATION_H