File indexing completed on 2024-04-21 05:51:15

0001 /*
0002     SPDX-FileCopyrightText: 2007-2008 Robert Knight <robertknight@gmail.com>
0003     SPDX-FileCopyrightText: 1997, 1998 Lars Doelle <lars.doelle@on-line.de>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef TERMINALDISPLAY_H
0009 #define TERMINALDISPLAY_H
0010 
0011 // Qt
0012 #include <QColor>
0013 #include <QPointer>
0014 #include <QWidget>
0015 
0016 #include <memory>
0017 
0018 // Konsole
0019 #include "../characters/Character.h"
0020 #include "Enumeration.h"
0021 #include "ScreenWindow.h"
0022 #include "ScrollState.h"
0023 #include "colorscheme/ColorScheme.h"
0024 #include "konsoleprivate_export.h"
0025 #include "widgets/TerminalHeaderBar.h"
0026 
0027 #include "TerminalBell.h"
0028 
0029 class QDrag;
0030 class QDragEnterEvent;
0031 class QDropEvent;
0032 class QLabel;
0033 class QTimer;
0034 class QEvent;
0035 class QVBoxLayout;
0036 class QKeyEvent;
0037 class QScroller;
0038 class QShowEvent;
0039 class QHideEvent;
0040 class QTimerEvent;
0041 class QScrollEvent;
0042 class QScrollPrepareEvent;
0043 class KMessageWidget;
0044 class QMimeData;
0045 
0046 struct UBiDi;
0047 
0048 namespace Konsole
0049 {
0050 class TerminalPainter;
0051 class TerminalScrollBar;
0052 class TerminalColor;
0053 class TerminalFont;
0054 
0055 class KonsolePrintManager;
0056 
0057 class FilterChain;
0058 class TerminalImageFilterChain;
0059 class SessionController;
0060 class IncrementalSearchBar;
0061 class HotSpot;
0062 class Profile;
0063 
0064 /**
0065  * This function adjusts a rect by adding a 1px border around it. The idea is to
0066  * compensate in case of approximation issues on highdpi displays with fractional
0067  * scaling applied.
0068  * As Qt6 may not be affected by this issue, the adjustment is not added in that
0069  * case. Hopefully the compiler ignores this function in that case.
0070  */
0071 inline QRect highdpi_adjust_rect(const QRect &rect)
0072 {
0073     return rect;
0074 }
0075 
0076 /**
0077  * A widget which displays output from a terminal emulation and sends input keypresses and mouse activity
0078  * to the terminal.
0079  *
0080  * When the terminal emulation receives new output from the program running in the terminal,
0081  * it will update the display by calling updateImage().
0082  *
0083  * TODO More documentation
0084  */
0085 class KONSOLEPRIVATE_EXPORT TerminalDisplay : public QWidget
0086 {
0087     Q_OBJECT
0088 
0089 public:
0090     /** Constructs a new terminal display widget with the specified parent. */
0091     explicit TerminalDisplay(QWidget *parent = nullptr);
0092     ~TerminalDisplay() override;
0093 
0094     void showDragTarget(const QPoint &cursorPos);
0095     void hideDragTarget();
0096 
0097     void applyProfile(const QExplicitlySharedDataPointer<Profile> &profile);
0098 
0099     /**
0100      * Sets the seed used to generate random colors for the display
0101      * (in color schemes that support them).
0102      */
0103     void setRandomSeed(uint randomSeed);
0104     /**
0105      * Returns the seed used to generate random colors for the display
0106      * (in color schemes that support them).
0107      */
0108     uint randomSeed() const;
0109 
0110     /** Sets the opacity of the terminal display. */
0111     void setOpacity(qreal opacity);
0112 
0113     /** Sets the background picture */
0114     void setWallpaper(const ColorSchemeWallpaper::Ptr &p);
0115 
0116     /**
0117      * Returns the display's filter chain.  When the image for the display is updated,
0118      * the text is passed through each filter in the chain.  Each filter can define
0119      * hotspots which correspond to certain strings (such as URLs or particular words).
0120      * Depending on the type of the hotspots created by the filter ( returned by Filter::Hotspot::type() )
0121      * the view will draw visual cues such as underlines on mouse-over for links or translucent
0122      * rectangles for markers.
0123      *
0124      * To add a new filter to the view, call:
0125      *      viewWidget->filterChain()->addFilter( filterObject );
0126      */
0127     FilterChain *filterChain() const;
0128 
0129     /**
0130      * Updates the filters in the display's filter chain.  This will cause
0131      * the hotspots to be updated to match the current image.
0132      *
0133      * WARNING:  This function can be expensive depending on the
0134      * image size and number of filters in the filterChain()
0135      *
0136      * TODO - This API does not really allow efficient usage.  Revise it so
0137      * that the processing can be done in a better way.
0138      *
0139      * eg:
0140      *      - Area of interest may be known ( eg. mouse cursor hovering
0141      *      over an area )
0142      */
0143     void processFilters();
0144 
0145     /**
0146      * Returns a list of menu actions created by the filters for the content
0147      * at the given @p position.
0148      */
0149     QSharedPointer<HotSpot> filterActions(const QPoint &position);
0150 
0151     /** Specifies whether or not the cursor can blink. */
0152     void setBlinkingCursorEnabled(bool blink);
0153 
0154     /** Specifies whether or not text can blink. */
0155     void setBlinkingTextEnabled(bool blink);
0156 
0157     void setSessionController(SessionController *controller);
0158     SessionController *sessionController();
0159     Session::Ptr session() const;
0160 
0161     /**
0162      * Sets the shape of the keyboard cursor.  This is the cursor drawn
0163      * at the position in the terminal where keyboard input will appear.
0164      *
0165      * In addition the terminal display widget also has a cursor for
0166      * the mouse pointer, which can be set using the QWidget::setCursor()
0167      * method.
0168      *
0169      * Defaults to BlockCursor
0170      */
0171     void setKeyboardCursorShape(Enum::CursorShapeEnum shape);
0172 
0173     /**
0174      * Sets the Cursor Style (DECSCUSR) via escape sequences
0175      * @p shape cursor shape
0176      * @p isBlinking if true, the cursor will be set to blink
0177      * @p customColor custom cursor color
0178      */
0179     void setCursorStyle(Enum::CursorShapeEnum shape, bool isBlinking, const QColor &customColor);
0180 
0181     /**
0182      * Resets the cursor style to the current profile cursor shape and
0183      * blinking settings
0184      */
0185     void resetCursorStyle();
0186 
0187     /**
0188      * Returns the number of lines of text which can be displayed in the widget.
0189      *
0190      * This will depend upon the height of the widget and the current font.
0191      * See fontHeight()
0192      */
0193     int lines() const
0194     {
0195         return _lines;
0196     }
0197 
0198     /**
0199      * Returns the number of characters of text which can be displayed on
0200      * each line in the widget.
0201      *
0202      * This will depend upon the width of the widget and the current font.
0203      * See fontWidth()
0204      */
0205     int columns() const
0206     {
0207         return _columns;
0208     }
0209 
0210     int usedColumns() const
0211     {
0212         return _usedColumns;
0213     }
0214 
0215     int id() const
0216     {
0217         return _id;
0218     }
0219 
0220     void setSize(int columns, int lines);
0221     void propagateSize();
0222 
0223     // reimplemented
0224     QSize sizeHint() const override;
0225 
0226     /**
0227      * Sets which characters, in addition to letters and numbers,
0228      * are regarded as being part of a word for the purposes
0229      * of selecting words in the display by double clicking on them.
0230      *
0231      * The word boundaries occur at the first and last characters which
0232      * are either a letter, number, or a character in @p wc
0233      *
0234      * @param wc An array of characters which are to be considered parts
0235      * of a word ( in addition to letters and numbers ).
0236      */
0237     void setWordCharacters(const QString &wc);
0238 
0239     TerminalHeaderBar *headerBar() const
0240     {
0241         return _headerBar;
0242     }
0243 
0244     void resetCursor();
0245 
0246     QRect contentRect() const
0247     {
0248         return _contentRect;
0249     }
0250     bool openLinksByDirectClick() const
0251     {
0252         return _openLinksByDirectClick;
0253     }
0254 
0255     /**
0256      * Sets the terminal screen section which is displayed in this widget.
0257      * When updateImage() is called, the display fetches the latest character image from the
0258      * the associated terminal screen window.
0259      *
0260      * In terms of the model-view paradigm, the ScreenWindow is the model which is rendered
0261      * by the TerminalDisplay.
0262      */
0263     void setScreenWindow(ScreenWindow *window);
0264     /** Returns the terminal screen section which is displayed in this widget.  See setScreenWindow() */
0265     QPointer<ScreenWindow> screenWindow() const
0266     {
0267         return _screenWindow;
0268     }
0269 
0270     // Select the current line.
0271     void selectCurrentLine();
0272 
0273     /**
0274      * Selects everything in the terminal
0275      */
0276     void selectAll();
0277 
0278     bool bracketedPasteMode() const;
0279 
0280     /**
0281      * Returns true if the flow control warning box is enabled.
0282      * See outputSuspended() and setFlowControlWarningEnabled()
0283      */
0284     bool flowControlWarningEnabled() const
0285     {
0286         return _flowControlWarningEnabled;
0287     }
0288 
0289     /** See setUsesMouseTracking() */
0290     bool usesMouseTracking() const;
0291 
0292     /**
0293      * Set whether mouse tracking should be allowed, even if requested.
0294      * This is stored separately from if mouse tracking is enabled, in case the
0295      * user turns it on/off while mouse tracking is requested.
0296      */
0297     void setAllowMouseTracking(const bool allow);
0298     bool allowsMouseTracking() const;
0299 
0300     bool hasCompositeFocus() const
0301     {
0302         return _hasCompositeFocus;
0303     }
0304 
0305     // maps an area in the character image to an area on the widget
0306     QRect imageToWidget(const QRect &imageArea) const;
0307     QRect widgetToImage(const QRect &widgetArea) const;
0308 
0309     // maps a point on the widget to the position ( ie. line and column )
0310     // of the character at that point. When the edge is true, it maps to
0311     // a character which left edge is closest to the point.
0312     QPair<int, int> getCharacterPosition(const QPoint &widgetPoint, bool edge) const;
0313 
0314     // toggle the header bar Minimize/Maximize button.
0315     void setExpandedMode(bool expand);
0316 
0317     TerminalScrollBar *scrollBar() const
0318     {
0319         return _scrollBar;
0320     }
0321 
0322     TerminalColor *terminalColor() const
0323     {
0324         return _terminalColor;
0325     }
0326 
0327     TerminalFont *terminalFont() const
0328     {
0329         return _terminalFont.get();
0330     }
0331 
0332     /**
0333      * Return the current color scheme
0334      */
0335     const std::shared_ptr<const ColorScheme> &colorScheme() const
0336     {
0337         return _colorScheme;
0338     }
0339 
0340     bool cursorBlinking() const
0341     {
0342         return _cursorBlinking;
0343     }
0344 
0345     bool textBlinking() const
0346     {
0347         return _textBlinking;
0348     }
0349 
0350     Enum::CursorShapeEnum cursorShape() const
0351     {
0352         return _cursorShape;
0353     }
0354 
0355     bool bidiEnabled() const
0356     {
0357         return _bidiEnabled;
0358     }
0359 
0360     bool semanticUpDown() const
0361     {
0362         return _semanticUpDown;
0363     }
0364 
0365     ColorSchemeWallpaper::Ptr wallpaper() const
0366     {
0367         return _wallpaper;
0368     }
0369 
0370     struct InputMethodData {
0371         QString preeditString;
0372         QRect previousPreeditRect;
0373     };
0374 
0375     // returns true if the cursor's position is on display.
0376     bool isCursorOnDisplay() const;
0377 
0378     // returns the position of the cursor in columns and lines
0379     QPoint cursorPosition() const;
0380 
0381     // returns 0 - not selecting, 1 - pending selection (button pressed but no movement yet), 2 - selecting
0382     int selectionState() const;
0383 
0384     bool trimTrailingWhitespace() const
0385     {
0386         return _trimTrailingSpaces;
0387     }
0388 
0389     Qt::Edge droppedEdge() const
0390     {
0391         return _overlayEdge;
0392     }
0393     IncrementalSearchBar *searchBar() const;
0394     Character getCursorCharacter(int column, int line);
0395 
0396     int loc(int x, int y) const;
0397 
0398     /**
0399      * Scrolls current ScreenWindow
0400      *
0401      * it's needed for proper handling scroll commands in the Vt102Emulation class
0402      */
0403     void scrollScreenWindow(enum ScreenWindow::RelativeScrollMode mode, int amount);
0404 
0405     /**
0406      * Causes the widget to display or hide a message informing the user that terminal
0407      * output has been suspended (by using the flow control key combination Ctrl+S)
0408      *
0409      * @param suspended True if terminal output has been suspended and the warning message should
0410      *                     be shown or false to indicate that terminal output has been resumed and that
0411      *                     the warning message should disappear.
0412      */
0413     void outputSuspended(bool suspended);
0414 
0415     // Used to show/hide the message widget
0416     void updateReadOnlyState(bool readonly);
0417 
0418     void setSelectMode(bool readonly);
0419 
0420     bool getReadOnly() const
0421     {
0422         return _readOnly || _selectMode;
0423     }
0424 
0425     // Get mapping between visual and logical positions in line
0426     // returns the index of the last non space character.
0427     int bidiMap(Character *screenline,
0428                 QString &line,
0429                 int *log2line,
0430                 int *line2log,
0431                 uint16_t *shapemap,
0432                 int32_t *vis2line,
0433                 bool &shaped,
0434                 bool shape = true,
0435                 bool bidi = true) const;
0436 
0437     void showNotification(QString text);
0438 
0439     //
0440     // Clear mouse selection, but not keyboard selection
0441     void clearMouseSelection();
0442     void removeLines(int lines);
0443 
0444     void setVisualCursorPosition(int x);
0445 
0446 public Q_SLOTS:
0447     /**
0448      * Causes the terminal display to fetch the latest character image from the associated
0449      * terminal screen ( see setScreenWindow() ) and redraw the display.
0450      */
0451     void updateImage();
0452 
0453     /** Copies the selected text to the X11 Selection. */
0454     void copyToX11Selection(bool useSavedText = false);
0455 
0456     /** Copies the selected text to the system clipboard. */
0457     void copyToClipboard(Screen::DecodingOptions options = Screen::PlainText);
0458 
0459     /**
0460      * Pastes the content of the clipboard into the display.
0461      *
0462      * URLs of local files are treated specially:
0463      *  - The scheme part, "file://", is removed from each URL
0464      *  - The URLs are pasted as a space-separated list of file paths
0465      */
0466     void pasteFromClipboard(bool appendEnter = false);
0467     /**
0468      * Pastes the content of the X11 selection into the
0469      * display.
0470      */
0471     void pasteFromX11Selection(bool appendEnter = false);
0472 
0473     /**
0474      * Changes whether the flow control warning box should be shown when the flow control
0475      * stop key (Ctrl+S) are pressed.
0476      */
0477     void setFlowControlWarningEnabled(bool enable);
0478 
0479     /**
0480      * Sets whether the program currently running in the terminal is interested
0481      * in Mouse Tracking events.
0482      *
0483      * When set to true, Konsole will send Mouse Tracking events.
0484      *
0485      * The user interaction needed to create text selections will change
0486      * also, and the user will be required to hold down the Shift key to
0487      * create a selection or perform other mouse activities inside the view
0488      * area, since the program running in the terminal is being allowed
0489      * to handle normal mouse events itself.
0490      *
0491      * @param on Set to true if the program running in the terminal is
0492      * interested in Mouse Tracking events or false otherwise.
0493      */
0494     void setUsesMouseTracking(bool on);
0495 
0496     void setBracketedPasteMode(bool on);
0497 
0498     /**
0499      * Shows a notification that a bell event has occurred in the terminal.
0500      * TODO: More documentation here
0501      */
0502     void bell(const QString &message);
0503 
0504     // Used for requestPrint
0505     void printScreen();
0506 
0507     void notificationClicked(const QString &xdgActivationToken);
0508 
0509 Q_SIGNALS:
0510     void requestToggleExpansion();
0511     void requestMoveToNewTab(TerminalDisplay *display);
0512 
0513     /**
0514      * Emitted when the user presses a key whilst the terminal widget has focus.
0515      */
0516     void keyPressedSignal(QKeyEvent *event);
0517 
0518     /**
0519      * A mouse event occurred.
0520      * @param button The mouse button (0 for left button, 1 for middle button, 2 for right button, 3 for release,
0521      *                                 4 for Shift, 8 for Alt, 16 for Meta, 64 for wheel up, 65 for wheel down)
0522      * @param column The character column where the event occurred
0523      * @param line The character row where the event occurred
0524      * @param eventType The type of event.  0 for a mouse press / release or 1 for mouse motion
0525      */
0526     void mouseSignal(int button, int column, int line, int eventType);
0527     void changedContentSizeSignal(int height, int width);
0528 
0529     /**
0530      * Emitted when the user right clicks on the display, or right-clicks
0531      * with the Shift key held down if usesMouseTracking() is true.
0532      *
0533      * This can be used to display a context menu.
0534      */
0535     void configureRequest(const QPoint &position);
0536 
0537     /**
0538      * When a shortcut which is also a valid terminal key sequence is pressed while
0539      * the terminal widget  has focus, this signal is emitted to allow the host to decide
0540      * whether the shortcut should be overridden.
0541      * When the shortcut is overridden, the key sequence will be sent to the terminal emulation instead
0542      * and the action associated with the shortcut will not be triggered.
0543      *
0544      * @p override is set to false by default and the shortcut will be triggered as normal.
0545      */
0546     void overrideShortcutCheck(QKeyEvent *keyEvent, bool &override);
0547 
0548     void activationRequest(const QString &xdgActivationToken);
0549     void sendStringToEmu(const QByteArray &local8BitString);
0550 
0551     void compositeFocusChanged(bool focused);
0552 
0553     void peekPrimaryRequested(bool doPeek);
0554 
0555 protected:
0556     // events
0557     bool event(QEvent *event) override;
0558     void paintEvent(QPaintEvent *pe) override;
0559     void showEvent(QShowEvent *event) override;
0560     void hideEvent(QHideEvent *event) override;
0561     void resizeEvent(QResizeEvent *event) override;
0562     void contextMenuEvent(QContextMenuEvent *event) override;
0563     void focusInEvent(QFocusEvent *event) override;
0564     void focusOutEvent(QFocusEvent *event) override;
0565     void keyPressEvent(QKeyEvent *event) override;
0566     void keyReleaseEvent(QKeyEvent *event) override;
0567     void leaveEvent(QEvent *event) override;
0568     void mouseDoubleClickEvent(QMouseEvent *ev) override;
0569     void mousePressEvent(QMouseEvent *ev) override;
0570     void mouseReleaseEvent(QMouseEvent *ev) override;
0571     void mouseMoveEvent(QMouseEvent *ev) override;
0572     void wheelEvent(QWheelEvent *ev) override;
0573     bool focusNextPrevChild(bool next) override;
0574     void scrollPrepareEvent(QScrollPrepareEvent *);
0575     void scrollEvent(QScrollEvent *);
0576 
0577     void extendSelection(const QPoint &position);
0578 
0579     // drag and drop
0580     void dragEnterEvent(QDragEnterEvent *event) override;
0581     void dropEvent(QDropEvent *event) override;
0582     void doDrag();
0583     enum DragState {
0584         diNone,
0585         diPending,
0586         diDragging,
0587     };
0588 
0589     struct DragInfo {
0590         DragState state;
0591         QPoint start;
0592         QDrag *dragObject;
0593     } _dragInfo;
0594 
0595     // classifies the 'ch' into one of three categories
0596     // and returns a character to indicate which category it is in
0597     //
0598     //     - A space (returns ' ')
0599     //     - Part of a word (returns 'a')
0600     //     - Other characters (returns the input character)
0601     QChar charClass(const Character &ch) const;
0602 
0603     void clearImage();
0604 
0605     void mouseTripleClickEvent(QMouseEvent *ev);
0606     void selectLine(QPoint pos, bool entireLine, bool fromTripleClick = false);
0607 
0608     // reimplemented
0609     void inputMethodEvent(QInputMethodEvent *event) override;
0610     QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;
0611 
0612 protected Q_SLOTS:
0613 
0614     void blinkTextEvent();
0615     void blinkCursorEvent();
0616 
0617 private Q_SLOTS:
0618 
0619     void viewScrolledByUser();
0620 
0621 private:
0622     Q_DISABLE_COPY(TerminalDisplay)
0623 
0624     // the area where the preedit string for input methods will be draw
0625     QRect preeditRect() const;
0626 
0627     // shows a notification window in the middle of the widget indicating the terminal's
0628     // current size in columns and lines
0629     void showResizeNotification();
0630 
0631     void calcGeometry();
0632     void updateImageSize();
0633     void makeImage();
0634 
0635     void paintFilters(QPainter &painter);
0636 
0637     void setupHeaderVisibility();
0638 
0639     // redraws the cursor
0640     void updateCursor();
0641 
0642     bool handleShortcutOverrideEvent(QKeyEvent *keyEvent);
0643 
0644     void doPaste(QString text, bool appendReturn);
0645 
0646     void processMidButtonClick(QMouseEvent *ev);
0647 
0648     QPoint findLineStart(const QPoint &pnt);
0649     QPoint findLineEnd(const QPoint &pnt);
0650     QPoint findWordStart(const QPoint &pnt);
0651     QPoint findWordEnd(const QPoint &pnt);
0652 
0653     /**
0654      * @param pnt A point, relative to this.
0655      * @return true if the given point is in the area with the main terminal content and not in some other widget.
0656      */
0657     bool isInTerminalRegion(const QPoint &pnt) const;
0658 
0659     // Uses the current settings for trimming whitespace and preserving linebreaks to create a proper flag value for Screen
0660     Screen::DecodingOptions currentDecodingOptions();
0661 
0662     // Boilerplate setup for MessageWidget
0663     KMessageWidget *createMessageWidget(const QString &text);
0664 
0665     // Some setters used by applyProfile
0666     void setAutoCopySelectedText(bool enabled);
0667     void setCopyTextAsHTML(bool enabled);
0668     void setMiddleClickPasteMode(Enum::MiddleClickPasteModeEnum mode);
0669 
0670     /**
0671      * Sets the display's contents margins.
0672      */
0673     void setMargin(int margin);
0674 
0675     /**
0676      * Sets whether the contents are centered between the margins.
0677      */
0678     void setCenterContents(bool enable);
0679 
0680     // Clear _screenWindow selection and also pending double click selection
0681     void clearSelection();
0682 
0683     // the window onto the terminal screen which this display
0684     // is currently showing.
0685     QPointer<ScreenWindow> _screenWindow;
0686 
0687     bool _bellMasked;
0688 
0689     QVBoxLayout *_verticalLayout = nullptr;
0690 
0691     int _lines = 1; // the number of lines that can be displayed in the widget
0692     int _columns = 1; // the number of columns that can be displayed in the widget
0693 
0694     // Character line and character column as per a previous call to
0695     // getCharacterPosition() in mouseMoveEvent().
0696     int _prevCharacterLine = -1;
0697     int _prevCharacterColumn = -1;
0698 
0699     int _usedLines = 1; // the number of lines that are actually being used, this will be less
0700     // than 'lines' if the character image provided with setImage() is smaller
0701     // than the maximum image size which can be displayed
0702 
0703     int _usedColumns = 1; // the number of columns that are actually being used, this will be less
0704     // than 'columns' if the character image provided with setImage() is smaller
0705     // than the maximum image size which can be displayed
0706 
0707     QRect _contentRect;
0708     Character *_image = nullptr; // [lines][columns]
0709     // only the area [usedLines][usedColumns] in the image contains valid data
0710 
0711     int _imageSize = 0;
0712     QVector<LineProperty> _lineProperties;
0713 
0714     QColor _colorTable[TABLE_COLORS];
0715 
0716     uint _randomSeed = 0;
0717 
0718     bool _resizing = false;
0719     bool _showTerminalSizeHint = true;
0720     bool _bidiEnabled = false;
0721     bool _bidiLineLTR = true;
0722     bool _bidiTableDirOverride = true;
0723     bool _usesMouseTracking = false;
0724     bool _allowMouseTracking = true;
0725     bool _bracketedPasteMode = false;
0726 
0727     QPoint _iPntSel; // initial selection point
0728     QPoint _pntSel; // current selection point
0729     QPoint _tripleSelBegin; // help avoid flicker
0730     int _actSel = 0; // selection state
0731     bool _wordSelectionMode = false;
0732     bool _lineSelectionMode = false;
0733     bool _preserveLineBreaks = true;
0734     bool _columnSelectionMode = false;
0735 
0736     bool _autoCopySelectedText = false;
0737     bool _copyTextAsHTML = true;
0738     Enum::MiddleClickPasteModeEnum _middleClickPasteMode = Enum::PasteFromX11Selection;
0739 
0740     QString _wordCharacters;
0741     TerminalBell _bell{Enum::NotifyBell};
0742 
0743     bool _allowBlinkingText = true; // allow text to blink
0744     bool _allowBlinkingCursor = false; // allow cursor to blink
0745     bool _textBlinking = false; // text is blinking, hide it when drawing
0746     bool _cursorBlinking = false; // cursor is blinking, hide it when drawing
0747     bool _hasTextBlinker = false; // has characters to blink
0748     QTimer *_blinkTextTimer = nullptr;
0749     QTimer *_blinkCursorTimer = nullptr;
0750 
0751     bool _openLinksByDirectClick = false; // Open URL and hosts by single mouse click
0752 
0753     bool _ctrlRequiredForDrag = true; // require Ctrl key for drag selected text
0754     bool _dropUrlsAsText = false; // always paste URLs as text without showing copy/move menu
0755 
0756     Enum::TripleClickModeEnum _tripleClickMode = Enum::SelectWholeLine;
0757     bool _possibleTripleClick = false; // is set in mouseDoubleClickEvent and cleared
0758                                        // after QApplication::doubleClickInterval() delay
0759     QPoint _tripleClickPos; // The position where a potential triple click was started
0760     QString _doubleClickSelectedText; // selected text whose copying may be cancelled by further events; copying
0761     QString _doubleClickSelectedHtml; // is delayed to prevent a triple-click from generating > 1 entries in the
0762                                       // clipboard history (a triple click is a double click at first ;)
0763 
0764     QLabel *_resizeWidget = nullptr;
0765     QTimer *_resizeTimer = nullptr;
0766 
0767     bool _flowControlWarningEnabled = false;
0768 
0769     // widgets related to the warning message that appears when the user presses Ctrl+S to suspend
0770     // terminal output - informing them what has happened and how to resume output
0771     KMessageWidget *_outputSuspendedMessageWidget = nullptr;
0772 
0773     QSize _size;
0774 
0775     std::shared_ptr<const ColorScheme> _colorScheme;
0776     ColorSchemeWallpaper::Ptr _wallpaper;
0777 
0778     // list of filters currently applied to the display.  used for links and
0779     // search highlight
0780     TerminalImageFilterChain *_filterChain = nullptr;
0781     bool _filterUpdateRequired = true;
0782 
0783     Enum::CursorShapeEnum _cursorShape = Enum::BlockCursor;
0784 
0785     InputMethodData _inputMethodData;
0786 
0787     // the delay in milliseconds between redrawing blinking text
0788     static const int TEXT_BLINK_DELAY = 500;
0789 
0790     // the duration of the size hint in milliseconds
0791     static const int SIZE_HINT_DURATION = 1000;
0792 
0793     SessionController *_sessionController = nullptr;
0794 
0795     bool _trimLeadingSpaces = false; // trim leading spaces in selected text
0796     bool _trimTrailingSpaces = false; // trim trailing spaces in selected text
0797     bool _mouseWheelZoom = false; // enable mouse wheel zooming or not
0798 
0799     int _margin = 1; // the contents margin
0800     bool _centerContents = false; // center the contents between margins
0801 
0802     KMessageWidget *_readOnlyMessageWidget = nullptr; // Message shown at the top when read-only mode gets activated
0803 
0804     // Needed to know whether the mode really changed between update calls
0805     bool _readOnly = false;
0806     bool _selectMode = false;
0807 
0808     bool _dimWhenInactive = false;
0809     int _dimValue;
0810 
0811     bool _borderWhenActive = false;
0812     QColor _focusBorderColor;
0813 
0814     ScrollState _scrollWheelState;
0815     IncrementalSearchBar *_searchBar = nullptr;
0816     TerminalHeaderBar *_headerBar = nullptr;
0817     QRect _searchResultRect;
0818     friend class TerminalDisplayAccessible;
0819 
0820     bool _drawOverlay = false;
0821     Qt::Edge _overlayEdge;
0822 
0823     bool _hasCompositeFocus = false;
0824     bool _displayVerticalLine = false;
0825     int _displayVerticalLineAtChar = 80;
0826 
0827     QKeySequence _peekPrimaryShortcut;
0828 
0829     TerminalPainter *_terminalPainter = nullptr;
0830     TerminalScrollBar *_scrollBar = nullptr;
0831     TerminalColor *_terminalColor = nullptr;
0832     std::unique_ptr<TerminalFont> _terminalFont;
0833 
0834     std::unique_ptr<KonsolePrintManager> _printManager;
0835 
0836     bool _semanticUpDown;
0837     bool _semanticInputClick;
0838 
0839     UBiDi *ubidi = nullptr;
0840     QPoint _visualCursorPosition = {0, 0};
0841 
0842     int _selModeModifiers;
0843     bool _selModeByModifiers; // Selection started by Shift+Arrow
0844 
0845     int _id;
0846 
0847     static int lastViewId;
0848 };
0849 
0850 }
0851 
0852 #endif // TERMINALDISPLAY_H