Mercurial > hg > octave-nkf
annotate libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp @ 19898:4197fc428c7d
maint: Update copyright notices for 2015.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 11 Feb 2015 14:19:08 -0500 |
parents | bd1369a2a651 |
children |
rev | line source |
---|---|
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1 /* Copyright (C) 2008 e_k (e_k@users.sourceforge.net) |
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19891
diff
changeset
|
2 Copyright (C) 2012-2015 Jacob Dawid <jacob.dawid@cybercatalyst.com> |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
3 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
4 This library is free software; you can redistribute it and/or |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
5 modify it under the terms of the GNU Library General Public |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
6 License as published by the Free Software Foundation; either |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
7 version 2 of the License, or (at your option) any later version. |
15659 | 8 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
9 This library is distributed in the hope that it will be useful, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
12 Library General Public License for more details. |
15659 | 13 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
14 You should have received a copy of the GNU Library General Public License |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
15 along with this library; see the file COPYING.LIB. If not, write to |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
17 Boston, MA 02110-1301, USA. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
18 */ |
15659 | 19 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
20 #include <QDebug> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
21 |
15653
35c891dce299
Removed INCLUDEPATH.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15652
diff
changeset
|
22 #include "unix/QUnixTerminalImpl.h" |
35c891dce299
Removed INCLUDEPATH.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15652
diff
changeset
|
23 #include "unix/kpty.h" |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
24 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
25 #include <termios.h> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
26 |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15656
diff
changeset
|
27 QUnixTerminalImpl::QUnixTerminalImpl(QWidget *parent) |
16639
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
28 : QTerminal(parent) { |
15862
98902367c781
gui: smaller minimal size of the command widget (bug #37038)
Torsten <ttl@justmail.de>
parents:
15681
diff
changeset
|
29 setMinimumSize(300, 200); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
30 initialize(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
31 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
32 |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15656
diff
changeset
|
33 void QUnixTerminalImpl::initialize() |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
34 { |
15659 | 35 m_terminalView = new TerminalView(this); |
15674
2318531b7880
Changed cursor to underline cursor.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15669
diff
changeset
|
36 m_terminalView->setKeyboardCursorShape(TerminalView::UnderlineCursor); |
15675
22bd268429d3
Cursor is now blinking in the terminal.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15674
diff
changeset
|
37 m_terminalView->setBlinkingCursor(true); |
15659 | 38 m_terminalView->setBellMode(TerminalView::NotifyBell); |
39 m_terminalView->setTerminalSizeHint(true); | |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15662
diff
changeset
|
40 m_terminalView->setContextMenuPolicy(Qt::CustomContextMenu); |
15659 | 41 m_terminalView->setTripleClickMode(TerminalView::SelectWholeLine); |
42 m_terminalView->setTerminalSizeStartup(true); | |
43 m_terminalView->setSize(80, 40); | |
44 m_terminalView->setScrollBarPosition(TerminalView::ScrollBarRight); | |
45 | |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15662
diff
changeset
|
46 connect(m_terminalView, SIGNAL(customContextMenuRequested(QPoint)), |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15662
diff
changeset
|
47 this, SLOT(handleCustomContextMenuRequested(QPoint))); |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15662
diff
changeset
|
48 |
17920
5c3f22dd0bbb
raise SIGINT in octave_interpreter instead of in QTerminal
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
49 connect (m_terminalView, SIGNAL (interrupt_signal (void)), |
5c3f22dd0bbb
raise SIGINT in octave_interpreter instead of in QTerminal
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
50 this, SLOT (terminal_interrupt ())); |
5c3f22dd0bbb
raise SIGINT in octave_interpreter instead of in QTerminal
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
51 |
15659 | 52 #ifdef Q_OS_MAC |
53 QFont font = QFont("Monaco"); | |
54 font.setStyleHint(QFont::TypeWriter); | |
55 font.setPointSize(11); | |
56 #else | |
57 QFont font = QFont("Monospace"); | |
58 font.setStyleHint(QFont::TypeWriter); | |
59 font.setPointSize(10); | |
60 #endif | |
61 setTerminalFont(font); | |
18499
155d8e90ee1f
improve focus of terminal widget (partial fix of bug #40823)
Torsten <ttl@justmail.de>
parents:
17920
diff
changeset
|
62 setFocusPolicy (Qt::StrongFocus); |
15659 | 63 setFocusProxy(m_terminalView); |
64 setFocus(Qt::OtherFocusReason); | |
65 | |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
66 m_kpty = new KPty(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
67 m_kpty->open(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
68 |
15659 | 69 m_terminalModel = new TerminalModel(m_kpty); |
70 m_terminalModel->setAutoClose(true); | |
71 m_terminalModel->setCodec(QTextCodec::codecForName("UTF-8")); | |
18758
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18640
diff
changeset
|
72 m_terminalModel->setHistoryType(HistoryTypeBuffer (1000)); |
15659 | 73 m_terminalModel->setDarkBackground(true); |
74 m_terminalModel->setKeyBindings(""); | |
75 m_terminalModel->run(); | |
76 m_terminalModel->addView(m_terminalView); | |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
77 connectToPty(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
78 } |
18758
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18640
diff
changeset
|
79 void QUnixTerminalImpl::setScrollBufferSize(int value) |
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18640
diff
changeset
|
80 { |
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18640
diff
changeset
|
81 if (value > 0) |
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18640
diff
changeset
|
82 { |
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18640
diff
changeset
|
83 m_terminalModel->clearHistory (); |
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18640
diff
changeset
|
84 m_terminalModel->setHistoryType (HistoryTypeBuffer ( value )); |
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18640
diff
changeset
|
85 } |
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18640
diff
changeset
|
86 else |
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18640
diff
changeset
|
87 m_terminalModel->setHistoryType (HistoryTypeNone ()); |
6e81b59d657c
Add preference for terminal windows buffer size (bug #41474)
Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
parents:
18640
diff
changeset
|
88 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
89 |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15656
diff
changeset
|
90 void QUnixTerminalImpl::connectToPty() |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
91 { |
16484
fa842e78f491
Restore STDERR stream pipe before exit to capture error messages.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15862
diff
changeset
|
92 // Store the file descriptor associated with the STDERR stream onto |
fa842e78f491
Restore STDERR stream pipe before exit to capture error messages.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15862
diff
changeset
|
93 // another temporary file descriptor for reconnect in the destructor. |
fa842e78f491
Restore STDERR stream pipe before exit to capture error messages.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15862
diff
changeset
|
94 fdstderr = dup (STDERR_FILENO); |
fa842e78f491
Restore STDERR stream pipe before exit to capture error messages.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15862
diff
changeset
|
95 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
96 int fds = m_kpty->slaveFd(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
97 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
98 dup2 (fds, STDIN_FILENO); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
99 dup2 (fds, STDOUT_FILENO); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
100 dup2 (fds, STDERR_FILENO); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
101 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
102 if(!isatty(STDIN_FILENO)) { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
103 qDebug("Error: stdin is not a tty."); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
104 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
105 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
106 if(!isatty(STDOUT_FILENO)) { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
107 qDebug("Error: stdout is not a tty."); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
108 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
109 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
110 if(!isatty(STDERR_FILENO)) { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
111 qDebug("Error: stderr is not a tty."); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
112 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
113 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
114 |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15656
diff
changeset
|
115 QUnixTerminalImpl::~QUnixTerminalImpl() |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
116 { |
16484
fa842e78f491
Restore STDERR stream pipe before exit to capture error messages.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15862
diff
changeset
|
117 // Restore stderr so that any errors at exit might appear somewhere. |
fa842e78f491
Restore STDERR stream pipe before exit to capture error messages.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15862
diff
changeset
|
118 dup2 (fdstderr, STDERR_FILENO); |
fa842e78f491
Restore STDERR stream pipe before exit to capture error messages.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
15862
diff
changeset
|
119 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
120 emit destroyed(); |
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 |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15659
diff
changeset
|
123 void QUnixTerminalImpl::setTerminalFont(const QFont &font) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
124 { |
15659 | 125 if(!m_terminalView) |
126 return; | |
127 m_terminalView->setVTFont(font); | |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
128 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
129 |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15656
diff
changeset
|
130 void QUnixTerminalImpl::setSize(int h, int v) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
131 { |
15659 | 132 if(!m_terminalView) |
133 return; | |
134 m_terminalView->setSize(h, v); | |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
135 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
136 |
15662
5758e0013246
Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15659
diff
changeset
|
137 void QUnixTerminalImpl::sendText(const QString& text) |
15656
c05926c0657d
Added sendText method again.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
138 { |
15659 | 139 m_terminalModel->sendText(text); |
15656
c05926c0657d
Added sendText method again.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
140 } |
c05926c0657d
Added sendText method again.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
141 |
15677
f620ecde2566
Added support for changing the cursor.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15675
diff
changeset
|
142 void QUnixTerminalImpl::setCursorType(CursorType type, bool blinking) |
f620ecde2566
Added support for changing the cursor.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15675
diff
changeset
|
143 { |
f620ecde2566
Added support for changing the cursor.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15675
diff
changeset
|
144 switch(type) { |
15680
6b1369106141
Fix error in setting the terminal cursor shape
Mike Miller <mtmiller@ieee.org>
parents:
15677
diff
changeset
|
145 case UnderlineCursor: m_terminalView->setKeyboardCursorShape(TerminalView::UnderlineCursor); break; |
6b1369106141
Fix error in setting the terminal cursor shape
Mike Miller <mtmiller@ieee.org>
parents:
15677
diff
changeset
|
146 case BlockCursor: m_terminalView->setKeyboardCursorShape(TerminalView::BlockCursor); break; |
6b1369106141
Fix error in setting the terminal cursor shape
Mike Miller <mtmiller@ieee.org>
parents:
15677
diff
changeset
|
147 case IBeamCursor: m_terminalView->setKeyboardCursorShape(TerminalView::IBeamCursor); break; |
15677
f620ecde2566
Added support for changing the cursor.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15675
diff
changeset
|
148 } |
f620ecde2566
Added support for changing the cursor.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15675
diff
changeset
|
149 m_terminalView->setBlinkingCursor(blinking); |
f620ecde2566
Added support for changing the cursor.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15675
diff
changeset
|
150 } |
f620ecde2566
Added support for changing the cursor.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15675
diff
changeset
|
151 |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16609
diff
changeset
|
152 // FIXME -- not sure how to make these work properly given the way the |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16609
diff
changeset
|
153 // Unix terminal handles colors. |
19790
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18499
diff
changeset
|
154 void QUnixTerminalImpl::setBackgroundColor (const QColor& color) |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18499
diff
changeset
|
155 { |
16688
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
156 ColorEntry cols[TABLE_COLORS]; |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
157 |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
158 const ColorEntry * curr_cols = m_terminalView->colorTable(); |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
159 for(int i=0;i<TABLE_COLORS;i++) |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
160 { |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
161 cols[i] = curr_cols[i]; |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
162 } |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
163 |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
164 cols[DEFAULT_BACK_COLOR].color = color; |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
165 |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
166 m_terminalView->setColorTable(cols); |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
167 |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
168 } |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
169 void QUnixTerminalImpl::setForegroundColor (const QColor& color) |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
170 { |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
171 ColorEntry cols[TABLE_COLORS]; |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
172 |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
173 const ColorEntry * curr_cols = m_terminalView->colorTable(); |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
174 for(int i=0;i<TABLE_COLORS;i++) |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
175 { |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
176 cols[i] = curr_cols[i]; |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
177 } |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
178 |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
179 cols[DEFAULT_FORE_COLOR].color = color; |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
180 |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
181 m_terminalView->setColorTable(cols); |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
182 |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
183 |
c19cc8c158b3
Allow setting background/forground terminal colors in Unix (bug #39016)
John Donoghue <john.donoghue@ieee.org>
parents:
16639
diff
changeset
|
184 } |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16609
diff
changeset
|
185 void QUnixTerminalImpl::setSelectionColor (const QColor& color) { } |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16609
diff
changeset
|
186 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16609
diff
changeset
|
187 void QUnixTerminalImpl::setCursorColor (bool useForegroundColor, |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16609
diff
changeset
|
188 const QColor& color) |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16609
diff
changeset
|
189 { |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16609
diff
changeset
|
190 m_terminalView->setKeyboardCursorColor (useForegroundColor, color); |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16609
diff
changeset
|
191 } |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16609
diff
changeset
|
192 |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15656
diff
changeset
|
193 void QUnixTerminalImpl::showEvent(QShowEvent *) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
194 { |
15659 | 195 m_terminalView->updateImage(); |
196 m_terminalView->repaint(); | |
197 m_terminalView->update(); | |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
198 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
199 |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15656
diff
changeset
|
200 void QUnixTerminalImpl::resizeEvent(QResizeEvent*) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
201 { |
15659 | 202 m_terminalView->resize(this->size()); |
203 m_terminalView->updateImage(); | |
204 m_terminalView->repaint(); | |
205 m_terminalView->update(); | |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
206 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
207 |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15656
diff
changeset
|
208 void QUnixTerminalImpl::copyClipboard() |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
209 { |
19891
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
19793
diff
changeset
|
210 m_terminalView->copyClipboard (_extra_interrupt); |
15651
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 |
15658
eaa7da75d202
Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15656
diff
changeset
|
213 void QUnixTerminalImpl::pasteClipboard() |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
214 { |
15659 | 215 m_terminalView->pasteClipboard(); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
216 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
217 |
18640
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18499
diff
changeset
|
218 void QUnixTerminalImpl::selectAll() |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18499
diff
changeset
|
219 { |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18499
diff
changeset
|
220 m_terminalView->selectAll(); |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18499
diff
changeset
|
221 } |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18499
diff
changeset
|
222 |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18499
diff
changeset
|
223 |
16794
1d1f02e0f6b4
GUI: enable clipboard content detection for terminal window context menu
John Donoghue <john.donoghue@ieee.org>
parents:
16688
diff
changeset
|
224 QString QUnixTerminalImpl::selectedText () |
1d1f02e0f6b4
GUI: enable clipboard content detection for terminal window context menu
John Donoghue <john.donoghue@ieee.org>
parents:
16688
diff
changeset
|
225 { |
1d1f02e0f6b4
GUI: enable clipboard content detection for terminal window context menu
John Donoghue <john.donoghue@ieee.org>
parents:
16688
diff
changeset
|
226 return m_terminalView->selectedText (); |
1d1f02e0f6b4
GUI: enable clipboard content detection for terminal window context menu
John Donoghue <john.donoghue@ieee.org>
parents:
16688
diff
changeset
|
227 } |
19891
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
19793
diff
changeset
|
228 |
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
19793
diff
changeset
|
229 void |
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
19793
diff
changeset
|
230 QUnixTerminalImpl::has_extra_interrupt (bool extra) |
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
19793
diff
changeset
|
231 { |
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
19793
diff
changeset
|
232 _extra_interrupt = extra; |
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
19793
diff
changeset
|
233 } |