Mercurial > hg > octave-terminal
changeset 13386:fc8f53c6994f
Added missing copyright notice, refactored code.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Sat, 09 Apr 2011 12:34:20 +0200 |
parents | 0b780509d3ac |
children | cd47f7e16ee8 |
files | gui//src/MainWindow.cpp gui//src/QTerminalWidget.cpp gui//src/Quint.cpp gui//src/TerminalMdiSubWindow.cpp gui//src/TerminalMdiSubWindow.h |
diffstat | 5 files changed, 62 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/gui//src/MainWindow.cpp +++ b/gui//src/MainWindow.cpp @@ -34,7 +34,6 @@ } MainWindow::~MainWindow() { - } void MainWindow::addTerminalWindow() {
--- a/gui//src/QTerminalWidget.cpp +++ b/gui//src/QTerminalWidget.cpp @@ -16,7 +16,6 @@ Boston, MA 02110-1301, USA. */ - #include "QTerminalWidget.h" #include "Session.h" #include "TerminalDisplay.h" @@ -70,11 +69,11 @@ initialize(); - if (startnow && m_impl->m_session) { + if(startnow && m_impl->m_session) { m_impl->m_session->run(); } - this->setFocus( Qt::OtherFocusReason ); + this->setFocus(Qt::OtherFocusReason); m_impl->m_terminalDisplay->resize(this->size()); this->setFocusProxy(m_impl->m_terminalDisplay); @@ -82,7 +81,7 @@ void QTerminalWidget::startShellProgram() { - if ( m_impl->m_session->isRunning() ) + if(m_impl->m_session->isRunning()) return; m_impl->m_session->run();
--- a/gui//src/Quint.cpp +++ b/gui//src/Quint.cpp @@ -19,18 +19,6 @@ #include <QtGui/QApplication> #include "MainWindow.h" -// System -#include <termios.h> -#include <sys/types.h> -#include <signal.h> -#include <sys/types.h> -#include <sys/wait.h> - -#include <iostream> -#include "pty.h" -#include <assert.h> -#include "QTerminalWidget.h" - int main(int argc, char *argv[]) { QApplication a(argc, argv);
--- a/gui//src/TerminalMdiSubWindow.cpp +++ b/gui//src/TerminalMdiSubWindow.cpp @@ -1,23 +1,27 @@ +/* Quint - 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 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + #include "TerminalMdiSubWindow.h" #include <QHBoxLayout> #include <QVBoxLayout> #include <QStringListModel> #include <QStringList> -void * octave_main_wrapper(void *ptr) -{ - //MainWindow *mainWindow = (MainWindow*)ptr; - - int argc = 3; - const char* argv[] = {"octave", "--interactive", "--line-editing"}; - octave_main(argc,(char**)argv,1); - switch_to_buffer (create_buffer (get_input_from_stdin ())); - - main_loop(); - clean_up_and_exit(0); - return 0; -} - TerminalMdiSubWindow::TerminalMdiSubWindow(QWidget *parent) : QMdiSubWindow(parent), m_terminalWidget(0), @@ -33,13 +37,13 @@ void TerminalMdiSubWindow::establishOctaveLink() { m_octaveLink = new OctaveLink(); - pthread_create(&octave_thread, NULL, octave_main_wrapper, (void*)this); - pthread_create(&octave_monitor_thread, 0, TerminalMdiSubWindow::octaveCallback, this); + pthread_create(&m_octaveThread, 0, TerminalMdiSubWindow::octaveMainWrapper, this); + pthread_create(&m_octaveCallbackThread, 0, TerminalMdiSubWindow::octaveCallback, this); command_editor::add_event_hook(server_rl_event_hook_function); int fdm, fds; if(openpty(&fdm, &fds, 0, 0, 0) < 0) { - fprintf (stderr, "oops!\n"); + assert(0); } dup2 (fds, 0); dup2 (fds, 1); @@ -102,8 +106,20 @@ model->setStringList(stringList); } -void* TerminalMdiSubWindow::octaveCallback(void *window) { - TerminalMdiSubWindow* terminalWindow = (TerminalMdiSubWindow*)window; +void* TerminalMdiSubWindow::octaveMainWrapper(void *widget) { + //MainWindow *mainWindow = (MainWindow*)ptr; + + int argc = 3; + const char* argv[] = {"octave", "--interactive", "--line-editing"}; + octave_main(argc, (char**)argv,1); + switch_to_buffer(create_buffer(get_input_from_stdin())); + main_loop(); + clean_up_and_exit(0); + return 0; +} + +void* TerminalMdiSubWindow::octaveCallback(void *widget) { + TerminalMdiSubWindow* terminalWindow = (TerminalMdiSubWindow*)widget; while(terminalWindow->isRunning) {
--- a/gui//src/TerminalMdiSubWindow.h +++ b/gui//src/TerminalMdiSubWindow.h @@ -1,3 +1,21 @@ +/* Quint - 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 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + #ifndef TERMINALMDISUBWINDOW_H #define TERMINALMDISUBWINDOW_H @@ -8,7 +26,6 @@ #include "QTerminalWidget.h" #include "OctaveLink.h" - // Octave includes #undef PACKAGE_BUGREPORT #undef PACKAGE_NAME @@ -48,7 +65,6 @@ #include <signal.h> #include <sys/types.h> #include <sys/wait.h> - #include <iostream> #include <vector> #include "pty.h" @@ -56,8 +72,10 @@ class TerminalMdiSubWindow : public QMdiSubWindow { Q_OBJECT public: + static void* octaveMainWrapper(void *widget); + static void* octaveCallback(void *widget); + void updateHistory(string_vector historyEntries); - static void* octaveCallback(void *octaveUI); TerminalMdiSubWindow(QWidget *parent = 0); ~TerminalMdiSubWindow(); @@ -72,9 +90,9 @@ QStatusBar *m_statusBar; OctaveLink *m_octaveLink; - // Threads for running octave and managing the data interaction - pthread_t octave_thread; - pthread_t octave_monitor_thread; + // Threads for running octave and managing the data interaction. + pthread_t m_octaveThread; + pthread_t m_octaveCallbackThread; bool isRunning; }; #endif // TERMINALMDISUBWINDOW_H