# HG changeset patch # User Jacob Dawid # Date 1311081527 -7200 # Node ID 86adc9c4ec4bd1eec4bf8582f7f6c0076488015e # Parent d53287c44e5ab0d661cd42d9309fd4ae8d8b90fe History deactivated. diff --git a/gui/src/HistoryDockWidget.cpp b/gui/src/HistoryDockWidget.cpp --- a/gui/src/HistoryDockWidget.cpp +++ b/gui/src/HistoryDockWidget.cpp @@ -49,22 +49,14 @@ layout->setMargin (2); widget ()->setLayout (layout); - connect (m_historyListView, SIGNAL (doubleClicked (QModelIndex)), this, - SLOT (handleListViewItemDoubleClicked (QModelIndex))); + //connect (m_historyListView, SIGNAL (doubleClicked (QModelIndex)), this, + // SLOT (handleListViewItemDoubleClicked (QModelIndex))); } void -HistoryDockWidget::updateHistory (string_vector historyEntries) -{ - QStringList stringList = m_historyListModel->stringList (); - for (int i = 0; i < historyEntries.length (); i++) - { - QString command (historyEntries[i].c_str ()); - if (!command.startsWith ("#")) - { - stringList.push_front (command); - } - } - m_historyListModel->setStringList (stringList); +HistoryDockWidget::updateHistory (QStringList history) +{/* + m_historyListModel->setStringList (history); emit information (tr ("History updated.")); + */ } diff --git a/gui/src/HistoryDockWidget.h b/gui/src/HistoryDockWidget.h --- a/gui/src/HistoryDockWidget.h +++ b/gui/src/HistoryDockWidget.h @@ -23,44 +23,19 @@ #include #include -// Octave includes -#undef PACKAGE_BUGREPORT -#undef PACKAGE_NAME -#undef PACKAGE_STRING -#undef PACKAGE_TARNAME -#undef PACKAGE_VERSION -#undef PACKAGE_URL -#include "octave/config.h" - -#include "octave/debug.h" -#include "octave/octave.h" -#include "octave/symtab.h" -#include "octave/parse.h" -#include "octave/unwind-prot.h" -#include "octave/toplev.h" -#include "octave/load-path.h" -#include "octave/error.h" -#include "octave/quit.h" -#include "octave/variables.h" -#include "octave/sighandlers.h" -#include "octave/sysdep.h" -#include "octave/str-vec.h" -#include "octave/cmd-hist.h" -#include "octave/cmd-edit.h" -#include "octave/oct-env.h" -#include "octave/symtab.h" -#include "cmd-edit.h" - class HistoryDockWidget:public QDockWidget { -Q_OBJECT public: - HistoryDockWidget (QWidget * parent = 0); - void updateHistory (string_vector historyEntries); +Q_OBJECT +public: + HistoryDockWidget (QWidget *parent = 0); + void updateHistory (QStringList history); - signals:void information (QString message); +signals: + void information (QString message); void commandDoubleClicked (QString command); - private slots:void handleListViewItemDoubleClicked (QModelIndex modelIndex); +private slots: + void handleListViewItemDoubleClicked (QModelIndex modelIndex); private: void construct (); diff --git a/gui/src/MainWindow.cpp b/gui/src/MainWindow.cpp --- a/gui/src/MainWindow.cpp +++ b/gui/src/MainWindow.cpp @@ -26,6 +26,7 @@ #include "FileEditorMdiSubWindow.h" #include "ImageViewerMdiSubWindow.h" #include "SettingsDialog.h" +#include "cmd-edit.h" MainWindow::MainWindow (QWidget * parent):QMainWindow (parent), m_isRunning (true) @@ -278,16 +279,6 @@ m_octaveCallbackThread->start (); command_editor::add_event_hook (OctaveLink::readlineEventHook); - - int fdm, fds; - if (openpty (&fdm, &fds, 0, 0, 0) < 0) - { - assert (0); - } - dup2 (fds, 0); - dup2 (fds, 1); - dup2 (fds, 2); - - m_octaveTerminal->openTeletype (fdm); + m_octaveTerminal->openTerminal (); reportStatusMessage (tr ("Established link to Octave.")); } diff --git a/gui/src/MainWindow.h b/gui/src/MainWindow.h --- a/gui/src/MainWindow.h +++ b/gui/src/MainWindow.h @@ -34,49 +34,6 @@ #include "BrowserWidget.h" #include "IRCWidget.h" -// Octave includes -#undef PACKAGE_BUGREPORT -#undef PACKAGE_NAME -#undef PACKAGE_STRING -#undef PACKAGE_TARNAME -#undef PACKAGE_VERSION -#undef PACKAGE_URL -#include "octave/config.h" - -#include "octave/debug.h" -#include "octave/octave.h" -#include "octave/symtab.h" -#include "octave/parse.h" -#include "octave/unwind-prot.h" -#include "octave/toplev.h" -#include "octave/load-path.h" -#include "octave/error.h" -#include "octave/quit.h" -#include "octave/variables.h" -#include "octave/sighandlers.h" -#include "octave/sysdep.h" -#include "octave/str-vec.h" -#include "octave/cmd-hist.h" -#include "octave/cmd-edit.h" -#include "octave/oct-env.h" -#include "octave/symtab.h" -#include "cmd-edit.h" - -typedef struct yy_buffer_state *YY_BUFFER_STATE; -extern OCTINTERP_API YY_BUFFER_STATE create_buffer (FILE * f); -extern OCTINTERP_API void switch_to_buffer (YY_BUFFER_STATE buf); -extern OCTINTERP_API FILE *get_input_from_stdin (void); - -// System -#include -#include -#include -#include -#include -#include -#include -#include "pty.h" - class OctaveMainThread; class OctaveCallbackThread; @@ -200,11 +157,10 @@ } // Collect history list. - string_vector historyList = - OctaveLink::instance ()->currentHistory (); - if (historyList.length ()) + QStringList history = OctaveLink::instance ()->currentHistory (); + if (history.length ()) { - m_mainWindow->historyDockWidget ()->updateHistory (historyList); + m_mainWindow->historyDockWidget ()->updateHistory (history); } usleep (100000); diff --git a/gui/src/OctaveLink.cpp b/gui/src/OctaveLink.cpp --- a/gui/src/OctaveLink.cpp +++ b/gui/src/OctaveLink.cpp @@ -128,7 +128,9 @@ m_historySemaphore->acquire (); for (int i = m_previousHistoryLength; i < currentLen; i++) { - m_historyBuffer.append (command_history::get_entry (i)); + QString entry = QString(command_history::get_entry (i).c_str()); + if (!entry.startsWith ("#")) + m_historyBuffer.append (entry); } m_historySemaphore->release (); m_previousHistoryLength = currentLen; @@ -149,14 +151,13 @@ return m_symbolTableCopy; } -string_vector +QStringList OctaveLink::currentHistory () { m_historySemaphore->acquire (); - string_vector retval (m_historyBuffer); - m_historyBuffer = string_vector (); + QStringList historyBuffer = m_historyBuffer; m_historySemaphore->release (); - return retval; + return historyBuffer; } void diff --git a/gui/src/OctaveLink.h b/gui/src/OctaveLink.h --- a/gui/src/OctaveLink.h +++ b/gui/src/OctaveLink.h @@ -75,23 +75,19 @@ #include #include #include +#include #include #include #include -typedef - symbol_table::symbol_record - SymbolRecord; -typedef octave_value - OctaveValue; +typedef symbol_table::symbol_record SymbolRecord; +typedef octave_value OctaveValue; /** * \class OctaveLink * Manages a link to an octave instance. */ -class - OctaveLink: - QObject +class OctaveLink:QObject { Q_OBJECT public: @@ -105,33 +101,33 @@ static QString octaveValueAsQString (OctaveValue octaveValue); - /** - * Returns a copy of the current symbol table buffer. - * \return Copy of the current symbol table buffer. - */ + /** + * Returns a copy of the current symbol table buffer. + * \return Copy of the current symbol table buffer. + */ QList < SymbolRecord > currentSymbolTable (); - /** - * Returns a copy of the current history buffer. - * \return Copy of the current history buffer. - */ - string_vector + /** + * Returns a copy of the current history buffer. + * \return Copy of the current history buffer. + */ + QStringList currentHistory (); void processOctaveServerData (); - /** - * Updates the current symbol table with new data - * from octave. - */ + /** + * Updates the current symbol table with new data + * from octave. + */ void fetchSymbolTable (); - /** - * Updates the current history buffer with new data - * from octave. - */ + /** + * Updates the current history buffer with new data + * from octave. + */ void fetchHistory (); @@ -145,13 +141,13 @@ OctaveLink (); ~OctaveLink (); - /** Variable related member variables. */ + /** Variable related member variables. */ QSemaphore * m_symbolTableSemaphore; QList < SymbolRecord > m_symbolTableBuffer; - /** History related member variables. */ + /** History related member variables. */ QSemaphore *m_historySemaphore; - string_vector m_historyBuffer; + QStringList m_historyBuffer; int m_previousHistoryLength; static OctaveLink m_singleton; }; diff --git a/gui/src/OctaveTerminal.cpp b/gui/src/OctaveTerminal.cpp --- a/gui/src/OctaveTerminal.cpp +++ b/gui/src/OctaveTerminal.cpp @@ -22,7 +22,11 @@ #include #include -OctaveTerminal::OctaveTerminal (QWidget * parent):QTerminalWidget (0, parent) +#include "pty.h" +#include "unistd.h" +#include + +OctaveTerminal::OctaveTerminal (QWidget * parent):QWidget (parent) { construct (); } @@ -34,5 +38,26 @@ void OctaveTerminal::construct () { - setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding); + m_terminalWidget = new QTerminalWidget (0, this); + m_terminalWidget->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding); + setFocusProxy (m_terminalWidget); + + QVBoxLayout *layout = new QVBoxLayout (); + layout->addWidget (m_terminalWidget); + setLayout (layout); } + +void +OctaveTerminal::openTerminal () +{ + int fdm, fds; + if (openpty (&fdm, &fds, 0, 0, 0) < 0) + { + assert (0); + } + dup2 (fds, 0); + dup2 (fds, 1); + dup2 (fds, 2); + + m_terminalWidget->openTeletype (fdm); +} diff --git a/gui/src/OctaveTerminal.h b/gui/src/OctaveTerminal.h --- a/gui/src/OctaveTerminal.h +++ b/gui/src/OctaveTerminal.h @@ -18,15 +18,20 @@ #ifndef OCTAVETERMINAL_H #define OCTAVETERMINAL_H +#include #include "QTerminalWidget.h" -class OctaveTerminal:public QTerminalWidget +class OctaveTerminal:public QWidget { -Q_OBJECT public: +Q_OBJECT +public: OctaveTerminal (QWidget * parent = 0); ~OctaveTerminal (); + void sendText (QString text) { m_terminalWidget->sendText(text); } + void openTerminal (); private: void construct (); + QTerminalWidget *m_terminalWidget; }; #endif // OCTAVETERMINAL_H