[45157b3] | 1 | /* |
---|
| 2 | This file is part of Konsole, an X terminal. |
---|
| 3 | |
---|
[64efc22] | 4 | Copyright 2007-2008 by Robert Knight <robertknight@gmail.com> |
---|
| 5 | Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de> |
---|
[45157b3] | 6 | |
---|
| 7 | This program is free software; you can redistribute it and/or modify |
---|
| 8 | it under the terms of the GNU General Public License as published by |
---|
| 9 | the Free Software Foundation; either version 2 of the License, or |
---|
| 10 | (at your option) any later version. |
---|
| 11 | |
---|
| 12 | This program is distributed in the hope that it will be useful, |
---|
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 15 | GNU General Public License for more details. |
---|
| 16 | |
---|
| 17 | You should have received a copy of the GNU General Public License |
---|
| 18 | along with this program; if not, write to the Free Software |
---|
| 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
| 20 | 02110-1301 USA. |
---|
| 21 | */ |
---|
| 22 | |
---|
| 23 | #ifndef EMULATION_H |
---|
| 24 | #define EMULATION_H |
---|
| 25 | |
---|
| 26 | // System |
---|
[64efc22] | 27 | #include <cstdio> |
---|
[45157b3] | 28 | |
---|
[64efc22] | 29 | // Qt |
---|
| 30 | #include <QKeyEvent> |
---|
[45157b3] | 31 | //#include <QPointer> |
---|
[64efc22] | 32 | #include <QTextCodec> |
---|
| 33 | #include <QTextStream> |
---|
| 34 | #include <QTimer> |
---|
[45157b3] | 35 | |
---|
[64efc22] | 36 | #include "qtermwidget_export.h" |
---|
| 37 | #include "KeyboardTranslator.h" |
---|
[45157b3] | 38 | |
---|
| 39 | namespace Konsole |
---|
| 40 | { |
---|
| 41 | |
---|
| 42 | class HistoryType; |
---|
| 43 | class Screen; |
---|
| 44 | class ScreenWindow; |
---|
| 45 | class TerminalCharacterDecoder; |
---|
| 46 | |
---|
[64efc22] | 47 | /** |
---|
| 48 | * This enum describes the available states which |
---|
[45157b3] | 49 | * the terminal emulation may be set to. |
---|
| 50 | * |
---|
[64efc22] | 51 | * These are the values used by Emulation::stateChanged() |
---|
[45157b3] | 52 | */ |
---|
[64efc22] | 53 | enum |
---|
| 54 | { |
---|
[45157b3] | 55 | /** The emulation is currently receiving user input. */ |
---|
[64efc22] | 56 | NOTIFYNORMAL=0, |
---|
| 57 | /** |
---|
[45157b3] | 58 | * The terminal program has triggered a bell event |
---|
| 59 | * to get the user's attention. |
---|
| 60 | */ |
---|
[64efc22] | 61 | NOTIFYBELL=1, |
---|
| 62 | /** |
---|
| 63 | * The emulation is currently receiving data from its |
---|
[45157b3] | 64 | * terminal input. |
---|
| 65 | */ |
---|
| 66 | NOTIFYACTIVITY=2, |
---|
| 67 | |
---|
[64efc22] | 68 | // unused here? |
---|
| 69 | NOTIFYSILENCE=3 |
---|
[45157b3] | 70 | }; |
---|
| 71 | |
---|
| 72 | /** |
---|
| 73 | * Base class for terminal emulation back-ends. |
---|
| 74 | * |
---|
[64efc22] | 75 | * The back-end is responsible for decoding an incoming character stream and |
---|
[45157b3] | 76 | * producing an output image of characters. |
---|
| 77 | * |
---|
| 78 | * When input from the terminal is received, the receiveData() slot should be called with |
---|
[64efc22] | 79 | * the data which has arrived. The emulation will process the data and update the |
---|
[45157b3] | 80 | * screen image accordingly. The codec used to decode the incoming character stream |
---|
[64efc22] | 81 | * into the unicode characters used internally can be specified using setCodec() |
---|
[45157b3] | 82 | * |
---|
[64efc22] | 83 | * The size of the screen image can be specified by calling setImageSize() with the |
---|
[45157b3] | 84 | * desired number of lines and columns. When new lines are added, old content |
---|
[64efc22] | 85 | * is moved into a history store, which can be set by calling setHistory(). |
---|
[45157b3] | 86 | * |
---|
[64efc22] | 87 | * The screen image can be accessed by creating a ScreenWindow onto this emulation |
---|
| 88 | * by calling createWindow(). Screen windows provide access to a section of the |
---|
| 89 | * output. Each screen window covers the same number of lines and columns as the |
---|
[45157b3] | 90 | * image size returned by imageSize(). The screen window can be moved up and down |
---|
[64efc22] | 91 | * and provides transparent access to both the current on-screen image and the |
---|
[45157b3] | 92 | * previous output. The screen windows emit an outputChanged signal |
---|
| 93 | * when the section of the image they are looking at changes. |
---|
| 94 | * Graphical views can then render the contents of a screen window, listening for notifications |
---|
[64efc22] | 95 | * of output changes from the screen window which they are associated with and updating |
---|
| 96 | * accordingly. |
---|
[45157b3] | 97 | * |
---|
| 98 | * The emulation also is also responsible for converting input from the connected views such |
---|
| 99 | * as keypresses and mouse activity into a character string which can be sent |
---|
| 100 | * to the terminal program. Key presses can be processed by calling the sendKeyEvent() slot, |
---|
| 101 | * while mouse events can be processed using the sendMouseEvent() slot. When the character |
---|
| 102 | * stream has been produced, the emulation will emit a sendData() signal with a pointer |
---|
| 103 | * to the character buffer. This data should be fed to the standard input of the terminal |
---|
| 104 | * process. The translation of key presses into an output character stream is performed |
---|
| 105 | * using a lookup in a set of key bindings which map key sequences to output |
---|
| 106 | * character sequences. The name of the key bindings set used can be specified using |
---|
| 107 | * setKeyBindings() |
---|
| 108 | * |
---|
[64efc22] | 109 | * The emulation maintains certain state information which changes depending on the |
---|
| 110 | * input received. The emulation can be reset back to its starting state by calling |
---|
| 111 | * reset(). |
---|
[45157b3] | 112 | * |
---|
| 113 | * The emulation also maintains an activity state, which specifies whether |
---|
| 114 | * terminal is currently active ( when data is received ), normal |
---|
| 115 | * ( when the terminal is idle or receiving user input ) or trying |
---|
| 116 | * to alert the user ( also known as a "Bell" event ). The stateSet() signal |
---|
| 117 | * is emitted whenever the activity state is set. This can be used to determine |
---|
| 118 | * how long the emulation has been active/idle for and also respond to |
---|
| 119 | * a 'bell' event in different ways. |
---|
| 120 | */ |
---|
[64efc22] | 121 | class QTERMWIDGET_EXPORT Emulation : public QObject |
---|
| 122 | { |
---|
[45157b3] | 123 | Q_OBJECT |
---|
| 124 | |
---|
| 125 | public: |
---|
[64efc22] | 126 | |
---|
| 127 | /** |
---|
| 128 | * This enum describes the available shapes for the keyboard cursor. |
---|
| 129 | * See setKeyboardCursorShape() |
---|
| 130 | */ |
---|
| 131 | enum class KeyboardCursorShape { |
---|
| 132 | /** A rectangular block which covers the entire area of the cursor character. */ |
---|
| 133 | BlockCursor = 0, |
---|
| 134 | /** |
---|
| 135 | * A single flat line which occupies the space at the bottom of the cursor |
---|
| 136 | * character's area. |
---|
| 137 | */ |
---|
| 138 | UnderlineCursor = 1, |
---|
| 139 | /** |
---|
| 140 | * An cursor shaped like the capital letter 'I', similar to the IBeam |
---|
| 141 | * cursor used in Qt/KDE text editors. |
---|
| 142 | */ |
---|
| 143 | IBeamCursor = 2 |
---|
| 144 | }; |
---|
| 145 | |
---|
| 146 | |
---|
| 147 | /** Constructs a new terminal emulation */ |
---|
[45157b3] | 148 | Emulation(); |
---|
[64efc22] | 149 | ~Emulation() override; |
---|
[45157b3] | 150 | |
---|
| 151 | /** |
---|
| 152 | * Creates a new window onto the output from this emulation. The contents |
---|
| 153 | * of the window are then rendered by views which are set to use this window using the |
---|
| 154 | * TerminalDisplay::setScreenWindow() method. |
---|
| 155 | */ |
---|
| 156 | ScreenWindow* createWindow(); |
---|
| 157 | |
---|
| 158 | /** Returns the size of the screen image which the emulation produces */ |
---|
[64efc22] | 159 | QSize imageSize() const; |
---|
[45157b3] | 160 | |
---|
| 161 | /** |
---|
| 162 | * Returns the total number of lines, including those stored in the history. |
---|
[64efc22] | 163 | */ |
---|
| 164 | int lineCount() const; |
---|
[45157b3] | 165 | |
---|
[64efc22] | 166 | /** |
---|
[45157b3] | 167 | * Sets the history store used by this emulation. When new lines |
---|
| 168 | * are added to the output, older lines at the top of the screen are transferred to a history |
---|
[64efc22] | 169 | * store. |
---|
[45157b3] | 170 | * |
---|
[64efc22] | 171 | * The number of lines which are kept and the storage location depend on the |
---|
[45157b3] | 172 | * type of store. |
---|
| 173 | */ |
---|
| 174 | void setHistory(const HistoryType&); |
---|
| 175 | /** Returns the history store used by this emulation. See setHistory() */ |
---|
[64efc22] | 176 | const HistoryType& history() const; |
---|
[45157b3] | 177 | /** Clears the history scroll. */ |
---|
| 178 | void clearHistory(); |
---|
| 179 | |
---|
[64efc22] | 180 | /** |
---|
| 181 | * Copies the output history from @p startLine to @p endLine |
---|
[45157b3] | 182 | * into @p stream, using @p decoder to convert the terminal |
---|
[64efc22] | 183 | * characters into text. |
---|
[45157b3] | 184 | * |
---|
[64efc22] | 185 | * @param decoder A decoder which converts lines of terminal characters with |
---|
[45157b3] | 186 | * appearance attributes into output text. PlainTextDecoder is the most commonly |
---|
| 187 | * used decoder. |
---|
[64efc22] | 188 | * @param startLine Index of first line to copy |
---|
| 189 | * @param endLine Index of last line to copy |
---|
[45157b3] | 190 | */ |
---|
| 191 | virtual void writeToStream(TerminalCharacterDecoder* decoder,int startLine,int endLine); |
---|
[64efc22] | 192 | |
---|
[45157b3] | 193 | /** Returns the codec used to decode incoming characters. See setCodec() */ |
---|
[64efc22] | 194 | const QTextCodec* codec() const { return _codec; } |
---|
[45157b3] | 195 | /** Sets the codec used to decode incoming characters. */ |
---|
| 196 | void setCodec(const QTextCodec*); |
---|
| 197 | |
---|
[64efc22] | 198 | /** |
---|
| 199 | * Convenience method. |
---|
[45157b3] | 200 | * Returns true if the current codec used to decode incoming |
---|
| 201 | * characters is UTF-8 |
---|
| 202 | */ |
---|
[64efc22] | 203 | bool utf8() const |
---|
| 204 | { Q_ASSERT(_codec); return _codec->mibEnum() == 106; } |
---|
| 205 | |
---|
[45157b3] | 206 | |
---|
| 207 | /** TODO Document me */ |
---|
[64efc22] | 208 | virtual char eraseChar() const; |
---|
[45157b3] | 209 | |
---|
[64efc22] | 210 | /** |
---|
[45157b3] | 211 | * Sets the key bindings used to key events |
---|
| 212 | * ( received through sendKeyEvent() ) into character |
---|
| 213 | * streams to send to the terminal. |
---|
| 214 | */ |
---|
| 215 | void setKeyBindings(const QString& name); |
---|
[64efc22] | 216 | /** |
---|
[45157b3] | 217 | * Returns the name of the emulation's current key bindings. |
---|
| 218 | * See setKeyBindings() |
---|
| 219 | */ |
---|
[64efc22] | 220 | QString keyBindings() const; |
---|
[45157b3] | 221 | |
---|
[64efc22] | 222 | /** |
---|
[45157b3] | 223 | * Copies the current image into the history and clears the screen. |
---|
| 224 | */ |
---|
| 225 | virtual void clearEntireScreen() =0; |
---|
| 226 | |
---|
| 227 | /** Resets the state of the terminal. */ |
---|
| 228 | virtual void reset() =0; |
---|
| 229 | |
---|
[64efc22] | 230 | /** |
---|
[45157b3] | 231 | * Returns true if the active terminal program wants |
---|
| 232 | * mouse input events. |
---|
| 233 | * |
---|
| 234 | * The programUsesMouseChanged() signal is emitted when this |
---|
| 235 | * changes. |
---|
| 236 | */ |
---|
| 237 | bool programUsesMouse() const; |
---|
| 238 | |
---|
[64efc22] | 239 | bool programBracketedPasteMode() const; |
---|
| 240 | |
---|
| 241 | public slots: |
---|
[45157b3] | 242 | |
---|
| 243 | /** Change the size of the emulation's image */ |
---|
| 244 | virtual void setImageSize(int lines, int columns); |
---|
[64efc22] | 245 | |
---|
| 246 | /** |
---|
[45157b3] | 247 | * Interprets a sequence of characters and sends the result to the terminal. |
---|
| 248 | * This is equivalent to calling sendKeyEvent() for each character in @p text in succession. |
---|
| 249 | */ |
---|
| 250 | virtual void sendText(const QString& text) = 0; |
---|
| 251 | |
---|
[64efc22] | 252 | /** |
---|
[45157b3] | 253 | * Interprets a key press event and emits the sendData() signal with |
---|
[64efc22] | 254 | * the resulting character stream. |
---|
[45157b3] | 255 | */ |
---|
[64efc22] | 256 | virtual void sendKeyEvent(QKeyEvent*, bool fromPaste); |
---|
| 257 | |
---|
| 258 | /** |
---|
[45157b3] | 259 | * Converts information about a mouse event into an xterm-compatible escape |
---|
| 260 | * sequence and emits the character sequence via sendData() |
---|
| 261 | */ |
---|
| 262 | virtual void sendMouseEvent(int buttons, int column, int line, int eventType); |
---|
[64efc22] | 263 | |
---|
[45157b3] | 264 | /** |
---|
[64efc22] | 265 | * Sends a string of characters to the foreground terminal process. |
---|
[45157b3] | 266 | * |
---|
[64efc22] | 267 | * @param string The characters to send. |
---|
[45157b3] | 268 | * @param length Length of @p string or if set to a negative value, @p string will |
---|
| 269 | * be treated as a null-terminated string and its length will be determined automatically. |
---|
| 270 | */ |
---|
| 271 | virtual void sendString(const char* string, int length = -1) = 0; |
---|
| 272 | |
---|
[64efc22] | 273 | /** |
---|
[45157b3] | 274 | * Processes an incoming stream of characters. receiveData() decodes the incoming |
---|
| 275 | * character buffer using the current codec(), and then calls receiveChar() for |
---|
[64efc22] | 276 | * each unicode character in the resulting buffer. |
---|
[45157b3] | 277 | * |
---|
| 278 | * receiveData() also starts a timer which causes the outputChanged() signal |
---|
| 279 | * to be emitted when it expires. The timer allows multiple updates in quick |
---|
| 280 | * succession to be buffered into a single outputChanged() signal emission. |
---|
| 281 | * |
---|
| 282 | * @param buffer A string of characters received from the terminal program. |
---|
| 283 | * @param len The length of @p buffer |
---|
| 284 | */ |
---|
| 285 | void receiveData(const char* buffer,int len); |
---|
| 286 | |
---|
| 287 | signals: |
---|
| 288 | |
---|
[64efc22] | 289 | /** |
---|
| 290 | * Emitted when a buffer of data is ready to send to the |
---|
[45157b3] | 291 | * standard input of the terminal. |
---|
| 292 | * |
---|
| 293 | * @param data The buffer of data ready to be sent |
---|
[64efc22] | 294 | * @param len The length of @p data in bytes |
---|
[45157b3] | 295 | */ |
---|
| 296 | void sendData(const char* data,int len); |
---|
| 297 | |
---|
[64efc22] | 298 | /** |
---|
[45157b3] | 299 | * Requests that sending of input to the emulation |
---|
| 300 | * from the terminal process be suspended or resumed. |
---|
| 301 | * |
---|
[64efc22] | 302 | * @param suspend If true, requests that sending of |
---|
| 303 | * input from the terminal process' stdout be |
---|
[45157b3] | 304 | * suspended. Otherwise requests that sending of |
---|
[64efc22] | 305 | * input be resumed. |
---|
[45157b3] | 306 | */ |
---|
| 307 | void lockPtyRequest(bool suspend); |
---|
| 308 | |
---|
| 309 | /** |
---|
| 310 | * Requests that the pty used by the terminal process |
---|
[64efc22] | 311 | * be set to UTF 8 mode. |
---|
[45157b3] | 312 | * |
---|
| 313 | * TODO: More documentation |
---|
| 314 | */ |
---|
| 315 | void useUtf8Request(bool); |
---|
| 316 | |
---|
| 317 | /** |
---|
| 318 | * Emitted when the activity state of the emulation is set. |
---|
| 319 | * |
---|
| 320 | * @param state The new activity state, one of NOTIFYNORMAL, NOTIFYACTIVITY |
---|
| 321 | * or NOTIFYBELL |
---|
| 322 | */ |
---|
| 323 | void stateSet(int state); |
---|
| 324 | |
---|
| 325 | /** TODO Document me */ |
---|
| 326 | void zmodemDetected(); |
---|
| 327 | |
---|
| 328 | |
---|
| 329 | /** |
---|
| 330 | * Requests that the color of the text used |
---|
| 331 | * to represent the tabs associated with this |
---|
| 332 | * emulation be changed. This is a Konsole-specific |
---|
| 333 | * extension from pre-KDE 4 times. |
---|
| 334 | * |
---|
| 335 | * TODO: Document how the parameter works. |
---|
| 336 | */ |
---|
| 337 | void changeTabTextColorRequest(int color); |
---|
| 338 | |
---|
[64efc22] | 339 | /** |
---|
[45157b3] | 340 | * This is emitted when the program running in the shell indicates whether or |
---|
| 341 | * not it is interested in mouse events. |
---|
| 342 | * |
---|
| 343 | * @param usesMouse This will be true if the program wants to be informed about |
---|
| 344 | * mouse events or false otherwise. |
---|
| 345 | */ |
---|
| 346 | void programUsesMouseChanged(bool usesMouse); |
---|
| 347 | |
---|
[64efc22] | 348 | void programBracketedPasteModeChanged(bool bracketedPasteMode); |
---|
| 349 | |
---|
| 350 | /** |
---|
[45157b3] | 351 | * Emitted when the contents of the screen image change. |
---|
| 352 | * The emulation buffers the updates from successive image changes, |
---|
| 353 | * and only emits outputChanged() at sensible intervals when |
---|
| 354 | * there is a lot of terminal activity. |
---|
| 355 | * |
---|
| 356 | * Normally there is no need for objects other than the screen windows |
---|
| 357 | * created with createWindow() to listen for this signal. |
---|
| 358 | * |
---|
| 359 | * ScreenWindow objects created using createWindow() will emit their |
---|
[64efc22] | 360 | * own outputChanged() signal in response to this signal. |
---|
[45157b3] | 361 | */ |
---|
| 362 | void outputChanged(); |
---|
| 363 | |
---|
| 364 | /** |
---|
[64efc22] | 365 | * Emitted when the program running in the terminal wishes to update the |
---|
[45157b3] | 366 | * session's title. This also allows terminal programs to customize other |
---|
[64efc22] | 367 | * aspects of the terminal emulation display. |
---|
[45157b3] | 368 | * |
---|
| 369 | * This signal is emitted when the escape sequence "\033]ARG;VALUE\007" |
---|
| 370 | * is received in the input string, where ARG is a number specifying what |
---|
| 371 | * should change and VALUE is a string specifying the new value. |
---|
| 372 | * |
---|
| 373 | * TODO: The name of this method is not very accurate since this method |
---|
| 374 | * is used to perform a whole range of tasks besides just setting |
---|
[64efc22] | 375 | * the user-title of the session. |
---|
[45157b3] | 376 | * |
---|
| 377 | * @param title Specifies what to change. |
---|
| 378 | * <ul> |
---|
| 379 | * <li>0 - Set window icon text and session title to @p newTitle</li> |
---|
| 380 | * <li>1 - Set window icon text to @p newTitle</li> |
---|
| 381 | * <li>2 - Set session title to @p newTitle</li> |
---|
| 382 | * <li>11 - Set the session's default background color to @p newTitle, |
---|
[64efc22] | 383 | * where @p newTitle can be an HTML-style string ("#RRGGBB") or a named |
---|
| 384 | * color (eg 'red', 'blue'). |
---|
[45157b3] | 385 | * See http://doc.trolltech.com/4.2/qcolor.html#setNamedColor for more |
---|
| 386 | * details. |
---|
| 387 | * </li> |
---|
| 388 | * <li>31 - Supposedly treats @p newTitle as a URL and opens it (NOT IMPLEMENTED)</li> |
---|
[64efc22] | 389 | * <li>32 - Sets the icon associated with the session. @p newTitle is the name |
---|
[45157b3] | 390 | * of the icon to use, which can be the name of any icon in the current KDE icon |
---|
| 391 | * theme (eg: 'konsole', 'kate', 'folder_home')</li> |
---|
| 392 | * </ul> |
---|
[64efc22] | 393 | * @param newTitle Specifies the new title |
---|
[45157b3] | 394 | */ |
---|
| 395 | |
---|
| 396 | void titleChanged(int title,const QString& newTitle); |
---|
| 397 | |
---|
| 398 | /** |
---|
| 399 | * Emitted when the program running in the terminal changes the |
---|
| 400 | * screen size. |
---|
| 401 | */ |
---|
| 402 | void imageSizeChanged(int lineCount , int columnCount); |
---|
| 403 | |
---|
[64efc22] | 404 | /** |
---|
| 405 | * Emitted when the setImageSize() is called on this emulation for |
---|
| 406 | * the first time. |
---|
| 407 | */ |
---|
| 408 | void imageSizeInitialized(); |
---|
| 409 | |
---|
| 410 | /** |
---|
| 411 | * Emitted after receiving the escape sequence which asks to change |
---|
| 412 | * the terminal emulator's size |
---|
| 413 | */ |
---|
| 414 | void imageResizeRequest(const QSize& sizz); |
---|
| 415 | |
---|
| 416 | /** |
---|
[45157b3] | 417 | * Emitted when the terminal program requests to change various properties |
---|
[64efc22] | 418 | * of the terminal display. |
---|
[45157b3] | 419 | * |
---|
| 420 | * A profile change command occurs when a special escape sequence, followed |
---|
| 421 | * by a string containing a series of name and value pairs is received. |
---|
| 422 | * This string can be parsed using a ProfileCommandParser instance. |
---|
| 423 | * |
---|
| 424 | * @param text A string expected to contain a series of key and value pairs in |
---|
| 425 | * the form: name=value;name2=value2 ... |
---|
| 426 | */ |
---|
| 427 | void profileChangeCommandReceived(const QString& text); |
---|
| 428 | |
---|
[64efc22] | 429 | /** |
---|
| 430 | * Emitted when a flow control key combination ( Ctrl+S or Ctrl+Q ) is pressed. |
---|
| 431 | * @param suspendKeyPressed True if Ctrl+S was pressed to suspend output or Ctrl+Q to |
---|
| 432 | * resume output. |
---|
| 433 | */ |
---|
| 434 | void flowControlKeyPressed(bool suspendKeyPressed); |
---|
| 435 | |
---|
| 436 | /** |
---|
| 437 | * Emitted when the cursor shape or its blinking state is changed via |
---|
| 438 | * DECSCUSR sequences. |
---|
| 439 | * |
---|
| 440 | * @param cursorShape One of 3 possible values in KeyboardCursorShape enum |
---|
| 441 | * @param blinkingCursorEnabled Whether to enable blinking or not |
---|
| 442 | */ |
---|
| 443 | void cursorChanged(KeyboardCursorShape cursorShape, bool blinkingCursorEnabled); |
---|
| 444 | |
---|
| 445 | void handleCommandFromKeyboard(KeyboardTranslator::Command command); |
---|
| 446 | void outputFromKeypressEvent(void); |
---|
| 447 | |
---|
[45157b3] | 448 | protected: |
---|
[64efc22] | 449 | virtual void setMode(int mode) = 0; |
---|
[45157b3] | 450 | virtual void resetMode(int mode) = 0; |
---|
[64efc22] | 451 | |
---|
| 452 | /** |
---|
[45157b3] | 453 | * Processes an incoming character. See receiveData() |
---|
[64efc22] | 454 | * @p ch A unicode character code. |
---|
[45157b3] | 455 | */ |
---|
[64efc22] | 456 | virtual void receiveChar(wchar_t ch); |
---|
[45157b3] | 457 | |
---|
[64efc22] | 458 | /** |
---|
[45157b3] | 459 | * Sets the active screen. The terminal has two screens, primary and alternate. |
---|
| 460 | * The primary screen is used by default. When certain interactive programs such |
---|
| 461 | * as Vim are run, they trigger a switch to the alternate screen. |
---|
| 462 | * |
---|
| 463 | * @param index 0 to switch to the primary screen, or 1 to switch to the alternate screen |
---|
| 464 | */ |
---|
[64efc22] | 465 | void setScreen(int index); |
---|
[45157b3] | 466 | |
---|
| 467 | enum EmulationCodec |
---|
| 468 | { |
---|
| 469 | LocaleCodec = 0, |
---|
| 470 | Utf8Codec = 1 |
---|
| 471 | }; |
---|
| 472 | void setCodec(EmulationCodec codec); // codec number, 0 = locale, 1=utf8 |
---|
| 473 | |
---|
| 474 | |
---|
| 475 | QList<ScreenWindow*> _windows; |
---|
[64efc22] | 476 | |
---|
| 477 | Screen* _currentScreen; // pointer to the screen which is currently active, |
---|
[45157b3] | 478 | // this is one of the elements in the screen[] array |
---|
| 479 | |
---|
| 480 | Screen* _screen[2]; // 0 = primary screen ( used by most programs, including the shell |
---|
| 481 | // scrollbars are enabled in this mode ) |
---|
| 482 | // 1 = alternate ( used by vi , emacs etc. |
---|
| 483 | // scrollbars are not enabled in this mode ) |
---|
[64efc22] | 484 | |
---|
| 485 | |
---|
| 486 | //decodes an incoming C-style character stream into a unicode QString using |
---|
[45157b3] | 487 | //the current text codec. (this allows for rendering of non-ASCII characters in text files etc.) |
---|
| 488 | const QTextCodec* _codec; |
---|
| 489 | QTextDecoder* _decoder; |
---|
| 490 | const KeyboardTranslator* _keyTranslator; // the keyboard layout |
---|
| 491 | |
---|
| 492 | protected slots: |
---|
[64efc22] | 493 | /** |
---|
[45157b3] | 494 | * Schedules an update of attached views. |
---|
| 495 | * Repeated calls to bufferedUpdate() in close succession will result in only a single update, |
---|
[64efc22] | 496 | * much like the Qt buffered update of widgets. |
---|
[45157b3] | 497 | */ |
---|
| 498 | void bufferedUpdate(); |
---|
| 499 | |
---|
[64efc22] | 500 | private slots: |
---|
[45157b3] | 501 | |
---|
| 502 | // triggered by timer, causes the emulation to send an updated screen image to each |
---|
| 503 | // view |
---|
[64efc22] | 504 | void showBulk(); |
---|
[45157b3] | 505 | |
---|
| 506 | void usesMouseChanged(bool usesMouse); |
---|
| 507 | |
---|
[64efc22] | 508 | void bracketedPasteModeChanged(bool bracketedPasteMode); |
---|
[45157b3] | 509 | |
---|
[64efc22] | 510 | private: |
---|
[45157b3] | 511 | bool _usesMouse; |
---|
[64efc22] | 512 | bool _bracketedPasteMode; |
---|
[45157b3] | 513 | QTimer _bulkTimer1; |
---|
| 514 | QTimer _bulkTimer2; |
---|
[64efc22] | 515 | |
---|
[45157b3] | 516 | }; |
---|
| 517 | |
---|
| 518 | } |
---|
| 519 | |
---|
| 520 | #endif // ifndef EMULATION_H |
---|