Mercurial > octave-nkf
annotate libgui/qterminal/libqterminal/win32/QWinTerminalImpl.h @ 16612:dae674adf045
handle text selection in GUI terminal for Windows
* QWinTerminalImpl.h, QWinTerminalImpl.cpp
(QConsolePrivate::posToCell, QConsolePrivate::getSelection,
QConsolePrivate::updateSelection): QWinTerminalImpl::mouseMoveEvent,
QWinTerminalImpl::mousePressEvent, QWinTerminalImpl::updateSelection
QWinTerminalImpl::mouseReleaseEvent): New functions.
(QConsolePrivate::m_beginSelection, QConsolePrivate::m_endSelection,
QConsolePrivate::m_selection): New variables.
(maybeSwapPoints): New static function.
(QConsolePrivate::QConsolePrivate): Initialize m_beginSelection and
m_endSelection.
(QWinTerminalImpl::viewPaintEvent): Draw an overlay for the
selection.
(QWinTerminalImpl::copyClipboard): Save selection to clipboard.
(QWinTerminalImpl::pasteClipboard): Send clipboard text to terminal.
Thanks to Michael Goffioul for help with this patch, especially the
QConsolePrivate::getSelection function.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 05 May 2013 02:51:49 -0400 |
parents | 739d7eb97b85 |
children | 818eef7b2618 |
rev | line source |
---|---|
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1 /* |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
3 Copyright (C) 2011 Michael Goffioul. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
4 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
5 This file is part of QConsole. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
6 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
7 Foobar is free software: you can redistribute it and/or modify |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
8 it under the terms of the GNU General Public License as published by |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
10 (at your option) any later version. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
11 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
12 QConsole is distributed in the hope that it will be useful, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
15 GNU General Public License for more details. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
16 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
18 along with Foobar. If not, see <http://www.gnu.org/licenses/>. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
19 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
20 */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
21 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
22 #ifndef __QConsole_h__ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
23 #define __QConsole_h__ 1 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
24 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
25 #include <QWidget> |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15652
diff
changeset
|
26 #include "QTerminalInterface.h" |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
27 class QFocusEvent; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
28 class QKeyEvent; |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
15681
diff
changeset
|
29 class QPainter; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
30 class QPaintEvent; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
31 class QResizeEvent; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
32 class QWheelEvent; |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
33 class QPoint; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
34 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
35 class QConsolePrivate; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
36 class QConsoleThread; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
37 class QConsoleView; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
38 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
39 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
40 |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15652
diff
changeset
|
41 class QWinTerminalImpl : public QTerminalInterface |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
42 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
43 Q_OBJECT |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
44 friend class QConsolePrivate; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
45 friend class QConsoleThread; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
46 friend class QConsoleView; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
47 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
48 public: |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15652
diff
changeset
|
49 QWinTerminalImpl (QWidget* parent = 0); |
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15652
diff
changeset
|
50 QWinTerminalImpl (const QString& cmd, QWidget* parent = 0); |
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15652
diff
changeset
|
51 ~QWinTerminalImpl (void); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
52 |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15658
diff
changeset
|
53 void setTerminalFont (const QFont& font); |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15658
diff
changeset
|
54 void setSize (int columns, int lines); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
55 void sendText (const QString& s); |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
15681
diff
changeset
|
56 void setCursorType (CursorType type, bool blinking); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
57 |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15658
diff
changeset
|
58 public slots: |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15658
diff
changeset
|
59 void copyClipboard (void); |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15658
diff
changeset
|
60 void pasteClipboard (void); |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
15681
diff
changeset
|
61 void blinkCursorEvent (void); |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15658
diff
changeset
|
62 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
63 signals: |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
64 void terminated (void); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
65 void titleChanged (const QString&); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
66 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
67 protected: |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
68 void viewPaintEvent (QConsoleView*, QPaintEvent*); |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
15681
diff
changeset
|
69 void setBlinkingCursor (bool blink); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
15681
diff
changeset
|
70 void setBlinkingCursorState (bool blink); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
71 void viewResizeEvent (QConsoleView*, QResizeEvent*); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
72 void wheelEvent (QWheelEvent*); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
73 void focusInEvent (QFocusEvent*); |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
15681
diff
changeset
|
74 void focusOutEvent (QFocusEvent*); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
15681
diff
changeset
|
75 void keyPressEvent (QKeyEvent*); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
76 bool winEvent (MSG*, long*); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
77 virtual void start (void); |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
78 void mouseMoveEvent (QMouseEvent *event); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
79 void mousePressEvent (QMouseEvent *event); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
80 void mouseReleaseEvent (QMouseEvent *event); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
81 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
82 private slots: |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
83 void scrollValueChanged (int value); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
84 void monitorConsole (void); |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
85 void updateSelection (void); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
86 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
87 private: |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
88 QConsolePrivate* d; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
89 }; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
90 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
91 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
92 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
93 #endif // __QConsole_h__ |