# HG changeset patch # User Jacob Dawid # Date 1302345260 -7200 # Node ID fc8f53c6994f3c2602d5c6f298df944c5225fd07 # Parent 0b780509d3ac3184d7661918161e3bf19c5b7f39 Added missing copyright notice, refactored code. diff --git a/gui//src/MainWindow.cpp b/gui//src/MainWindow.cpp --- a/gui//src/MainWindow.cpp +++ b/gui//src/MainWindow.cpp @@ -34,7 +34,6 @@ } MainWindow::~MainWindow() { - } void MainWindow::addTerminalWindow() { diff --git a/gui//src/QTerminalWidget.cpp b/gui//src/QTerminalWidget.cpp --- 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(); diff --git a/gui//src/Quint.cpp b/gui//src/Quint.cpp --- a/gui//src/Quint.cpp +++ b/gui//src/Quint.cpp @@ -19,18 +19,6 @@ #include #include "MainWindow.h" -// System -#include -#include -#include -#include -#include - -#include -#include "pty.h" -#include -#include "QTerminalWidget.h" - int main(int argc, char *argv[]) { QApplication a(argc, argv); diff --git a/gui//src/TerminalMdiSubWindow.cpp b/gui//src/TerminalMdiSubWindow.cpp --- 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 . + */ + #include "TerminalMdiSubWindow.h" #include #include #include #include -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) { diff --git a/gui//src/TerminalMdiSubWindow.h b/gui//src/TerminalMdiSubWindow.h --- 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 . + */ + #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 #include #include - #include #include #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