Mercurial > octave
annotate libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp @ 25731:c799c0dbe0b5 stable
Fix scrolling command window in Windows 10 (bug #52496).
* QWinTerminalImpl.cpp: Disable auto-scroll when manually scrolling up.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Thu, 02 Aug 2018 23:46:48 +0200 |
parents | 6652d3823428 |
children | c7ea6c3cd8de |
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 |
25054
6652d3823428
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3 Copyright (C) 2011-2018 Michael Goffioul |
15651
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 |
17795
0a8c35ae5ce1
maint: Fix various problems with GPL copyright statements.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
7 This program is free software: you can redistribute it and/or modify |
15651
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 |
17795
0a8c35ae5ce1
maint: Fix various problems with GPL copyright statements.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
12 This program is distributed in the hope that it will be useful, |
15651
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 |
17795
0a8c35ae5ce1
maint: Fix various problems with GPL copyright statements.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
18 along with this program. If not, |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24153
diff
changeset
|
19 see <https://www.gnu.org/licenses/>. |
15651
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 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
23 #include <QApplication> |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
24 #include <QClipboard> |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
25 #include <QColor> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
26 #include <QFont> |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
27 #include <QGridLayout> |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
28 #include <QPaintEvent> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
29 #include <QPainter> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
30 #include <QResizeEvent> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
31 #include <QScrollBar> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
32 #include <QtDebug> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
33 #include <QThread> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
34 #include <QTimer> |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
35 #include <QToolTip> |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
36 #include <QCursor> |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
37 #include <QMessageBox> |
18655
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
38 #include <QDragEnterEvent> |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
39 #include <QDropEvent> |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
40 #include <QUrl> |
22551
b749559245a1
* libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp: added include QMimeData
John D
parents:
22323
diff
changeset
|
41 #include <QMimeData> |
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 #include <fcntl.h> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
44 #include <io.h> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
45 #include <stdio.h> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
46 #include <stdarg.h> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
47 #define WIN32_LEAN_AND_MEAN |
16999
477ed3b55497
QWinTerminalImpl.cpp: Don't define _WIN32_WINNT unconditionally.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16970
diff
changeset
|
48 #if ! defined (_WIN32_WINNT) && ! defined (NTDDI_VERSION) |
477ed3b55497
QWinTerminalImpl.cpp: Don't define _WIN32_WINNT unconditionally.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16970
diff
changeset
|
49 #define _WIN32_WINNT 0x0500 |
477ed3b55497
QWinTerminalImpl.cpp: Don't define _WIN32_WINNT unconditionally.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16970
diff
changeset
|
50 #endif |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
51 #include <windows.h> |
22732
2d74b4653e5d
Change codepage only for Windows 7 and newer (bug #49509).
Markus Mützel <markus.muetzel@gmx.de>
parents:
22686
diff
changeset
|
52 #include <versionhelpers.h> |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
53 #include <cstring> |
16648
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
54 #include <csignal> |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
55 #include <limits> |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
56 |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
57 #include "QWinTerminalImpl.h" |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
58 #include "QTerminalColors.h" |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
59 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
60 // Uncomment to log activity to LOGFILENAME |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
61 // #define DEBUG_QCONSOLE |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
62 #define LOGFILENAME "QConsole.log" |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
63 // Uncomment to create hidden console window |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
64 #define HIDDEN_CONSOLE |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
65 |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
66 #ifdef _MSC_VER |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
67 # pragma warning(disable : 4996) |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
68 #endif |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
69 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
70 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
71 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
72 class QConsoleView : public QWidget |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
73 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
74 public: |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
75 QConsoleView (QWinTerminalImpl* parent = 0) : QWidget (parent), q (parent) { } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
76 ~QConsoleView (void) { } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
77 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
78 protected: |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
79 void paintEvent (QPaintEvent* event) { q->viewPaintEvent (this, event); } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
80 void resizeEvent (QResizeEvent* event) { q->viewResizeEvent (this, event); } |
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: |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
83 QWinTerminalImpl* q; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
84 }; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
85 |
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 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
88 class QConsoleThread : public QThread |
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 public: |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
91 QConsoleThread (QWinTerminalImpl* console) : QThread (console), q (console) { } |
15651
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 protected: |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
94 void run (void) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
95 { q->start (); } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
96 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
97 private: |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
98 QWinTerminalImpl* q; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
99 }; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
100 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
101 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
102 |
17248
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
103 static QString translateKey (QKeyEvent *ev) |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
104 { |
17360
afc3d47f7704
Update windows GUI terminal handling
John Donoghue <john.donoghue@ieee.org>
parents:
17264
diff
changeset
|
105 QString esc = "\x1b"; |
17248
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
106 QString s; |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
107 |
17360
afc3d47f7704
Update windows GUI terminal handling
John Donoghue <john.donoghue@ieee.org>
parents:
17264
diff
changeset
|
108 if (ev->key () == Qt::Key_Delete) |
afc3d47f7704
Update windows GUI terminal handling
John Donoghue <john.donoghue@ieee.org>
parents:
17264
diff
changeset
|
109 s = esc + "[C\b"; |
afc3d47f7704
Update windows GUI terminal handling
John Donoghue <john.donoghue@ieee.org>
parents:
17264
diff
changeset
|
110 else if (!ev->text ().isEmpty ()) |
17248
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
111 s = ev->text (); |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
112 else |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
113 { |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
114 |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
115 switch (ev->key ()) |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
116 { |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
117 case Qt::Key_Up: |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
118 s = esc + "[A"; |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
119 break; |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
120 |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
121 case Qt::Key_Down: |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
122 s = esc + "[B"; |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
123 break; |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
124 |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
125 case Qt::Key_Right: |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
126 s = esc + "[C"; |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
127 break; |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
128 |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
129 case Qt::Key_Left: |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
130 s = esc + "[D"; |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
131 break; |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
132 |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
133 case Qt::Key_Home: |
17360
afc3d47f7704
Update windows GUI terminal handling
John Donoghue <john.donoghue@ieee.org>
parents:
17264
diff
changeset
|
134 s = esc + "[H"; |
17248
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
135 break; |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
136 |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
137 case Qt::Key_End: |
17360
afc3d47f7704
Update windows GUI terminal handling
John Donoghue <john.donoghue@ieee.org>
parents:
17264
diff
changeset
|
138 s = esc + "[F"; |
17248
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
139 break; |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
140 |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
141 case Qt::Key_Insert: |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
142 s = esc + "[2~"; |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
143 break; |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
144 |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
145 case Qt::Key_PageUp: |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
146 s = esc + "[5~"; |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
147 break; |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
148 |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
149 case Qt::Key_PageDown: |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
150 s = esc + "[6~"; |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
151 break; |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
152 |
17360
afc3d47f7704
Update windows GUI terminal handling
John Donoghue <john.donoghue@ieee.org>
parents:
17264
diff
changeset
|
153 case Qt::Key_Escape: |
afc3d47f7704
Update windows GUI terminal handling
John Donoghue <john.donoghue@ieee.org>
parents:
17264
diff
changeset
|
154 s = esc; |
afc3d47f7704
Update windows GUI terminal handling
John Donoghue <john.donoghue@ieee.org>
parents:
17264
diff
changeset
|
155 break; |
afc3d47f7704
Update windows GUI terminal handling
John Donoghue <john.donoghue@ieee.org>
parents:
17264
diff
changeset
|
156 |
17248
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
157 default: |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
158 break; |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
159 } |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
160 } |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
161 |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
162 return s; |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
163 } |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
164 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
165 class QConsolePrivate |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
166 { |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
167 friend class QWinTerminalImpl; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
168 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
169 public: |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
170 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
171 enum KeyboardCursorType |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
172 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
173 BlockCursor, |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
174 UnderlineCursor, |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
175 IBeamCursor |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
176 }; |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
177 |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
178 QConsolePrivate (QWinTerminalImpl* parent, const QString& cmd = QString ()); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
179 ~QConsolePrivate (void); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
180 |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
181 void updateConsoleSize (bool sync = false, bool allow_smaller_width = false); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
182 void syncConsoleParameters (void); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
183 void grabConsoleBuffer (CHAR_INFO* buf = 0); |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
184 void updateHorizontalScrollBar (void); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
185 void updateVerticalScrollBar (void); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
186 void setHorizontalScrollValue (int value); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
187 void setVerticalScrollValue (int value); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
188 void updateConsoleView (bool grab = true); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
189 void monitorConsole (void); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
190 void startCommand (void); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
191 void sendConsoleText (const QString& s); |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
192 QRect cursorRect (void); |
18555
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18271
diff
changeset
|
193 void selectAll(); |
18661
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
194 void selectWord(const QPoint& cellPos); |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
195 void selectLine(const QPoint& cellPos); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
196 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
197 void log (const char* fmt, ...); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
198 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
199 void closeStandardIO (int fd, DWORD stdHandleId, const char* name); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
200 void setupStandardIO (DWORD stdHandleId, int fd, const char* name, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
201 const char* devName); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
202 |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
203 QPoint posToCell (const QPoint& pt); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
204 QString getSelection (void); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
205 void updateSelection (void); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
206 void clearSelection (void); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
207 |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
208 QColor backgroundColor (void) const; |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
209 QColor foregroundColor (void) const; |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
210 QColor selectionColor (void) const; |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
211 QColor cursorColor (void) const; |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
212 |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
213 void setBackgroundColor (const QColor& color); |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
214 void setForegroundColor (const QColor& color); |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
215 void setSelectionColor (const QColor& color); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
216 void setCursorColor (bool useForegroundColor, const QColor& color); |
18610
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18555
diff
changeset
|
217 void setScrollBufferSize (int value); |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
218 |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
219 void drawTextBackground (QPainter& p, int cx1, int cy1, int cx2, int cy2, |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
220 int cw, int ch); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
221 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
222 void drawSelection (QPainter& p, int cx1, int cy1, int cx2, int cy2, |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
223 int cw, int ch); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
224 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
225 void drawCursor (QPainter& p); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
226 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
227 void drawText (QPainter& p, int cx1, int cy1, int cx2, int cy2, |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
228 int cw, int ch); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
229 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
230 private: |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
231 QWinTerminalImpl* q; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
232 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
233 private: |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
234 QFont m_font; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
235 QString m_command; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
236 QConsoleColors m_colors; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
237 bool m_inWheelEvent; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
238 QString m_title; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
239 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
240 QSize m_charSize; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
241 QSize m_bufferSize; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
242 QRect m_consoleRect; |
25731
c799c0dbe0b5
Fix scrolling command window in Windows 10 (bug #52496).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
243 bool m_auto_scroll; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
244 QPoint m_cursorPos; |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
245 bool m_cursorBlinking; |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
246 bool m_hasBlinkingCursor; |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
247 QTimer *m_blinkCursorTimer; |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
248 KeyboardCursorType m_cursorType; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
249 |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
250 QPoint m_beginSelection; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
251 QPoint m_endSelection; |
16647
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
252 bool m_settingSelection; |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
253 |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
254 QColor m_selectionColor; |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
255 QColor m_cursorColor; |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
256 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
257 HANDLE m_stdOut; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
258 HWND m_consoleWindow; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
259 CHAR_INFO* m_buffer; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
260 CHAR_INFO* m_tmpBuffer; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
261 HANDLE m_process; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
262 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
263 QConsoleView* m_consoleView; |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
264 QScrollBar* m_horizontalScrollBar; |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
265 QScrollBar* m_verticalScrollBar; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
266 QTimer* m_consoleWatcher; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
267 QConsoleThread *m_consoleThread; |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
268 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
269 // The delay in milliseconds between redrawing blinking text. |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
270 static const int BLINK_DELAY = 500; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
271 }; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
272 |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
273 static void maybeSwapPoints (QPoint& begin, QPoint& end) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
274 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
275 if (end.y () < begin.y () |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
276 || (end.y () == begin.y () && end.x () < begin.x ())) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
277 qSwap (begin, end); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
278 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
279 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
280 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
281 |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
282 QConsolePrivate::QConsolePrivate (QWinTerminalImpl* parent, const QString& cmd) |
25731
c799c0dbe0b5
Fix scrolling command window in Windows 10 (bug #52496).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
283 : q (parent), m_command (cmd), m_auto_scroll (true), m_cursorBlinking (false), |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18626
diff
changeset
|
284 m_hasBlinkingCursor (true), m_cursorType (BlockCursor), |
18626
6535cb2b8e23
libqterminal: Initialize m_cursorBlinking value (Bug #41814)
John Donoghue <john.donoghue@ieee.org>
parents:
18242
diff
changeset
|
285 m_beginSelection (0, 0), m_endSelection (0, 0), m_settingSelection (false), |
16647
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
286 m_process (NULL), m_inWheelEvent (false) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
287 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
288 log (NULL); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
289 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
290 // Possibly detach from any existing console |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
291 log ("Detaching from existing console (if any)...\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
292 FreeConsole (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
293 log ("Closing standard IO...\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
294 closeStandardIO (0, STD_INPUT_HANDLE, "STDIN"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
295 closeStandardIO (1, STD_OUTPUT_HANDLE, "STDOUT"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
296 closeStandardIO (2, STD_ERROR_HANDLE, "STDERR"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
297 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
298 #ifdef HIDDEN_CONSOLE |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
299 HWINSTA hOrigSta, hNewSta; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
300 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
301 // Create new (hidden) console |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
302 hOrigSta = GetProcessWindowStation (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
303 hNewSta = CreateWindowStation (NULL, 0, GENERIC_ALL, NULL); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
304 log ("Current Windows station: %p.\nNew Windows station: %p.\n", hOrigSta, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
305 hNewSta); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
306 if (! SetProcessWindowStation (hNewSta)) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
307 log ("Failed to switch to new Windows station.\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
308 #endif |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
309 if (! AllocConsole ()) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
310 log ("Failed to create new console.\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
311 #ifdef HIDDEN_CONSOLE |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
312 if (! SetProcessWindowStation (hOrigSta)) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
313 log ("Failed to restore original Windows station.\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
314 if (! CloseWindowStation (hNewSta)) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
315 log ("Failed to close new Windows station.\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
316 #endif |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
317 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
318 log ("New (hidden) console created.\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
319 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
320 setupStandardIO (STD_INPUT_HANDLE, 0, "STDIN", "CONIN$"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
321 setupStandardIO (STD_OUTPUT_HANDLE, 1, "STDOUT", "CONOUT$"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
322 setupStandardIO (STD_ERROR_HANDLE, 2, "STDERR", "CONOUT$"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
323 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
324 log ("Standard input/output/error set up.\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
325 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
326 *stdin = *(fdopen (0, "rb")); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
327 *stdout = *(fdopen (1, "wb")); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
328 *stderr = *(fdopen (2, "wb")); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
329 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
330 log ("POSIX standard streams created.\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
331 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
332 setvbuf (stdin, NULL, _IONBF, 0); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
333 setvbuf (stdout, NULL, _IONBF, 0); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
334 setvbuf (stderr, NULL, _IONBF, 0); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
335 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
336 log ("POSIX standard stream buffers adjusted.\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
337 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
338 HANDLE hStdOut = GetStdHandle (STD_OUTPUT_HANDLE); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
339 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
340 log ("Console allocated: hStdOut: %p\n", hStdOut); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
341 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
342 m_stdOut = hStdOut; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
343 m_consoleWindow = GetConsoleWindow (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
344 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
345 // In case the console window hasn't been created hidden... |
17972
afeb233ea443
[Win32] Keep console shown when HIDDEN_CONSOLE is not defined.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17920
diff
changeset
|
346 #ifdef HIDDEN_CONSOLE |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
347 ShowWindow (m_consoleWindow, SW_HIDE); |
17972
afeb233ea443
[Win32] Keep console shown when HIDDEN_CONSOLE is not defined.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17920
diff
changeset
|
348 #endif |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
349 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
350 CONSOLE_SCREEN_BUFFER_INFO sbi; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
351 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
352 GetConsoleScreenBufferInfo (hStdOut, &sbi); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
353 m_bufferSize = QSize (sbi.dwSize.X, qMax (sbi.dwSize.Y, (SHORT)500)); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
354 m_consoleRect = QRect (sbi.srWindow.Left, sbi.srWindow.Top, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
355 sbi.srWindow.Right - sbi.srWindow.Left + 1, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
356 sbi.srWindow.Bottom - sbi.srWindow.Top + 1); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
357 m_cursorPos = QPoint (sbi.dwCursorPosition.X, sbi.dwCursorPosition.Y); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
358 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
359 log ("Initial console parameters:\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
360 log (" buffer size: %d x %d\n", m_bufferSize.width (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
361 m_bufferSize.height ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
362 log (" window: (%d, %d) -> (%d, %d) [%d x %d]\n", |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
363 m_consoleRect.left (), m_consoleRect.top (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
364 m_consoleRect.right (), m_consoleRect.bottom (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
365 m_consoleRect.width (), m_consoleRect.height ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
366 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
367 wchar_t titleBuf[260]; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
368 GetConsoleTitleW (titleBuf, sizeof (titleBuf)); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
369 q->setWindowTitle (QString::fromWCharArray (titleBuf)); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
370 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
371 m_font.setFamily ("Lucida Console"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
372 m_font.setPointSize (9); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
373 m_font.setStyleHint (QFont::TypeWriter); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
374 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
375 m_buffer = m_tmpBuffer = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
376 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
377 m_consoleView = new QConsoleView (parent); |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
378 m_horizontalScrollBar = new QScrollBar (Qt::Horizontal, parent); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
379 m_verticalScrollBar = new QScrollBar (Qt::Vertical, parent); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
380 |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
381 QGridLayout* l = new QGridLayout (parent); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
382 l->setContentsMargins (0, 0, 0, 0); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
383 l->setSpacing (0); |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
384 l->addWidget (m_consoleView, 0, 0); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
385 l->addWidget (m_horizontalScrollBar, 1, 0); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
386 l->addWidget (m_verticalScrollBar, 0, 1); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
387 |
22732
2d74b4653e5d
Change codepage only for Windows 7 and newer (bug #49509).
Markus Mützel <markus.muetzel@gmx.de>
parents:
22686
diff
changeset
|
388 if (IsWindows7OrGreater ()) |
2d74b4653e5d
Change codepage only for Windows 7 and newer (bug #49509).
Markus Mützel <markus.muetzel@gmx.de>
parents:
22686
diff
changeset
|
389 { |
2d74b4653e5d
Change codepage only for Windows 7 and newer (bug #49509).
Markus Mützel <markus.muetzel@gmx.de>
parents:
22686
diff
changeset
|
390 SetConsoleCP (65001); |
2d74b4653e5d
Change codepage only for Windows 7 and newer (bug #49509).
Markus Mützel <markus.muetzel@gmx.de>
parents:
22686
diff
changeset
|
391 SetConsoleOutputCP (65001); |
2d74b4653e5d
Change codepage only for Windows 7 and newer (bug #49509).
Markus Mützel <markus.muetzel@gmx.de>
parents:
22686
diff
changeset
|
392 } |
22686
8c749f33ce0a
Set codepage in console for windows to UTF-8 (bug #43099)
Markus Mützel <markus.muetzel@gmx.de>
parents:
22551
diff
changeset
|
393 |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
394 // Choose 15 (0xF) as index into the Windows console color map for the |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
395 // background and 0 (0x0) as the index for the foreground. This |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
396 // selection corresponds to the indices used in the foregroundColor, |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
397 // setForegroundColor, backgroundColor, and SetBackgroundColor |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
398 // functions. |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
399 |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
400 SetConsoleTextAttribute (m_stdOut, 0xF0); |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
401 |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
402 // Defaults. |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
403 setBackgroundColor (Qt::white); |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
404 setForegroundColor (Qt::black); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
405 setSelectionColor (Qt::lightGray); |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
406 setCursorColor (false, Qt::darkGray); |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
407 |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
408 // FIXME -- should we set the palette? |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
409 QPalette palette (backgroundColor ()); |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
410 m_consoleView->setPalette (palette); |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
411 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
412 m_consoleView->setAutoFillBackground (true); |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
413 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
414 m_consoleView->setFont (m_font); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
415 parent->setFocusPolicy (Qt::StrongFocus); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
416 parent->winId (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
417 |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
418 updateHorizontalScrollBar (); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
419 updateVerticalScrollBar (); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
420 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
421 m_consoleWatcher = new QTimer (parent); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
422 m_consoleWatcher->setInterval (10); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
423 m_consoleWatcher->setSingleShot (false); |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
424 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
425 m_blinkCursorTimer = new QTimer (parent); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
426 QObject::connect (m_blinkCursorTimer, SIGNAL (timeout()), |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18626
diff
changeset
|
427 q, SLOT (blinkCursorEvent ())); |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
428 |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
429 QObject::connect (m_horizontalScrollBar, SIGNAL (valueChanged (int)), |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
430 q, SLOT (horizontalScrollValueChanged (int))); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
431 |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
432 QObject::connect (m_verticalScrollBar, SIGNAL (valueChanged (int)), |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
433 q, SLOT (verticalScrollValueChanged (int))); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
434 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
435 QObject::connect (m_consoleWatcher, SIGNAL (timeout (void)), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
436 q, SLOT (monitorConsole (void))); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
437 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
438 m_consoleWatcher->start (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
439 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
440 if (m_command.isEmpty ()) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
441 m_consoleThread = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
442 else |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
443 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
444 m_consoleThread = new QConsoleThread (q); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
445 QObject::connect (m_consoleThread, SIGNAL (finished (void)), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
446 q, SIGNAL (terminated (void))); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
447 m_consoleThread->start (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
448 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
449 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
450 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
451 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
452 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
453 QConsolePrivate::~QConsolePrivate (void) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
454 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
455 if (m_consoleThread && m_consoleThread->isRunning () && m_process) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
456 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
457 TerminateProcess (m_process, (UINT)-1); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
458 m_consoleThread->wait (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
459 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
460 if (m_buffer) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
461 delete [] m_buffer; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
462 if (m_tmpBuffer) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
463 delete [] m_tmpBuffer; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
464 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
465 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
466 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
467 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
468 void QConsolePrivate::setupStandardIO (DWORD stdHandleId, int targetFd, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
469 const char* name, const char* devName) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
470 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
471 log ("Opening %s...\n", devName); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
472 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
473 int fd = open (devName, _O_RDWR | _O_BINARY); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
474 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
475 if (fd != -1) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
476 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
477 if (fd != targetFd) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
478 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
479 log ("Opened %s is not at target file descriptor %d, " |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
480 "duplicating...\n", name, targetFd); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
481 if (dup2 (fd, targetFd) == -1) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
482 log ("Failed to duplicate file descriptor: errno=%d.\n", errno); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
483 if (close (fd) == -1) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
484 log ("Failed to close original file descriptor: errno=%d.\n", |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
485 errno); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
486 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
487 else |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
488 log ("%s opened and assigned to file descriptor %d.\n", devName, fd); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
489 if (! SetStdHandle (stdHandleId, (HANDLE) _get_osfhandle (targetFd))) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
490 log ("Failed to re-assign %s: error=%08x.\n", name, GetLastError ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
491 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
492 else |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
493 log ("Failed to open %s: errno=%d.\n", devName, errno); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
494 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
495 |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
496 QPoint QConsolePrivate::posToCell (const QPoint& p) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
497 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
498 return QPoint (m_consoleRect.left () + p.x () / m_charSize.width (), |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
499 m_consoleRect.top () + p.y () / m_charSize.height ()); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
500 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
501 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
502 QString QConsolePrivate::getSelection (void) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
503 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
504 QString selection; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
505 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
506 QPoint begin = m_beginSelection; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
507 QPoint end = m_endSelection; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
508 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
509 maybeSwapPoints (begin, end); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
510 |
16628
a66c285729a6
use swapped points when getting selection text in Windows terminal
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
511 if (begin != end) |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
512 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
513 CHAR_INFO* buf; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
514 COORD bufSize, bufCoord; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
515 SMALL_RECT bufRect; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
516 int nr; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
517 |
16628
a66c285729a6
use swapped points when getting selection text in Windows terminal
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
518 nr = end.y () - begin.y () + 1; |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
519 buf = new CHAR_INFO[m_bufferSize.width () * nr]; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
520 bufSize.X = m_bufferSize.width (); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
521 bufSize.Y = nr; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
522 bufCoord.X = 0; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
523 bufCoord.Y = 0; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
524 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
525 bufRect.Left = 0; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
526 bufRect.Right = m_bufferSize.width (); |
16628
a66c285729a6
use swapped points when getting selection text in Windows terminal
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
527 bufRect.Top = begin.y (); |
a66c285729a6
use swapped points when getting selection text in Windows terminal
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
528 bufRect.Bottom = end.y (); |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
529 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
530 if (ReadConsoleOutput (m_stdOut, buf, bufSize, bufCoord, &bufRect)) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
531 { |
16628
a66c285729a6
use swapped points when getting selection text in Windows terminal
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
532 int start_pos = begin.x (); |
a66c285729a6
use swapped points when getting selection text in Windows terminal
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
533 int end_pos = (nr - 1) * m_bufferSize.width () + end.x (); |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
534 int lastNonSpace = -1; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
535 |
16628
a66c285729a6
use swapped points when getting selection text in Windows terminal
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
536 for (int i = start_pos; i <= end_pos; i++) |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
537 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
538 if (i && (i % m_bufferSize.width ()) == 0) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
539 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
540 if (lastNonSpace >= 0) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
541 selection.truncate (lastNonSpace); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
542 selection.append ('\n'); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
543 lastNonSpace = selection.length (); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
544 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
545 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
546 QChar c (buf[i].Char.UnicodeChar); |
24054
8a6747c6db1a
* libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp: use standard code formatting
John D <john.donoghue@ieee.org>
parents:
24053
diff
changeset
|
547 if (c.isNull ()) |
24152
7db56856b870
Fix building with Qt4 for Windows (bug #52237).
Markus Mützel <markus.muetzel@gmx.de>
parents:
24054
diff
changeset
|
548 c = QChar (' '); |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
549 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
550 selection.append (c); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
551 if (! c.isSpace ()) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
552 lastNonSpace = selection.length (); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
553 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
554 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
555 if (lastNonSpace >= 0) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
556 selection.truncate (lastNonSpace); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
557 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
558 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
559 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
560 return selection; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
561 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
562 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
563 void QConsolePrivate::updateSelection (void) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
564 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
565 QPoint begin = m_beginSelection; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
566 QPoint end = m_endSelection; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
567 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
568 maybeSwapPoints (begin, end); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
569 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
570 begin.rx () = 0; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
571 end.rx () = m_consoleRect.width (); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
572 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
573 m_consoleView->update (); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
574 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
575 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
576 void QConsolePrivate::clearSelection (void) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
577 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
578 m_beginSelection = m_endSelection = QPoint (); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
579 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
580 m_consoleView->update (); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
581 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
582 |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
583 QColor QConsolePrivate::backgroundColor (void) const |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
584 { |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
585 return m_colors[15]; |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
586 } |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
587 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
588 QColor QConsolePrivate::foregroundColor (void) const |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
589 { |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
590 return m_colors[0]; |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
591 } |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
592 |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
593 QColor QConsolePrivate::selectionColor (void) const |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
594 { |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
595 return m_selectionColor; |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
596 } |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
597 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
598 QColor QConsolePrivate::cursorColor (void) const |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
599 { |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
600 return m_cursorColor.isValid () ? m_cursorColor : foregroundColor (); |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
601 } |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
602 |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
603 void QConsolePrivate::setBackgroundColor (const QColor& color) |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
604 { |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
605 m_colors[15] = color; |
18271
8449cc186059
Set terminal palette background color (Bug #41206)
John Donoghue <john.donoghue@ieee.org>
parents:
18242
diff
changeset
|
606 |
8449cc186059
Set terminal palette background color (Bug #41206)
John Donoghue <john.donoghue@ieee.org>
parents:
18242
diff
changeset
|
607 QPalette palette (color); |
8449cc186059
Set terminal palette background color (Bug #41206)
John Donoghue <john.donoghue@ieee.org>
parents:
18242
diff
changeset
|
608 m_consoleView->setPalette (palette); |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
609 } |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
610 |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
611 void QConsolePrivate::setForegroundColor (const QColor& color) |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
612 { |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
613 m_colors[0] = color; |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
614 } |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
615 |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
616 void QConsolePrivate::setSelectionColor (const QColor& color) |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
617 { |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
618 m_selectionColor = color; |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
619 } |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
620 |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
621 void QConsolePrivate::setCursorColor (bool useForegroundColor, |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
622 const QColor& color) |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
623 { |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
624 m_cursorColor = useForegroundColor ? QColor () : color; |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
625 } |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
626 |
18610
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18555
diff
changeset
|
627 void QConsolePrivate::setScrollBufferSize (int value) |
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18555
diff
changeset
|
628 { |
19440
9c719c504e8d
command window buffer size configurable on windows (bug #41474)
Torsten <ttl@justmail.de>
parents:
19303
diff
changeset
|
629 CONSOLE_SCREEN_BUFFER_INFO sbi; |
9c719c504e8d
command window buffer size configurable on windows (bug #41474)
Torsten <ttl@justmail.de>
parents:
19303
diff
changeset
|
630 GetConsoleScreenBufferInfo (m_stdOut, &sbi); |
9c719c504e8d
command window buffer size configurable on windows (bug #41474)
Torsten <ttl@justmail.de>
parents:
19303
diff
changeset
|
631 |
9c719c504e8d
command window buffer size configurable on windows (bug #41474)
Torsten <ttl@justmail.de>
parents:
19303
diff
changeset
|
632 m_bufferSize = QSize (sbi.dwSize.X, (SHORT)value); |
9c719c504e8d
command window buffer size configurable on windows (bug #41474)
Torsten <ttl@justmail.de>
parents:
19303
diff
changeset
|
633 |
9c719c504e8d
command window buffer size configurable on windows (bug #41474)
Torsten <ttl@justmail.de>
parents:
19303
diff
changeset
|
634 updateConsoleSize (true); |
18610
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18555
diff
changeset
|
635 } |
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18555
diff
changeset
|
636 |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
637 void QConsolePrivate::drawTextBackground (QPainter& p, int cx1, int cy1, |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
638 int cx2, int cy2, int cw, int ch) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
639 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
640 p.save (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
641 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
642 int ascent = p.fontMetrics ().ascent (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
643 int stride = m_consoleRect.width (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
644 int y = ascent + cy1 * ch;; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
645 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
646 for (int j = cy1; j <= cy2; j++, y += ch) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
647 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
648 int len = 0; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
649 bool hasChar = false; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
650 int x = cx1 * cw; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
651 WORD attr = 0; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
652 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
653 for (int i = cx1; i <= cx2; i++) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
654 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
655 CHAR_INFO* ci = &(m_buffer[stride*j+i]); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
656 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
657 if ((ci->Attributes & 0x00ff) != attr) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
658 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
659 // Character attributes changed |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
660 if (len != 0) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
661 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
662 // String buffer not empty -> draw it |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
663 if (hasChar || (attr & 0x00f0)) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
664 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
665 if (attr & 0x00f0) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
666 p.fillRect (x, y-ascent, len * cw, ch, p.brush ()); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
667 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
668 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
669 x += (len * cw); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
670 len = 0; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
671 hasChar = false; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
672 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
673 // Update current brush and store current attributes |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
674 attr = (ci->Attributes & 0x00ff); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
675 p.setBrush (m_colors[(attr >> 4) & 0x000f]); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
676 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
677 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
678 // Append current character to the string buffer |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
679 len++; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
680 if (ci->Char.UnicodeChar != L' ') |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
681 hasChar = true; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
682 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
683 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
684 if (len != 0 && (hasChar || (attr & 0x00f0))) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
685 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
686 // Line end reached, but string buffer not empty -> draw it |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
687 // No need to update s or x, they will be reset on the next |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
688 // for-loop iteration |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
689 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
690 if (attr & 0x00f0) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
691 p.fillRect (x, y-ascent, len * cw, ch, p.brush ()); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
692 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
693 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
694 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
695 p.restore (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
696 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
697 |
18555
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18271
diff
changeset
|
698 void QConsolePrivate::selectAll() |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18271
diff
changeset
|
699 { |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18271
diff
changeset
|
700 m_beginSelection = QPoint (0,0); |
19595
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19594
diff
changeset
|
701 m_endSelection = QPoint(m_bufferSize.width (), |
18555
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18271
diff
changeset
|
702 m_cursorPos.y()); |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18271
diff
changeset
|
703 updateSelection(); |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18271
diff
changeset
|
704 } |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18271
diff
changeset
|
705 |
18661
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
706 void QConsolePrivate::selectWord (const QPoint & cellpos) |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
707 { |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
708 QPoint begin = cellpos; |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
709 QPoint end = cellpos; |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
710 |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
711 int stride = m_consoleRect.width (); |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
712 |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
713 int verticalScrollOffset = m_consoleRect.top (); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
714 int horizontalScrollOffset = m_consoleRect.left (); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
715 |
18661
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
716 // get begin, end in buffer offsets |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
717 begin.ry () -= verticalScrollOffset; |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
718 end.ry () -= verticalScrollOffset; |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
719 |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
720 begin.rx () -= horizontalScrollOffset; |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
721 end.rx () -= horizontalScrollOffset; |
18661
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
722 |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
723 // loog at current clicked on char to determinate ig getting space chunk or nonspace chunk |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
724 if (QChar(m_buffer[begin.y ()*stride + begin.x ()].Char.UnicodeChar).isSpace () == false) |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
725 { |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
726 // from current char, go back and fwd to find start and end of block |
19595
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19594
diff
changeset
|
727 while(begin.x () > 0 && |
18661
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
728 QChar(m_buffer[begin.y ()*stride + begin.x () -1].Char.UnicodeChar).isSpace() == false) |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
729 { |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
730 begin.rx () --; |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
731 } |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
732 |
19595
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19594
diff
changeset
|
733 while(end.x () < m_consoleRect.width () && |
18661
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
734 QChar(m_buffer[end.y ()*stride + end.x () +1].Char.UnicodeChar).isSpace() == false) |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
735 { |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
736 end.rx () ++; |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
737 } |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
738 } |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
739 else |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
740 { |
19595
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19594
diff
changeset
|
741 while(begin.x () > 0 && |
18661
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
742 QChar(m_buffer[begin.y ()*stride + begin.x () -1].Char.UnicodeChar).isSpace()) |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
743 { |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
744 begin.rx () --; |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
745 } |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
746 |
19595
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19594
diff
changeset
|
747 while(end.x () < m_consoleRect.width () && |
18661
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
748 QChar(m_buffer[end.y ()*stride + end.x () +1].Char.UnicodeChar).isSpace ()) |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
749 { |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
750 end.rx () ++; |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
751 } |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
752 } |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
753 |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
754 // convert console offsets to absolute cell positions |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
755 begin.ry () += verticalScrollOffset; |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
756 end.ry () += verticalScrollOffset; |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
757 |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
758 begin.rx () += horizontalScrollOffset; |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
759 end.rx () += horizontalScrollOffset; |
18661
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
760 |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
761 m_beginSelection = begin; |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
762 m_endSelection = end; |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
763 |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
764 updateSelection (); |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
765 } |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
766 |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
767 void QConsolePrivate::selectLine (const QPoint & cellpos) |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
768 { |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
769 m_beginSelection = QPoint (0, cellpos.y ()); |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
770 m_endSelection = QPoint (m_bufferSize.width ()-1, cellpos.y ()); |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
771 updateSelection (); |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
772 } |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
773 |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
774 |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
775 void QConsolePrivate::drawSelection (QPainter& p, int cx1, int cy1, |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
776 int cx2, int cy2, int cw, int ch) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
777 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
778 p.save (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
779 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
780 QPoint begin = m_beginSelection; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
781 QPoint end = m_endSelection; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
782 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
783 bool haveSelection = (begin != end); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
784 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
785 if (haveSelection) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
786 maybeSwapPoints (begin, end); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
787 |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
788 int verticalScrollOffset = m_consoleRect.top (); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
789 int horizontalScrollOffset = m_consoleRect.left (); |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
790 |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
791 begin.ry () -= verticalScrollOffset; |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
792 end.ry () -= verticalScrollOffset; |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
793 |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
794 begin.rx () -= horizontalScrollOffset; |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
795 end.rx () -= horizontalScrollOffset; |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
796 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
797 int ascent = p.fontMetrics ().ascent (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
798 int stride = m_consoleRect.width (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
799 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
800 int y = ascent + cy1 * ch;; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
801 for (int j = cy1; j <= cy2; j++, y += ch) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
802 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
803 int charsThisLine = 0; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
804 int len = 0; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
805 bool hasChar = false; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
806 WORD attr = 0; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
807 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
808 for (int i = cx1; i <= cx2; i++) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
809 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
810 CHAR_INFO* ci = &(m_buffer[stride*j+i]); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
811 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
812 if ((ci->Attributes & 0x00ff) != attr) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
813 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
814 // Character attributes changed |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
815 if (len != 0) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
816 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
817 charsThisLine += len; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
818 len = 0; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
819 hasChar = false; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
820 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
821 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
822 // Store current attributes |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
823 attr = (ci->Attributes & 0x00ff); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
824 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
825 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
826 // Append current character to the string buffer |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
827 len++; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
828 if (ci->Char.UnicodeChar != L' ') |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
829 hasChar = true; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
830 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
831 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
832 if (len != 0 && (hasChar || (attr & 0x00f0))) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
833 charsThisLine += len; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
834 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
835 if (haveSelection && j >= begin.y () && j <= end.y ()) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
836 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
837 int selectionBegin = j == begin.y () ? begin.x (): 0; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
838 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
839 int len = ((j == end.y () && end.x () < charsThisLine) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
840 ? end.x () - selectionBegin + 1 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
841 : stride - selectionBegin); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
842 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
843 p.fillRect (selectionBegin * cw, y-ascent, len * cw, ch, |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
844 selectionColor ()); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
845 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
846 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
847 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
848 p.restore (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
849 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
850 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
851 void QConsolePrivate::drawCursor (QPainter& p) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
852 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
853 if (! m_cursorBlinking) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
854 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
855 p.save (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
856 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
857 QRect rect = cursorRect (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
858 QColor color = cursorColor (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
859 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
860 p.setPen (color); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
861 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
862 if (m_cursorType == QConsolePrivate::BlockCursor) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
863 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
864 if (q->hasFocus ()) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
865 p.fillRect (rect, color); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
866 else |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
867 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
868 // draw the cursor outline, adjusting the area so that |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
869 // it is draw entirely inside 'rect' |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18626
diff
changeset
|
870 |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
871 int penWidth = qMax (1, p.pen().width()); |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18626
diff
changeset
|
872 |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
873 p.drawRect (rect.adjusted (penWidth/2, penWidth/2, |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
874 - penWidth/2 - penWidth%2, |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
875 - penWidth/2 - penWidth%2)); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
876 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
877 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
878 else if (m_cursorType == QConsolePrivate::UnderlineCursor) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
879 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
880 p.drawLine (rect.left (), rect.bottom (), |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
881 rect.right (), rect.bottom ()); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
882 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
883 else if (m_cursorType == QConsolePrivate::IBeamCursor) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
884 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
885 p.drawLine (rect.left (), rect.top (), |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
886 rect.left (), rect.bottom ()); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
887 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
888 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
889 p.restore (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
890 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
891 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
892 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
893 void QConsolePrivate::drawText (QPainter& p, int cx1, int cy1, |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
894 int cx2, int cy2, int cw, int ch) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
895 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
896 p.save (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
897 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
898 p.setFont (m_font); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
899 p.setPen (foregroundColor ()); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
900 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
901 QString s; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
902 s.reserve (cx2 - cx1 + 1); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
903 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
904 int ascent = p.fontMetrics ().ascent (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
905 int stride = m_consoleRect.width (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
906 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
907 int y = ascent + cy1 * ch;; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
908 for (int j = cy1; j <= cy2; j++, y += ch) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
909 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
910 // Reset string buffer and starting X coordinate |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
911 s.clear (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
912 bool hasChar = false; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
913 int x = cx1 * cw; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
914 WORD attr = 0; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
915 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
916 for (int i = cx1; i <= cx2; i++) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
917 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
918 CHAR_INFO* ci = &(m_buffer[stride*j+i]); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
919 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
920 if ((ci->Attributes & 0x00ff) != attr) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
921 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
922 // Character attributes changed |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
923 if (! s.isEmpty ()) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
924 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
925 // String buffer not empty -> draw it |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
926 if (hasChar || (attr & 0x00f0)) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
927 p.drawText (x, y, s); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
928 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
929 x += (s.length () * cw); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
930 s.clear (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
931 hasChar = false; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
932 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
933 // Update current pen and store current attributes |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
934 attr = (ci->Attributes & 0x00ff); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
935 p.setPen (m_colors[attr & 0x000f]); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
936 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
937 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
938 // Append current character to the string buffer |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
939 s.append (ci->Char.UnicodeChar); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
940 if (ci->Char.UnicodeChar != L' ') |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
941 hasChar = true; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
942 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
943 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
944 if (! s.isEmpty () && (hasChar || (attr & 0x00f0))) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
945 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
946 // Line end reached, but string buffer not empty -> draw it |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
947 // No need to update s or x, they will be reset on the next |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
948 // for-loop iteration |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
949 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
950 p.drawText (x, y, s); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
951 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
952 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
953 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
954 p.restore (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
955 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
956 |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
957 ///////////////////////////////////////////////////////////////////////////// |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
958 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
959 void QConsolePrivate::closeStandardIO (int fd, DWORD stdHandleId, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
960 const char* name) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
961 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
962 if (close (fd) == -1) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
963 log ("Failed to close file descriptor %d: errno=%d.\n", fd, errno); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
964 if (! CloseHandle (GetStdHandle (stdHandleId))) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
965 log ("Failed to close Win32 %s: error=%08x.\n", name, GetLastError ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
966 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
967 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
968 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
969 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
970 void QConsolePrivate::log (const char* fmt, ...) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
971 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
972 #ifdef DEBUG_QCONSOLE |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
973 if (fmt) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
974 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
975 va_list l; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
976 FILE* flog = fopen (LOGFILENAME, "ab"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
977 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
978 va_start (l, fmt); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
979 vfprintf (flog, fmt, l); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
980 va_end (l); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
981 fclose (flog); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
982 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
983 else |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
984 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
985 // Special case to re-initialize the log file |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
986 FILE* flog = fopen (LOGFILENAME, "w"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
987 fclose (flog); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
988 } |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
989 #else |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
990 Q_UNUSED (fmt); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
991 #endif |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
992 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
993 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
994 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
995 |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
996 void QConsolePrivate::updateConsoleSize (bool sync, bool allow_smaller_width) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
997 { |
19845
29692bc97899
fix font in windows terminal when scaling is 150% or more (bug #41938)
Torsten <ttl@justmail.de>
parents:
19690
diff
changeset
|
998 QFontMetrics fm = m_consoleView->fontMetrics (); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
999 QSize winSize = m_consoleView->size (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1000 |
16617
3a17dd5964e3
use average width for character size in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16612
diff
changeset
|
1001 m_charSize.rwidth () = fm.averageCharWidth (); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1002 m_charSize.rheight () = fm.lineSpacing (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1003 |
16617
3a17dd5964e3
use average width for character size in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16612
diff
changeset
|
1004 m_consoleRect.setWidth (winSize.width () / fm.averageCharWidth ()); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1005 m_consoleRect.setHeight (winSize.height () / fm.lineSpacing ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1006 |
19270
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1007 // Don't shrink the size of the buffer. That way wide lines won't be |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1008 // truncated and will reappear if the window is enlarged again later. |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1009 |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1010 if (allow_smaller_width || m_consoleRect.width () > m_bufferSize.width ()) |
19270
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1011 m_bufferSize.rwidth () = m_consoleRect.width (); |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1012 |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1013 if (qMax (m_bufferSize.height (), m_consoleRect.height ()) |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1014 > m_bufferSize.height ()) |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1015 m_bufferSize.rheight () = qMax (m_bufferSize.height (), |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1016 m_consoleRect.height ()); |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1017 |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1018 // Store the terminal size in the environment. When Octave is |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1019 // initialized, we ask the command editor (usually readline) to prefer |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1020 // using these values rather than querying the terminal so that the |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1021 // buffer size can be larger than the size of the window that the |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1022 // command editor will actually use. |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1023 |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1024 qputenv ("LINES", QByteArray::number (m_consoleRect.height ())); |
19595
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19594
diff
changeset
|
1025 qputenv ("COLUMNS", QByteArray::number (m_consoleRect.width ())); |
19270
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1026 |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1027 // Force the command line editor (usually readline) to notice the |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1028 // change in screen size as soon as possible. |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1029 |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1030 q->setSize (m_consoleRect.height (), m_consoleRect.width ()); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1031 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1032 m_consoleRect.moveLeft (0); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1033 if (m_consoleRect.bottom () >= m_bufferSize.height ()) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1034 m_consoleRect.moveTop (m_bufferSize.height () - m_consoleRect.height ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1035 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1036 log ("Console resized:\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1037 log (" widget size: %d x %d\n", winSize.width (), winSize.height ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1038 log (" buffer size: %d x %d\n", m_bufferSize.width (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1039 m_bufferSize.height ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1040 log (" window: (%d, %d) -> (%d, %d) [%d x %d]\n", |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1041 m_consoleRect.left (), m_consoleRect.top (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1042 m_consoleRect.right (), m_consoleRect.bottom (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1043 m_consoleRect.width (), m_consoleRect.height ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1044 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1045 if (sync) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1046 syncConsoleParameters (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1047 |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1048 updateHorizontalScrollBar (); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1049 updateVerticalScrollBar (); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1050 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1051 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1052 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1053 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1054 void QConsolePrivate::syncConsoleParameters (void) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1055 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1056 CONSOLE_SCREEN_BUFFER_INFO sbi; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1057 HANDLE hStdOut = m_stdOut; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1058 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1059 GetConsoleScreenBufferInfo (hStdOut, &sbi); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1060 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1061 COORD bs; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1062 SMALL_RECT sr; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1063 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1064 bs.X = sbi.dwSize.X; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1065 bs.Y = m_bufferSize.height (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1066 sr.Left = sbi.srWindow.Left; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1067 sr.Right = sbi.srWindow.Right; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1068 sr.Top = m_consoleRect.top (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1069 sr.Bottom = m_consoleRect.bottom (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1070 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1071 if (bs.Y > sbi.dwSize.Y) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1072 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1073 SetConsoleScreenBufferSize (hStdOut, bs); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1074 SetConsoleWindowInfo (hStdOut, TRUE, &sr); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1075 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1076 else |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1077 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1078 SetConsoleWindowInfo (hStdOut, TRUE, &sr); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1079 SetConsoleScreenBufferSize (hStdOut, bs); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1080 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1081 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1082 bs.X = m_bufferSize.width (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1083 sr.Left = m_consoleRect.left (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1084 sr.Right = m_consoleRect.right (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1085 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1086 if (bs.X > sbi.dwSize.X) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1087 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1088 SetConsoleScreenBufferSize (hStdOut, bs); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1089 SetConsoleWindowInfo (hStdOut, TRUE, &sr); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1090 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1091 else |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1092 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1093 SetConsoleWindowInfo (hStdOut, TRUE, &sr); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1094 SetConsoleScreenBufferSize (hStdOut, bs); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1095 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1096 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1097 log ("Sync'ing console parameters:\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1098 log (" buffer size: %d x %d\n", bs.X, bs.Y); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1099 log (" window: (%d, %d) -> (%d, %d)\n", |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1100 sr.Left, sr.Top, sr.Right, sr.Bottom); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1101 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1102 if (m_buffer) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1103 delete [] m_buffer; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1104 if (m_tmpBuffer) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1105 delete [] m_tmpBuffer; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1106 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1107 int bufSize = m_consoleRect.width () * m_consoleRect.height (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1108 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1109 m_buffer = new CHAR_INFO[bufSize]; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1110 m_tmpBuffer = new CHAR_INFO[bufSize]; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1111 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1112 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1113 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1114 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1115 void QConsolePrivate::grabConsoleBuffer (CHAR_INFO* buf) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1116 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1117 COORD bs, bc; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1118 SMALL_RECT r; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1119 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1120 bs.X = m_consoleRect.width (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1121 bs.Y = m_consoleRect.height (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1122 bc.X = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1123 bc.Y = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1124 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1125 r.Left = m_consoleRect.left (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1126 r.Top = m_consoleRect.top (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1127 r.Right = m_consoleRect.right (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1128 r.Bottom = m_consoleRect.bottom (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1129 |
25731
c799c0dbe0b5
Fix scrolling command window in Windows 10 (bug #52496).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1130 log ("ReadConsoleOutput (%d,%d) -> (%d,%d)\n", r.Left, r.Top, r.Right, r.Bottom); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1131 if (! ReadConsoleOutput (m_stdOut, (buf ? buf : m_buffer), bs, bc, &r)) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1132 qCritical ("cannot read console output"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1133 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1134 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1135 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1136 |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1137 void QConsolePrivate::updateHorizontalScrollBar (void) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1138 { |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1139 m_horizontalScrollBar->setMinimum (0); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1140 if (m_bufferSize.width () > m_consoleRect.width ()) |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1141 m_horizontalScrollBar->setMaximum (m_bufferSize.width () - m_consoleRect.width ()); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1142 else |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1143 m_horizontalScrollBar->setMaximum (0); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1144 m_horizontalScrollBar->setSingleStep (1); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1145 m_horizontalScrollBar->setPageStep (m_consoleRect.width ()); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1146 m_horizontalScrollBar->setValue (m_consoleRect.left ()); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1147 |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1148 log ("Horizontal scrollbar parameters updated: %d/%d/%d/%d\n", |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1149 m_horizontalScrollBar->minimum (), |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1150 m_horizontalScrollBar->maximum (), |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1151 m_horizontalScrollBar->singleStep (), |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1152 m_horizontalScrollBar->pageStep ()); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1153 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1154 |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1155 void QConsolePrivate::updateVerticalScrollBar (void) |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1156 { |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1157 m_verticalScrollBar->setMinimum (0); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1158 if (m_bufferSize.height () > m_consoleRect.height ()) |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1159 m_verticalScrollBar->setMaximum (m_bufferSize.height () - m_consoleRect.height ()); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1160 else |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1161 m_verticalScrollBar->setMaximum (0); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1162 m_verticalScrollBar->setSingleStep (1); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1163 m_verticalScrollBar->setPageStep (m_consoleRect.height ()); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1164 m_verticalScrollBar->setValue (m_consoleRect.top ()); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1165 |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1166 log ("Vertical scrollbar parameters updated: %d/%d/%d/%d\n", |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1167 m_verticalScrollBar->minimum (), m_verticalScrollBar->maximum (), |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1168 m_verticalScrollBar->singleStep (), m_verticalScrollBar->pageStep ()); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1169 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1170 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1171 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1172 |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1173 void QConsolePrivate::setHorizontalScrollValue (int value) |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1174 { |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1175 if (value == m_consoleRect.left ()) |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1176 return; |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1177 |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1178 SMALL_RECT r; |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1179 HANDLE hStdOut = m_stdOut; |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1180 |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1181 if (value + m_consoleRect.width () > m_bufferSize.width ()) |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1182 value = m_bufferSize.width () - m_consoleRect.width (); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1183 |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1184 r.Left = value; |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1185 r.Top = m_consoleRect.top (); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1186 r.Right = value + m_consoleRect.width () - 1; |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1187 r.Bottom = m_consoleRect.bottom (); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1188 |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1189 log ("Scrolling window horizontally: (%d, %d) -> (%d, %d) [%d x %d]\n", |
19595
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19594
diff
changeset
|
1190 r.Left, r.Top, r.Right, r.Bottom, |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1191 r.Right - r.Left + 1, r.Bottom - r.Top + 1); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1192 |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1193 if (SetConsoleWindowInfo (hStdOut, TRUE, &r)) |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1194 { |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1195 m_consoleRect.moveLeft (value); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1196 updateConsoleView (); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1197 } |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1198 } |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1199 |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1200 void QConsolePrivate::setVerticalScrollValue (int value) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1201 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1202 if (value == m_consoleRect.top ()) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1203 return; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1204 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1205 SMALL_RECT r; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1206 HANDLE hStdOut = m_stdOut; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1207 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1208 if (value + m_consoleRect.height () > m_bufferSize.height ()) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1209 value = m_bufferSize.height () - m_consoleRect.height (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1210 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1211 r.Left = m_consoleRect.left (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1212 r.Top = value; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1213 r.Right = m_consoleRect.right (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1214 r.Bottom = value + m_consoleRect.height () - 1; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1215 |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1216 log ("Scrolling window vertically: (%d, %d) -> (%d, %d) [%d x %d]\n", |
19595
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19594
diff
changeset
|
1217 r.Left, r.Top, r.Right, r.Bottom, |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1218 r.Right - r.Left + 1, r.Bottom - r.Top + 1); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1219 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1220 if (SetConsoleWindowInfo (hStdOut, TRUE, &r)) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1221 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1222 m_consoleRect.moveTop (value); |
25731
c799c0dbe0b5
Fix scrolling command window in Windows 10 (bug #52496).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1223 |
c799c0dbe0b5
Fix scrolling command window in Windows 10 (bug #52496).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1224 CONSOLE_SCREEN_BUFFER_INFO sbi; |
c799c0dbe0b5
Fix scrolling command window in Windows 10 (bug #52496).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1225 if (GetConsoleScreenBufferInfo (hStdOut, &sbi)) |
c799c0dbe0b5
Fix scrolling command window in Windows 10 (bug #52496).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1226 { |
c799c0dbe0b5
Fix scrolling command window in Windows 10 (bug #52496).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1227 if (sbi.dwCursorPosition.Y > m_consoleRect.bottom ()) |
c799c0dbe0b5
Fix scrolling command window in Windows 10 (bug #52496).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1228 m_auto_scroll = false; |
c799c0dbe0b5
Fix scrolling command window in Windows 10 (bug #52496).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1229 else |
c799c0dbe0b5
Fix scrolling command window in Windows 10 (bug #52496).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1230 m_auto_scroll = true; |
c799c0dbe0b5
Fix scrolling command window in Windows 10 (bug #52496).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1231 } |
c799c0dbe0b5
Fix scrolling command window in Windows 10 (bug #52496).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1232 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1233 updateConsoleView (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1234 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1235 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1236 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1237 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1238 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1239 void QConsolePrivate::updateConsoleView (bool grab) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1240 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1241 if (grab) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1242 grabConsoleBuffer (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1243 m_consoleView->update (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1244 m_consoleWatcher->start (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1245 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1246 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1247 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1248 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1249 void QConsolePrivate::monitorConsole (void) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1250 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1251 CONSOLE_SCREEN_BUFFER_INFO sbi; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1252 HANDLE hStdOut = GetStdHandle (STD_OUTPUT_HANDLE); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1253 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1254 static wchar_t titleBuf[260]; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1255 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1256 GetConsoleTitleW (titleBuf, sizeof (titleBuf)); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1257 QString title = QString::fromWCharArray (titleBuf); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1258 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1259 if (title != m_title) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1260 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1261 q->setWindowTitle (title); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1262 emit q->titleChanged (title); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1263 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1264 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1265 if (GetConsoleScreenBufferInfo (hStdOut, &sbi)) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1266 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1267 if (m_bufferSize.width () != sbi.dwSize.X |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1268 || m_bufferSize.height () != sbi.dwSize.Y) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1269 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1270 // Buffer size changed |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1271 m_bufferSize.rwidth () = sbi.dwSize.X; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1272 m_bufferSize.rheight () = sbi.dwSize.Y; |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1273 updateHorizontalScrollBar (); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1274 updateVerticalScrollBar (); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1275 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1276 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1277 if (m_cursorPos.x () != sbi.dwCursorPosition.X |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1278 || m_cursorPos.y () != sbi.dwCursorPosition.Y) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1279 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1280 // Cursor position changed |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1281 m_consoleView->update |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1282 ((m_cursorPos.x () - sbi.srWindow.Left) * m_charSize.width (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1283 (m_cursorPos.y () - sbi.srWindow.Top) * m_charSize.height (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1284 m_charSize.width (), m_charSize.height ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1285 m_cursorPos.rx () = sbi.dwCursorPosition.X; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1286 m_cursorPos.ry () = sbi.dwCursorPosition.Y; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1287 m_consoleView->update |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1288 ((m_cursorPos.x () - sbi.srWindow.Left) * m_charSize.width (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1289 (m_cursorPos.y () - sbi.srWindow.Top) * m_charSize.height (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1290 m_charSize.width (), m_charSize.height ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1291 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1292 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1293 if (m_consoleRect.left () != sbi.srWindow.Left |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1294 || m_consoleRect.right () != sbi.srWindow.Right |
25731
c799c0dbe0b5
Fix scrolling command window in Windows 10 (bug #52496).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1295 || (m_auto_scroll && |
c799c0dbe0b5
Fix scrolling command window in Windows 10 (bug #52496).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1296 (m_consoleRect.top () != sbi.srWindow.Top |
c799c0dbe0b5
Fix scrolling command window in Windows 10 (bug #52496).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1297 || m_consoleRect.bottom () != sbi.srWindow.Bottom))) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1298 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1299 // Console window changed |
25731
c799c0dbe0b5
Fix scrolling command window in Windows 10 (bug #52496).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1300 log ("--> Console window changed\n"); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1301 m_consoleRect = QRect (sbi.srWindow.Left, sbi.srWindow.Top, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1302 sbi.srWindow.Right - sbi.srWindow.Left + 1, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1303 sbi.srWindow.Bottom - sbi.srWindow.Top + 1); |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1304 updateHorizontalScrollBar (); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1305 updateVerticalScrollBar (); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1306 updateConsoleView (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1307 return; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1308 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1309 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1310 if (m_tmpBuffer && m_buffer) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1311 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1312 grabConsoleBuffer (m_tmpBuffer); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1313 if (memcmp (m_tmpBuffer, m_buffer, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1314 sizeof (CHAR_INFO) * m_consoleRect.width () * |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1315 m_consoleRect.height ())) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1316 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1317 // FIXME: compute the area to update based on the |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1318 // difference between the 2 buffers. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1319 qSwap (m_buffer, m_tmpBuffer); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1320 updateConsoleView (false); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1321 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1322 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1323 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1324 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1325 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1326 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1327 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1328 void QConsolePrivate::startCommand (void) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1329 { |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1330 QString cmd = m_command; |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1331 |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1332 if (cmd.isEmpty ()) |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1333 cmd = qgetenv ("COMSPEC").constData (); |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1334 |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1335 if (! cmd.isEmpty ()) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1336 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1337 STARTUPINFO si; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1338 PROCESS_INFORMATION pi; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1339 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1340 ZeroMemory (&si, sizeof (si)); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1341 si.cb = sizeof (si); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1342 ZeroMemory (&pi, sizeof (pi)); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1343 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1344 if (CreateProcessW (NULL, |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1345 (LPWSTR)cmd.unicode (), |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1346 NULL, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1347 NULL, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1348 TRUE, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1349 0, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1350 NULL, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1351 NULL, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1352 &si, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1353 &pi)) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1354 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1355 CloseHandle (pi.hThread); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1356 m_process = pi.hProcess; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1357 WaitForSingleObject (m_process, INFINITE); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1358 CloseHandle (m_process); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1359 m_process = NULL; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1360 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1361 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1362 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1363 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1364 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1365 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1366 void QConsolePrivate::sendConsoleText (const QString& s) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1367 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1368 // Send the string in chunks of 512 characters. Each character is |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1369 // translated into an equivalent keypress event. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1370 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1371 #define TEXT_CHUNK_SIZE 512 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1372 |
17262
12e5fa85f1bb
Windows GUI: clear any terminal selection when pressing a key/pasting to terminal.
John Donoghue <john.donoghue@ieee.org>
parents:
17248
diff
changeset
|
1373 // clear any selection on inserting text |
12e5fa85f1bb
Windows GUI: clear any terminal selection when pressing a key/pasting to terminal.
John Donoghue <john.donoghue@ieee.org>
parents:
17248
diff
changeset
|
1374 clearSelection(); |
25731
c799c0dbe0b5
Fix scrolling command window in Windows 10 (bug #52496).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1375 // enable auto-scrolling |
c799c0dbe0b5
Fix scrolling command window in Windows 10 (bug #52496).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
1376 m_auto_scroll = true; |
17262
12e5fa85f1bb
Windows GUI: clear any terminal selection when pressing a key/pasting to terminal.
John Donoghue <john.donoghue@ieee.org>
parents:
17248
diff
changeset
|
1377 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1378 int len = s.length (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1379 INPUT_RECORD events[TEXT_CHUNK_SIZE]; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1380 DWORD nEvents = 0, written; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1381 HANDLE hStdIn = GetStdHandle (STD_INPUT_HANDLE); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1382 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1383 ZeroMemory (events, sizeof (events)); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1384 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1385 for (int i = 0; i < len; i++) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1386 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1387 QChar c = s.at (i); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1388 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1389 if (c == L'\r' || c == L'\n') |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1390 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1391 if (c == L'\r' && i < (len - 1) && s.at (i+1) == L'\n') |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1392 i++; |
18242
450f50d3eb18
GUI: Use WriteConsoleInput for sending terminal newline (Bug #41123)
John Donoghue <john.donoghue@ieee.org>
parents:
17972
diff
changeset
|
1393 |
450f50d3eb18
GUI: Use WriteConsoleInput for sending terminal newline (Bug #41123)
John Donoghue <john.donoghue@ieee.org>
parents:
17972
diff
changeset
|
1394 // add new line |
450f50d3eb18
GUI: Use WriteConsoleInput for sending terminal newline (Bug #41123)
John Donoghue <john.donoghue@ieee.org>
parents:
17972
diff
changeset
|
1395 events[nEvents].EventType = KEY_EVENT; |
450f50d3eb18
GUI: Use WriteConsoleInput for sending terminal newline (Bug #41123)
John Donoghue <john.donoghue@ieee.org>
parents:
17972
diff
changeset
|
1396 events[nEvents].Event.KeyEvent.bKeyDown = TRUE; |
450f50d3eb18
GUI: Use WriteConsoleInput for sending terminal newline (Bug #41123)
John Donoghue <john.donoghue@ieee.org>
parents:
17972
diff
changeset
|
1397 events[nEvents].Event.KeyEvent.wRepeatCount = 1; |
450f50d3eb18
GUI: Use WriteConsoleInput for sending terminal newline (Bug #41123)
John Donoghue <john.donoghue@ieee.org>
parents:
17972
diff
changeset
|
1398 events[nEvents].Event.KeyEvent.wVirtualKeyCode = |
450f50d3eb18
GUI: Use WriteConsoleInput for sending terminal newline (Bug #41123)
John Donoghue <john.donoghue@ieee.org>
parents:
17972
diff
changeset
|
1399 VK_RETURN; |
450f50d3eb18
GUI: Use WriteConsoleInput for sending terminal newline (Bug #41123)
John Donoghue <john.donoghue@ieee.org>
parents:
17972
diff
changeset
|
1400 events[nEvents].Event.KeyEvent.wVirtualScanCode = 0; |
450f50d3eb18
GUI: Use WriteConsoleInput for sending terminal newline (Bug #41123)
John Donoghue <john.donoghue@ieee.org>
parents:
17972
diff
changeset
|
1401 events[nEvents].Event.KeyEvent.uChar.UnicodeChar = c.unicode (); |
450f50d3eb18
GUI: Use WriteConsoleInput for sending terminal newline (Bug #41123)
John Donoghue <john.donoghue@ieee.org>
parents:
17972
diff
changeset
|
1402 events[nEvents].Event.KeyEvent.dwControlKeyState = 0; |
450f50d3eb18
GUI: Use WriteConsoleInput for sending terminal newline (Bug #41123)
John Donoghue <john.donoghue@ieee.org>
parents:
17972
diff
changeset
|
1403 nEvents++; |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18626
diff
changeset
|
1404 |
18242
450f50d3eb18
GUI: Use WriteConsoleInput for sending terminal newline (Bug #41123)
John Donoghue <john.donoghue@ieee.org>
parents:
17972
diff
changeset
|
1405 WriteConsoleInput (hStdIn, events, nEvents, &written); |
450f50d3eb18
GUI: Use WriteConsoleInput for sending terminal newline (Bug #41123)
John Donoghue <john.donoghue@ieee.org>
parents:
17972
diff
changeset
|
1406 nEvents = 0; |
450f50d3eb18
GUI: Use WriteConsoleInput for sending terminal newline (Bug #41123)
John Donoghue <john.donoghue@ieee.org>
parents:
17972
diff
changeset
|
1407 ZeroMemory (events, sizeof (events)); |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18626
diff
changeset
|
1408 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1409 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1410 else |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1411 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1412 events[nEvents].EventType = KEY_EVENT; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1413 events[nEvents].Event.KeyEvent.bKeyDown = TRUE; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1414 events[nEvents].Event.KeyEvent.wRepeatCount = 1; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1415 events[nEvents].Event.KeyEvent.wVirtualKeyCode = |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1416 LOBYTE (VkKeyScan (c.unicode ())); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1417 events[nEvents].Event.KeyEvent.wVirtualScanCode = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1418 events[nEvents].Event.KeyEvent.uChar.UnicodeChar = c.unicode (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1419 events[nEvents].Event.KeyEvent.dwControlKeyState = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1420 nEvents++; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1421 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1422 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1423 if (nEvents == TEXT_CHUNK_SIZE |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1424 || (nEvents > 0 && i == (len - 1))) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1425 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1426 WriteConsoleInput (hStdIn, events, nEvents, &written); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1427 nEvents = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1428 ZeroMemory (events, sizeof (events)); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1429 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1430 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1431 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1432 |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1433 QRect |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1434 QConsolePrivate::cursorRect (void) |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1435 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1436 int cw = m_charSize.width (); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1437 int ch = m_charSize.height (); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1438 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1439 return QRect ((m_cursorPos.x () - m_consoleRect.x ()) * cw, |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1440 (m_cursorPos.y () - m_consoleRect.y ()) * ch, |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1441 cw, ch); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1442 } |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1443 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1444 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1445 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1446 QWinTerminalImpl::QWinTerminalImpl (QWidget* parent) |
18661
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1447 : QTerminal (parent), d (new QConsolePrivate (this)), |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1448 allowTripleClick (false) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1449 { |
17264
aa09b746fa16
Windows GUI: Reimplement tabbing in terminal window
John Donoghue <john.donoghue@ieee.org>
parents:
17262
diff
changeset
|
1450 installEventFilter (this); |
aa09b746fa16
Windows GUI: Reimplement tabbing in terminal window
John Donoghue <john.donoghue@ieee.org>
parents:
17262
diff
changeset
|
1451 |
16970
78116b88dbf5
enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents:
16881
diff
changeset
|
1452 connect (this, SIGNAL (set_global_shortcuts_signal (bool)), |
78116b88dbf5
enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents:
16881
diff
changeset
|
1453 parent, SLOT (set_global_shortcuts (bool))); |
19943
88233ac3f3ea
fix issue with ctrl-c for copying when editor has focus and is docked
Torsten <ttl@justmail.de>
parents:
19845
diff
changeset
|
1454 connect (this, SIGNAL (set_global_shortcuts_signal (bool)), |
88233ac3f3ea
fix issue with ctrl-c for copying when editor has focus and is docked
Torsten <ttl@justmail.de>
parents:
19845
diff
changeset
|
1455 this, SLOT (set_global_shortcuts (bool))); |
18655
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1456 |
19270
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1457 connect (this, SIGNAL (set_screen_size_signal (int, int)), |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1458 parent, SLOT (set_screen_size (int, int))); |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1459 |
18655
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1460 setAcceptDrops (true); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1461 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1462 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1463 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1464 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1465 QWinTerminalImpl::QWinTerminalImpl (const QString& cmd, QWidget* parent) |
16639
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16629
diff
changeset
|
1466 : QTerminal (parent), d (new QConsolePrivate (this, cmd)) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1467 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1468 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1469 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1470 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1471 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1472 QWinTerminalImpl::~QWinTerminalImpl (void) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1473 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1474 delete d; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1475 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1476 |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1477 void QWinTerminalImpl::mouseMoveEvent (QMouseEvent *event) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1478 { |
16647
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1479 if (d->m_settingSelection) |
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1480 { |
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1481 d->m_endSelection = d->posToCell (event->pos ()); |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1482 |
16647
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1483 updateSelection (); |
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1484 } |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1485 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1486 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1487 void QWinTerminalImpl::mousePressEvent (QMouseEvent *event) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1488 { |
18661
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1489 if (allowTripleClick) |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1490 { |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1491 mouseTripleClickEvent (event); |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1492 } |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1493 else if (event->button () == Qt::LeftButton) |
16647
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1494 { |
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1495 d->m_settingSelection = true; |
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1496 |
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1497 d->m_beginSelection = d->posToCell (event->pos ()); |
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1498 } |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1499 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1500 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1501 void QWinTerminalImpl::mouseReleaseEvent (QMouseEvent *event) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1502 { |
18661
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1503 if (event->button () == Qt::LeftButton && d->m_settingSelection) |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1504 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1505 d->m_endSelection = d->posToCell (event->pos ()); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1506 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1507 updateSelection (); |
16647
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1508 |
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1509 d->m_settingSelection = false; |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1510 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1511 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1512 |
18661
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1513 void QWinTerminalImpl::mouseDoubleClickEvent (QMouseEvent *event) |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1514 { |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1515 if (event->button () == Qt::LeftButton) |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1516 { |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1517 // doubleclick - select word |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1518 d->m_settingSelection = false; |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1519 |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1520 d->selectWord (d->posToCell (event->pos ())); |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1521 |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1522 allowTripleClick = true; |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1523 |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1524 QTimer::singleShot (QApplication::doubleClickInterval (),this, |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1525 SLOT (tripleClickTimeout ())); |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1526 |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1527 } |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1528 } |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1529 |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1530 void QWinTerminalImpl::mouseTripleClickEvent (QMouseEvent *event) |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1531 { |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1532 if (event->button () == Qt::LeftButton) |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1533 { |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1534 d->selectLine (d->posToCell (event->pos ())); |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1535 } |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1536 } |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1537 |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1538 void QWinTerminalImpl::tripleClickTimeout () |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1539 { |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1540 allowTripleClick = false; |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1541 } |
8b9e99c061f9
GUI: Windows GUI terminal support for double click (Bug #41468)
John Donoghue <john.donoghue@ieee.org>
parents:
18655
diff
changeset
|
1542 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1543 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1544 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1545 void QWinTerminalImpl::viewResizeEvent (QConsoleView*, QResizeEvent*) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1546 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1547 d->updateConsoleSize (true); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1548 d->grabConsoleBuffer (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1549 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1550 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1551 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1552 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1553 void QWinTerminalImpl::viewPaintEvent (QConsoleView* w, QPaintEvent* event) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1554 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1555 QPainter p (w); |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
1556 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
1557 int cw = d->m_charSize.width (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
1558 int ch = d->m_charSize.height (); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1559 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1560 QRect updateRect = event->rect (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1561 |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
1562 int cx1 = updateRect.left () / cw; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
1563 int cy1 = updateRect.top () / ch; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
1564 int cx2 = qMin (d->m_consoleRect.width () - 1, updateRect.right () / cw); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
1565 int cy2 = qMin (d->m_consoleRect.height () - 1, updateRect.bottom () / ch); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1566 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1567 if (cx1 > d->m_consoleRect.width () - 1 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1568 || cy1 > d->m_consoleRect.height () - 1) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1569 return; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1570 |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
1571 d->drawTextBackground (p, cx1, cy1, cx2, cy2, cw, ch); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
1572 d->drawSelection (p, cx1, cy1, cx2, cy2, cw, ch); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
1573 d->drawCursor (p); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
1574 d->drawText (p, cx1, cy1, cx2, cy2, cw, ch); |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1575 } |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1576 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1577 void QWinTerminalImpl::blinkCursorEvent (void) |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1578 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1579 if (d->m_hasBlinkingCursor) |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1580 d->m_cursorBlinking = ! d->m_cursorBlinking; |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1581 else |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1582 d->m_cursorBlinking = false; |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1583 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1584 d->m_consoleView->update (d->cursorRect ()); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1585 } |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1586 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1587 void QWinTerminalImpl::setBlinkingCursor (bool blink) |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1588 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1589 d->m_hasBlinkingCursor = blink; |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1590 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1591 setBlinkingCursorState (blink); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1592 } |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1593 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1594 void QWinTerminalImpl::setBlinkingCursorState (bool blink) |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1595 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1596 if (blink && ! d->m_blinkCursorTimer->isActive ()) |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1597 d->m_blinkCursorTimer->start (d->BLINK_DELAY); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1598 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1599 if (! blink && d->m_blinkCursorTimer->isActive ()) |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1600 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1601 d->m_blinkCursorTimer->stop (); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1602 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1603 if (d->m_cursorBlinking) |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1604 blinkCursorEvent (); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1605 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1606 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1607 |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1608 // Reset width of console buffer and terminal window to be the same. |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1609 |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1610 void QWinTerminalImpl::init_terminal_size (void) |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1611 { |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1612 d->updateConsoleSize (true, true); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1613 } |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1614 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1615 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1616 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1617 void QWinTerminalImpl::wheelEvent (QWheelEvent* event) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1618 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1619 if (! d->m_inWheelEvent) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1620 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1621 // Forward to the scrollbar (avoid recursion) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1622 d->m_inWheelEvent = true; |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1623 QApplication::sendEvent (d->m_verticalScrollBar, event); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1624 d->m_inWheelEvent = false; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1625 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1626 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1627 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1628 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1629 |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1630 void QWinTerminalImpl::horizontalScrollValueChanged (int value) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1631 { |
19303
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1632 d->setHorizontalScrollValue (value); |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1633 } |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1634 |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1635 void QWinTerminalImpl::verticalScrollValueChanged (int value) |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1636 { |
c6615ca0a11d
horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents:
19270
diff
changeset
|
1637 d->setVerticalScrollValue (value); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1638 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1639 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1640 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1641 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1642 void QWinTerminalImpl::monitorConsole (void) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1643 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1644 d->monitorConsole (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1645 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1646 |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1647 void QWinTerminalImpl::updateSelection (void) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1648 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1649 d->updateSelection (); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1650 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1651 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1652 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1653 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1654 void QWinTerminalImpl::focusInEvent (QFocusEvent* event) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1655 { |
16970
78116b88dbf5
enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents:
16881
diff
changeset
|
1656 emit set_global_shortcuts_signal (false); // disable some shortcuts |
78116b88dbf5
enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents:
16881
diff
changeset
|
1657 |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1658 setBlinkingCursorState (true); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1659 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1660 QWidget::focusInEvent (event); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1661 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1662 |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1663 void QWinTerminalImpl::focusOutEvent (QFocusEvent* event) |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1664 { |
16970
78116b88dbf5
enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents:
16881
diff
changeset
|
1665 emit set_global_shortcuts_signal (true); // re-enable shortcuts |
78116b88dbf5
enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents:
16881
diff
changeset
|
1666 |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1667 // Force the cursor to be redrawn. |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1668 d->m_cursorBlinking = true; |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1669 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1670 setBlinkingCursorState (false); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1671 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1672 QWidget::focusOutEvent (event); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1673 } |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1674 |
17264
aa09b746fa16
Windows GUI: Reimplement tabbing in terminal window
John Donoghue <john.donoghue@ieee.org>
parents:
17262
diff
changeset
|
1675 bool QWinTerminalImpl::eventFilter (QObject *obj, QEvent * event) |
aa09b746fa16
Windows GUI: Reimplement tabbing in terminal window
John Donoghue <john.donoghue@ieee.org>
parents:
17262
diff
changeset
|
1676 { |
aa09b746fa16
Windows GUI: Reimplement tabbing in terminal window
John Donoghue <john.donoghue@ieee.org>
parents:
17262
diff
changeset
|
1677 // if a keypress, filter out tab keys so that the next/prev tabbing is |
aa09b746fa16
Windows GUI: Reimplement tabbing in terminal window
John Donoghue <john.donoghue@ieee.org>
parents:
17262
diff
changeset
|
1678 // disabled - but we still need to pass along to the console . |
aa09b746fa16
Windows GUI: Reimplement tabbing in terminal window
John Donoghue <john.donoghue@ieee.org>
parents:
17262
diff
changeset
|
1679 if (event->type () == QEvent::KeyPress) |
aa09b746fa16
Windows GUI: Reimplement tabbing in terminal window
John Donoghue <john.donoghue@ieee.org>
parents:
17262
diff
changeset
|
1680 { |
aa09b746fa16
Windows GUI: Reimplement tabbing in terminal window
John Donoghue <john.donoghue@ieee.org>
parents:
17262
diff
changeset
|
1681 QKeyEvent* k = static_cast<QKeyEvent*>(event); |
aa09b746fa16
Windows GUI: Reimplement tabbing in terminal window
John Donoghue <john.donoghue@ieee.org>
parents:
17262
diff
changeset
|
1682 if (k->key () == Qt::Key_Tab) |
aa09b746fa16
Windows GUI: Reimplement tabbing in terminal window
John Donoghue <john.donoghue@ieee.org>
parents:
17262
diff
changeset
|
1683 { |
aa09b746fa16
Windows GUI: Reimplement tabbing in terminal window
John Donoghue <john.donoghue@ieee.org>
parents:
17262
diff
changeset
|
1684 sendText ("\t"); |
aa09b746fa16
Windows GUI: Reimplement tabbing in terminal window
John Donoghue <john.donoghue@ieee.org>
parents:
17262
diff
changeset
|
1685 return true; |
aa09b746fa16
Windows GUI: Reimplement tabbing in terminal window
John Donoghue <john.donoghue@ieee.org>
parents:
17262
diff
changeset
|
1686 } |
aa09b746fa16
Windows GUI: Reimplement tabbing in terminal window
John Donoghue <john.donoghue@ieee.org>
parents:
17262
diff
changeset
|
1687 } |
aa09b746fa16
Windows GUI: Reimplement tabbing in terminal window
John Donoghue <john.donoghue@ieee.org>
parents:
17262
diff
changeset
|
1688 return false; |
aa09b746fa16
Windows GUI: Reimplement tabbing in terminal window
John Donoghue <john.donoghue@ieee.org>
parents:
17262
diff
changeset
|
1689 } |
aa09b746fa16
Windows GUI: Reimplement tabbing in terminal window
John Donoghue <john.donoghue@ieee.org>
parents:
17262
diff
changeset
|
1690 |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1691 void QWinTerminalImpl::keyPressEvent (QKeyEvent* event) |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1692 { |
17248
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
1693 QString s = translateKey (event); |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
1694 if (!s.isEmpty ()) |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
1695 sendText (s); |
0b2a0acd0315
Use keyPressEvent instead of winEvent for keyboard input
John Donoghue <john.donoghue@ieee.org>
parents:
17224
diff
changeset
|
1696 |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1697 if (d->m_hasBlinkingCursor) |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1698 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1699 d->m_blinkCursorTimer->start (d->BLINK_DELAY); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1700 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1701 if (d->m_cursorBlinking) |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1702 blinkCursorEvent (); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1703 } |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1704 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1705 QWidget::keyPressEvent (event); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1706 } |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1707 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1708 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1709 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1710 void QWinTerminalImpl::start (void) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1711 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1712 d->startCommand (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1713 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1714 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1715 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1716 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1717 void QWinTerminalImpl::sendText (const QString& s) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1718 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1719 d->sendConsoleText (s); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1720 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1721 |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1722 void QWinTerminalImpl::setCursorType (CursorType type, bool blinking) |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1723 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1724 switch (type) |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1725 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1726 case UnderlineCursor: |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1727 d->m_cursorType = QConsolePrivate::UnderlineCursor; |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1728 break; |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1729 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1730 case BlockCursor: |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1731 d->m_cursorType = QConsolePrivate::BlockCursor; |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1732 break; |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1733 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1734 case IBeamCursor: |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1735 d->m_cursorType = QConsolePrivate::IBeamCursor; |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1736 break; |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1737 } |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1738 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1739 setBlinkingCursor (blinking); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1740 } |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1741 |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1742 void QWinTerminalImpl::setBackgroundColor (const QColor& color) |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1743 { |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1744 d->setBackgroundColor (color); |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1745 } |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1746 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1747 void QWinTerminalImpl::setForegroundColor (const QColor& color) |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1748 { |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1749 d->setForegroundColor (color); |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1750 } |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1751 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1752 void QWinTerminalImpl::setSelectionColor (const QColor& color) |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1753 { |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1754 d->setSelectionColor (color); |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1755 } |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1756 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1757 void QWinTerminalImpl::setCursorColor (bool useForegroundColor, |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1758 const QColor& color) |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1759 { |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1760 d->setCursorColor (useForegroundColor, color); |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1761 } |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1762 |
18610
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18555
diff
changeset
|
1763 void QWinTerminalImpl::setScrollBufferSize(int value) |
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18555
diff
changeset
|
1764 { |
19440
9c719c504e8d
command window buffer size configurable on windows (bug #41474)
Torsten <ttl@justmail.de>
parents:
19303
diff
changeset
|
1765 d->setScrollBufferSize (value); |
18610
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18555
diff
changeset
|
1766 } |
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18555
diff
changeset
|
1767 |
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18555
diff
changeset
|
1768 |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1769 ////////////////////////////////////////////////////////////////////////////// |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1770 |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1771 void QWinTerminalImpl::setTerminalFont (const QFont& f) |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1772 { |
15666
20299b92a64e
Added patch that allows for changing the terminal font.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15665
diff
changeset
|
1773 d->m_font = f; |
20299b92a64e
Added patch that allows for changing the terminal font.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15665
diff
changeset
|
1774 d->m_consoleView->setFont (f); |
20299b92a64e
Added patch that allows for changing the terminal font.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15665
diff
changeset
|
1775 d->updateConsoleSize (true); |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1776 } |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1777 |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1778 ////////////////////////////////////////////////////////////////////////////// |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1779 |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1780 void QWinTerminalImpl::setSize (int columns, int lines) |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1781 { |
19270
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1782 d->log ("emit set_screen_size_signal (%d, %d)\n", columns, lines); |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1783 |
efccb2a65b9a
preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents:
18661
diff
changeset
|
1784 emit set_screen_size_signal (columns, lines); |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1785 } |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1786 |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1787 ////////////////////////////////////////////////////////////////////////////// |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1788 |
19690
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
19595
diff
changeset
|
1789 void QWinTerminalImpl::copyClipboard () |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1790 { |
16881
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16794
diff
changeset
|
1791 if(!hasFocus()) return; |
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16794
diff
changeset
|
1792 |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1793 QClipboard *clipboard = QApplication::clipboard (); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1794 |
16648
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
1795 QString selection = d->getSelection (); |
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
1796 |
20137
4ba6c61c8794
no copying of empty text in terminal when copy shortcut is not Ctrl-C
Torsten <ttl@justmail.de>
parents:
19943
diff
changeset
|
1797 if (selection.isEmpty ()) |
4ba6c61c8794
no copying of empty text in terminal when copy shortcut is not Ctrl-C
Torsten <ttl@justmail.de>
parents:
19943
diff
changeset
|
1798 { |
4ba6c61c8794
no copying of empty text in terminal when copy shortcut is not Ctrl-C
Torsten <ttl@justmail.de>
parents:
19943
diff
changeset
|
1799 if (! _extra_interrupt) |
4ba6c61c8794
no copying of empty text in terminal when copy shortcut is not Ctrl-C
Torsten <ttl@justmail.de>
parents:
19943
diff
changeset
|
1800 terminal_interrupt (); |
4ba6c61c8794
no copying of empty text in terminal when copy shortcut is not Ctrl-C
Torsten <ttl@justmail.de>
parents:
19943
diff
changeset
|
1801 } |
16648
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
1802 else |
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
1803 { |
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
1804 clipboard->setText (selection); |
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
1805 emit report_status_message (tr ("copied selection to clipboard")); |
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
1806 } |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1807 } |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1808 |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1809 ////////////////////////////////////////////////////////////////////////////// |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1810 |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1811 void QWinTerminalImpl::pasteClipboard (void) |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1812 { |
16881
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16794
diff
changeset
|
1813 if(!hasFocus()) return; |
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16794
diff
changeset
|
1814 |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1815 QString text = QApplication::clipboard()->text (QClipboard::Clipboard); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1816 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1817 if (! text.isEmpty ()) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1818 sendText (text); |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1819 } |
16794
1d1f02e0f6b4
GUI: enable clipboard content detection for terminal window context menu
John Donoghue <john.donoghue@ieee.org>
parents:
16648
diff
changeset
|
1820 |
18555
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18271
diff
changeset
|
1821 ////////////////////////////////////////////////////////////////////////////// |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18271
diff
changeset
|
1822 |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18271
diff
changeset
|
1823 void QWinTerminalImpl::selectAll (void) |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18271
diff
changeset
|
1824 { |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18271
diff
changeset
|
1825 if(!hasFocus()) return; |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18271
diff
changeset
|
1826 |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18271
diff
changeset
|
1827 d->selectAll(); |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18271
diff
changeset
|
1828 } |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18271
diff
changeset
|
1829 |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18271
diff
changeset
|
1830 |
16794
1d1f02e0f6b4
GUI: enable clipboard content detection for terminal window context menu
John Donoghue <john.donoghue@ieee.org>
parents:
16648
diff
changeset
|
1831 |
1d1f02e0f6b4
GUI: enable clipboard content detection for terminal window context menu
John Donoghue <john.donoghue@ieee.org>
parents:
16648
diff
changeset
|
1832 ////////////////////////////////////////////////////////////////////////////// |
1d1f02e0f6b4
GUI: enable clipboard content detection for terminal window context menu
John Donoghue <john.donoghue@ieee.org>
parents:
16648
diff
changeset
|
1833 |
1d1f02e0f6b4
GUI: enable clipboard content detection for terminal window context menu
John Donoghue <john.donoghue@ieee.org>
parents:
16648
diff
changeset
|
1834 QString QWinTerminalImpl::selectedText () |
1d1f02e0f6b4
GUI: enable clipboard content detection for terminal window context menu
John Donoghue <john.donoghue@ieee.org>
parents:
16648
diff
changeset
|
1835 { |
1d1f02e0f6b4
GUI: enable clipboard content detection for terminal window context menu
John Donoghue <john.donoghue@ieee.org>
parents:
16648
diff
changeset
|
1836 QString selection = d->getSelection (); |
1d1f02e0f6b4
GUI: enable clipboard content detection for terminal window context menu
John Donoghue <john.donoghue@ieee.org>
parents:
16648
diff
changeset
|
1837 return selection; |
1d1f02e0f6b4
GUI: enable clipboard content detection for terminal window context menu
John Donoghue <john.donoghue@ieee.org>
parents:
16648
diff
changeset
|
1838 } |
18655
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1839 |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1840 ////////////////////////////////////////////////////////////////////////////// |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1841 |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1842 void QWinTerminalImpl::dragEnterEvent (QDragEnterEvent *event) |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1843 { |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1844 if (event->mimeData ()->hasUrls ()) |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1845 { |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1846 event->acceptProposedAction(); |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1847 } |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1848 } |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1849 |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1850 ////////////////////////////////////////////////////////////////////////////// |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1851 |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1852 void QWinTerminalImpl::dropEvent (QDropEvent *event) |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1853 { |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1854 QString dropText; |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1855 |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1856 if (event->mimeData ()->hasUrls ()) |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1857 { |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1858 foreach (QUrl url, event->mimeData ()->urls ()) |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1859 { |
19595
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19594
diff
changeset
|
1860 if(dropText.length () > 0) |
23787
b481a9baeb61
Replace += "\n" with += '\n' which avoids string constructor for performance.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
1861 dropText += '\n'; |
18655
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1862 dropText += url.toLocalFile (); |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1863 } |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1864 sendText (dropText); |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1865 } |
41489b96ebca
GUI: allow drag and drop to win32 GUI command window (Bug #41443)
John Donoghue <john.donoghue@ieee.org>
parents:
18634
diff
changeset
|
1866 } |
19690
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
19595
diff
changeset
|
1867 |
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
19595
diff
changeset
|
1868 ////////////////////////////////////////////////////////////////////////////// |
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
19595
diff
changeset
|
1869 |
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
19595
diff
changeset
|
1870 void QWinTerminalImpl::has_extra_interrupt (bool extra) |
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
19595
diff
changeset
|
1871 { |
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
19595
diff
changeset
|
1872 _extra_interrupt = extra; |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
20137
diff
changeset
|
1873 } |