Mercurial > octave
annotate libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp @ 16648:b04413e5a811
improve handling of interrupts, copy and paste shortcuts
* QTerminal.h (QTerminal::report_status_message): New signal.
(QTerminal::QTerminal): Set shortcuts for copy and paste actions.
Add copy and paste actions to QTerminal widget.
Connect settings_changed, report_status_message, copyClipboard_signal,
and pasteClipboard_signal.
* QWinTerminalImpl.cpp (QWinTerminalImpl::copyClipboard): If selection
is set, copy it and report status message. Otherwise, interrupt.
* TerminalView.cpp (TerminalView::copyClipboard): Likewise.
* main-window.cc (main_menu::construct_file_menu): Don't set shortcut
for open action.
(main_window::construct_edit_menu): Delete unimplemented cut, select
all, and delete actions.
Connect copy and paste actions to signals.
(main_window::copyClipboard_signal,
main_window::pasteClipboard_signal): New signals.
(main_window::copyClipboard, main_window::pasteClipboard): New slots.
(main_window::_cut_action): Delete member variable.
* octave-qt-link.cc (octave_qt_link::do_pre_input_event):
Disable input processing by the windows console.
(octave_qt_link::do_post_input_event):
Enable input processing by the windows console.
* terminal-dock-widget.h, terminal-dock-widget.cc:
Delete notice_settings, copyClipboard, and pasteClipboard signals,
slots, and connections.
(terminal_dock_widget::terminal_dock_widget):
Don't connect visibilityChanged signal.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 13 May 2013 07:26:37 -0400 |
parents | d446e99f89f7 |
children | 1d1f02e0f6b4 |
rev | line source |
---|---|
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1 /* |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
3 Copyright (C) 2011 Michael Goffioul. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
4 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
5 This file is part of QConsole. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
6 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
7 Foobar is free software: you can redistribute it and/or modify |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
8 it under the terms of the GNU General Public License as published by |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
10 (at your option) any later version. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
11 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
12 QConsole is distributed in the hope that it will be useful, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
15 GNU General Public License for more details. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
16 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
18 along with Foobar. If not, see <http://www.gnu.org/licenses/>. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
19 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
20 */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
21 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
22 #include <QApplication> |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
23 #include <QClipboard> |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
24 #include <QColor> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
25 #include <QFont> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
26 #include <QHBoxLayout> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
27 #include <QPaintEvent> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
28 #include <QPainter> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
29 #include <QResizeEvent> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
30 #include <QScrollBar> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
31 #include <QtDebug> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
32 #include <QThread> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
33 #include <QTimer> |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
34 #include <QToolTip> |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
35 #include <QCursor> |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
36 #include <QMessageBox> |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
37 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
38 #include <fcntl.h> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
39 #include <io.h> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
40 #include <stdio.h> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
41 #include <stdarg.h> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
42 #define WIN32_LEAN_AND_MEAN |
15665
4ee03200951e
Applied patch for compiling with mingw.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15662
diff
changeset
|
43 #define _WIN32_WINNT 0x0500 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
44 #include <windows.h> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
45 #include <cstring> |
16648
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
46 #include <csignal> |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
47 #include <limits> |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
48 |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
49 #include "QWinTerminalImpl.h" |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
50 #include "QTerminalColors.h" |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
51 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
52 // Uncomment to log activity to LOGFILENAME |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
53 // #define DEBUG_QCONSOLE |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
54 #define LOGFILENAME "QConsole.log" |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
55 // Uncomment to create hidden console window |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
56 #define HIDDEN_CONSOLE |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
57 |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
58 #ifdef _MSC_VER |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
59 # pragma warning(disable : 4996) |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
60 #endif |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
61 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
62 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
63 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
64 class QConsoleView : public QWidget |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
65 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
66 public: |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
67 QConsoleView (QWinTerminalImpl* parent = 0) : QWidget (parent), q (parent) { } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
68 ~QConsoleView (void) { } |
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 protected: |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
71 void paintEvent (QPaintEvent* event) { q->viewPaintEvent (this, event); } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
72 void resizeEvent (QResizeEvent* event) { q->viewResizeEvent (this, event); } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
73 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
74 private: |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
75 QWinTerminalImpl* q; |
15651
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 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
78 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
79 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
80 class QConsoleThread : public QThread |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
81 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
82 public: |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
83 QConsoleThread (QWinTerminalImpl* console) : QThread (console), q (console) { } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
84 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
85 protected: |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
86 void run (void) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
87 { q->start (); } |
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 private: |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
90 QWinTerminalImpl* q; |
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 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
93 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
94 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
95 class QConsolePrivate |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
96 { |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
97 friend class QWinTerminalImpl; |
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 public: |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
100 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
101 enum KeyboardCursorType |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
102 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
103 BlockCursor, |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
104 UnderlineCursor, |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
105 IBeamCursor |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
106 }; |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
107 |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
108 QConsolePrivate (QWinTerminalImpl* parent, const QString& cmd = QString ()); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
109 ~QConsolePrivate (void); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
110 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
111 void updateConsoleSize (bool sync = false); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
112 void syncConsoleParameters (void); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
113 void grabConsoleBuffer (CHAR_INFO* buf = 0); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
114 void updateScrollBar (void); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
115 void setScrollValue (int value); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
116 void updateConsoleView (bool grab = true); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
117 void monitorConsole (void); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
118 void startCommand (void); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
119 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
|
120 QRect cursorRect (void); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
121 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
122 void log (const char* fmt, ...); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
123 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
124 void closeStandardIO (int fd, DWORD stdHandleId, const char* name); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
125 void setupStandardIO (DWORD stdHandleId, int fd, const char* name, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
126 const char* devName); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
127 |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
128 QPoint posToCell (const QPoint& pt); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
129 QString getSelection (void); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
130 void updateSelection (void); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
131 void clearSelection (void); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
132 |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
133 QColor backgroundColor (void) const; |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
134 QColor foregroundColor (void) const; |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
135 QColor selectionColor (void) const; |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
136 QColor cursorColor (void) const; |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
137 |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
138 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
|
139 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
|
140 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
|
141 void setCursorColor (bool useForegroundColor, const QColor& color); |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
142 |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
143 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
|
144 int cw, int ch); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
145 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
146 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
|
147 int cw, int ch); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
148 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
149 void drawCursor (QPainter& p); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
150 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
151 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
|
152 int cw, int ch); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
153 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
154 private: |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
155 QWinTerminalImpl* q; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
156 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
157 private: |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
158 QFont m_font; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
159 QString m_command; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
160 QConsoleColors m_colors; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
161 bool m_inWheelEvent; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
162 QString m_title; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
163 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
164 QSize m_charSize; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
165 QSize m_bufferSize; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
166 QRect m_consoleRect; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
167 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
|
168 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
|
169 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
|
170 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
|
171 KeyboardCursorType m_cursorType; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
172 |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
173 QPoint m_beginSelection; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
174 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
|
175 bool m_settingSelection; |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
176 |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
177 QColor m_selectionColor; |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
178 QColor m_cursorColor; |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
179 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
180 HANDLE m_stdOut; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
181 HWND m_consoleWindow; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
182 CHAR_INFO* m_buffer; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
183 CHAR_INFO* m_tmpBuffer; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
184 HANDLE m_process; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
185 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
186 QConsoleView* m_consoleView; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
187 QScrollBar* m_scrollBar; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
188 QTimer* m_consoleWatcher; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
189 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
|
190 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
191 // 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
|
192 static const int BLINK_DELAY = 500; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
193 }; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
194 |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
195 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
|
196 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
197 if (end.y () < begin.y () |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
198 || (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
|
199 qSwap (begin, end); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
200 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
201 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
202 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
203 |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
204 QConsolePrivate::QConsolePrivate (QWinTerminalImpl* parent, const QString& cmd) |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
205 : q (parent), m_command (cmd), m_hasBlinkingCursor (true), |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
206 m_cursorType (BlockCursor), m_beginSelection (0, 0), |
16647
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
207 m_endSelection (0, 0), m_settingSelection (false), |
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
208 m_process (NULL), m_inWheelEvent (false) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
209 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
210 log (NULL); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
211 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
212 // Possibly detach from any existing console |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
213 log ("Detaching from existing console (if any)...\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
214 FreeConsole (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
215 log ("Closing standard IO...\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
216 closeStandardIO (0, STD_INPUT_HANDLE, "STDIN"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
217 closeStandardIO (1, STD_OUTPUT_HANDLE, "STDOUT"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
218 closeStandardIO (2, STD_ERROR_HANDLE, "STDERR"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
219 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
220 #ifdef HIDDEN_CONSOLE |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
221 HWINSTA hOrigSta, hNewSta; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
222 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
223 // Create new (hidden) console |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
224 hOrigSta = GetProcessWindowStation (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
225 hNewSta = CreateWindowStation (NULL, 0, GENERIC_ALL, NULL); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
226 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
|
227 hNewSta); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
228 if (! SetProcessWindowStation (hNewSta)) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
229 log ("Failed to switch to new Windows station.\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
230 #endif |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
231 if (! AllocConsole ()) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
232 log ("Failed to create new console.\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
233 #ifdef HIDDEN_CONSOLE |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
234 if (! SetProcessWindowStation (hOrigSta)) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
235 log ("Failed to restore original Windows station.\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
236 if (! CloseWindowStation (hNewSta)) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
237 log ("Failed to close new Windows station.\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
238 #endif |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
239 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
240 log ("New (hidden) console created.\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
241 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
242 setupStandardIO (STD_INPUT_HANDLE, 0, "STDIN", "CONIN$"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
243 setupStandardIO (STD_OUTPUT_HANDLE, 1, "STDOUT", "CONOUT$"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
244 setupStandardIO (STD_ERROR_HANDLE, 2, "STDERR", "CONOUT$"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
245 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
246 log ("Standard input/output/error set up.\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
247 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
248 *stdin = *(fdopen (0, "rb")); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
249 *stdout = *(fdopen (1, "wb")); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
250 *stderr = *(fdopen (2, "wb")); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
251 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
252 log ("POSIX standard streams created.\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
253 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
254 setvbuf (stdin, NULL, _IONBF, 0); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
255 setvbuf (stdout, NULL, _IONBF, 0); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
256 setvbuf (stderr, NULL, _IONBF, 0); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
257 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
258 log ("POSIX standard stream buffers adjusted.\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
259 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
260 HANDLE hStdOut = GetStdHandle (STD_OUTPUT_HANDLE); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
261 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
262 log ("Console allocated: hStdOut: %p\n", hStdOut); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
263 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
264 m_stdOut = hStdOut; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
265 m_consoleWindow = GetConsoleWindow (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
266 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
267 // In case the console window hasn't been created hidden... |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
268 ShowWindow (m_consoleWindow, SW_HIDE); |
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 CONSOLE_SCREEN_BUFFER_INFO sbi; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
271 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
272 GetConsoleScreenBufferInfo (hStdOut, &sbi); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
273 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
|
274 m_consoleRect = QRect (sbi.srWindow.Left, sbi.srWindow.Top, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
275 sbi.srWindow.Right - sbi.srWindow.Left + 1, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
276 sbi.srWindow.Bottom - sbi.srWindow.Top + 1); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
277 m_cursorPos = QPoint (sbi.dwCursorPosition.X, sbi.dwCursorPosition.Y); |
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 log ("Initial console parameters:\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
280 log (" buffer size: %d x %d\n", m_bufferSize.width (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
281 m_bufferSize.height ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
282 log (" window: (%d, %d) -> (%d, %d) [%d x %d]\n", |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
283 m_consoleRect.left (), m_consoleRect.top (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
284 m_consoleRect.right (), m_consoleRect.bottom (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
285 m_consoleRect.width (), m_consoleRect.height ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
286 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
287 wchar_t titleBuf[260]; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
288 GetConsoleTitleW (titleBuf, sizeof (titleBuf)); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
289 q->setWindowTitle (QString::fromWCharArray (titleBuf)); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
290 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
291 m_font.setFamily ("Lucida Console"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
292 m_font.setPointSize (9); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
293 m_font.setStyleHint (QFont::TypeWriter); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
294 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
295 m_buffer = m_tmpBuffer = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
296 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
297 m_consoleView = new QConsoleView (parent); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
298 m_scrollBar = new QScrollBar (Qt::Vertical, parent); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
299 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
300 QHBoxLayout* l = new QHBoxLayout (parent); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
301 l->setContentsMargins (0, 0, 0, 0); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
302 l->setSpacing (0); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
303 l->addWidget (m_consoleView, 1); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
304 l->addWidget (m_scrollBar, 0); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
305 |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
306 // 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
|
307 // 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
|
308 // 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
|
309 // setForegroundColor, backgroundColor, and SetBackgroundColor |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
310 // functions. |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
311 |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
312 SetConsoleTextAttribute (m_stdOut, 0xF0); |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
313 |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
314 // Defaults. |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
315 setBackgroundColor (Qt::white); |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
316 setForegroundColor (Qt::black); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
317 setSelectionColor (Qt::lightGray); |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
318 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
|
319 |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
320 // 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
|
321 QPalette palette (backgroundColor ()); |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
322 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
|
323 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
324 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
|
325 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
326 m_consoleView->setFont (m_font); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
327 parent->setFocusPolicy (Qt::StrongFocus); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
328 parent->winId (); |
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 updateScrollBar (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
331 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
332 m_consoleWatcher = new QTimer (parent); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
333 m_consoleWatcher->setInterval (10); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
334 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
|
335 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
336 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
|
337 QObject::connect (m_blinkCursorTimer, SIGNAL (timeout()), |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
338 q, SLOT (blinkCursorEvent ())); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
339 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
340 QObject::connect (m_scrollBar, SIGNAL (valueChanged (int)), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
341 q, SLOT (scrollValueChanged (int))); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
342 QObject::connect (m_consoleWatcher, SIGNAL (timeout (void)), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
343 q, SLOT (monitorConsole (void))); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
344 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
345 m_consoleWatcher->start (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
346 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
347 if (m_command.isEmpty ()) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
348 m_consoleThread = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
349 else |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
350 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
351 m_consoleThread = new QConsoleThread (q); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
352 QObject::connect (m_consoleThread, SIGNAL (finished (void)), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
353 q, SIGNAL (terminated (void))); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
354 m_consoleThread->start (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
355 } |
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 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
358 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
359 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
360 QConsolePrivate::~QConsolePrivate (void) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
361 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
362 if (m_consoleThread && m_consoleThread->isRunning () && m_process) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
363 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
364 TerminateProcess (m_process, (UINT)-1); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
365 m_consoleThread->wait (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
366 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
367 if (m_buffer) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
368 delete [] m_buffer; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
369 if (m_tmpBuffer) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
370 delete [] m_tmpBuffer; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
371 } |
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 ////////////////////////////////////////////////////////////////////////////// |
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 void QConsolePrivate::setupStandardIO (DWORD stdHandleId, int targetFd, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
376 const char* name, const char* devName) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
377 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
378 log ("Opening %s...\n", devName); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
379 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
380 int fd = open (devName, _O_RDWR | _O_BINARY); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
381 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
382 if (fd != -1) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
383 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
384 if (fd != targetFd) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
385 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
386 log ("Opened %s is not at target file descriptor %d, " |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
387 "duplicating...\n", name, targetFd); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
388 if (dup2 (fd, targetFd) == -1) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
389 log ("Failed to duplicate file descriptor: errno=%d.\n", errno); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
390 if (close (fd) == -1) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
391 log ("Failed to close original file descriptor: errno=%d.\n", |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
392 errno); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
393 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
394 else |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
395 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
|
396 if (! SetStdHandle (stdHandleId, (HANDLE) _get_osfhandle (targetFd))) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
397 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
|
398 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
399 else |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
400 log ("Failed to open %s: errno=%d.\n", devName, errno); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
401 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
402 |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
403 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
|
404 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
405 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
|
406 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
|
407 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
408 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
409 QString QConsolePrivate::getSelection (void) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
410 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
411 QString selection; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
412 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
413 QPoint begin = m_beginSelection; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
414 QPoint end = m_endSelection; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
415 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
416 maybeSwapPoints (begin, end); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
417 |
16628
a66c285729a6
use swapped points when getting selection text in Windows terminal
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
418 if (begin != end) |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
419 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
420 CHAR_INFO* buf; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
421 COORD bufSize, bufCoord; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
422 SMALL_RECT bufRect; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
423 int nr; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
424 |
16628
a66c285729a6
use swapped points when getting selection text in Windows terminal
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
425 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
|
426 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
|
427 bufSize.X = m_bufferSize.width (); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
428 bufSize.Y = nr; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
429 bufCoord.X = 0; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
430 bufCoord.Y = 0; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
431 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
432 bufRect.Left = 0; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
433 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
|
434 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
|
435 bufRect.Bottom = end.y (); |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
436 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
437 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
|
438 { |
16628
a66c285729a6
use swapped points when getting selection text in Windows terminal
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
439 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
|
440 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
|
441 int lastNonSpace = -1; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
442 |
16628
a66c285729a6
use swapped points when getting selection text in Windows terminal
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
443 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
|
444 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
445 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
|
446 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
447 if (lastNonSpace >= 0) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
448 selection.truncate (lastNonSpace); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
449 selection.append ('\n'); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
450 lastNonSpace = selection.length (); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
451 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
452 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
453 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
|
454 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
455 selection.append (c); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
456 if (! c.isSpace ()) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
457 lastNonSpace = selection.length (); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
458 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
459 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
460 if (lastNonSpace >= 0) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
461 selection.truncate (lastNonSpace); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
462 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
463 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
464 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
465 return selection; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
466 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
467 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
468 void QConsolePrivate::updateSelection (void) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
469 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
470 QPoint begin = m_beginSelection; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
471 QPoint end = m_endSelection; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
472 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
473 maybeSwapPoints (begin, end); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
474 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
475 begin.rx () = 0; |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
476 end.rx () = m_consoleRect.width (); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
477 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
478 m_consoleView->update (); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
479 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
480 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
481 void QConsolePrivate::clearSelection (void) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
482 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
483 m_beginSelection = m_endSelection = QPoint (); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
484 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
485 m_consoleView->update (); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
486 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
487 |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
488 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
|
489 { |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
490 return m_colors[15]; |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
491 } |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
492 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
493 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
|
494 { |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
495 return m_colors[0]; |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
496 } |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
497 |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
498 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
|
499 { |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
500 return m_selectionColor; |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
501 } |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
502 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
503 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
|
504 { |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
505 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
|
506 } |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
507 |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
508 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
|
509 { |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
510 m_colors[15] = color; |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
511 } |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
512 |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
513 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
|
514 { |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
515 m_colors[0] = color; |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
516 } |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
517 |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
518 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
|
519 { |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
520 m_selectionColor = color; |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
521 } |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
522 |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
523 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
|
524 const QColor& color) |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
525 { |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
526 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
|
527 } |
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
528 |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
529 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
|
530 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
|
531 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
532 p.save (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
533 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
534 int ascent = p.fontMetrics ().ascent (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
535 int stride = m_consoleRect.width (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
536 int y = ascent + cy1 * ch;; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
537 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
538 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
|
539 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
540 int len = 0; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
541 bool hasChar = false; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
542 int x = cx1 * cw; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
543 WORD attr = 0; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
544 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
545 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
|
546 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
547 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
|
548 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
549 if ((ci->Attributes & 0x00ff) != attr) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
550 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
551 // Character attributes changed |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
552 if (len != 0) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
553 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
554 // String buffer not empty -> draw it |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
555 if (hasChar || (attr & 0x00f0)) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
556 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
557 if (attr & 0x00f0) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
558 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
|
559 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
560 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
561 x += (len * cw); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
562 len = 0; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
563 hasChar = false; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
564 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
565 // 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
|
566 attr = (ci->Attributes & 0x00ff); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
567 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
|
568 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
569 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
570 // 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
|
571 len++; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
572 if (ci->Char.UnicodeChar != L' ') |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
573 hasChar = true; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
574 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
575 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
576 if (len != 0 && (hasChar || (attr & 0x00f0))) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
577 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
578 // 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
|
579 // 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
|
580 // for-loop iteration |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
581 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
582 if (attr & 0x00f0) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
583 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
|
584 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
585 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
586 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
587 p.restore (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
588 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
589 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
590 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
|
591 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
|
592 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
593 p.save (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
594 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
595 QPoint begin = m_beginSelection; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
596 QPoint end = m_endSelection; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
597 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
598 bool haveSelection = (begin != end); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
599 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
600 if (haveSelection) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
601 maybeSwapPoints (begin, end); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
602 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
603 int scrollOffset = m_consoleRect.top (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
604 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
605 begin.ry () -= scrollOffset; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
606 end.ry () -= scrollOffset; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
607 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
608 int ascent = p.fontMetrics ().ascent (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
609 int stride = m_consoleRect.width (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
610 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
611 int y = ascent + cy1 * ch;; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
612 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
|
613 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
614 int charsThisLine = 0; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
615 int len = 0; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
616 bool hasChar = false; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
617 WORD attr = 0; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
618 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
619 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
|
620 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
621 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
|
622 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
623 if ((ci->Attributes & 0x00ff) != attr) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
624 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
625 // Character attributes changed |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
626 if (len != 0) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
627 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
628 charsThisLine += len; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
629 len = 0; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
630 hasChar = false; |
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 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
633 // Store current attributes |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
634 attr = (ci->Attributes & 0x00ff); |
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 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
637 // 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
|
638 len++; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
639 if (ci->Char.UnicodeChar != L' ') |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
640 hasChar = true; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
641 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
642 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
643 if (len != 0 && (hasChar || (attr & 0x00f0))) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
644 charsThisLine += len; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
645 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
646 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
|
647 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
648 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
|
649 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
650 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
|
651 ? end.x () - selectionBegin + 1 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
652 : stride - selectionBegin); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
653 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
654 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
|
655 selectionColor ()); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
656 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
657 } |
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 p.restore (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
660 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
661 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
662 void QConsolePrivate::drawCursor (QPainter& p) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
663 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
664 if (! m_cursorBlinking) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
665 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
666 p.save (); |
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 QRect rect = cursorRect (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
669 QColor color = cursorColor (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
670 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
671 p.setPen (color); |
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 if (m_cursorType == QConsolePrivate::BlockCursor) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
674 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
675 if (q->hasFocus ()) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
676 p.fillRect (rect, color); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
677 else |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
678 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
679 // 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
|
680 // it is draw entirely inside 'rect' |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
681 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
682 int penWidth = qMax (1, p.pen().width()); |
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 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
|
685 - penWidth/2 - penWidth%2, |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
686 - penWidth/2 - penWidth%2)); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
687 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
688 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
689 else if (m_cursorType == QConsolePrivate::UnderlineCursor) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
690 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
691 p.drawLine (rect.left (), rect.bottom (), |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
692 rect.right (), rect.bottom ()); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
693 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
694 else if (m_cursorType == QConsolePrivate::IBeamCursor) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
695 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
696 p.drawLine (rect.left (), rect.top (), |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
697 rect.left (), rect.bottom ()); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
698 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
699 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
700 p.restore (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
701 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
702 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
703 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
704 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
|
705 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
|
706 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
707 p.save (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
708 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
709 p.setFont (m_font); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
710 p.setPen (foregroundColor ()); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
711 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
712 QString s; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
713 s.reserve (cx2 - cx1 + 1); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
714 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
715 int ascent = p.fontMetrics ().ascent (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
716 int stride = m_consoleRect.width (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
717 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
718 int y = ascent + cy1 * ch;; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
719 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
|
720 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
721 // 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
|
722 s.clear (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
723 bool hasChar = false; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
724 int x = cx1 * cw; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
725 WORD attr = 0; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
726 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
727 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
|
728 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
729 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
|
730 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
731 if ((ci->Attributes & 0x00ff) != attr) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
732 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
733 // Character attributes changed |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
734 if (! s.isEmpty ()) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
735 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
736 // String buffer not empty -> draw it |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
737 if (hasChar || (attr & 0x00f0)) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
738 p.drawText (x, y, s); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
739 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
740 x += (s.length () * cw); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
741 s.clear (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
742 hasChar = false; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
743 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
744 // 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
|
745 attr = (ci->Attributes & 0x00ff); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
746 p.setPen (m_colors[attr & 0x000f]); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
747 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
748 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
749 // 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
|
750 s.append (ci->Char.UnicodeChar); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
751 if (ci->Char.UnicodeChar != L' ') |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
752 hasChar = true; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
753 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
754 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
755 if (! s.isEmpty () && (hasChar || (attr & 0x00f0))) |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
756 { |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
757 // 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
|
758 // 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
|
759 // for-loop iteration |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
760 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
761 p.drawText (x, y, s); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
762 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
763 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
764 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
765 p.restore (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
766 } |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
767 |
16618
13728d41fb6a
use functions to handle colors in Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16617
diff
changeset
|
768 ///////////////////////////////////////////////////////////////////////////// |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
769 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
770 void QConsolePrivate::closeStandardIO (int fd, DWORD stdHandleId, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
771 const char* name) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
772 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
773 if (close (fd) == -1) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
774 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
|
775 if (! CloseHandle (GetStdHandle (stdHandleId))) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
776 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
|
777 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
778 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
779 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
780 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
781 void QConsolePrivate::log (const char* fmt, ...) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
782 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
783 #ifdef DEBUG_QCONSOLE |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
784 if (fmt) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
785 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
786 va_list l; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
787 FILE* flog = fopen (LOGFILENAME, "ab"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
788 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
789 va_start (l, fmt); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
790 vfprintf (flog, fmt, l); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
791 va_end (l); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
792 fclose (flog); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
793 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
794 else |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
795 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
796 // Special case to re-initialize the log file |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
797 FILE* flog = fopen (LOGFILENAME, "w"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
798 fclose (flog); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
799 } |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
800 #else |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
801 Q_UNUSED (fmt); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
802 #endif |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
803 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
804 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
805 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
806 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
807 void QConsolePrivate::updateConsoleSize (bool sync) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
808 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
809 QFontMetrics fm (m_font); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
810 QSize winSize = m_consoleView->size (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
811 |
16617
3a17dd5964e3
use average width for character size in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16612
diff
changeset
|
812 m_charSize.rwidth () = fm.averageCharWidth (); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
813 m_charSize.rheight () = fm.lineSpacing (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
814 |
16617
3a17dd5964e3
use average width for character size in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16612
diff
changeset
|
815 m_consoleRect.setWidth (winSize.width () / fm.averageCharWidth ()); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
816 m_consoleRect.setHeight (winSize.height () / fm.lineSpacing ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
817 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
818 m_bufferSize.rwidth () = m_consoleRect.width (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
819 m_bufferSize.rheight () = qMax (m_bufferSize.height (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
820 m_consoleRect.height ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
821 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
822 m_consoleRect.moveLeft (0); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
823 if (m_consoleRect.bottom () >= m_bufferSize.height ()) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
824 m_consoleRect.moveTop (m_bufferSize.height () - m_consoleRect.height ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
825 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
826 log ("Console resized:\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
827 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
|
828 log (" buffer size: %d x %d\n", m_bufferSize.width (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
829 m_bufferSize.height ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
830 log (" window: (%d, %d) -> (%d, %d) [%d x %d]\n", |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
831 m_consoleRect.left (), m_consoleRect.top (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
832 m_consoleRect.right (), m_consoleRect.bottom (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
833 m_consoleRect.width (), m_consoleRect.height ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
834 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
835 if (sync) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
836 syncConsoleParameters (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
837 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
838 updateScrollBar (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
839 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
840 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
841 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
842 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
843 void QConsolePrivate::syncConsoleParameters (void) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
844 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
845 CONSOLE_SCREEN_BUFFER_INFO sbi; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
846 HANDLE hStdOut = m_stdOut; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
847 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
848 GetConsoleScreenBufferInfo (hStdOut, &sbi); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
849 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
850 COORD bs; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
851 SMALL_RECT sr; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
852 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
853 bs.X = sbi.dwSize.X; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
854 bs.Y = m_bufferSize.height (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
855 sr.Left = sbi.srWindow.Left; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
856 sr.Right = sbi.srWindow.Right; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
857 sr.Top = m_consoleRect.top (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
858 sr.Bottom = m_consoleRect.bottom (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
859 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
860 if (bs.Y > sbi.dwSize.Y) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
861 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
862 SetConsoleScreenBufferSize (hStdOut, bs); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
863 SetConsoleWindowInfo (hStdOut, TRUE, &sr); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
864 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
865 else |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
866 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
867 SetConsoleWindowInfo (hStdOut, TRUE, &sr); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
868 SetConsoleScreenBufferSize (hStdOut, bs); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
869 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
870 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
871 bs.X = m_bufferSize.width (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
872 sr.Left = m_consoleRect.left (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
873 sr.Right = m_consoleRect.right (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
874 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
875 if (bs.X > sbi.dwSize.X) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
876 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
877 SetConsoleScreenBufferSize (hStdOut, bs); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
878 SetConsoleWindowInfo (hStdOut, TRUE, &sr); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
879 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
880 else |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
881 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
882 SetConsoleWindowInfo (hStdOut, TRUE, &sr); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
883 SetConsoleScreenBufferSize (hStdOut, bs); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
884 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
885 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
886 log ("Sync'ing console parameters:\n"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
887 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
|
888 log (" window: (%d, %d) -> (%d, %d)\n", |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
889 sr.Left, sr.Top, sr.Right, sr.Bottom); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
890 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
891 if (m_buffer) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
892 delete [] m_buffer; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
893 if (m_tmpBuffer) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
894 delete [] m_tmpBuffer; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
895 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
896 int bufSize = m_consoleRect.width () * m_consoleRect.height (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
897 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
898 m_buffer = new CHAR_INFO[bufSize]; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
899 m_tmpBuffer = new CHAR_INFO[bufSize]; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
900 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
901 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
902 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
903 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
904 void QConsolePrivate::grabConsoleBuffer (CHAR_INFO* buf) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
905 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
906 COORD bs, bc; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
907 SMALL_RECT r; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
908 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
909 bs.X = m_consoleRect.width (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
910 bs.Y = m_consoleRect.height (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
911 bc.X = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
912 bc.Y = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
913 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
914 r.Left = m_consoleRect.left (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
915 r.Top = m_consoleRect.top (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
916 r.Right = m_consoleRect.right (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
917 r.Bottom = m_consoleRect.bottom (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
918 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
919 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
|
920 qCritical ("cannot read console output"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
921 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
922 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
923 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
924 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
925 void QConsolePrivate::updateScrollBar (void) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
926 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
927 m_scrollBar->setMinimum (0); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
928 if (m_bufferSize.height () > m_consoleRect.height ()) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
929 m_scrollBar->setMaximum (m_bufferSize.height () - m_consoleRect.height ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
930 else |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
931 m_scrollBar->setMaximum (0); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
932 m_scrollBar->setSingleStep (1); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
933 m_scrollBar->setPageStep (m_consoleRect.height ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
934 m_scrollBar->setValue (m_consoleRect.top ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
935 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
936 log ("Scrollbar parameters updated: %d/%d/%d/%d\n", |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
937 m_scrollBar->minimum (), m_scrollBar->maximum (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
938 m_scrollBar->singleStep (), m_scrollBar->pageStep ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
939 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
940 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
941 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
942 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
943 void QConsolePrivate::setScrollValue (int value) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
944 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
945 if (value == m_consoleRect.top ()) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
946 return; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
947 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
948 SMALL_RECT r; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
949 HANDLE hStdOut = m_stdOut; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
950 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
951 if (value + m_consoleRect.height () > m_bufferSize.height ()) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
952 value = m_bufferSize.height () - m_consoleRect.height (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
953 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
954 r.Left = m_consoleRect.left (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
955 r.Top = value; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
956 r.Right = m_consoleRect.right (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
957 r.Bottom = value + m_consoleRect.height () - 1; |
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 log ("Scrolling window: (%d, %d) -> (%d, %d) [%d x %d]\n", |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
960 r.Left, r.Top, r.Right, r.Bottom, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
961 r.Right - r.Left + 1, r.Bottom - r.Top + 1); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
962 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
963 if (SetConsoleWindowInfo (hStdOut, TRUE, &r)) |
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 m_consoleRect.moveTop (value); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
966 updateConsoleView (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
967 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
968 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
969 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
970 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
971 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
972 void QConsolePrivate::updateConsoleView (bool grab) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
973 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
974 if (grab) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
975 grabConsoleBuffer (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
976 m_consoleView->update (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
977 m_consoleWatcher->start (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
978 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
979 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
980 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
981 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
982 void QConsolePrivate::monitorConsole (void) |
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 CONSOLE_SCREEN_BUFFER_INFO sbi; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
985 HANDLE hStdOut = GetStdHandle (STD_OUTPUT_HANDLE); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
986 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
987 static wchar_t titleBuf[260]; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
988 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
989 GetConsoleTitleW (titleBuf, sizeof (titleBuf)); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
990 QString title = QString::fromWCharArray (titleBuf); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
991 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
992 if (title != m_title) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
993 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
994 q->setWindowTitle (title); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
995 emit q->titleChanged (title); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
996 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
997 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
998 if (GetConsoleScreenBufferInfo (hStdOut, &sbi)) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
999 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1000 if (m_bufferSize.width () != sbi.dwSize.X |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1001 || m_bufferSize.height () != sbi.dwSize.Y) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1002 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1003 // Buffer size changed |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1004 m_bufferSize.rwidth () = sbi.dwSize.X; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1005 m_bufferSize.rheight () = sbi.dwSize.Y; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1006 updateScrollBar (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1007 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1008 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1009 if (m_cursorPos.x () != sbi.dwCursorPosition.X |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1010 || m_cursorPos.y () != sbi.dwCursorPosition.Y) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1011 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1012 // Cursor position changed |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1013 m_consoleView->update |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1014 ((m_cursorPos.x () - sbi.srWindow.Left) * m_charSize.width (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1015 (m_cursorPos.y () - sbi.srWindow.Top) * m_charSize.height (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1016 m_charSize.width (), m_charSize.height ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1017 m_cursorPos.rx () = sbi.dwCursorPosition.X; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1018 m_cursorPos.ry () = sbi.dwCursorPosition.Y; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1019 m_consoleView->update |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1020 ((m_cursorPos.x () - sbi.srWindow.Left) * m_charSize.width (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1021 (m_cursorPos.y () - sbi.srWindow.Top) * m_charSize.height (), |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1022 m_charSize.width (), m_charSize.height ()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1023 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1024 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1025 if (m_consoleRect.left () != sbi.srWindow.Left |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1026 || m_consoleRect.right () != sbi.srWindow.Right |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1027 || m_consoleRect.top () != sbi.srWindow.Top |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1028 || m_consoleRect.bottom () != sbi.srWindow.Bottom) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1029 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1030 // Console window changed |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1031 m_consoleRect = QRect (sbi.srWindow.Left, sbi.srWindow.Top, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1032 sbi.srWindow.Right - sbi.srWindow.Left + 1, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1033 sbi.srWindow.Bottom - sbi.srWindow.Top + 1); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1034 updateScrollBar (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1035 updateConsoleView (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1036 return; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1037 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1038 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1039 if (m_tmpBuffer && m_buffer) |
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 grabConsoleBuffer (m_tmpBuffer); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1042 if (memcmp (m_tmpBuffer, m_buffer, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1043 sizeof (CHAR_INFO) * m_consoleRect.width () * |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1044 m_consoleRect.height ())) |
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 // FIXME: compute the area to update based on the |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1047 // difference between the 2 buffers. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1048 qSwap (m_buffer, m_tmpBuffer); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1049 updateConsoleView (false); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1050 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1051 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1052 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1053 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1054 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1055 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1056 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1057 void QConsolePrivate::startCommand (void) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1058 { |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1059 QString cmd = m_command; |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1060 |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1061 if (cmd.isEmpty ()) |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1062 cmd = qgetenv ("COMSPEC").constData (); |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1063 |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1064 if (! cmd.isEmpty ()) |
15651
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 STARTUPINFO si; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1067 PROCESS_INFORMATION pi; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1068 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1069 ZeroMemory (&si, sizeof (si)); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1070 si.cb = sizeof (si); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1071 ZeroMemory (&pi, sizeof (pi)); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1072 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1073 if (CreateProcessW (NULL, |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1074 (LPWSTR)cmd.unicode (), |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1075 NULL, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1076 NULL, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1077 TRUE, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1078 0, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1079 NULL, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1080 NULL, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1081 &si, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1082 &pi)) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1083 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1084 CloseHandle (pi.hThread); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1085 m_process = pi.hProcess; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1086 WaitForSingleObject (m_process, INFINITE); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1087 CloseHandle (m_process); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1088 m_process = NULL; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1089 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1090 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1091 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1092 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1093 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1094 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1095 void QConsolePrivate::sendConsoleText (const QString& s) |
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 // 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
|
1098 // translated into an equivalent keypress event. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1099 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1100 #define TEXT_CHUNK_SIZE 512 |
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 int len = s.length (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1103 INPUT_RECORD events[TEXT_CHUNK_SIZE]; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1104 DWORD nEvents = 0, written; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1105 HANDLE hStdIn = GetStdHandle (STD_INPUT_HANDLE); |
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 ZeroMemory (events, sizeof (events)); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1108 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1109 for (int i = 0; i < len; i++) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1110 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1111 QChar c = s.at (i); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1112 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1113 if (c == L'\r' || c == L'\n') |
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 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
|
1116 i++; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1117 if (nEvents) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1118 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1119 WriteConsoleInput (hStdIn, events, nEvents, &written); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1120 nEvents = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1121 ZeroMemory (events, sizeof (events)); |
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 PostMessage (m_consoleWindow, WM_KEYDOWN, VK_RETURN, 0x001C0001); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1124 PostMessage (m_consoleWindow, WM_KEYDOWN, VK_RETURN, 0xC01C0001); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1125 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1126 else |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1127 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1128 events[nEvents].EventType = KEY_EVENT; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1129 events[nEvents].Event.KeyEvent.bKeyDown = TRUE; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1130 events[nEvents].Event.KeyEvent.wRepeatCount = 1; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1131 events[nEvents].Event.KeyEvent.wVirtualKeyCode = |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1132 LOBYTE (VkKeyScan (c.unicode ())); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1133 events[nEvents].Event.KeyEvent.wVirtualScanCode = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1134 events[nEvents].Event.KeyEvent.uChar.UnicodeChar = c.unicode (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1135 events[nEvents].Event.KeyEvent.dwControlKeyState = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1136 nEvents++; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1137 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1138 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1139 if (nEvents == TEXT_CHUNK_SIZE |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1140 || (nEvents > 0 && i == (len - 1))) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1141 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1142 WriteConsoleInput (hStdIn, events, nEvents, &written); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1143 nEvents = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1144 ZeroMemory (events, sizeof (events)); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1145 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1146 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1147 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1148 |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1149 QRect |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1150 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
|
1151 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1152 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
|
1153 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
|
1154 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1155 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
|
1156 (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
|
1157 cw, ch); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1158 } |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1159 |
15651
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 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1162 QWinTerminalImpl::QWinTerminalImpl (QWidget* parent) |
16639
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16629
diff
changeset
|
1163 : QTerminal (parent), d (new QConsolePrivate (this)) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1164 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1165 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1166 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1167 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1168 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1169 QWinTerminalImpl::QWinTerminalImpl (const QString& cmd, QWidget* parent) |
16639
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16629
diff
changeset
|
1170 : QTerminal (parent), d (new QConsolePrivate (this, cmd)) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1171 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1172 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1173 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1174 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1175 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1176 QWinTerminalImpl::~QWinTerminalImpl (void) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1177 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1178 delete d; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1179 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1180 |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1181 void QWinTerminalImpl::mouseMoveEvent (QMouseEvent *event) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1182 { |
16647
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1183 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
|
1184 { |
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1185 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
|
1186 |
16647
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1187 updateSelection (); |
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1188 } |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1189 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1190 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1191 void QWinTerminalImpl::mousePressEvent (QMouseEvent *event) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1192 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1193 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
|
1194 { |
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1195 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
|
1196 |
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1197 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
|
1198 } |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1199 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1200 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1201 void QWinTerminalImpl::mouseReleaseEvent (QMouseEvent *event) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1202 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1203 if (event->button () == Qt::LeftButton) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1204 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1205 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
|
1206 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1207 updateSelection (); |
16647
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1208 |
d446e99f89f7
disallow setting selection with right mouse button in windows terminal
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
1209 d->m_settingSelection = false; |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1210 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1211 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1212 |
15651
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 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1215 void QWinTerminalImpl::viewResizeEvent (QConsoleView*, QResizeEvent*) |
15651
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 d->updateConsoleSize (true); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1218 d->grabConsoleBuffer (); |
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 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1221 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1222 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1223 void QWinTerminalImpl::viewPaintEvent (QConsoleView* w, QPaintEvent* event) |
15651
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 QPainter p (w); |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
1226 |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
1227 int cw = d->m_charSize.width (); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
1228 int ch = d->m_charSize.height (); |
15651
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 QRect updateRect = event->rect (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1231 |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
1232 int cx1 = updateRect.left () / cw; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
1233 int cy1 = updateRect.top () / ch; |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
1234 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
|
1235 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
|
1236 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1237 if (cx1 > d->m_consoleRect.width () - 1 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1238 || cy1 > d->m_consoleRect.height () - 1) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1239 return; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1240 |
16619
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
1241 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
|
1242 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
|
1243 d->drawCursor (p); |
db31d1e77d7b
split drawing apart to avoid XOR operation
John W. Eaton <jwe@octave.org>
parents:
16618
diff
changeset
|
1244 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
|
1245 } |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1246 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1247 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
|
1248 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1249 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
|
1250 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
|
1251 else |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1252 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
|
1253 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1254 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
|
1255 } |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1256 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1257 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
|
1258 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1259 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
|
1260 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1261 setBlinkingCursorState (blink); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1262 } |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1263 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1264 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
|
1265 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1266 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
|
1267 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
|
1268 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1269 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
|
1270 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1271 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
|
1272 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1273 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
|
1274 blinkCursorEvent (); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1275 } |
15651
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 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1278 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1279 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1280 void QWinTerminalImpl::wheelEvent (QWheelEvent* event) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1281 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1282 if (! d->m_inWheelEvent) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1283 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1284 // Forward to the scrollbar (avoid recursion) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1285 d->m_inWheelEvent = true; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1286 QApplication::sendEvent (d->m_scrollBar, event); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1287 d->m_inWheelEvent = false; |
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 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1290 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1291 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1292 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1293 bool QWinTerminalImpl::winEvent (MSG* msg, long* result) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1294 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1295 switch (msg->message) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1296 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1297 case WM_KEYDOWN: |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1298 case WM_KEYUP: |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1299 //case WM_CHAR: |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1300 // Forward Win32 message to the console window |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1301 PostMessage (d->m_consoleWindow, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1302 msg->message, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1303 msg->wParam, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1304 msg->lParam); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1305 result = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1306 return true; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1307 default: |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1308 return false; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1309 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1310 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1311 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1312 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1313 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1314 void QWinTerminalImpl::scrollValueChanged (int value) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1315 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1316 d->setScrollValue (value); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1317 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1318 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1319 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1320 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1321 void QWinTerminalImpl::monitorConsole (void) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1322 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1323 d->monitorConsole (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1324 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1325 |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1326 void QWinTerminalImpl::updateSelection (void) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1327 { |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1328 d->updateSelection (); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1329 } |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1330 |
15651
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 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1333 void QWinTerminalImpl::focusInEvent (QFocusEvent* event) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1334 { |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1335 setBlinkingCursorState (true); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1336 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1337 QWidget::focusInEvent (event); |
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 |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1340 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
|
1341 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1342 // 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
|
1343 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
|
1344 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1345 setBlinkingCursorState (false); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1346 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1347 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
|
1348 } |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1349 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1350 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
|
1351 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1352 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
|
1353 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1354 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
|
1355 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1356 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
|
1357 blinkCursorEvent (); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1358 } |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1359 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1360 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
|
1361 } |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1362 |
15651
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 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1365 void QWinTerminalImpl::start (void) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1366 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1367 d->startCommand (); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1368 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1369 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1370 ////////////////////////////////////////////////////////////////////////////// |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1371 |
15660
a6df0e2a082a
Corrections for windows code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15658
diff
changeset
|
1372 void QWinTerminalImpl::sendText (const QString& s) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1373 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1374 d->sendConsoleText (s); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1375 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1376 |
16608
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1377 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
|
1378 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1379 switch (type) |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1380 { |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1381 case UnderlineCursor: |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1382 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
|
1383 break; |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1384 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1385 case BlockCursor: |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1386 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
|
1387 break; |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1388 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1389 case IBeamCursor: |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1390 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
|
1391 break; |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1392 } |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1393 |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1394 setBlinkingCursor (blinking); |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1395 } |
739d7eb97b85
make blinking cursor and different cursor styles for Windows GUI terminal
John W. Eaton <jwe@octave.org>
parents:
16513
diff
changeset
|
1396 |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1397 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
|
1398 { |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1399 d->setBackgroundColor (color); |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1400 } |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1401 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1402 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
|
1403 { |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1404 d->setForegroundColor (color); |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1405 } |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1406 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1407 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
|
1408 { |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1409 d->setSelectionColor (color); |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1410 } |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1411 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1412 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
|
1413 const QColor& color) |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1414 { |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1415 d->setCursorColor (useForegroundColor, color); |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1416 } |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16619
diff
changeset
|
1417 |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1418 ////////////////////////////////////////////////////////////////////////////// |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1419 |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1420 void QWinTerminalImpl::setTerminalFont (const QFont& f) |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1421 { |
15666
20299b92a64e
Added patch that allows for changing the terminal font.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15665
diff
changeset
|
1422 d->m_font = f; |
20299b92a64e
Added patch that allows for changing the terminal font.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15665
diff
changeset
|
1423 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
|
1424 d->updateConsoleSize (true); |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1425 } |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1426 |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1427 ////////////////////////////////////////////////////////////////////////////// |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1428 |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1429 void QWinTerminalImpl::setSize (int columns, int lines) |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1430 { |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1431 Q_UNUSED (columns); |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1432 Q_UNUSED (lines); |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1433 } |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1434 |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1435 ////////////////////////////////////////////////////////////////////////////// |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1436 |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1437 void QWinTerminalImpl::copyClipboard (void) |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1438 { |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1439 QClipboard *clipboard = QApplication::clipboard (); |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1440 |
16648
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
1441 QString selection = d->getSelection (); |
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
1442 |
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
1443 if (selection.isEmpty ()) |
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
1444 { |
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
1445 ::raise (SIGINT); |
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
1446 } |
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
1447 else |
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
1448 { |
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
1449 clipboard->setText (selection); |
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
1450 |
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16647
diff
changeset
|
1451 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
|
1452 } |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1453 } |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1454 |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1455 ////////////////////////////////////////////////////////////////////////////// |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1456 |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1457 void QWinTerminalImpl::pasteClipboard (void) |
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1458 { |
16612
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1459 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
|
1460 |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1461 if (! text.isEmpty ()) |
dae674adf045
handle text selection in GUI terminal for Windows
John W. Eaton <jwe@octave.org>
parents:
16608
diff
changeset
|
1462 sendText (text); |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15660
diff
changeset
|
1463 } |