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