TerminalDisplay.h 26.5 KB
Newer Older
1
/*
2
    Copyright (C) 2007 by Robert Knight <robertknight@gmail.com>
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
    Copyright (C) 1997,1998 by Lars Doelle <lars.doelle@on-line.de>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301  USA.
*/
20

21
22
#ifndef TERMINALDISPLAY_H
#define TERMINALDISPLAY_H
23

24
// Qt
Dirk Mueller's avatar
Dirk Mueller committed
25
#include <QtGui/QColor>
26
#include <QtCore/QPointer>
27
#include <QtGui/QWidget>
28

29
// Konsole
30
#include "Filter.h"
31
#include "Character.h"
32

33
34
35
class QDrag;
class QDragEnterEvent;
class QDropEvent;
Laurent Montel's avatar
Laurent Montel committed
36
37
class QLabel;
class QTimer;
38
class QEvent;
Urs Wolfer's avatar
Urs Wolfer committed
39
class QFrame;
40
class QGridLayout;
41
42
class QKeyEvent;
class QScrollBar;
43
44
class QShowEvent;
class QHideEvent;
45
class QTimerEvent;
46
47
48
class QWidget;

class KMenu;
49
50
51
52
53
54

namespace Konsole
{

extern unsigned short vt100_graphics[32];

55
class ScreenWindow;
56

57
58
59
60
/**
 * A widget which displays output from a terminal emulation and sends input keypresses and mouse activity
 * to the terminal.
 *
61
 * When the terminal emulation receives new output from the program running in the terminal, 
62
63
64
 * it will update the display by calling updateImage().
 *
 * TODO More documentation
65
 */
66
class TerminalDisplay : public QWidget
67
68
69
70
{
   Q_OBJECT

public:
71
    /** Constructs a new terminal display widget with the specified parent. */
72
73
    TerminalDisplay(QWidget *parent=0);
    virtual ~TerminalDisplay();
74

75
    /** Returns the terminal color palette used by the display. */
76
    const ColorEntry* colorTable() const;
77
78
    /** Sets the terminal color palette used by the display. */
    void setColorTable(const ColorEntry table[]);
Constantin Berzan's avatar
APIDOX    
Constantin Berzan committed
79
80
81
82
    /**
     * Sets the seed used to generate random colors for the display
     * (in color schemes that support them).
     */
83
    void setRandomSeed(uint seed);
Constantin Berzan's avatar
APIDOX    
Constantin Berzan committed
84
85
86
87
    /**
     * Returns the seed used to generate random colors for the display
     * (in color schemes that support them).
     */
88
89
    uint randomSeed() const;

90
91
    /** Sets the opacity of the terminal display. */
    void setOpacity(qreal opacity);
92

93
94
95
    /** 
     * This enum describes the location where the scroll bar is positioned in the display widget.
     */
96
    enum ScrollBarPosition 
97
    { 
98
        /** Do not show the scroll bar. */
99
        NoScrollBar=0, 
100
        /** Show the scroll bar on the left side of the display. */
101
        ScrollBarLeft=1, 
102
        /** Show the scroll bar on the right side of the display. */
103
        ScrollBarRight=2 
104
    };
105
106
107
108
    /** 
     * Specifies whether the terminal display has a vertical scroll bar, and if so whether it
     * is shown on the left or right side of the display.
     */
109
    void setScrollBarPosition(ScrollBarPosition position);
110

111
112
113
114
115
116
    /** 
     * Sets the current position and range of the display's scroll bar.
     *
     * @param cursor The position of the scroll bar's thumb.
     * @param lines The maximum value of the scroll bar.
     */
117
118
    void setScroll(int cursor, int lines);

119
120
121
122
123
124
125
126
127
128
129
130
    /** 
     * Returns the display's filter chain.  When the image for the display is updated,
     * the text is passed through each filter in the chain.  Each filter can define
     * hotspots which correspond to certain strings (such as URLs or particular words).
     * Depending on the type of the hotspots created by the filter ( returned by Filter::Hotspot::type() )
     * the view will draw visual cues such as underlines on mouse-over for links or translucent
     * rectangles for markers.
     *
     * To add a new filter to the view, call:
     *      viewWidget->filterChain()->addFilter( filterObject );
     */
    FilterChain* filterChain() const;
131
132
133
134

    /** 
     * Updates the filters in the display's filter chain.  This will cause
     * the hotspots to be updated to match the current image.
135
     *
136
137
     * WARNING:  This function can be expensive depending on the 
     * image size and number of filters in the filterChain()
138
     *
139
140
141
142
143
144
     * TODO - This API does not really allow efficient usage.  Revise it so
     * that the processing can be done in a better way.
     *
     * eg:
     *      - Area of interest may be known ( eg. mouse cursor hovering
     *      over an area )
145
     */  
146
    void processFilters();
147

148
149
150
151
152
153
    /** 
     * Returns a list of menu actions created by the filters for the content
     * at the given @p position.
     */
    QList<QAction*> filterActions(const QPoint& position);

154
155
156
    /** Returns true if the cursor is set to blink or false otherwise. */
    bool blinkingCursor() { return _hasBlinkingCursor; }
    /** Specifies whether or not the cursor blinks. */
Stephan Binner's avatar
Stephan Binner committed
157
    void setBlinkingCursor(bool blink);
158

159
160
    void setCtrlDrag(bool enable) { _ctrlDrag=enable; }
    bool ctrlDrag() { return _ctrlDrag; }
161

162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
	/** 
     *  This enum describes the methods for selecting text when
 	 *  the user triple-clicks within the display. 
 	 */
	enum TripleClickMode
	{
		/** Select the whole line underneath the cursor. */
		SelectWholeLine,
		/** Select from the current cursor position to the end of the line. */
		SelectForwardsFromCursor
	};
    /** Sets how the text is selected when the user triple clicks within the display. */	
    void setTripleClickMode(TripleClickMode mode) { _tripleClickMode = mode; }
	/** See setTripleClickSelectionMode() */
    TripleClickMode tripleClickMode() { return _tripleClickMode; }
177

178
179
180
    void setLineSpacing(uint);
    uint lineSpacing() const;

181
    void emitSelection(bool useXselection,bool appendReturn);
182

183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
    /**
     * This enum describes the available shapes for the keyboard cursor.
     * See setKeyboardCursorShape()
     */
    enum KeyboardCursorShape
    {
        /** A rectangular block which covers the entire area of the cursor character. */
        BlockCursor,
        /** 
         * A single flat line which occupies the space at the bottom of the cursor
         * character's area.
         */
        UnderlineCursor,
        /** 
         * An cursor shaped like the capital letter 'I', similar to the IBeam 
         * cursor used in Qt/KDE text editors.
         */
        IBeamCursor
    };
    /** 
     * Sets the shape of the keyboard cursor.  This is the cursor drawn   
     * at the position in the terminal where keyboard input will appear.
     *
     * In addition the terminal display widget also has a cursor for 
     * the mouse pointer, which can be set using the QWidget::setCursor()
     * method.
     *
     * Defaults to BlockCursor
     */
    void setKeyboardCursorShape(KeyboardCursorShape shape);
    /**
     * Returns the shape of the keyboard cursor.  See setKeyboardCursorShape()
     */
    KeyboardCursorShape keyboardCursorShape() const;

218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
    /**
     * Sets the color used to draw the keyboard cursor.  
     *
     * The keyboard cursor defaults to using the foreground color of the character
     * underneath it.
     *
     * @param useForegroundColor If true, the cursor color will change to match
     * the foreground color of the character underneath it as it is moved, in this
     * case, the @p color parameter is ignored and the color of the character
     * under the cursor is inverted to ensure that it is still readable.
     * @param color The color to use to draw the cursor.  This is only taken into
     * account if @p useForegroundColor is false.
     */
    void setKeyboardCursorColor(bool useForegroundColor , const QColor& color);

    /** 
     * Returns the color of the keyboard cursor, or an invalid color if the keyboard
     * cursor color is set to change according to the foreground color of the character
     * underneath it. 
     */
    QColor keyboardCursorColor() const;

240
241
242
243
244
245
    /**
     * Returns the number of lines of text which can be displayed in the widget.
     *
     * This will depend upon the height of the widget and the current font.
     * See fontHeight()
     */
246
    int  lines()   { return _lines;   }
247
248
249
250
251
252
253
    /**
     * Returns the number of characters of text which can be displayed on
     * each line in the widget.
     *
     * This will depend upon the width of the widget and the current font.
     * See fontWidth()
     */
254
    int  columns() { return _columns; }
255

256
257
258
    /**
     * Returns the height of the characters in the font used to draw the text in the display.
     */
259
    int  fontHeight()   { return _fontHeight;   }
260
261
262
263
    /**
     * Returns the width of the characters in the display.  
     * This assumes the use of a fixed-width font.
     */
264
    int  fontWidth()    { return _fontWidth; }
265

266
267
    void setSize(int cols, int lins);
    void setFixedSize(int cols, int lins);
268
269
    
    // reimplemented
270
271
    QSize sizeHint() const;

272
273
274
275
276
277
278
279
280
281
282
    /**
     * Sets which characters, in addition to letters and numbers, 
     * are regarded as being part of a word for the purposes
     * of selecting words in the display by double clicking on them.
     *
     * The word boundaries occur at the first and last characters which
     * are either a letter, number, or a character in @p wc
     *
     * @param wc An array of characters which are to be considered parts
     * of a word ( in addition to letters and numbers ).
     */
283
    void setWordCharacters(const QString& wc);
284
285
286
287
288
289
    /** 
     * Returns the characters which are considered part of a word for the 
     * purpose of selecting words in the display with the mouse.
     *
     * @see setWordCharacters()
     */
290
    QString wordCharacters() { return _wordCharacters; }
291

292
293
294
295
296
297
298
    /** 
     * Sets the type of effect used to alert the user when a 'bell' occurs in the 
     * terminal session.
     *
     * The terminal session can trigger the bell effect by calling bell() with
     * the alert message.
     */
299
    void setBellMode(int mode);
300
301
302
303
304
305
    /** 
     * Returns the type of effect used to alert the user when a 'bell' occurs in
     * the terminal session.
     * 
     * See setBellMode()
     */
306
    int bellMode() { return _bellMode; }
307
308
309
310
311
312
313
314
315

    /**
     * This enum describes the different types of sounds and visual effects which
     * can be used to alert the user when a 'bell' occurs in the terminal
     * session.
     */
    enum BellMode
    { 
        /** A system beep. */
Robert Knight's avatar
   
Robert Knight committed
316
        SystemBeepBell=0, 
317
318
319
320
        /** 
         * KDE notification.  This may play a sound, show a passive popup
         * or perform some other action depending on the user's settings.
         */
Robert Knight's avatar
   
Robert Knight committed
321
        NotifyBell=1, 
322
        /** A silent, visual bell (eg. inverting the display's colors briefly) */
Robert Knight's avatar
   
Robert Knight committed
323
        VisualBell=2, 
324
        /** No bell effects */
Robert Knight's avatar
   
Robert Knight committed
325
        NoBell=3 
326
    };
327

328
    void setSelection(const QString &t);
329

330
331
332
333
    /** 
     * Reimplemented.  Has no effect.  Use setVTFont() to change the font
     * used to draw characters in the display.
     */
334
    virtual void setFont(const QFont &);
335
336

    /** Returns the font used to draw characters in the display */
337
    QFont getVTFont() { return font(); }
338
339
340
341
342
343

    /** 
     * Sets the font used to draw the display.  Has no effect if @p font
     * is larger than the size of the display itself.    
     */
    void setVTFont(const QFont& font);
344

345
346
347
348
    /**
     * Specified whether anti-aliasing of text in the terminal display
     * is enabled or not.  Defaults to enabled.
     */
349
    static void setAntialias( bool antialias ) { _antialiasText = antialias; }
350
351
352
    /** 
     * Returns true if anti-aliasing of text in the terminal is enabled.
     */
353
    static bool antialias()                 { return _antialiasText;   }
354
    
355
356
357
358
359
    /**
     * Sets whether or not the current height and width of the 
     * terminal in lines and columns is displayed whilst the widget
     * is being resized.
     */
360
    void setTerminalSizeHint(bool on) { _terminalSizeHint=on; }
361
362
363
364
365
    /** 
     * Returns whether or not the current height and width of
     * the terminal in lines and columns is displayed whilst the widget
     * is being resized.
     */
366
    bool terminalSizeHint() { return _terminalSizeHint; }
367
368
369
370
371
372
    /** 
     * Sets whether the terminal size display is shown briefly
     * after the widget is first shown.
     *
     * See setTerminalSizeHint() , isTerminalSizeHint()
     */
373
    void setTerminalSizeStartup(bool on) { _terminalSizeStartup=on; }
374

375
376
377
378
    /**
     * Sets the status of the BiDi rendering inside the terminal display.
     * Defaults to disabled.
     */
379
    void setBidiEnabled(bool set) { _bidiEnabled=set; }
380
381
382
    /**
     * Returns the status of the BiDi rendering in this widget.
     */
383
    bool isBidiEnabled() { return _bidiEnabled; }
384

385
386
387
388
389
390
391
392
    /**
     * Sets the terminal screen section which is displayed in this widget.
     * When updateImage() is called, the display fetches the latest character image from the
     * the associated terminal screen window.
     *
     * In terms of the model-view paradigm, the ScreenWindow is the model which is rendered
     * by the TerminalDisplay.
     */
393
    void setScreenWindow( ScreenWindow* window );
394
    /** Returns the terminal screen section which is displayed in this widget.  See setScreenWindow() */
395
396
    ScreenWindow* screenWindow() const;

397
398
    static bool HAVE_TRANSPARENCY;

399
public slots:
400

401
402
403
404
405
406
407
408
409
410
    /** 
     * Causes the terminal display to fetch the latest character image from the associated
     * terminal screen ( see setScreenWindow() ) and redraw the display.
     */
    void updateImage(); 
    /**
     * Causes the terminal display to fetch the latest line status flags from the 
     * associated terminal screen ( see setScreenWindow() ).  
     */ 
    void updateLineProperties();
411

412
    /** Copies the selected text to the clipboard. */
413
    void copyClipboard();
414
415
416
417
    /** 
     * Pastes the content of the clipboard into the 
     * display.
     */
418
    void pasteClipboard();
419
420
421
422
    /**
     * Pastes the content of the selection into the
     * display.
     */
423
    void pasteSelection();
Robert Knight's avatar
   
Robert Knight committed
424
425
426
427
428
429

	/** 
 	  * Changes whether the flow control warning box should be shown when the flow control
 	  * stop key (Ctrl+S) are pressed.
 	  */
	void setFlowControlWarningEnabled(bool enabled);
430
431
	
    /** 
432
433
434
435
436
437
438
439
	 * Causes the widget to display or hide a message informing the user that terminal
	 * output has been suspended (by using the flow control key combination Ctrl+S)
	 *
	 * @param suspended True if terminal output has been suspended and the warning message should
	 *				 	be shown or false to indicate that terminal output has been resumed and that
	 *				 	the warning message should disappear.
	 */ 
	void outputSuspended(bool suspended);
440

Robert Knight's avatar
   
Robert Knight committed
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
    /**
     * Sets whether the program whoose output is being displayed in the view
     * is interested in mouse events.
     *
     * If this is set to true, mouse signals will be emitted by the view when the user clicks, drags
     * or otherwise moves the mouse inside the view.
     * The user interaction needed to create selections will also change, and the user will be required
     * to hold down the shift key to create a selection or perform other mouse activities inside the 
     * view area - since the program running in the terminal is being allowed to handle normal mouse
     * events itself.
     *
     * @param usesMouse Set to true if the program running in the terminal is interested in mouse events
     * or false otherwise.
     */
    void setUsesMouse(bool usesMouse);
456
457
458
459
  
    /** See setUsesMouse() */
    bool usesMouse() const;

Robert Knight's avatar
   
Robert Knight committed
460
461
462
463
464
    /** 
     * Shows a notification that a bell event has occurred in the terminal.
     * TODO: More documentation here
     */
    void bell(const QString& message);
Robert Knight's avatar
   
Robert Knight committed
465

466
467
468
469
470
471
472
473
474
475
476
477
	/** 
	 * Sets the background of the display to the specified color. 
	 * @see setColorTable(), setForegroundColor() 
	 */
	void setBackgroundColor(const QColor& color);

	/** 
	 * Sets the text of the display to the specified color. 
	 * @see setColorTable(), setBackgroundColor()
	 */
	void setForegroundColor(const QColor& color);

478
signals:
479

480
481
482
    /**
     * Emitted when the user presses a key whilst the terminal widget has focus.
     */
483
    void keyPressedSignal(QKeyEvent *e);
484
485
486
487
488
489
490
491
492

    /**
     * Emitted when the user presses the suspend or resume flow control key combinations 
     * 
     * @param suspend true if the user pressed Ctrl+S (the suspend output key combination) or
     * false if the user pressed Ctrl+Q (the resume output key combination)
     */
    void flowControlKeyPressed(bool suspend);
    
493
494
    /** 
     * A mouse event occurred.
495
496
497
     * @param button The mouse button (0 for left button, 1 for middle button, 2 for right button, 3 for release)
     * @param column The character column where the event occurred
     * @param line The character row where the event occurred
498
499
     * @param eventType The type of event.  0 for a mouse press / release or 1 for mouse motion
     */
500
    void mouseSignal(int button, int column, int line, int eventType);
501
502
    void changedFontMetricSignal(int height, int width);
    void changedContentSizeSignal(int height, int width);
503
504
505
506
507
508
509
510

    /** 
     * Emitted when the user right clicks on the display, or right-clicks with the Shift
     * key held down if usesMouse() is true.
     *
     * This can be used to display a context menu.
     */
    void configureRequest( TerminalDisplay*, int state, const QPoint& position );
511

512
513
   void isBusySelecting(bool);
   void sendStringToEmu(const char*);
514
515

protected:
516
    virtual bool event( QEvent * );
517

518
    virtual void paintEvent( QPaintEvent * );
519

520
521
522
    virtual void showEvent(QShowEvent*);
    virtual void hideEvent(QHideEvent*);
    virtual void resizeEvent(QResizeEvent*);
523

524
    virtual void fontChange(const QFont &font);
525
526
	virtual void focusInEvent(QFocusEvent* event);
	virtual void focusOutEvent(QFocusEvent* event);
527
528
529
530
531
532
533
    virtual void keyPressEvent(QKeyEvent* event);
    virtual void mouseDoubleClickEvent(QMouseEvent* ev);
    virtual void mousePressEvent( QMouseEvent* );
    virtual void mouseReleaseEvent( QMouseEvent* );
    virtual void mouseMoveEvent( QMouseEvent* );
    virtual void extendSelection( const QPoint& pos );
    virtual void wheelEvent( QWheelEvent* );
534

535
536
537
538
539
    virtual bool focusNextPrevChild( bool next );
    
    // drag and drop
    virtual void dragEnterEvent(QDragEnterEvent* event);
    virtual void dropEvent(QDropEvent* event);
540
541
542
543
544
545
    void doDrag();
    enum DragState { diNone, diPending, diDragging };

    struct _dragInfo {
      DragState       state;
      QPoint          start;
Adam Treat's avatar
Adam Treat committed
546
      QDrag           *dragObject;
547
548
    } dragInfo;

549
550
551
552
553
554
555
	// classifies the 'ch' into one of three categories
	// and returns a character to indicate which category it is in
	//
	// 	- A space (returns ' ') 
	// 	- Part of a word (returns 'a')
	// 	- Other characters (returns the input character)
    QChar charClass(QChar ch) const;
556
557
558

    void clearImage();

559
560
    void mouseTripleClickEvent(QMouseEvent* ev);

561
562
563
    // reimplemented
    virtual void inputMethodEvent ( QInputMethodEvent* event );
    virtual QVariant inputMethodQuery( Qt::InputMethodQuery query ) const;
564

565
protected slots:
566

567
    void scrollBarPositionChanged(int value);
568
    void blinkEvent();
Stephan Binner's avatar
Stephan Binner committed
569
    void blinkCursorEvent();
570
    
571
572
573
    //Renables bell noises and visuals.  Used to disable further bells for a short period of time
    //after emitting the first in a sequence of bell events.
    void enableBell();
574

575
576
private slots:

577
578
579
    void swapColorTable();
    void tripleClickTimeout();  // resets possibleTripleClick

580
581
private:

582
583
584
585
586
    // -- Drawing helpers --

    // divides the part of the display specified by 'rect' into
    // fragments according to their colors and styles and calls
    // drawTextFragment() to draw the fragments 
587
    void drawContents(QPainter &paint, const QRect &rect);
588
589
590
591
592
    // draws a section of text, all the text in this section
    // has a common color and style
    void drawTextFragment(QPainter& painter, const QRect& rect, 
                          const QString& text, const Character* style); 
    // draws the background for a text fragment
Robert Knight's avatar
   
Robert Knight committed
593
594
595
596
597
    // if useOpacitySetting is true then the color's alpha value will be set to
    // the display's transparency (set with setOpacity()), otherwise the background
    // will be drawn fully opaque
    void drawBackground(QPainter& painter, const QRect& rect, const QColor& color,
						bool useOpacitySetting);
598
599
600
601
602
603
604
605
606
607
    // draws the cursor character
    void drawCursor(QPainter& painter, const QRect& rect , const QColor& foregroundColor, 
                                       const QColor& backgroundColor , bool& invertColors);
    // draws the characters or line graphics in a text fragment
    void drawCharacters(QPainter& painter, const QRect& rect,  const QString& text, 
                                           const Character* style, bool invertCharacterColor);
    // draws a string of line graphics
	void drawLineCharString(QPainter& painter, int x, int y, 
                            const QString& str, const Character* attributes);

608
    // draws the preedit string for input methods
609
610
    void drawInputMethodPreeditString(QPainter& painter , const QRect& rect);

611
612
    // --

613
    // maps an area in the character image to an area on the widget 
614
    QRect imageToWidget(const QRect& imageArea) const;
615
616
617

    // maps a point on the widget to the position ( ie. line and column ) 
    // of the character at that point.
618
    void getCharacterPosition(const QPoint& widgetPoint,int& line,int& column) const;
619
620
621

    // the area where the preedit string for input methods will be draw
    QRect preeditRect() const;
622

623
624
625
626
    // shows a notification window in the middle of the widget indicating the terminal's
    // current size in columns and lines
    void showResizeNotification();

627
628
    // scrolls the image by a number of lines.  
    // 'lines' may be positive ( to scroll the image down ) 
629
    // or negative ( to scroll the image up )
630
631
632
633
    // 'region' is the part of the image to scroll - currently only
    // the top, bottom and height of 'region' are taken into account,
    // the left and right are ignored.
    void scrollImage(int lines , const QRect& region);
634

635
636
637
    void calcGeometry();
    void propagateSize();
    void updateImageSize();
638
639
    void makeImage();
    
640
    void paintFilters(QPainter& painter);
641
642
643
644
645

	// returns a region covering all of the areas of the widget which contain
	// a hotspot
	QRegion hotSpotRegion() const;

646
647
648
	// returns the position of the cursor in columns and lines
	QPoint cursorPosition() const;

649
650
651
	// redraws the cursor
	void updateCursor();

652
653
    // the window onto the terminal screen which this display
    // is currently showing.  
654
    QPointer<ScreenWindow> _screenWindow;
655

656
    bool _allowBell;
657

658
    QGridLayout* _gridLayout;
659

660
661
662
663
    bool _fixedFont; // has fixed pitch
    int  _fontHeight;     // height
    int  _fontWidth;     // width
    int  _fontAscent;     // ascend
664

Robert Knight's avatar
   
Robert Knight committed
665
666
    int _leftMargin;    // offset
    int _topMargin;    // offset
667

668
669
    int _lines;      // the number of lines that can be displayed in the widget
    int _columns;    // the number of columns that can be displayed in the widget
670
    
671
    int _usedLines;  // the number of lines that are actually being used, this will be less
672
673
                    // than 'lines' if the character image provided with setImage() is smaller
                    // than the maximum image size which can be displayed
674

675
    int _usedColumns; // the number of columns that are actually being used, this will be less
676
677
                     // than 'columns' if the character image provided with setImage() is smaller
                     // than the maximum image size which can be displayed
678
    
679
680
681
    int _contentHeight;
    int _contentWidth;
    Character* _image; // [lines][columns]
682
683
               // only the area [usedLines][usedColumns] in the image contains valid data

684
685
686
687
    int _imageSize;
    QVector<LineProperty> _lineProperties;

    ColorEntry _colorTable[TABLE_COLORS];
688
    uint _randomSeed;
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706

    bool _resizing;
    bool _terminalSizeHint;
    bool _terminalSizeStartup;
    bool _bidiEnabled;
    bool _mouseMarks;

    QPoint  _iPntSel; // initial selection point
    QPoint  _pntSel; // current selection point
    QPoint  _tripleSelBegin; // help avoid flicker
    int     _actSel; // selection state
    bool    _wordSelectionMode;
    bool    _lineSelectionMode;
    bool    _preserveLineBreaks;
    bool    _columnSelectionMode;

    QClipboard*  _clipboard;
    QScrollBar* _scrollBar;
707
    ScrollBarPosition _scrollbarLocation;
708
709
710
711
712
713
714
715
    QString     _wordCharacters;
    int         _bellMode;

    bool _blinking;   // hide text in paintEvent
    bool _hasBlinker; // has characters to blink
    bool _cursorBlinking;     // hide cursor in paintEvent
    bool _hasBlinkingCursor;  // has blinking cursor enabled
    bool _ctrlDrag;           // require Ctrl key for drag
716
    TripleClickMode _tripleClickMode;
717
718
719
720
721
722
723
724
725
    bool _isFixedSize; //Columns / lines are locked.
    QTimer* _blinkTimer;  // active when hasBlinker
    QTimer* _blinkCursorTimer;  // active when hasBlinkingCursor

    KMenu* _drop;
    QString _dropText;
    int _dndFileCount;

    bool _possibleTripleClick;  // is set in mouseDoubleClickEvent and deleted
726
                               // after QApplication::doubleClickInterval() delay
727

728

729
    QLabel* _resizeWidget;
730
    QTimer* _resizeTimer;
731

Robert Knight's avatar
   
Robert Knight committed
732
733
734
735
736
	bool _flowControlWarningEnabled;

    //widgets related to the warning message that appears when the user presses Ctrl+S to suspend
    //terminal output - informing them what has happened and how to resume output
    QLabel* _outputSuspendedLabel; 
737
    	
738
    uint _lineSpacing;
739

740
    bool _colorsInverted; // true during visual bell
741

742
    QSize _size;
743
	
744
745
    QRgb _blendColor;

Robert Knight's avatar
   
Robert Knight committed
746
747
    // list of filters currently applied to the display.  used for links and
    // search highlight
748
    TerminalImageFilterChain* _filterChain;
749
    QRect _mouseOverHotspotArea;
750

751
    KeyboardCursorShape _cursorShape;
Robert Knight's avatar
   
Robert Knight committed
752
753
754
755
756

    // custom cursor color.  if this is invalid then the foreground
    // color of the character under the cursor is used
    QColor _cursorColor;  

757
758
759
760
761
762
763
764

    struct InputMethodData
    {
        QString preeditString;
        QRect previousPreeditRect;
    };
    InputMethodData _inputMethodData;

765
766
    static bool _antialiasText;   // do we antialias or not

Robert Knight's avatar
   
Robert Knight committed
767
768
769
770
771
    //the delay in milliseconds between redrawing blinking text
    static const int BLINK_DELAY = 500;
	static const int DEFAULT_LEFT_MARGIN = 1;
	static const int DEFAULT_TOP_MARGIN = 1;

772
773
774
775
776
public:
    static void setTransparencyEnabled(bool enable)
    {
        HAVE_TRANSPARENCY = enable;
    }
777
778
};

779
780
781
782
783
784
785
786
787
788
789
790
class AutoScrollHandler : public QObject
{
public:
	AutoScrollHandler(QWidget* parent);
protected:
	virtual void timerEvent(QTimerEvent* event);
	virtual bool eventFilter(QObject* watched,QEvent* event);
private:
	QWidget* widget() const { return static_cast<QWidget*>(parent()); }
	int _timerId;
};

Stephan Binner's avatar
Stephan Binner committed
791
}
792

793
#endif // TERMINALDISPLAY_H