Mercurial > hg > octave-lojdl
changeset 14244:7ede35410aa5 gui
GUI: Build in previous terminal widget.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Sun, 22 Jan 2012 16:06:55 +0100 |
parents | b871a65c5681 |
children | 8e92abfa60d5 |
files | gui/octave-gui/octave-gui.pro gui/octave-gui/src/FileEditorMdiSubWindow.cpp gui/octave-gui/src/FileEditorMdiSubWindow.h gui/octave-gui/src/MainWindow.cpp gui/octave-gui/src/MainWindow.h gui/octave-gui/src/TerminalWidget.cpp gui/octave-gui/src/TerminalWidget.h |
diffstat | 7 files changed, 90 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/octave-gui/octave-gui.pro +++ b/gui/octave-gui/octave-gui.pro @@ -98,16 +98,10 @@ src/irc/IRCClientImpl.cpp \ src/backend/ReadlineAdapter.cpp \ src/WelcomeWizard.cpp \ - src/AbstractTerminalView.cpp + src/TerminalWidget.cpp unix { -SOURCES +=\ - src/TerminalHighlighter.cpp \ - src/TerminalView.cpp \ - src/terminal/KPty.cpp \ - src/terminal/KPtyDevice.cpp \ - src/terminal/LinuxTerminalEmulation.cpp \ - src/terminal/TerminalEmulation.cpp +SOURCES += } win32 { @@ -137,16 +131,10 @@ src/irc/IRCClientImpl.h \ src/backend/ReadlineAdapter.h \ src/WelcomeWizard.h \ - src/AbstractTerminalView.h + src/TerminalWidget.h unix { -HEADERS += \ - src/TerminalHighlighter.h \ - src/TerminalView.h \ - src/terminal/KPtyDevice.h \ - src/terminal/KPty.h \ - src/terminal/LinuxTerminalEmulation.h \ - src/terminal/TerminalEmulation.h +HEADERS += } win32 {
--- a/gui/octave-gui/src/FileEditorMdiSubWindow.cpp +++ b/gui/octave-gui/src/FileEditorMdiSubWindow.cpp @@ -251,7 +251,8 @@ { if (m_editor->isModified ()) saveFile(m_fileName); - m_terminalView->sendText (QString ("run \'%1\'\n").arg (m_fileName)); + QString text = QString ("run \'%1\'\n").arg (m_fileName); + m_terminalView->sendText (text); //m_terminalView->widget ()->setFocus (); } @@ -338,7 +339,7 @@ // function for setting the already existing lexer from MainWindow void -FileEditorMdiSubWindow::initEditor (AbstractTerminalView* terminalView, +FileEditorMdiSubWindow::initEditor (TerminalWidget* terminalView, LexerOctaveGui* lexer, MainWindow* mainWindow) {
--- a/gui/octave-gui/src/FileEditorMdiSubWindow.h +++ b/gui/octave-gui/src/FileEditorMdiSubWindow.h @@ -19,7 +19,7 @@ #define FILEEDITORMDISUBWINDOW_H #include "MainWindow.h" -#include "AbstractTerminalView.h" +#include "TerminalWidget.h" #include <QMdiSubWindow> #include <QToolBar> #include <QAction> @@ -45,7 +45,7 @@ FileEditorMdiSubWindow (QWidget * parent = 0); ~FileEditorMdiSubWindow (); void loadFile (QString fileName); - void initEditor (AbstractTerminalView *terminalView, + void initEditor (TerminalWidget *terminalView, LexerOctaveGui *lexer, MainWindow *mainWindow); @@ -78,7 +78,7 @@ QStatusBar *m_statusBar; QString m_fileName; QString m_fileNameShort; - AbstractTerminalView* m_terminalView; + TerminalWidget* m_terminalView; QAction* m_copyAction; QAction* m_cutAction; MainWindow* m_mainWindow;
--- a/gui/octave-gui/src/MainWindow.cpp +++ b/gui/octave-gui/src/MainWindow.cpp @@ -27,10 +27,6 @@ #include "ImageViewerMdiSubWindow.h" #include "SettingsDialog.h" -#ifdef Q_OS_UNIX -# include "qtermwidget.h" -#endif - #define VERSION_STRING "Octave GUI (0.8.5)" MainWindow::MainWindow (QWidget * parent):QMainWindow (parent) @@ -129,8 +125,9 @@ QString selectedFile = QFileDialog::getSaveFileName (this, tr ("Save Workspace"), ResourceManager::instance ()->homePath ()); - m_terminalView->sendText (QString ("save \'%1\'\n").arg (selectedFile)); - m_terminalView->widget ()->setFocus (); + QString text = QString ("save \'%1\'\n").arg (selectedFile); + m_terminalView->sendText (text); + m_terminalView->setFocus (); } void @@ -139,22 +136,24 @@ QString selectedFile = QFileDialog::getOpenFileName (this, tr ("Load Workspace"), ResourceManager::instance ()->homePath ()); - m_terminalView->sendText (QString ("load \'%1\'\n").arg (selectedFile)); - m_terminalView->widget ()->setFocus (); + QString text = QString ("load \'%1\'\n").arg (selectedFile); + m_terminalView->sendText (text); + m_terminalView->setFocus (); } void MainWindow::handleClearWorkspaceRequest () { - m_terminalView->sendText ("clear\n"); - m_terminalView->widget ()->setFocus (); + QString text = QString ("clear\n"); + m_terminalView->sendText (text); + m_terminalView->setFocus (); } void MainWindow::handleCommandDoubleClicked (QString command) { m_terminalView->sendText (command); - m_terminalView->widget ()->setFocus (); + m_terminalView->setFocus (); } void @@ -290,20 +289,20 @@ m_statusBar = new QStatusBar (this); // Setup essential MDI Windows. - m_terminalView = AbstractTerminalView::create (this); + m_terminalView = new TerminalWidget (this); m_documentationWidget = new BrowserWidget (this); m_ircWidget = new IRCWidget (this); // Octave Terminal subwindow. m_terminalViewSubWindow = new NonClosableMdiSubWindow (this); - m_terminalViewSubWindow->setWidget (m_terminalView->widget ()); + m_terminalViewSubWindow->setWidget (m_terminalView); m_centralMdiArea->addSubWindow (m_terminalViewSubWindow, Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint); m_terminalViewSubWindow->setObjectName ("OctaveTerminalSubWindow"); m_terminalViewSubWindow->setWindowTitle (tr ("Terminal")); m_terminalViewSubWindow ->setWindowIcon (ResourceManager::instance ()->icon (ResourceManager::Terminal)); - m_terminalViewSubWindow->setFocusProxy (m_terminalView->widget ()); + m_terminalViewSubWindow->setFocusProxy (m_terminalView); m_terminalViewSubWindow->setStatusTip (tr ("Enter your commands into the Octave terminal.")); m_terminalViewSubWindow->setMinimumSize (300, 300);
--- a/gui/octave-gui/src/MainWindow.h +++ b/gui/octave-gui/src/MainWindow.h @@ -28,7 +28,6 @@ #include <Qsci/qsciapis.h> #include <QMdiSubWindow> #include "ResourceManager.h" -#include "AbstractTerminalView.h" #include "OctaveLink.h" #include "WorkspaceView.h" #include "HistoryDockWidget.h" @@ -36,6 +35,7 @@ #include "BrowserWidget.h" #include "irc/IRCWidget.h" #include "lexer/lexeroctavegui.h" +#include "TerminalWidget.h" class NonClosableMdiSubWindow : public QMdiSubWindow { @@ -62,7 +62,7 @@ MainWindow (QWidget * parent = 0); ~MainWindow (); - AbstractTerminalView *terminalView () + TerminalWidget *terminalView () { return m_terminalView; } @@ -113,7 +113,7 @@ QMdiArea *m_centralMdiArea; // Mdi sub windows. - AbstractTerminalView *m_terminalView; + TerminalWidget *m_terminalView; BrowserWidget *m_documentationWidget; IRCWidget *m_ircWidget;
new file mode 100644 --- /dev/null +++ b/gui/octave-gui/src/TerminalWidget.cpp @@ -0,0 +1,36 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "TerminalWidget.h" +#include "pty.h" + +TerminalWidget::TerminalWidget(QWidget *parent) + : QTermWidget(0, parent) { + int fdm; + int fds; + + if ( openpty (&fdm, &fds, 0, 0, 0) < 0 ) + { + fprintf (stderr, "oops!\n"); + } + + dup2 (fds, 0); + dup2 (fds, 1); + dup2 (fds, 2); + + openTeletype(fdm); +}
new file mode 100644 --- /dev/null +++ b/gui/octave-gui/src/TerminalWidget.h @@ -0,0 +1,28 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef TERMINALWIDGET_H +#define TERMINALWIDGET_H + +#include "qtermwidget.h" + +class TerminalWidget : public QTermWidget { +public: + TerminalWidget(QWidget *parent = 0); +}; + +#endif // TERMINALWIDGET_H