1 | /* |
---|
2 | Copyright (C) 2007 by Robert Knight <robertknight@gmail.com> |
---|
3 | Copyright (C) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> |
---|
4 | |
---|
5 | Rewritten for QT4 by e_k <e_k at users.sourceforge.net>, Copyright (C)2008 |
---|
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 TERMINALDISPLAY_H |
---|
24 | #define TERMINALDISPLAY_H |
---|
25 | |
---|
26 | // Qt |
---|
27 | #include <QtGui/QColor> |
---|
28 | #include <QtCore/QPointer> |
---|
29 | #include <QtGui/QWidget> |
---|
30 | |
---|
31 | // Konsole |
---|
32 | #include "Filter.h" |
---|
33 | #include "Character.h" |
---|
34 | #include "ColorTables.h" |
---|
35 | |
---|
36 | class QDrag; |
---|
37 | class QDragEnterEvent; |
---|
38 | class QDropEvent; |
---|
39 | class QLabel; |
---|
40 | class QTimer; |
---|
41 | class QEvent; |
---|
42 | class QFrame; |
---|
43 | class QGridLayout; |
---|
44 | class QKeyEvent; |
---|
45 | class QScrollBar; |
---|
46 | class QShowEvent; |
---|
47 | class QHideEvent; |
---|
48 | class QWidget; |
---|
49 | |
---|
50 | //class KMenu; |
---|
51 | |
---|
52 | namespace Konsole |
---|
53 | { |
---|
54 | |
---|
55 | extern unsigned short vt100_graphics[32]; |
---|
56 | |
---|
57 | class ScreenWindow; |
---|
58 | |
---|
59 | /** |
---|
60 | * A widget which displays output from a terminal emulation and sends input keypresses and mouse activity |
---|
61 | * to the terminal. |
---|
62 | * |
---|
63 | * When the terminal emulation receives new output from the program running in the terminal, |
---|
64 | * it will update the display by calling updateImage(). |
---|
65 | * |
---|
66 | * TODO More documentation |
---|
67 | */ |
---|
68 | class TerminalDisplay : public QWidget |
---|
69 | { |
---|
70 | Q_OBJECT |
---|
71 | |
---|
72 | public: |
---|
73 | /** Constructs a new terminal display widget with the specified parent. */ |
---|
74 | TerminalDisplay(QWidget *parent=0); |
---|
75 | virtual ~TerminalDisplay(); |
---|
76 | |
---|
77 | /** Returns the terminal color palette used by the display. */ |
---|
78 | const ColorEntry* colorTable() const; |
---|
79 | /** Sets the terminal color palette used by the display. */ |
---|
80 | void setColorTable(const ColorEntry table[]); |
---|
81 | /** |
---|
82 | * Sets the seed used to generate random colors for the display |
---|
83 | * (in color schemes that support them). |
---|
84 | */ |
---|
85 | void setRandomSeed(uint seed); |
---|
86 | /** |
---|
87 | * Returns the seed used to generate random colors for the display |
---|
88 | * (in color schemes that support them). |
---|
89 | */ |
---|
90 | uint randomSeed() const; |
---|
91 | |
---|
92 | /** Sets the opacity of the terminal display. */ |
---|
93 | void setOpacity(qreal opacity); |
---|
94 | |
---|
95 | /** |
---|
96 | * This enum describes the location where the scroll bar is positioned in the display widget. |
---|
97 | */ |
---|
98 | enum ScrollBarPosition |
---|
99 | { |
---|
100 | /** Do not show the scroll bar. */ |
---|
101 | NoScrollBar=0, |
---|
102 | /** Show the scroll bar on the left side of the display. */ |
---|
103 | ScrollBarLeft=1, |
---|
104 | /** Show the scroll bar on the right side of the display. */ |
---|
105 | ScrollBarRight=2 |
---|
106 | }; |
---|
107 | /** |
---|
108 | * Specifies whether the terminal display has a vertical scroll bar, and if so whether it |
---|
109 | * is shown on the left or right side of the display. |
---|
110 | */ |
---|
111 | void setScrollBarPosition(ScrollBarPosition position); |
---|
112 | |
---|
113 | /** |
---|
114 | * Sets the current position and range of the display's scroll bar. |
---|
115 | * |
---|
116 | * @param cursor The position of the scroll bar's thumb. |
---|
117 | * @param lines The maximum value of the scroll bar. |
---|
118 | */ |
---|
119 | void setScroll(int cursor, int lines); |
---|
120 | |
---|
121 | /** |
---|
122 | * Returns the display's filter chain. When the image for the display is updated, |
---|
123 | * the text is passed through each filter in the chain. Each filter can define |
---|
124 | * hotspots which correspond to certain strings (such as URLs or particular words). |
---|
125 | * Depending on the type of the hotspots created by the filter ( returned by Filter::Hotspot::type() ) |
---|
126 | * the view will draw visual cues such as underlines on mouse-over for links or translucent |
---|
127 | * rectangles for markers. |
---|
128 | * |
---|
129 | * To add a new filter to the view, call: |
---|
130 | * viewWidget->filterChain()->addFilter( filterObject ); |
---|
131 | */ |
---|
132 | FilterChain* filterChain() const; |
---|
133 | |
---|
134 | /** |
---|
135 | * Updates the filters in the display's filter chain. This will cause |
---|
136 | * the hotspots to be updated to match the current image. |
---|
137 | * |
---|
138 | * WARNING: This function can be expensive depending on the |
---|
139 | * image size and number of filters in the filterChain() |
---|
140 | * |
---|
141 | * TODO - This API does not really allow efficient usage. Revise it so |
---|
142 | * that the processing can be done in a better way. |
---|
143 | * |
---|
144 | * eg: |
---|
145 | * - Area of interest may be known ( eg. mouse cursor hovering |
---|
146 | * over an area ) |
---|
147 | */ |
---|
148 | void processFilters(); |
---|
149 | |
---|
150 | /** |
---|
151 | * Returns a list of menu actions created by the filters for the content |
---|
152 | * at the given @p position. |
---|
153 | */ |
---|
154 | QList<QAction*> filterActions(const QPoint& position); |
---|
155 | |
---|
156 | /** Returns true if the cursor is set to blink or false otherwise. */ |
---|
157 | bool blinkingCursor() { return _hasBlinkingCursor; } |
---|
158 | /** Specifies whether or not the cursor blinks. */ |
---|
159 | void setBlinkingCursor(bool blink); |
---|
160 | |
---|
161 | void setCtrlDrag(bool enable) { _ctrlDrag=enable; } |
---|
162 | bool ctrlDrag() { return _ctrlDrag; } |
---|
163 | |
---|
164 | /** |
---|
165 | * This enum describes the methods for selecting text when |
---|
166 | * the user triple-clicks within the display. |
---|
167 | */ |
---|
168 | enum TripleClickMode |
---|
169 | { |
---|
170 | /** Select the whole line underneath the cursor. */ |
---|
171 | SelectWholeLine, |
---|
172 | /** Select from the current cursor position to the end of the line. */ |
---|
173 | SelectForwardsFromCursor |
---|
174 | }; |
---|
175 | /** Sets how the text is selected when the user triple clicks within the display. */ |
---|
176 | void setTripleClickMode(TripleClickMode mode) { _tripleClickMode = mode; } |
---|
177 | /** See setTripleClickSelectionMode() */ |
---|
178 | TripleClickMode tripleClickMode() { return _tripleClickMode; } |
---|
179 | |
---|
180 | void setLineSpacing(uint); |
---|
181 | uint lineSpacing() const; |
---|
182 | |
---|
183 | void emitSelection(bool useXselection,bool appendReturn); |
---|
184 | |
---|
185 | /** |
---|
186 | * This enum describes the available shapes for the keyboard cursor. |
---|
187 | * See setKeyboardCursorShape() |
---|
188 | */ |
---|
189 | enum KeyboardCursorShape |
---|
190 | { |
---|
191 | /** A rectangular block which covers the entire area of the cursor character. */ |
---|
192 | BlockCursor, |
---|
193 | /** |
---|
194 | * A single flat line which occupies the space at the bottom of the cursor |
---|
195 | * character's area. |
---|
196 | */ |
---|
197 | UnderlineCursor, |
---|
198 | /** |
---|
199 | * An cursor shaped like the capital letter 'I', similar to the IBeam |
---|
200 | * cursor used in Qt/KDE text editors. |
---|
201 | */ |
---|
202 | IBeamCursor |
---|
203 | }; |
---|
204 | /** |
---|
205 | * Sets the shape of the keyboard cursor. This is the cursor drawn |
---|
206 | * at the position in the terminal where keyboard input will appear. |
---|
207 | * |
---|
208 | * In addition the terminal display widget also has a cursor for |
---|
209 | * the mouse pointer, which can be set using the QWidget::setCursor() |
---|
210 | * method. |
---|
211 | * |
---|
212 | * Defaults to BlockCursor |
---|
213 | */ |
---|
214 | void setKeyboardCursorShape(KeyboardCursorShape shape); |
---|
215 | /** |
---|
216 | * Returns the shape of the keyboard cursor. See setKeyboardCursorShape() |
---|
217 | */ |
---|
218 | KeyboardCursorShape keyboardCursorShape() const; |
---|
219 | |
---|
220 | /** |
---|
221 | * Sets the color used to draw the keyboard cursor. |
---|
222 | * |
---|
223 | * The keyboard cursor defaults to using the foreground color of the character |
---|
224 | * underneath it. |
---|
225 | * |
---|
226 | * @param useForegroundColor If true, the cursor color will change to match |
---|
227 | * the foreground color of the character underneath it as it is moved, in this |
---|
228 | * case, the @p color parameter is ignored and the color of the character |
---|
229 | * under the cursor is inverted to ensure that it is still readable. |
---|
230 | * @param color The color to use to draw the cursor. This is only taken into |
---|
231 | * account if @p useForegroundColor is false. |
---|
232 | */ |
---|
233 | void setKeyboardCursorColor(bool useForegroundColor , const QColor& color); |
---|
234 | |
---|
235 | /** |
---|
236 | * Returns the color of the keyboard cursor, or an invalid color if the keyboard |
---|
237 | * cursor color is set to change according to the foreground color of the character |
---|
238 | * underneath it. |
---|
239 | */ |
---|
240 | QColor keyboardCursorColor() const; |
---|
241 | |
---|
242 | /** |
---|
243 | * Returns the number of lines of text which can be displayed in the widget. |
---|
244 | * |
---|
245 | * This will depend upon the height of the widget and the current font. |
---|
246 | * See fontHeight() |
---|
247 | */ |
---|
248 | int lines() { return _lines; } |
---|
249 | /** |
---|
250 | * Returns the number of characters of text which can be displayed on |
---|
251 | * each line in the widget. |
---|
252 | * |
---|
253 | * This will depend upon the width of the widget and the current font. |
---|
254 | * See fontWidth() |
---|
255 | */ |
---|
256 | int columns() { return _columns; } |
---|
257 | |
---|
258 | /** |
---|
259 | * Returns the height of the characters in the font used to draw the text in the display. |
---|
260 | */ |
---|
261 | int fontHeight() { return _fontHeight; } |
---|
262 | /** |
---|
263 | * Returns the width of the characters in the display. |
---|
264 | * This assumes the use of a fixed-width font. |
---|
265 | */ |
---|
266 | int fontWidth() { return _fontWidth; } |
---|
267 | |
---|
268 | void setSize(int cols, int lins); |
---|
269 | void setFixedSize(int cols, int lins); |
---|
270 | |
---|
271 | // reimplemented |
---|
272 | QSize sizeHint() const; |
---|
273 | |
---|
274 | /** |
---|
275 | * Sets which characters, in addition to letters and numbers, |
---|
276 | * are regarded as being part of a word for the purposes |
---|
277 | * of selecting words in the display by double clicking on them. |
---|
278 | * |
---|
279 | * The word boundaries occur at the first and last characters which |
---|
280 | * are either a letter, number, or a character in @p wc |
---|
281 | * |
---|
282 | * @param wc An array of characters which are to be considered parts |
---|
283 | * of a word ( in addition to letters and numbers ). |
---|
284 | */ |
---|
285 | void setWordCharacters(const QString& wc); |
---|
286 | /** |
---|
287 | * Returns the characters which are considered part of a word for the |
---|
288 | * purpose of selecting words in the display with the mouse. |
---|
289 | * |
---|
290 | * @see setWordCharacters() |
---|
291 | */ |
---|
292 | QString wordCharacters() { return _wordCharacters; } |
---|
293 | |
---|
294 | /** |
---|
295 | * Sets the type of effect used to alert the user when a 'bell' occurs in the |
---|
296 | * terminal session. |
---|
297 | * |
---|
298 | * The terminal session can trigger the bell effect by calling bell() with |
---|
299 | * the alert message. |
---|
300 | */ |
---|
301 | void setBellMode(int mode); |
---|
302 | /** |
---|
303 | * Returns the type of effect used to alert the user when a 'bell' occurs in |
---|
304 | * the terminal session. |
---|
305 | * |
---|
306 | * See setBellMode() |
---|
307 | */ |
---|
308 | int bellMode() { return _bellMode; } |
---|
309 | |
---|
310 | /** |
---|
311 | * This enum describes the different types of sounds and visual effects which |
---|
312 | * can be used to alert the user when a 'bell' occurs in the terminal |
---|
313 | * session. |
---|
314 | */ |
---|
315 | enum BellMode |
---|
316 | { |
---|
317 | /** A system beep. */ |
---|
318 | SystemBeepBell=0, |
---|
319 | /** |
---|
320 | * KDE notification. This may play a sound, show a passive popup |
---|
321 | * or perform some other action depending on the user's settings. |
---|
322 | */ |
---|
323 | NotifyBell=1, |
---|
324 | /** A silent, visual bell (eg. inverting the display's colors briefly) */ |
---|
325 | VisualBell=2, |
---|
326 | /** No bell effects */ |
---|
327 | NoBell=3 |
---|
328 | }; |
---|
329 | |
---|
330 | void setSelection(const QString &t); |
---|
331 | |
---|
332 | /** |
---|
333 | * Reimplemented. Has no effect. Use setVTFont() to change the font |
---|
334 | * used to draw characters in the display. |
---|
335 | */ |
---|
336 | virtual void setFont(const QFont &); |
---|
337 | |
---|
338 | /** Returns the font used to draw characters in the display */ |
---|
339 | QFont getVTFont() { return font(); } |
---|
340 | |
---|
341 | /** |
---|
342 | * Sets the font used to draw the display. Has no effect if @p font |
---|
343 | * is larger than the size of the display itself. |
---|
344 | */ |
---|
345 | void setVTFont(const QFont& font); |
---|
346 | |
---|
347 | /** |
---|
348 | * Specified whether anti-aliasing of text in the terminal display |
---|
349 | * is enabled or not. Defaults to enabled. |
---|
350 | */ |
---|
351 | static void setAntialias( bool antialias ) { _antialiasText = antialias; } |
---|
352 | /** |
---|
353 | * Returns true if anti-aliasing of text in the terminal is enabled. |
---|
354 | */ |
---|
355 | static bool antialias() { return _antialiasText; } |
---|
356 | |
---|
357 | /** |
---|
358 | * Sets whether or not the current height and width of the |
---|
359 | * terminal in lines and columns is displayed whilst the widget |
---|
360 | * is being resized. |
---|
361 | */ |
---|
362 | void setTerminalSizeHint(bool on) { _terminalSizeHint=on; } |
---|
363 | /** |
---|
364 | * Returns whether or not the current height and width of |
---|
365 | * the terminal in lines and columns is displayed whilst the widget |
---|
366 | * is being resized. |
---|
367 | */ |
---|
368 | bool terminalSizeHint() { return _terminalSizeHint; } |
---|
369 | /** |
---|
370 | * Sets whether the terminal size display is shown briefly |
---|
371 | * after the widget is first shown. |
---|
372 | * |
---|
373 | * See setTerminalSizeHint() , isTerminalSizeHint() |
---|
374 | */ |
---|
375 | void setTerminalSizeStartup(bool on) { _terminalSizeStartup=on; } |
---|
376 | |
---|
377 | void setBidiEnabled(bool set) { _bidiEnabled=set; } |
---|
378 | bool isBidiEnabled() { return _bidiEnabled; } |
---|
379 | |
---|
380 | /** |
---|
381 | * Sets the terminal screen section which is displayed in this widget. |
---|
382 | * When updateImage() is called, the display fetches the latest character image from the |
---|
383 | * the associated terminal screen window. |
---|
384 | * |
---|
385 | * In terms of the model-view paradigm, the ScreenWindow is the model which is rendered |
---|
386 | * by the TerminalDisplay. |
---|
387 | */ |
---|
388 | void setScreenWindow( ScreenWindow* window ); |
---|
389 | /** Returns the terminal screen section which is displayed in this widget. See setScreenWindow() */ |
---|
390 | ScreenWindow* screenWindow() const; |
---|
391 | |
---|
392 | static bool HAVE_TRANSPARENCY; |
---|
393 | |
---|
394 | public slots: |
---|
395 | |
---|
396 | /** |
---|
397 | * Causes the terminal display to fetch the latest character image from the associated |
---|
398 | * terminal screen ( see setScreenWindow() ) and redraw the display. |
---|
399 | */ |
---|
400 | void updateImage(); |
---|
401 | /** |
---|
402 | * Causes the terminal display to fetch the latest line status flags from the |
---|
403 | * associated terminal screen ( see setScreenWindow() ). |
---|
404 | */ |
---|
405 | void updateLineProperties(); |
---|
406 | |
---|
407 | /** Copies the selected text to the clipboard. */ |
---|
408 | void copyClipboard(); |
---|
409 | /** |
---|
410 | * Pastes the content of the clipboard into the |
---|
411 | * display. |
---|
412 | */ |
---|
413 | void pasteClipboard(); |
---|
414 | /** |
---|
415 | * Pastes the content of the selection into the |
---|
416 | * display. |
---|
417 | */ |
---|
418 | void pasteSelection(); |
---|
419 | |
---|
420 | /** |
---|
421 | * Changes whether the flow control warning box should be shown when the flow control |
---|
422 | * stop key (Ctrl+S) are pressed. |
---|
423 | */ |
---|
424 | void setFlowControlWarningEnabled(bool enabled); |
---|
425 | |
---|
426 | /** |
---|
427 | * Causes the widget to display or hide a message informing the user that terminal |
---|
428 | * output has been suspended (by using the flow control key combination Ctrl+S) |
---|
429 | * |
---|
430 | * @param suspended True if terminal output has been suspended and the warning message should |
---|
431 | * be shown or false to indicate that terminal output has been resumed and that |
---|
432 | * the warning message should disappear. |
---|
433 | */ |
---|
434 | void outputSuspended(bool suspended); |
---|
435 | |
---|
436 | /** |
---|
437 | * Sets whether the program whoose output is being displayed in the view |
---|
438 | * is interested in mouse events. |
---|
439 | * |
---|
440 | * If this is set to true, mouse signals will be emitted by the view when the user clicks, drags |
---|
441 | * or otherwise moves the mouse inside the view. |
---|
442 | * The user interaction needed to create selections will also change, and the user will be required |
---|
443 | * to hold down the shift key to create a selection or perform other mouse activities inside the |
---|
444 | * view area - since the program running in the terminal is being allowed to handle normal mouse |
---|
445 | * events itself. |
---|
446 | * |
---|
447 | * @param usesMouse Set to true if the program running in the terminal is interested in mouse events |
---|
448 | * or false otherwise. |
---|
449 | */ |
---|
450 | void setUsesMouse(bool usesMouse); |
---|
451 | |
---|
452 | /** See setUsesMouse() */ |
---|
453 | bool usesMouse() const; |
---|
454 | |
---|
455 | /** |
---|
456 | * Shows a notification that a bell event has occurred in the terminal. |
---|
457 | * TODO: More documentation here |
---|
458 | */ |
---|
459 | void bell(const QString& message); |
---|
460 | |
---|
461 | signals: |
---|
462 | |
---|
463 | /** |
---|
464 | * Emitted when the user presses a key whilst the terminal widget has focus. |
---|
465 | */ |
---|
466 | void keyPressedSignal(QKeyEvent *e); |
---|
467 | |
---|
468 | /** |
---|
469 | * Emitted when the user presses the suspend or resume flow control key combinations |
---|
470 | * |
---|
471 | * @param suspend true if the user pressed Ctrl+S (the suspend output key combination) or |
---|
472 | * false if the user pressed Ctrl+Q (the resume output key combination) |
---|
473 | */ |
---|
474 | void flowControlKeyPressed(bool suspend); |
---|
475 | |
---|
476 | /** |
---|
477 | * A mouse event occurred. |
---|
478 | * @param button The mouse button (0 for left button, 1 for middle button, 2 for right button, 3 for release) |
---|
479 | * @param column The character column where the event occurred |
---|
480 | * @param line The character row where the event occurred |
---|
481 | * @param eventType The type of event. 0 for a mouse press / release or 1 for mouse motion |
---|
482 | */ |
---|
483 | void mouseSignal(int button, int column, int line, int eventType); |
---|
484 | void changedFontMetricSignal(int height, int width); |
---|
485 | void changedContentSizeSignal(int height, int width); |
---|
486 | |
---|
487 | /** |
---|
488 | * Emitted when the user right clicks on the display, or right-clicks with the Shift |
---|
489 | * key held down if usesMouse() is true. |
---|
490 | * |
---|
491 | * This can be used to display a context menu. |
---|
492 | */ |
---|
493 | void configureRequest( TerminalDisplay*, int state, const QPoint& position ); |
---|
494 | |
---|
495 | void isBusySelecting(bool); |
---|
496 | void sendStringToEmu(const char*); |
---|
497 | |
---|
498 | protected: |
---|
499 | virtual bool event( QEvent * ); |
---|
500 | |
---|
501 | virtual void paintEvent( QPaintEvent * ); |
---|
502 | |
---|
503 | virtual void showEvent(QShowEvent*); |
---|
504 | virtual void hideEvent(QHideEvent*); |
---|
505 | virtual void resizeEvent(QResizeEvent*); |
---|
506 | |
---|
507 | virtual void fontChange(const QFont &font); |
---|
508 | |
---|
509 | virtual void keyPressEvent(QKeyEvent* event); |
---|
510 | virtual void mouseDoubleClickEvent(QMouseEvent* ev); |
---|
511 | virtual void mousePressEvent( QMouseEvent* ); |
---|
512 | virtual void mouseReleaseEvent( QMouseEvent* ); |
---|
513 | virtual void mouseMoveEvent( QMouseEvent* ); |
---|
514 | virtual void extendSelection( const QPoint& pos ); |
---|
515 | virtual void wheelEvent( QWheelEvent* ); |
---|
516 | |
---|
517 | virtual bool focusNextPrevChild( bool next ); |
---|
518 | |
---|
519 | // drag and drop |
---|
520 | virtual void dragEnterEvent(QDragEnterEvent* event); |
---|
521 | virtual void dropEvent(QDropEvent* event); |
---|
522 | void doDrag(); |
---|
523 | enum DragState { diNone, diPending, diDragging }; |
---|
524 | |
---|
525 | struct _dragInfo { |
---|
526 | DragState state; |
---|
527 | QPoint start; |
---|
528 | QDrag *dragObject; |
---|
529 | } dragInfo; |
---|
530 | |
---|
531 | virtual int charClass(quint16) const; |
---|
532 | |
---|
533 | void clearImage(); |
---|
534 | |
---|
535 | void mouseTripleClickEvent(QMouseEvent* ev); |
---|
536 | |
---|
537 | // reimplemented |
---|
538 | virtual void inputMethodEvent ( QInputMethodEvent* event ); |
---|
539 | virtual QVariant inputMethodQuery( Qt::InputMethodQuery query ) const; |
---|
540 | |
---|
541 | protected slots: |
---|
542 | |
---|
543 | void scrollBarPositionChanged(int value); |
---|
544 | void blinkEvent(); |
---|
545 | void blinkCursorEvent(); |
---|
546 | |
---|
547 | //Renables bell noises and visuals. Used to disable further bells for a short period of time |
---|
548 | //after emitting the first in a sequence of bell events. |
---|
549 | void enableBell(); |
---|
550 | |
---|
551 | private slots: |
---|
552 | |
---|
553 | void swapColorTable(); |
---|
554 | void tripleClickTimeout(); // resets possibleTripleClick |
---|
555 | |
---|
556 | private: |
---|
557 | |
---|
558 | // -- Drawing helpers -- |
---|
559 | |
---|
560 | // divides the part of the display specified by 'rect' into |
---|
561 | // fragments according to their colors and styles and calls |
---|
562 | // drawTextFragment() to draw the fragments |
---|
563 | void drawContents(QPainter &paint, const QRect &rect); |
---|
564 | // draws a section of text, all the text in this section |
---|
565 | // has a common color and style |
---|
566 | void drawTextFragment(QPainter& painter, const QRect& rect, |
---|
567 | const QString& text, const Character* style); |
---|
568 | // draws the background for a text fragment |
---|
569 | // if useOpacitySetting is true then the color's alpha value will be set to |
---|
570 | // the display's transparency (set with setOpacity()), otherwise the background |
---|
571 | // will be drawn fully opaque |
---|
572 | void drawBackground(QPainter& painter, const QRect& rect, const QColor& color, |
---|
573 | bool useOpacitySetting); |
---|
574 | // draws the cursor character |
---|
575 | void drawCursor(QPainter& painter, const QRect& rect , const QColor& foregroundColor, |
---|
576 | const QColor& backgroundColor , bool& invertColors); |
---|
577 | // draws the characters or line graphics in a text fragment |
---|
578 | void drawCharacters(QPainter& painter, const QRect& rect, const QString& text, |
---|
579 | const Character* style, bool invertCharacterColor); |
---|
580 | // draws a string of line graphics |
---|
581 | void drawLineCharString(QPainter& painter, int x, int y, |
---|
582 | const QString& str, const Character* attributes); |
---|
583 | |
---|
584 | // draws the preedit string for input methods |
---|
585 | void drawInputMethodPreeditString(QPainter& painter , const QRect& rect); |
---|
586 | |
---|
587 | // -- |
---|
588 | |
---|
589 | // maps an area in the character image to an area on the widget |
---|
590 | QRect imageToWidget(const QRect& imageArea) const; |
---|
591 | |
---|
592 | // maps a point on the widget to the position ( ie. line and column ) |
---|
593 | // of the character at that point. |
---|
594 | void getCharacterPosition(const QPoint& widgetPoint,int& line,int& column) const; |
---|
595 | |
---|
596 | // the area where the preedit string for input methods will be draw |
---|
597 | QRect preeditRect() const; |
---|
598 | |
---|
599 | // shows a notification window in the middle of the widget indicating the terminal's |
---|
600 | // current size in columns and lines |
---|
601 | void showResizeNotification(); |
---|
602 | |
---|
603 | // scrolls the image by a number of lines. |
---|
604 | // 'lines' may be positive ( to scroll the image down ) |
---|
605 | // or negative ( to scroll the image up ) |
---|
606 | // 'region' is the part of the image to scroll - currently only |
---|
607 | // the top, bottom and height of 'region' are taken into account, |
---|
608 | // the left and right are ignored. |
---|
609 | void scrollImage(int lines , const QRect& region); |
---|
610 | |
---|
611 | void calcGeometry(); |
---|
612 | void propagateSize(); |
---|
613 | void updateImageSize(); |
---|
614 | void makeImage(); |
---|
615 | |
---|
616 | void paintFilters(QPainter& painter); |
---|
617 | |
---|
618 | // returns a region covering all of the areas of the widget which contain |
---|
619 | // a hotspot |
---|
620 | QRegion hotSpotRegion() const; |
---|
621 | |
---|
622 | // returns the position of the cursor in columns and lines |
---|
623 | QPoint cursorPosition() const; |
---|
624 | |
---|
625 | // the window onto the terminal screen which this display |
---|
626 | // is currently showing. |
---|
627 | QPointer<ScreenWindow> _screenWindow; |
---|
628 | |
---|
629 | bool _allowBell; |
---|
630 | |
---|
631 | QGridLayout* _gridLayout; |
---|
632 | |
---|
633 | bool _fixedFont; // has fixed pitch |
---|
634 | int _fontHeight; // height |
---|
635 | int _fontWidth; // width |
---|
636 | int _fontAscent; // ascend |
---|
637 | |
---|
638 | int _leftMargin; // offset |
---|
639 | int _topMargin; // offset |
---|
640 | |
---|
641 | int _lines; // the number of lines that can be displayed in the widget |
---|
642 | int _columns; // the number of columns that can be displayed in the widget |
---|
643 | |
---|
644 | int _usedLines; // the number of lines that are actually being used, this will be less |
---|
645 | // than 'lines' if the character image provided with setImage() is smaller |
---|
646 | // than the maximum image size which can be displayed |
---|
647 | |
---|
648 | int _usedColumns; // the number of columns that are actually being used, this will be less |
---|
649 | // than 'columns' if the character image provided with setImage() is smaller |
---|
650 | // than the maximum image size which can be displayed |
---|
651 | |
---|
652 | int _contentHeight; |
---|
653 | int _contentWidth; |
---|
654 | Character* _image; // [lines][columns] |
---|
655 | // only the area [usedLines][usedColumns] in the image contains valid data |
---|
656 | |
---|
657 | int _imageSize; |
---|
658 | QVector<LineProperty> _lineProperties; |
---|
659 | |
---|
660 | ColorEntry _colorTable[TABLE_COLORS]; |
---|
661 | uint _randomSeed; |
---|
662 | |
---|
663 | bool _resizing; |
---|
664 | bool _terminalSizeHint; |
---|
665 | bool _terminalSizeStartup; |
---|
666 | bool _bidiEnabled; |
---|
667 | bool _mouseMarks; |
---|
668 | |
---|
669 | QPoint _iPntSel; // initial selection point |
---|
670 | QPoint _pntSel; // current selection point |
---|
671 | QPoint _tripleSelBegin; // help avoid flicker |
---|
672 | int _actSel; // selection state |
---|
673 | bool _wordSelectionMode; |
---|
674 | bool _lineSelectionMode; |
---|
675 | bool _preserveLineBreaks; |
---|
676 | bool _columnSelectionMode; |
---|
677 | |
---|
678 | QClipboard* _clipboard; |
---|
679 | QScrollBar* _scrollBar; |
---|
680 | ScrollBarPosition _scrollbarLocation; |
---|
681 | QString _wordCharacters; |
---|
682 | int _bellMode; |
---|
683 | |
---|
684 | bool _blinking; // hide text in paintEvent |
---|
685 | bool _hasBlinker; // has characters to blink |
---|
686 | bool _cursorBlinking; // hide cursor in paintEvent |
---|
687 | bool _hasBlinkingCursor; // has blinking cursor enabled |
---|
688 | bool _ctrlDrag; // require Ctrl key for drag |
---|
689 | TripleClickMode _tripleClickMode; |
---|
690 | bool _isFixedSize; //Columns / lines are locked. |
---|
691 | QTimer* _blinkTimer; // active when hasBlinker |
---|
692 | QTimer* _blinkCursorTimer; // active when hasBlinkingCursor |
---|
693 | |
---|
694 | // KMenu* _drop; |
---|
695 | QString _dropText; |
---|
696 | int _dndFileCount; |
---|
697 | |
---|
698 | bool _possibleTripleClick; // is set in mouseDoubleClickEvent and deleted |
---|
699 | // after QApplication::doubleClickInterval() delay |
---|
700 | |
---|
701 | |
---|
702 | QLabel* _resizeWidget; |
---|
703 | QTimer* _resizeTimer; |
---|
704 | |
---|
705 | bool _flowControlWarningEnabled; |
---|
706 | |
---|
707 | //widgets related to the warning message that appears when the user presses Ctrl+S to suspend |
---|
708 | //terminal output - informing them what has happened and how to resume output |
---|
709 | QLabel* _outputSuspendedLabel; |
---|
710 | |
---|
711 | uint _lineSpacing; |
---|
712 | |
---|
713 | bool _colorsInverted; // true during visual bell |
---|
714 | |
---|
715 | QSize _size; |
---|
716 | |
---|
717 | QRgb _blendColor; |
---|
718 | |
---|
719 | // list of filters currently applied to the display. used for links and |
---|
720 | // search highlight |
---|
721 | TerminalImageFilterChain* _filterChain; |
---|
722 | QRect _mouseOverHotspotArea; |
---|
723 | |
---|
724 | KeyboardCursorShape _cursorShape; |
---|
725 | |
---|
726 | // custom cursor color. if this is invalid then the foreground |
---|
727 | // color of the character under the cursor is used |
---|
728 | QColor _cursorColor; |
---|
729 | |
---|
730 | |
---|
731 | struct InputMethodData |
---|
732 | { |
---|
733 | QString preeditString; |
---|
734 | QRect previousPreeditRect; |
---|
735 | }; |
---|
736 | InputMethodData _inputMethodData; |
---|
737 | |
---|
738 | static bool _antialiasText; // do we antialias or not |
---|
739 | |
---|
740 | //the delay in milliseconds between redrawing blinking text |
---|
741 | static const int BLINK_DELAY = 500; |
---|
742 | static const int DEFAULT_LEFT_MARGIN = 1; |
---|
743 | static const int DEFAULT_TOP_MARGIN = 1; |
---|
744 | |
---|
745 | public: |
---|
746 | static void setTransparencyEnabled(bool enable) |
---|
747 | { |
---|
748 | HAVE_TRANSPARENCY = enable; |
---|
749 | } |
---|
750 | }; |
---|
751 | |
---|
752 | } |
---|
753 | |
---|
754 | #endif // TERMINALDISPLAY_H |
---|