Mercurial > octave-nkf
annotate gui/src/TerminalView.cpp @ 13674:c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Sun, 25 Sep 2011 10:52:42 +0200 |
parents | 9b74f97919e1 |
children | c0e0625ffd13 |
rev | line source |
---|---|
13504
13e3d60aff2d
Replaced Quint with OctaveGUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13501
diff
changeset
|
1 /* OctaveGUI - A graphical user interface for Octave |
13674
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13667
diff
changeset
|
2 * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) |
13501 | 3 * |
4 * This program is free software: you can redistribute it and/or modify | |
13674
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13667
diff
changeset
|
5 * it under the terms of the GNU Affero General Public License as |
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13667
diff
changeset
|
6 * published by the Free Software Foundation, either version 3 of the |
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13667
diff
changeset
|
7 * License, or (at your option) any later version. |
13501 | 8 * |
9 * This program is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13674
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13667
diff
changeset
|
12 * GNU Affero General Public License for more details. |
13501 | 13 * |
13674
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13667
diff
changeset
|
14 * You should have received a copy of the GNU Affero General Public License |
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13667
diff
changeset
|
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
13501 | 16 */ |
17 | |
13665
ddc3c20d0e2f
Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13663
diff
changeset
|
18 #include "TerminalHighlighter.h" |
13648
da69cec2459f
Renamed OctaveTerminal to TerminalView.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13640
diff
changeset
|
19 #include "TerminalView.h" |
13501 | 20 #include <QHBoxLayout> |
21 #include <QVBoxLayout> | |
22 #include <QStringListModel> | |
23 #include <QStringList> | |
13628
aa54bdaee8c8
Partially resotred receiving data.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13626
diff
changeset
|
24 #include <QScrollBar> |
13501 | 25 |
13648
da69cec2459f
Renamed OctaveTerminal to TerminalView.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13640
diff
changeset
|
26 TerminalView::TerminalView (QWidget * parent) |
13640
bad5cb3cfe20
Cleanly separated terminal emulation code with an interface for platform-dependent terminals.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13637
diff
changeset
|
27 : QPlainTextEdit (parent), Terminal () |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
28 { |
13665
ddc3c20d0e2f
Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13663
diff
changeset
|
29 setFont (QFont ("Monospace", 10)); |
13663
746c99f44c4b
Now using a terminal font.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13648
diff
changeset
|
30 setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding); |
746c99f44c4b
Now using a terminal font.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13648
diff
changeset
|
31 m_terminalEmulation = TerminalEmulation::newTerminalEmulation (this); |
13665
ddc3c20d0e2f
Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13663
diff
changeset
|
32 |
ddc3c20d0e2f
Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13663
diff
changeset
|
33 TerminalHighlighter *terminalHighlighter = new TerminalHighlighter (); |
ddc3c20d0e2f
Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13663
diff
changeset
|
34 terminalHighlighter->setDocument (document ()); |
13501 | 35 } |
36 | |
13648
da69cec2459f
Renamed OctaveTerminal to TerminalView.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13640
diff
changeset
|
37 TerminalView::~TerminalView () |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
38 { |
13501 | 39 } |
40 | |
13640
bad5cb3cfe20
Cleanly separated terminal emulation code with an interface for platform-dependent terminals.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13637
diff
changeset
|
41 QTextCursor |
13648
da69cec2459f
Renamed OctaveTerminal to TerminalView.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13640
diff
changeset
|
42 TerminalView::textCursor () |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
43 { |
13640
bad5cb3cfe20
Cleanly separated terminal emulation code with an interface for platform-dependent terminals.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13637
diff
changeset
|
44 return QPlainTextEdit::textCursor(); |
13501 | 45 } |
13517
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13515
diff
changeset
|
46 |
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13515
diff
changeset
|
47 void |
13648
da69cec2459f
Renamed OctaveTerminal to TerminalView.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13640
diff
changeset
|
48 TerminalView::setTextCursor (const QTextCursor &cursor) |
13517
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13515
diff
changeset
|
49 { |
13640
bad5cb3cfe20
Cleanly separated terminal emulation code with an interface for platform-dependent terminals.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13637
diff
changeset
|
50 QPlainTextEdit::setTextCursor (cursor); |
bad5cb3cfe20
Cleanly separated terminal emulation code with an interface for platform-dependent terminals.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13637
diff
changeset
|
51 } |
13517
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13515
diff
changeset
|
52 |
13640
bad5cb3cfe20
Cleanly separated terminal emulation code with an interface for platform-dependent terminals.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13637
diff
changeset
|
53 void |
13648
da69cec2459f
Renamed OctaveTerminal to TerminalView.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13640
diff
changeset
|
54 TerminalView::bell () |
13640
bad5cb3cfe20
Cleanly separated terminal emulation code with an interface for platform-dependent terminals.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13637
diff
changeset
|
55 { |
bad5cb3cfe20
Cleanly separated terminal emulation code with an interface for platform-dependent terminals.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13637
diff
changeset
|
56 |
13517
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13515
diff
changeset
|
57 } |
13626
cc90c62ada21
Removed terminal, instead now using QPlainTextEdit, which looks much nicer and is not that error-prone...
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13620
diff
changeset
|
58 |
cc90c62ada21
Removed terminal, instead now using QPlainTextEdit, which looks much nicer and is not that error-prone...
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13620
diff
changeset
|
59 void |
13648
da69cec2459f
Renamed OctaveTerminal to TerminalView.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13640
diff
changeset
|
60 TerminalView::keyPressEvent (QKeyEvent * keyEvent) |
13626
cc90c62ada21
Removed terminal, instead now using QPlainTextEdit, which looks much nicer and is not that error-prone...
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13620
diff
changeset
|
61 { |
13640
bad5cb3cfe20
Cleanly separated terminal emulation code with an interface for platform-dependent terminals.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13637
diff
changeset
|
62 m_terminalEmulation->processKeyEvent (keyEvent); |
13626
cc90c62ada21
Removed terminal, instead now using QPlainTextEdit, which looks much nicer and is not that error-prone...
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13620
diff
changeset
|
63 } |
13666
68c50b393f1d
Improved highlighting and incremented version.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13665
diff
changeset
|
64 |
68c50b393f1d
Improved highlighting and incremented version.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13665
diff
changeset
|
65 void |
68c50b393f1d
Improved highlighting and incremented version.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13665
diff
changeset
|
66 TerminalView::mousePressEvent (QMouseEvent *mouseEvent) |
68c50b393f1d
Improved highlighting and incremented version.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13665
diff
changeset
|
67 { |
68c50b393f1d
Improved highlighting and incremented version.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13665
diff
changeset
|
68 // TODO: Pass mouse events to the terminal emulation. |
68c50b393f1d
Improved highlighting and incremented version.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13665
diff
changeset
|
69 mouseEvent->accept(); |
68c50b393f1d
Improved highlighting and incremented version.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13665
diff
changeset
|
70 } |
13667
9b74f97919e1
Fixed KPtyDevice.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13666
diff
changeset
|
71 |
9b74f97919e1
Fixed KPtyDevice.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13666
diff
changeset
|
72 void |
9b74f97919e1
Fixed KPtyDevice.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13666
diff
changeset
|
73 TerminalView::mouseDoubleClickEvent (QMouseEvent *mouseEvent) |
9b74f97919e1
Fixed KPtyDevice.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13666
diff
changeset
|
74 { |
9b74f97919e1
Fixed KPtyDevice.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13666
diff
changeset
|
75 // TODO: Pass mouse events to the terminal emulation. |
9b74f97919e1
Fixed KPtyDevice.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13666
diff
changeset
|
76 mouseEvent->accept(); |
9b74f97919e1
Fixed KPtyDevice.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13666
diff
changeset
|
77 } |
9b74f97919e1
Fixed KPtyDevice.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13666
diff
changeset
|
78 |
9b74f97919e1
Fixed KPtyDevice.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13666
diff
changeset
|
79 void |
9b74f97919e1
Fixed KPtyDevice.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13666
diff
changeset
|
80 TerminalView::wheelEvent (QWheelEvent *wheelEvent) |
9b74f97919e1
Fixed KPtyDevice.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13666
diff
changeset
|
81 { |
9b74f97919e1
Fixed KPtyDevice.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13666
diff
changeset
|
82 // TODO: Pass mouse events to the terminal emulation. |
9b74f97919e1
Fixed KPtyDevice.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13666
diff
changeset
|
83 wheelEvent->accept(); |
9b74f97919e1
Fixed KPtyDevice.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13666
diff
changeset
|
84 } |