source: ogBrowser-Git/qtermwidget/lib/qtermwidget.h @ c0cec9d

jenkinsmain
Last change on this file since c0cec9d was fedf2a2, checked in by Vadim Troshchinskiy Shmelev <vtroshchinskiy@…>, 18 months ago

Update Qtermwidget to Qt6 version
Remove build files

  • Property mode set to 100644
File size: 10.9 KB
Line 
1/*  Copyright (C) 2008 e_k (e_k@users.sourceforge.net)
2
3    This library is free software; you can redistribute it and/or
4    modify it under the terms of the GNU Library General Public
5    License as published by the Free Software Foundation; either
6    version 2 of the License, or (at your option) any later version.
7
8    This library is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11    Library General Public License for more details.
12
13    You should have received a copy of the GNU Library General Public License
14    along with this library; see the file COPYING.LIB.  If not, write to
15    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16    Boston, MA 02110-1301, USA.
17*/
18
19
20#ifndef _Q_TERM_WIDGET
21#define _Q_TERM_WIDGET
22
23#include <QTranslator>
24#include <QWidget>
25#include "Emulation.h"
26#include "Filter.h"
27#include "qtermwidget_export.h"
28#include "qtermwidget_version.h"
29#include "qtermwidget_interface.h"
30
31class QVBoxLayout;
32class TermWidgetImpl;
33class SearchBar;
34class QUrl;
35
36class QTERMWIDGET_EXPORT QTermWidget : public QWidget, public QTermWidgetInterface {
37    Q_OBJECT
38    Q_PLUGIN_METADATA(IID "lxqt.qtermwidget" FILE "qtermwidget.json")
39    Q_INTERFACES(QTermWidgetInterface)
40
41public:
42
43    using KeyboardCursorShape = Konsole::Emulation::KeyboardCursorShape;
44
45    //Creation of widget
46    QTermWidget(int startnow, // 1 = start shell program immediately
47                QWidget * parent = nullptr);
48    // A dummy constructor for Qt Designer. startnow is 1 by default
49    QTermWidget(QWidget *parent = nullptr);
50
51    ~QTermWidget() override;
52
53    //Initial size
54    QSize sizeHint() const override;
55
56    // expose TerminalDisplay::TerminalSizeHint, setTerminalSizeHint
57    void setTerminalSizeHint(bool enabled) override;
58    bool terminalSizeHint() override;
59
60    //start shell program if it was not started in constructor
61    void startShellProgram() override;
62
63    /**
64     * Start terminal teletype as is
65     * and redirect data for external recipient.
66     * It can be used for display and control a remote terminal.
67     */
68    void startTerminalTeletype() override;
69
70    int getShellPID() override;
71
72    /**
73     * Get the PID of the foreground process
74     */
75    int getForegroundProcessId() override;
76
77    void changeDir(const QString & dir) override;
78
79    //look-n-feel, if you don`t like defaults
80
81    //  Terminal font
82    // Default is application font with family Monospace, size 10
83    // Beware of a performance penalty and display/alignment issues when using a proportional font.
84    void setTerminalFont(const QFont & font) override;
85    QFont getTerminalFont() override;
86    void setTerminalOpacity(qreal level) override;
87    void setTerminalBackgroundImage(const QString& backgroundImage) override;
88    void setTerminalBackgroundMode(int mode) override;
89
90    //environment
91    void setEnvironment(const QStringList & environment) override;
92
93    //  Shell program, default is /bin/bash
94    void setShellProgram(const QString & program) override;
95
96    //working directory
97    void setWorkingDirectory(const QString & dir) override;
98    QString workingDirectory() override;
99
100    // Shell program args, default is none
101    void setArgs(const QStringList & args) override;
102
103    //Text codec, default is UTF-8
104    void setTextCodec(QTextCodec * codec) override;
105
106    /** @brief Sets the color scheme, default is white on black
107     *
108     * @param[in] name The name of the color scheme, either returned from
109     * availableColorSchemes() or a full path to a color scheme.
110     */
111    void setColorScheme(const QString & name) override;
112
113    /**
114     * @brief Retrieves the available color schemes in the OS for the terminal.
115     *
116     * @note This function is needed in addition to the static one for making it availble when accessing QTermWidget as a plugin.
117     *
118     * @return A list of color schemes.
119     */
120    QStringList getAvailableColorSchemes() override;
121    static QStringList availableColorSchemes();
122    static void addCustomColorSchemeDir(const QString& custom_dir);
123
124    void setBackgroundColor(const QColor &color);
125    void setForegroundColor(const QColor &color);
126    void setANSIColor(const int ansiColorId, const QColor &color);
127
128
129    /** Sets the history size (in lines)
130     *
131     * @param lines history size
132     *  lines = 0, no history
133     *  lies < 0, infinite history
134     */
135    void setHistorySize(int lines) override;
136
137    // Returns the history size (in lines)
138    int historySize() const override;
139
140    // Presence of scrollbar
141    void setScrollBarPosition(QTermWidgetInterface::ScrollBarPosition) override;
142
143    // Wrapped, scroll to end.
144    void scrollToEnd() override;
145
146    // Send some text to terminal
147    void sendText(const QString & text) override;
148
149    // Send key event to terminal
150    void sendKeyEvent(QKeyEvent* e) override;
151
152    // Sets whether flow control is enabled
153    void setFlowControlEnabled(bool enabled) override;
154
155    // Returns whether flow control is enabled
156    bool flowControlEnabled(void) override;
157
158    /**
159     * Sets whether the flow control warning box should be shown
160     * when the flow control stop key (Ctrl+S) is pressed.
161     */
162    void setFlowControlWarningEnabled(bool enabled) override;
163
164    /*! Get all available keyboard bindings
165     */
166    static QStringList availableKeyBindings();
167
168    //! Return current key bindings
169    QString keyBindings() override;
170
171    void setMotionAfterPasting(int) override;
172
173    /** Return the number of lines in the history buffer. */
174    int historyLinesCount() override;
175
176    int screenColumnsCount() override;
177    int screenLinesCount() override;
178
179    void setSelectionStart(int row, int column) override;
180    void setSelectionEnd(int row, int column) override;
181    void getSelectionStart(int& row, int& column) override;
182    void getSelectionEnd(int& row, int& column) override;
183
184    /**
185     * Returns the currently selected text.
186     * @param preserveLineBreaks Specifies whether new line characters should
187     * be inserted into the returned text at the end of each terminal line.
188     */
189    QString selectedText(bool preserveLineBreaks = true) override;
190
191    void setMonitorActivity(bool) override;
192    void setMonitorSilence(bool) override;
193    void setSilenceTimeout(int seconds) override;
194
195    /** Returns the available hotspot for the given point \em pos.
196     *
197     * This method may return a nullptr if no hotspot is available.
198     *
199     * @param[in] pos The point of interest in the QTermWidget coordinates.
200     * @return Hotspot for the given position, or nullptr if no hotspot.
201     */
202    Filter::HotSpot* getHotSpotAt(const QPoint& pos) const;
203
204    /** Returns the available hotspots for the given row and column.
205     *
206     * @return Hotspot for the given position, or nullptr if no hotspot.
207     */
208    Filter::HotSpot* getHotSpotAt(int row, int column) const;
209
210    /*
211     * Proxy for TerminalDisplay::filterActions
212     * */
213    QList<QAction*> filterActions(const QPoint& position) override;
214
215    /**
216     * Returns a pty slave file descriptor.
217     * This can be used for display and control
218     * a remote terminal.
219     */
220    int getPtySlaveFd() const override;
221
222    /**
223     * Sets the shape of the keyboard cursor.  This is the cursor drawn
224     * at the position in the terminal where keyboard input will appear.
225     */
226    void setKeyboardCursorShape(KeyboardCursorShape shape);
227
228    void setBlinkingCursor(bool blink) override;
229
230    /** Enables or disables bidi text in the terminal. */
231    void setBidiEnabled(bool enabled) override;
232    bool isBidiEnabled() override;
233
234    /**
235     * Automatically close the terminal session after the shell process exits or
236     * keep it running.
237     */
238    void setAutoClose(bool) override;
239
240    QString title() const override;
241    QString icon() const override;
242
243    /** True if the title() or icon() was (ever) changed by the session. */
244    bool isTitleChanged() const override;
245
246    /** change and wrap text corresponding to paste mode **/
247    void bracketText(QString& text) override;
248
249    /** forcefully disable bracketed paste mode **/
250    void disableBracketedPasteMode(bool disable) override;
251    bool bracketedPasteModeIsDisabled() const override;
252
253    /** Set the empty space outside the terminal */
254    void setMargin(int) override;
255
256    /** Get the empty space outside the terminal */
257    int getMargin() const override;
258
259    void setDrawLineChars(bool drawLineChars) override;
260
261    void setBoldIntense(bool boldIntense) override;
262
263    void setConfirmMultilinePaste(bool confirmMultilinePaste) override;
264    void setTrimPastedTrailingNewlines(bool trimPastedTrailingNewlines) override;
265
266    QTermWidgetInterface *createWidget(int startnow) const override;
267signals:
268    void finished();
269    void copyAvailable(bool);
270
271    void termGetFocus();
272    void termLostFocus();
273
274    void termKeyPressed(QKeyEvent *);
275
276    void urlActivated(const QUrl&, bool fromContextMenu);
277
278    void bell(const QString& message);
279
280    void activity();
281    void silence();
282
283    /**
284     * Emitted when emulator send data to the terminal process
285     * (redirected for external recipient). It can be used for
286     * control and display the remote terminal.
287     */
288    void sendData(const char *,int);
289
290    void profileChanged(const QString & profile);
291
292    void titleChanged();
293
294    /**
295     * Signals that we received new data from the process running in the
296     * terminal emulator
297     */
298    void receivedData(const QString &text);
299
300public slots:
301    // Copy selection to clipboard
302    void copyClipboard();
303
304    // Paste clipboard to terminal
305    void pasteClipboard();
306
307    // Paste selection to terminal
308    void pasteSelection();
309
310    // Set zoom
311    void zoomIn();
312    void zoomOut();
313
314    // Set size
315    void setSize(const QSize &);
316
317    /*! Set named key binding for given widget
318     */
319    void setKeyBindings(const QString & kb);
320
321    /*! Clear the terminal content and move to home position
322     */
323    void clear();
324
325    void toggleShowSearchBar();
326
327    void saveHistory(QIODevice *device);
328protected:
329    void resizeEvent(QResizeEvent *) override;
330
331protected slots:
332    void sessionFinished();
333    void selectionChanged(bool textSelected);
334
335private slots:
336    void find();
337    void findNext();
338    void findPrevious();
339    void matchFound(int startColumn, int startLine, int endColumn, int endLine);
340    void noMatchFound();
341    /**
342     * Emulation::cursorChanged() signal propagates to here and QTermWidget
343     * sends the specified cursor states to the terminal display
344     */
345    void cursorChanged(Konsole::Emulation::KeyboardCursorShape cursorShape, bool blinkingCursorEnabled);
346
347private:
348    void search(bool forwards, bool next);
349    void setZoom(int step);
350    void init(int startnow);
351    TermWidgetImpl * m_impl;
352    SearchBar* m_searchBar;
353    QVBoxLayout *m_layout;
354    QTranslator *m_translator;
355};
356
357
358//Maybe useful, maybe not
359
360#ifdef __cplusplus
361extern "C"
362#endif
363void * createTermWidget(int startnow, void * parent);
364
365#endif
Note: See TracBrowser for help on using the repository browser.