# HG changeset patch # User Jacob Dawid # Date 1327244815 -3600 # Node ID 7ede35410aa55930da50f3d71ec0f2fd72736861 # Parent b871a65c56818e9262c814ade14082f7ed999f00 GUI: Build in previous terminal widget. diff -r b871a65c5681 -r 7ede35410aa5 gui/octave-gui/octave-gui.pro --- a/gui/octave-gui/octave-gui.pro Sun Jan 22 15:17:37 2012 +0100 +++ b/gui/octave-gui/octave-gui.pro Sun Jan 22 16:06:55 2012 +0100 @@ -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 { diff -r b871a65c5681 -r 7ede35410aa5 gui/octave-gui/src/FileEditorMdiSubWindow.cpp --- a/gui/octave-gui/src/FileEditorMdiSubWindow.cpp Sun Jan 22 15:17:37 2012 +0100 +++ b/gui/octave-gui/src/FileEditorMdiSubWindow.cpp Sun Jan 22 16:06:55 2012 +0100 @@ -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) { diff -r b871a65c5681 -r 7ede35410aa5 gui/octave-gui/src/FileEditorMdiSubWindow.h --- a/gui/octave-gui/src/FileEditorMdiSubWindow.h Sun Jan 22 15:17:37 2012 +0100 +++ b/gui/octave-gui/src/FileEditorMdiSubWindow.h Sun Jan 22 16:06:55 2012 +0100 @@ -19,7 +19,7 @@ #define FILEEDITORMDISUBWINDOW_H #include "MainWindow.h" -#include "AbstractTerminalView.h" +#include "TerminalWidget.h" #include #include #include @@ -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; diff -r b871a65c5681 -r 7ede35410aa5 gui/octave-gui/src/MainWindow.cpp --- a/gui/octave-gui/src/MainWindow.cpp Sun Jan 22 15:17:37 2012 +0100 +++ b/gui/octave-gui/src/MainWindow.cpp Sun Jan 22 16:06:55 2012 +0100 @@ -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); diff -r b871a65c5681 -r 7ede35410aa5 gui/octave-gui/src/MainWindow.h --- a/gui/octave-gui/src/MainWindow.h Sun Jan 22 15:17:37 2012 +0100 +++ b/gui/octave-gui/src/MainWindow.h Sun Jan 22 16:06:55 2012 +0100 @@ -28,7 +28,6 @@ #include #include #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; diff -r b871a65c5681 -r 7ede35410aa5 gui/octave-gui/src/TerminalWidget.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/octave-gui/src/TerminalWidget.cpp Sun Jan 22 16:06:55 2012 +0100 @@ -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 . + */ + +#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); +} diff -r b871a65c5681 -r 7ede35410aa5 gui/octave-gui/src/TerminalWidget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/octave-gui/src/TerminalWidget.h Sun Jan 22 16:06:55 2012 +0100 @@ -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 . + */ + +#ifndef TERMINALWIDGET_H +#define TERMINALWIDGET_H + +#include "qtermwidget.h" + +class TerminalWidget : public QTermWidget { +public: + TerminalWidget(QWidget *parent = 0); +}; + +#endif // TERMINALWIDGET_H