source: ogBrowser-Git/qtermwidget/lib/TerminalDisplay.h @ ffbf8ac

jenkinsmain
Last change on this file since ffbf8ac was 64efc22, checked in by Vadim Troshchinskiy <vtroshchinskiy@…>, 19 months ago

Update qtermwidget to modern version

  • Property mode set to 100644
File size: 29.6 KB
Line 
1/*
2    Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
3    Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18    02110-1301  USA.
19*/
20
21#ifndef TERMINALDISPLAY_H
22#define TERMINALDISPLAY_H
23
24// Qt
25#include <QColor>
26#include <QPointer>
27#include <QWidget>
28
29// Konsole
30#include "Filter.h"
31#include "Character.h"
32#include "qtermwidget.h"
33//#include "konsole_export.h"
34#define KONSOLEPRIVATE_EXPORT
35
36class QDrag;
37class QDragEnterEvent;
38class QDropEvent;
39class QLabel;
40class QTimer;
41class QEvent;
42class QGridLayout;
43class QKeyEvent;
44class QScrollBar;
45class QShowEvent;
46class QHideEvent;
47class QTimerEvent;
48class QWidget;
49
50//class KMenu;
51
52namespace Konsole
53{
54
55    enum MotionAfterPasting
56    {
57        // No move screenwindow after pasting
58        NoMoveScreenWindow = 0,
59        // Move start of screenwindow after pasting
60        MoveStartScreenWindow = 1,
61        // Move end of screenwindow after pasting
62        MoveEndScreenWindow = 2
63    };
64
65    enum BackgroundMode {
66        None,
67        Stretch,
68        Zoom,
69        Fit,
70        Center
71    };
72
73extern unsigned short vt100_graphics[32];
74
75class ScreenWindow;
76
77/**
78 * A widget which displays output from a terminal emulation and sends input keypresses and mouse activity
79 * to the terminal.
80 *
81 * When the terminal emulation receives new output from the program running in the terminal,
82 * it will update the display by calling updateImage().
83 *
84 * TODO More documentation
85 */
86class KONSOLEPRIVATE_EXPORT TerminalDisplay : public QWidget
87{
88   Q_OBJECT
89
90public:
91    /** Constructs a new terminal display widget with the specified parent. */
92    TerminalDisplay(QWidget *parent=nullptr);
93    ~TerminalDisplay() override;
94
95    /** Returns the terminal color palette used by the display. */
96    const ColorEntry* colorTable() const;
97    /** Sets the terminal color palette used by the display. */
98    void setColorTable(const ColorEntry table[]);
99    /**
100     * Sets the seed used to generate random colors for the display
101     * (in color schemes that support them).
102     */
103    void setRandomSeed(uint seed);
104    /**
105     * Returns the seed used to generate random colors for the display
106     * (in color schemes that support them).
107     */
108    uint randomSeed() const;
109
110    /** Sets the opacity of the terminal display. */
111    void setOpacity(qreal opacity);
112
113    /** Sets the background image of the terminal display. */
114    void setBackgroundImage(const QString& backgroundImage);
115
116    /** Sets the background image mode of the terminal display. */
117    void setBackgroundMode(BackgroundMode mode);
118
119    /**
120     * Specifies whether the terminal display has a vertical scroll bar, and if so whether it
121     * is shown on the left or right side of the display.
122     */
123    void setScrollBarPosition(QTermWidget::ScrollBarPosition position);
124
125    /**
126     * Sets the current position and range of the display's scroll bar.
127     *
128     * @param cursor The position of the scroll bar's thumb.
129     * @param lines The maximum value of the scroll bar.
130     */
131    void setScroll(int cursor, int lines);
132
133    /**
134     * Scroll to the bottom of the terminal (reset scrolling).
135     */
136    void scrollToEnd();
137
138    /**
139     * Returns the display's filter chain.  When the image for the display is updated,
140     * the text is passed through each filter in the chain.  Each filter can define
141     * hotspots which correspond to certain strings (such as URLs or particular words).
142     * Depending on the type of the hotspots created by the filter ( returned by Filter::Hotspot::type() )
143     * the view will draw visual cues such as underlines on mouse-over for links or translucent
144     * rectangles for markers.
145     *
146     * To add a new filter to the view, call:
147     *      viewWidget->filterChain()->addFilter( filterObject );
148     */
149    FilterChain* filterChain() const;
150
151    /**
152     * Updates the filters in the display's filter chain.  This will cause
153     * the hotspots to be updated to match the current image.
154     *
155     * WARNING:  This function can be expensive depending on the
156     * image size and number of filters in the filterChain()
157     *
158     * TODO - This API does not really allow efficient usage.  Revise it so
159     * that the processing can be done in a better way.
160     *
161     * eg:
162     *      - Area of interest may be known ( eg. mouse cursor hovering
163     *      over an area )
164     */
165    void processFilters();
166
167    /**
168     * Returns a list of menu actions created by the filters for the content
169     * at the given @p position.
170     */
171    QList<QAction*> filterActions(const QPoint& position);
172
173    /** Returns true if the cursor is set to blink or false otherwise. */
174    bool blinkingCursor() { return _hasBlinkingCursor; }
175    /** Specifies whether or not the cursor blinks. */
176    void setBlinkingCursor(bool blink);
177
178    /** Specifies whether or not text can blink. */
179    void setBlinkingTextEnabled(bool blink);
180
181    void setCtrlDrag(bool enable) { _ctrlDrag=enable; }
182    bool ctrlDrag() { return _ctrlDrag; }
183
184    /**
185     *  This enum describes the methods for selecting text when
186      *  the user triple-clicks within the display.
187      */
188    enum TripleClickMode
189    {
190        /** Select the whole line underneath the cursor. */
191        SelectWholeLine,
192        /** Select from the current cursor position to the end of the line. */
193        SelectForwardsFromCursor
194    };
195    /** Sets how the text is selected when the user triple clicks within the display. */
196    void setTripleClickMode(TripleClickMode mode) { _tripleClickMode = mode; }
197    /** See setTripleClickSelectionMode() */
198    TripleClickMode tripleClickMode() { return _tripleClickMode; }
199
200    void setLineSpacing(uint);
201    void setMargin(int);
202
203    int margin() const;
204    uint lineSpacing() const;
205
206    void emitSelection(bool useXselection,bool appendReturn);
207
208    /** change and wrap text corresponding to paste mode **/
209    void bracketText(QString& text) const;
210
211    /**
212     * Sets the shape of the keyboard cursor.  This is the cursor drawn
213     * at the position in the terminal where keyboard input will appear.
214     *
215     * In addition the terminal display widget also has a cursor for
216     * the mouse pointer, which can be set using the QWidget::setCursor()
217     * method.
218     *
219     * Defaults to BlockCursor
220     */
221    void setKeyboardCursorShape(QTermWidget::KeyboardCursorShape shape);
222    /**
223     * Returns the shape of the keyboard cursor.  See setKeyboardCursorShape()
224     */
225    QTermWidget::KeyboardCursorShape keyboardCursorShape() const;
226
227    /**
228     * Sets the color used to draw the keyboard cursor.
229     *
230     * The keyboard cursor defaults to using the foreground color of the character
231     * underneath it.
232     *
233     * @param useForegroundColor If true, the cursor color will change to match
234     * the foreground color of the character underneath it as it is moved, in this
235     * case, the @p color parameter is ignored and the color of the character
236     * under the cursor is inverted to ensure that it is still readable.
237     * @param color The color to use to draw the cursor.  This is only taken into
238     * account if @p useForegroundColor is false.
239     */
240    void setKeyboardCursorColor(bool useForegroundColor , const QColor& color);
241
242    /**
243     * Returns the color of the keyboard cursor, or an invalid color if the keyboard
244     * cursor color is set to change according to the foreground color of the character
245     * underneath it.
246     */
247    QColor keyboardCursorColor() const;
248
249    /**
250     * Returns the number of lines of text which can be displayed in the widget.
251     *
252     * This will depend upon the height of the widget and the current font.
253     * See fontHeight()
254     */
255    int  lines()   { return _lines;   }
256    /**
257     * Returns the number of characters of text which can be displayed on
258     * each line in the widget.
259     *
260     * This will depend upon the width of the widget and the current font.
261     * See fontWidth()
262     */
263    int  columns() { return _columns; }
264
265    /**
266     * Returns the height of the characters in the font used to draw the text in the display.
267     */
268    int  fontHeight()   { return _fontHeight;   }
269    /**
270     * Returns the width of the characters in the display.
271     * This assumes the use of a fixed-width font.
272     */
273    int  fontWidth()    { return _fontWidth; }
274
275    void setSize(int cols, int lins);
276    void setFixedSize(int cols, int lins);
277
278    // reimplemented
279    QSize sizeHint() const override;
280
281    /**
282     * Sets which characters, in addition to letters and numbers,
283     * are regarded as being part of a word for the purposes
284     * of selecting words in the display by double clicking on them.
285     *
286     * The word boundaries occur at the first and last characters which
287     * are either a letter, number, or a character in @p wc
288     *
289     * @param wc An array of characters which are to be considered parts
290     * of a word ( in addition to letters and numbers ).
291     */
292    void setWordCharacters(const QString& wc);
293    /**
294     * Returns the characters which are considered part of a word for the
295     * purpose of selecting words in the display with the mouse.
296     *
297     * @see setWordCharacters()
298     */
299    QString wordCharacters() { return _wordCharacters; }
300
301    /**
302     * Sets the type of effect used to alert the user when a 'bell' occurs in the
303     * terminal session.
304     *
305     * The terminal session can trigger the bell effect by calling bell() with
306     * the alert message.
307     */
308    void setBellMode(int mode);
309    /**
310     * Returns the type of effect used to alert the user when a 'bell' occurs in
311     * the terminal session.
312     *
313     * See setBellMode()
314     */
315    int bellMode() { return _bellMode; }
316
317    /**
318     * This enum describes the different types of sounds and visual effects which
319     * can be used to alert the user when a 'bell' occurs in the terminal
320     * session.
321     */
322    enum BellMode
323    {
324        /** A system beep. */
325        SystemBeepBell=0,
326        /**
327         * KDE notification.  This may play a sound, show a passive popup
328         * or perform some other action depending on the user's settings.
329         */
330        NotifyBell=1,
331        /** A silent, visual bell (eg. inverting the display's colors briefly) */
332        VisualBell=2,
333        /** No bell effects */
334        NoBell=3
335    };
336
337    void setSelection(const QString &t);
338
339    /**
340     * Reimplemented.  Has no effect.  Use setVTFont() to change the font
341     * used to draw characters in the display.
342     */
343    virtual void setFont(const QFont &);
344
345    /** Returns the font used to draw characters in the display */
346    QFont getVTFont() { return font(); }
347
348    /**
349     * Sets the font used to draw the display.  Has no effect if @p font
350     * is larger than the size of the display itself.
351     */
352    void setVTFont(const QFont& font);
353
354    /**
355     * Specified whether anti-aliasing of text in the terminal display
356     * is enabled or not.  Defaults to enabled.
357     */
358    static void setAntialias( bool antialias ) { _antialiasText = antialias; }
359    /**
360     * Returns true if anti-aliasing of text in the terminal is enabled.
361     */
362    static bool antialias()                 { return _antialiasText;   }
363
364    /**
365     * Specify whether line chars should be drawn by ourselves or left to
366     * underlying font rendering libraries.
367     */
368    void setDrawLineChars(bool drawLineChars) { _drawLineChars = drawLineChars; }
369
370    /**
371     * Specifies whether characters with intense colors should be rendered
372     * as bold. Defaults to true.
373     */
374    void setBoldIntense(bool value) { _boldIntense = value; }
375    /**
376     * Returns true if characters with intense colors are rendered in bold.
377     */
378    bool getBoldIntense() { return _boldIntense; }
379
380    /**
381     * Sets whether or not the current height and width of the
382     * terminal in lines and columns is displayed whilst the widget
383     * is being resized.
384     */
385    void setTerminalSizeHint(bool on) { _terminalSizeHint=on; }
386    /**
387     * Returns whether or not the current height and width of
388     * the terminal in lines and columns is displayed whilst the widget
389     * is being resized.
390     */
391    bool terminalSizeHint() { return _terminalSizeHint; }
392    /**
393     * Sets whether the terminal size display is shown briefly
394     * after the widget is first shown.
395     *
396     * See setTerminalSizeHint() , isTerminalSizeHint()
397     */
398    void setTerminalSizeStartup(bool on) { _terminalSizeStartup=on; }
399
400    /**
401     * Sets the status of the BiDi rendering inside the terminal display.
402     * Defaults to disabled.
403     */
404    void setBidiEnabled(bool set) { _bidiEnabled=set; }
405    /**
406     * Returns the status of the BiDi rendering in this widget.
407     */
408    bool isBidiEnabled() { return _bidiEnabled; }
409
410    /**
411     * Sets the terminal screen section which is displayed in this widget.
412     * When updateImage() is called, the display fetches the latest character image from the
413     * the associated terminal screen window.
414     *
415     * In terms of the model-view paradigm, the ScreenWindow is the model which is rendered
416     * by the TerminalDisplay.
417     */
418    void setScreenWindow( ScreenWindow* window );
419    /** Returns the terminal screen section which is displayed in this widget.  See setScreenWindow() */
420    ScreenWindow* screenWindow() const;
421
422    static bool HAVE_TRANSPARENCY;
423
424    void setMotionAfterPasting(MotionAfterPasting action);
425    int motionAfterPasting();
426    void setConfirmMultilinePaste(bool confirmMultilinePaste);
427    void setTrimPastedTrailingNewlines(bool trimPastedTrailingNewlines);
428
429    // maps a point on the widget to the position ( ie. line and column )
430    // of the character at that point.
431    void getCharacterPosition(const QPointF& widgetPoint,int& line,int& column) const;
432
433    void disableBracketedPasteMode(bool disable) { _disabledBracketedPasteMode = disable; }
434    bool bracketedPasteModeIsDisabled() const { return _disabledBracketedPasteMode; }
435
436public slots:
437
438    /**
439     * Causes the terminal display to fetch the latest character image from the associated
440     * terminal screen ( see setScreenWindow() ) and redraw the display.
441     */
442    void updateImage();
443
444    /** Essentially calls processFilters().
445     */
446    void updateFilters();
447
448    /**
449     * Causes the terminal display to fetch the latest line status flags from the
450     * associated terminal screen ( see setScreenWindow() ).
451     */
452    void updateLineProperties();
453
454    /** Copies the selected text to the clipboard. */
455    void copyClipboard();
456    /**
457     * Pastes the content of the clipboard into the
458     * display.
459     */
460    void pasteClipboard();
461    /**
462     * Pastes the content of the selection into the
463     * display.
464     */
465    void pasteSelection();
466
467    /**
468       * Changes whether the flow control warning box should be shown when the flow control
469       * stop key (Ctrl+S) are pressed.
470       */
471    void setFlowControlWarningEnabled(bool enabled);
472    /**
473     * Returns true if the flow control warning box is enabled.
474     * See outputSuspended() and setFlowControlWarningEnabled()
475     */
476    bool flowControlWarningEnabled() const
477    { return _flowControlWarningEnabled; }
478
479    /**
480     * Causes the widget to display or hide a message informing the user that terminal
481     * output has been suspended (by using the flow control key combination Ctrl+S)
482     *
483     * @param suspended True if terminal output has been suspended and the warning message should
484     *                     be shown or false to indicate that terminal output has been resumed and that
485     *                     the warning message should disappear.
486     */
487    void outputSuspended(bool suspended);
488
489    /**
490     * Sets whether the program whose output is being displayed in the view
491     * is interested in mouse events.
492     *
493     * If this is set to true, mouse signals will be emitted by the view when the user clicks, drags
494     * or otherwise moves the mouse inside the view.
495     * The user interaction needed to create selections will also change, and the user will be required
496     * to hold down the shift key to create a selection or perform other mouse activities inside the
497     * view area - since the program running in the terminal is being allowed to handle normal mouse
498     * events itself.
499     *
500     * @param usesMouse Set to true if the program running in the terminal is interested in mouse events
501     * or false otherwise.
502     */
503    void setUsesMouse(bool usesMouse);
504
505    /** See setUsesMouse() */
506    bool usesMouse() const;
507
508    void setBracketedPasteMode(bool bracketedPasteMode);
509    bool bracketedPasteMode() const;
510
511    /**
512     * Shows a notification that a bell event has occurred in the terminal.
513     * TODO: More documentation here
514     */
515    void bell(const QString& message);
516
517    /**
518     * Sets the background of the display to the specified color.
519     * @see setColorTable(), setForegroundColor()
520     */
521    void setBackgroundColor(const QColor& color);
522
523    /**
524     * Sets the text of the display to the specified color.
525     * @see setColorTable(), setBackgroundColor()
526     */
527    void setForegroundColor(const QColor& color);
528
529    void selectionChanged();
530
531signals:
532
533    /**
534     * Emitted when the user presses a key whilst the terminal widget has focus.
535     */
536    void keyPressedSignal(QKeyEvent *e, bool fromPaste);
537
538    /**
539     * A mouse event occurred.
540     * @param button The mouse button (0 for left button, 1 for middle button, 2 for right button, 3 for release)
541     * @param column The character column where the event occurred
542     * @param line The character row where the event occurred
543     * @param eventType The type of event.  0 for a mouse press / release or 1 for mouse motion
544     */
545    void mouseSignal(int button, int column, int line, int eventType);
546    void changedFontMetricSignal(int height, int width);
547    void changedContentSizeSignal(int height, int width);
548
549    /**
550     * Emitted when the user right clicks on the display, or right-clicks with the Shift
551     * key held down if usesMouse() is true.
552     *
553     * This can be used to display a context menu.
554     */
555    void configureRequest(const QPoint& position);
556
557    /**
558     * When a shortcut which is also a valid terminal key sequence is pressed while
559     * the terminal widget  has focus, this signal is emitted to allow the host to decide
560     * whether the shortcut should be overridden.
561     * When the shortcut is overridden, the key sequence will be sent to the terminal emulation instead
562     * and the action associated with the shortcut will not be triggered.
563     *
564     * @p override is set to false by default and the shortcut will be triggered as normal.
565     */
566    void overrideShortcutCheck(QKeyEvent* keyEvent,bool& override);
567
568   void isBusySelecting(bool);
569   void sendStringToEmu(const char*);
570
571   // qtermwidget signals
572        void copyAvailable(bool);
573        void termGetFocus();
574        void termLostFocus();
575
576    void notifyBell(const QString&);
577    void usesMouseChanged();
578
579protected:
580    bool event( QEvent * ) override;
581
582    void paintEvent( QPaintEvent * ) override;
583
584    void showEvent(QShowEvent*) override;
585    void hideEvent(QHideEvent*) override;
586    void resizeEvent(QResizeEvent*) override;
587
588    virtual void fontChange(const QFont &font);
589    void focusInEvent(QFocusEvent* event) override;
590    void focusOutEvent(QFocusEvent* event) override;
591    void keyPressEvent(QKeyEvent* event) override;
592    void mouseDoubleClickEvent(QMouseEvent* ev) override;
593    void mousePressEvent( QMouseEvent* ) override;
594    void mouseReleaseEvent( QMouseEvent* ) override;
595    void mouseMoveEvent( QMouseEvent* ) override;
596    virtual void extendSelection( const QPoint& pos );
597    void wheelEvent( QWheelEvent* ) override;
598
599    bool focusNextPrevChild( bool next ) override;
600
601    // drag and drop
602    void dragEnterEvent(QDragEnterEvent* event) override;
603    void dropEvent(QDropEvent* event) override;
604    void doDrag();
605    enum DragState { diNone, diPending, diDragging };
606
607    struct _dragInfo {
608      DragState       state;
609      QPoint          start;
610      QDrag           *dragObject;
611    } dragInfo;
612
613    // classifies the 'ch' into one of three categories
614    // and returns a character to indicate which category it is in
615    //
616    //     - A space (returns ' ')
617    //     - Part of a word (returns 'a')
618    //     - Other characters (returns the input character)
619    QChar charClass(QChar ch) const;
620
621    void clearImage();
622
623    void mouseTripleClickEvent(QMouseEvent* ev);
624
625    // reimplemented
626    void inputMethodEvent ( QInputMethodEvent* event ) override;
627    QVariant inputMethodQuery( Qt::InputMethodQuery query ) const override;
628
629protected slots:
630
631    void scrollBarPositionChanged(int value);
632    void blinkEvent();
633    void blinkCursorEvent();
634
635    //Renables bell noises and visuals.  Used to disable further bells for a short period of time
636    //after emitting the first in a sequence of bell events.
637    void enableBell();
638
639private slots:
640
641    void swapColorTable();
642    void tripleClickTimeout();  // resets possibleTripleClick
643
644private:
645
646    // -- Drawing helpers --
647
648    // determine the width of this text
649    int textWidth(int startColumn, int length, int line) const;
650    // determine the area that encloses this series of characters
651    QRect calculateTextArea(int topLeftX, int topLeftY, int startColumn, int line, int length);
652
653    // divides the part of the display specified by 'rect' into
654    // fragments according to their colors and styles and calls
655    // drawTextFragment() to draw the fragments
656    void drawContents(QPainter &paint, const QRect &rect);
657    // draws a section of text, all the text in this section
658    // has a common color and style
659    void drawTextFragment(QPainter& painter, const QRect& rect,
660                          const std::wstring& text, const Character* style);
661    // draws the background for a text fragment
662    // if useOpacitySetting is true then the color's alpha value will be set to
663    // the display's transparency (set with setOpacity()), otherwise the background
664    // will be drawn fully opaque
665    void drawBackground(QPainter& painter, const QRect& rect, const QColor& color,
666                        bool useOpacitySetting);
667    // draws the cursor character
668    void drawCursor(QPainter& painter, const QRect& rect , const QColor& foregroundColor,
669                                       const QColor& backgroundColor , bool& invertColors);
670    // draws the characters or line graphics in a text fragment
671    void drawCharacters(QPainter& painter, const QRect& rect,  const std::wstring& text,
672                                           const Character* style, bool invertCharacterColor);
673    // draws a string of line graphics
674    void drawLineCharString(QPainter& painter, int x, int y,
675                            const std::wstring& str, const Character* attributes) const;
676
677    // draws the preedit string for input methods
678    void drawInputMethodPreeditString(QPainter& painter , const QRect& rect);
679
680    // --
681
682    // maps an area in the character image to an area on the widget
683    QRect imageToWidget(const QRect& imageArea) const;
684
685    // the area where the preedit string for input methods will be draw
686    QRect preeditRect() const;
687
688    // shows a notification window in the middle of the widget indicating the terminal's
689    // current size in columns and lines
690    void showResizeNotification();
691
692    // scrolls the image by a number of lines.
693    // 'lines' may be positive ( to scroll the image down )
694    // or negative ( to scroll the image up )
695    // 'region' is the part of the image to scroll - currently only
696    // the top, bottom and height of 'region' are taken into account,
697    // the left and right are ignored.
698    void scrollImage(int lines , const QRect& region);
699
700    // shows the multiline prompt
701    bool multilineConfirmation(const QString& text);
702
703    void calcGeometry();
704    void propagateSize();
705    void updateImageSize();
706    void makeImage();
707
708    void paintFilters(QPainter& painter);
709
710    void calDrawTextAdditionHeight(QPainter& painter);
711
712    // returns a region covering all of the areas of the widget which contain
713    // a hotspot
714    QRegion hotSpotRegion() const;
715
716    // returns the position of the cursor in columns and lines
717    QPoint cursorPosition() const;
718
719    // redraws the cursor
720    void updateCursor();
721
722    bool handleShortcutOverrideEvent(QKeyEvent* event);
723
724    bool isLineChar(wchar_t c) const;
725    bool isLineCharString(const std::wstring& string) const;
726
727    // the window onto the terminal screen which this display
728    // is currently showing.
729    QPointer<ScreenWindow> _screenWindow;
730
731    bool _allowBell;
732
733    QGridLayout* _gridLayout;
734
735    bool _fixedFont; // has fixed pitch
736    int  _fontHeight;     // height
737    int  _fontWidth;     // width
738    int  _fontAscent;     // ascend
739    bool _boldIntense;   // Whether intense colors should be rendered with bold font
740    int  _drawTextAdditionHeight;   // additional height to prevent font trancation
741    bool _drawTextTestFlag;         // indicate it is a testing or not
742
743    int _leftMargin;    // offset
744    int _topMargin;    // offset
745
746    int _lines;      // the number of lines that can be displayed in the widget
747    int _columns;    // the number of columns that can be displayed in the widget
748
749    int _usedLines;  // the number of lines that are actually being used, this will be less
750                    // than 'lines' if the character image provided with setImage() is smaller
751                    // than the maximum image size which can be displayed
752
753    int _usedColumns; // the number of columns that are actually being used, this will be less
754                     // than 'columns' if the character image provided with setImage() is smaller
755                     // than the maximum image size which can be displayed
756
757    int _contentHeight;
758    int _contentWidth;
759    Character* _image; // [lines][columns]
760               // only the area [usedLines][usedColumns] in the image contains valid data
761
762    int _imageSize;
763    QVector<LineProperty> _lineProperties;
764
765    ColorEntry _colorTable[TABLE_COLORS];
766    uint _randomSeed;
767
768    bool _resizing;
769    bool _terminalSizeHint;
770    bool _terminalSizeStartup;
771    bool _bidiEnabled;
772    bool _mouseMarks;
773    bool _bracketedPasteMode;
774    bool _disabledBracketedPasteMode;
775
776    QPoint  _iPntSel; // initial selection point
777    QPoint  _pntSel; // current selection point
778    QPoint  _tripleSelBegin; // help avoid flicker
779    int     _actSel; // selection state
780    bool    _wordSelectionMode;
781    bool    _lineSelectionMode;
782    bool    _preserveLineBreaks;
783    bool    _columnSelectionMode;
784
785    QClipboard*  _clipboard;
786    QScrollBar* _scrollBar;
787    QTermWidget::ScrollBarPosition _scrollbarLocation;
788    QString     _wordCharacters;
789    int         _bellMode;
790
791    bool _blinking;   // hide text in paintEvent
792    bool _hasBlinker; // has characters to blink
793    bool _cursorBlinking;     // hide cursor in paintEvent
794    bool _hasBlinkingCursor;  // has blinking cursor enabled
795    bool _allowBlinkingText;  // allow text to blink
796    bool _ctrlDrag;           // require Ctrl key for drag
797    TripleClickMode _tripleClickMode;
798    bool _isFixedSize; //Columns / lines are locked.
799    QTimer* _blinkTimer;  // active when hasBlinker
800    QTimer* _blinkCursorTimer;  // active when hasBlinkingCursor
801
802    //QMenu* _drop;
803    QString _dropText;
804    int _dndFileCount;
805
806    bool _possibleTripleClick;  // is set in mouseDoubleClickEvent and deleted
807                               // after QApplication::doubleClickInterval() delay
808
809
810    QLabel* _resizeWidget;
811    QTimer* _resizeTimer;
812
813    bool _flowControlWarningEnabled;
814
815    //widgets related to the warning message that appears when the user presses Ctrl+S to suspend
816    //terminal output - informing them what has happened and how to resume output
817    QLabel* _outputSuspendedLabel;
818
819    uint _lineSpacing;
820
821    bool _colorsInverted; // true during visual bell
822
823    QSize _size;
824
825    qreal _opacity;
826
827    QPixmap _backgroundImage;
828    BackgroundMode _backgroundMode;
829
830    // list of filters currently applied to the display.  used for links and
831    // search highlight
832    TerminalImageFilterChain* _filterChain;
833    QRegion _mouseOverHotspotArea;
834
835    QTermWidget::KeyboardCursorShape _cursorShape;
836
837    // custom cursor color.  if this is invalid then the foreground
838    // color of the character under the cursor is used
839    QColor _cursorColor;
840
841
842    MotionAfterPasting mMotionAfterPasting;
843    bool _confirmMultilinePaste;
844    bool _trimPastedTrailingNewlines;
845
846    struct InputMethodData
847    {
848        std::wstring preeditString;
849        QRect previousPreeditRect;
850    };
851    InputMethodData _inputMethodData;
852
853    static bool _antialiasText;   // do we antialias or not
854
855    //the delay in milliseconds between redrawing blinking text
856    static const int TEXT_BLINK_DELAY = 500;
857
858    int _leftBaseMargin;
859    int _topBaseMargin;
860
861    bool _drawLineChars;
862
863public:
864    static void setTransparencyEnabled(bool enable)
865    {
866        HAVE_TRANSPARENCY = enable;
867    }
868};
869
870class AutoScrollHandler : public QObject
871{
872Q_OBJECT
873
874public:
875    AutoScrollHandler(QWidget* parent);
876protected:
877    void timerEvent(QTimerEvent* event) override;
878    bool eventFilter(QObject* watched,QEvent* event) override;
879private:
880    QWidget* widget() const { return static_cast<QWidget*>(parent()); }
881    int _timerId;
882};
883
884}
885
886#endif // TERMINALDISPLAY_H
Note: See TracBrowser for help on using the repository browser.