Mercurial > octave-nkf
changeset 13360:28160d541ddb
Rename qtermwidget to QTerminalWidget
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Thu, 07 Apr 2011 12:17:53 +0200 |
parents | a505e220858b |
children | 67ffdb3264a6 |
files | gui//Makefile gui//QTerminalWidget.cpp gui//QTerminalWidget.h gui//Quint gui//Quint.pro gui//qtermwidget.cpp gui//qtermwidget.h gui//terminal.cpp gui//terminal.h |
diffstat | 9 files changed, 352 insertions(+), 357 deletions(-) [+] |
line wrap: on
line diff
--- a/gui//Makefile Thu Apr 07 12:12:13 2011 +0200 +++ b/gui//Makefile Thu Apr 07 12:17:53 2011 +0200 @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: Quint -# Generated by qmake (2.01a) (Qt 4.7.2) on: Do. Apr 7 12:08:50 2011 +# Generated by qmake (2.01a) (Qt 4.7.2) on: Do. Apr 7 12:14:44 2011 # Project: Quint.pro # Template: app # Command: /usr/bin/qmake -spec /usr/share/qt4/mkspecs/linux-g++ QMLJSDEBUGGER_PATH=/usr/share/qtcreator/qml/qmljsdebugger -o Makefile Quint.pro @@ -63,7 +63,7 @@ k3processcontroller.cpp \ Session.cpp \ ShellCommand.cpp \ - qtermwidget.cpp moc_mainwindow.cpp \ + QTerminalWidget.cpp moc_mainwindow.cpp \ moc_terminal.cpp \ moc_ScreenWindow.cpp \ moc_Emulation.cpp \ @@ -74,7 +74,7 @@ moc_k3process.cpp \ moc_k3processcontroller.cpp \ moc_Session.cpp \ - moc_qtermwidget.cpp + moc_QTerminalWidget.cpp OBJECTS = object-files/main.o \ object-files/mainwindow.o \ object-files/terminal.o \ @@ -95,7 +95,7 @@ object-files/k3processcontroller.o \ object-files/Session.o \ object-files/ShellCommand.o \ - object-files/qtermwidget.o \ + object-files/QTerminalWidget.o \ object-files/moc_mainwindow.o \ object-files/moc_terminal.o \ object-files/moc_ScreenWindow.o \ @@ -107,7 +107,7 @@ object-files/moc_k3process.o \ object-files/moc_k3processcontroller.o \ object-files/moc_Session.o \ - object-files/moc_qtermwidget.o + object-files/moc_QTerminalWidget.o DIST = /usr/share/qt4/mkspecs/common/g++.conf \ /usr/share/qt4/mkspecs/common/unix.conf \ /usr/share/qt4/mkspecs/common/linux.conf \ @@ -212,7 +212,7 @@ dist: @$(CHK_DIR_EXISTS) object-files/Quint1.0.0 || $(MKDIR) object-files/Quint1.0.0 - $(COPY_FILE) --parents $(SOURCES) $(DIST) object-files/Quint1.0.0/ && $(COPY_FILE) --parents mainwindow.h terminal.h TerminalCharacterDecoder.h Character.h CharacterColor.h KeyboardTranslator.h ExtendedDefaultTranslator.h Screen.h History.h BlockArray.h konsole_wcwidth.h ScreenWindow.h Emulation.h Vt102Emulation.h TerminalDisplay.h Filter.h LineFont.h Pty.h kpty.h kpty_p.h k3process.h k3processcontroller.h Session.h ShellCommand.h qtermwidget.h object-files/Quint1.0.0/ && $(COPY_FILE) --parents main.cpp mainwindow.cpp terminal.cpp TerminalCharacterDecoder.cpp KeyboardTranslator.cpp Screen.cpp History.cpp BlockArray.cpp konsole_wcwidth.cpp ScreenWindow.cpp Emulation.cpp Vt102Emulation.cpp TerminalDisplay.cpp Filter.cpp Pty.cpp kpty.cpp k3process.cpp k3processcontroller.cpp Session.cpp ShellCommand.cpp qtermwidget.cpp object-files/Quint1.0.0/ && (cd `dirname object-files/Quint1.0.0` && $(TAR) Quint1.0.0.tar Quint1.0.0 && $(COMPRESS) Quint1.0.0.tar) && $(MOVE) `dirname object-files/Quint1.0.0`/Quint1.0.0.tar.gz . && $(DEL_FILE) -r object-files/Quint1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) object-files/Quint1.0.0/ && $(COPY_FILE) --parents mainwindow.h terminal.h TerminalCharacterDecoder.h Character.h CharacterColor.h KeyboardTranslator.h ExtendedDefaultTranslator.h Screen.h History.h BlockArray.h konsole_wcwidth.h ScreenWindow.h Emulation.h Vt102Emulation.h TerminalDisplay.h Filter.h LineFont.h Pty.h kpty.h kpty_p.h k3process.h k3processcontroller.h Session.h ShellCommand.h QTerminalWidget.h object-files/Quint1.0.0/ && $(COPY_FILE) --parents main.cpp mainwindow.cpp terminal.cpp TerminalCharacterDecoder.cpp KeyboardTranslator.cpp Screen.cpp History.cpp BlockArray.cpp konsole_wcwidth.cpp ScreenWindow.cpp Emulation.cpp Vt102Emulation.cpp TerminalDisplay.cpp Filter.cpp Pty.cpp kpty.cpp k3process.cpp k3processcontroller.cpp Session.cpp ShellCommand.cpp QTerminalWidget.cpp object-files/Quint1.0.0/ && (cd `dirname object-files/Quint1.0.0` && $(TAR) Quint1.0.0.tar Quint1.0.0 && $(COMPRESS) Quint1.0.0.tar) && $(MOVE) `dirname object-files/Quint1.0.0`/Quint1.0.0.tar.gz . && $(DEL_FILE) -r object-files/Quint1.0.0 clean:compiler_clean @@ -233,14 +233,13 @@ mocables: compiler_moc_header_make_all compiler_moc_source_make_all -compiler_moc_header_make_all: moc_mainwindow.cpp moc_terminal.cpp moc_ScreenWindow.cpp moc_Emulation.cpp moc_Vt102Emulation.cpp moc_TerminalDisplay.cpp moc_Filter.cpp moc_Pty.cpp moc_k3process.cpp moc_k3processcontroller.cpp moc_Session.cpp moc_qtermwidget.cpp +compiler_moc_header_make_all: moc_mainwindow.cpp moc_terminal.cpp moc_ScreenWindow.cpp moc_Emulation.cpp moc_Vt102Emulation.cpp moc_TerminalDisplay.cpp moc_Filter.cpp moc_Pty.cpp moc_k3process.cpp moc_k3processcontroller.cpp moc_Session.cpp moc_QTerminalWidget.cpp compiler_moc_header_clean: - -$(DEL_FILE) moc_mainwindow.cpp moc_terminal.cpp moc_ScreenWindow.cpp moc_Emulation.cpp moc_Vt102Emulation.cpp moc_TerminalDisplay.cpp moc_Filter.cpp moc_Pty.cpp moc_k3process.cpp moc_k3processcontroller.cpp moc_Session.cpp moc_qtermwidget.cpp + -$(DEL_FILE) moc_mainwindow.cpp moc_terminal.cpp moc_ScreenWindow.cpp moc_Emulation.cpp moc_Vt102Emulation.cpp moc_TerminalDisplay.cpp moc_Filter.cpp moc_Pty.cpp moc_k3process.cpp moc_k3processcontroller.cpp moc_Session.cpp moc_QTerminalWidget.cpp moc_mainwindow.cpp: mainwindow.h /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) mainwindow.h -o moc_mainwindow.cpp -moc_terminal.cpp: qtermwidget.h \ - terminal.h +moc_terminal.cpp: terminal.h /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) terminal.h -o moc_terminal.cpp moc_ScreenWindow.cpp: Character.h \ @@ -290,8 +289,8 @@ Session.h /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) Session.h -o moc_Session.cpp -moc_qtermwidget.cpp: qtermwidget.h - /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) qtermwidget.h -o moc_qtermwidget.cpp +moc_QTerminalWidget.cpp: QTerminalWidget.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) QTerminalWidget.h -o moc_QTerminalWidget.cpp compiler_rcc_make_all: compiler_rcc_clean: @@ -316,12 +315,10 @@ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o object-files/main.o main.cpp object-files/mainwindow.o: mainwindow.cpp mainwindow.h \ - terminal.h \ - qtermwidget.h + terminal.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o object-files/mainwindow.o mainwindow.cpp -object-files/terminal.o: terminal.cpp terminal.h \ - qtermwidget.h +object-files/terminal.o: terminal.cpp terminal.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o object-files/terminal.o terminal.cpp object-files/TerminalCharacterDecoder.o: TerminalCharacterDecoder.cpp TerminalCharacterDecoder.h \ @@ -437,8 +434,7 @@ object-files/ShellCommand.o: ShellCommand.cpp ShellCommand.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o object-files/ShellCommand.o ShellCommand.cpp -object-files/qtermwidget.o: qtermwidget.cpp qtermwidget.h \ - Session.h \ +object-files/QTerminalWidget.o: QTerminalWidget.cpp Session.h \ History.h \ BlockArray.h \ Character.h \ @@ -446,7 +442,7 @@ TerminalDisplay.h \ Filter.h \ ColorTables.h - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o object-files/qtermwidget.o qtermwidget.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o object-files/QTerminalWidget.o QTerminalWidget.cpp object-files/moc_mainwindow.o: moc_mainwindow.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o object-files/moc_mainwindow.o moc_mainwindow.cpp @@ -481,8 +477,8 @@ object-files/moc_Session.o: moc_Session.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o object-files/moc_Session.o moc_Session.cpp -object-files/moc_qtermwidget.o: moc_qtermwidget.cpp - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o object-files/moc_qtermwidget.o moc_qtermwidget.cpp +object-files/moc_QTerminalWidget.o: moc_QTerminalWidget.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o object-files/moc_QTerminalWidget.o moc_QTerminalWidget.cpp ####### Install
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui//QTerminalWidget.cpp Thu Apr 07 12:17:53 2011 +0200 @@ -0,0 +1,221 @@ +/* Copyright (C) 2008 e_k (e_k@users.sourceforge.net) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + + +#include "QTerminalWidget.h" +#include "Session.h" +#include "TerminalDisplay.h" + +using namespace Konsole; + +void *createTermWidget(int startnow, void *parent) +{ + return (void*) new QTerminalWidget(startnow, (QWidget*)parent); +} + +struct TermWidgetImpl +{ + TermWidgetImpl(QWidget* parent = 0); + + TerminalDisplay *m_terminalDisplay; + Session *m_session; + + Session* createSession(); + TerminalDisplay* createTerminalDisplay(Session *session, QWidget* parent); +}; + +TermWidgetImpl::TermWidgetImpl(QWidget* parent) +{ + this->m_session = createSession(); + this->m_terminalDisplay = createTerminalDisplay(this->m_session, parent); +} + + +Session *TermWidgetImpl::createSession() +{ + Session *session = new Session(); + + session->setTitle(Session::NameRole, "QTermWidget"); + session->setProgram("/bin/bash"); + QStringList args(""); + session->setArguments(args); + session->setAutoClose(true); + + session->setCodec(QTextCodec::codecForName("UTF-8")); + + session->setFlowControlEnabled(true); + session->setHistoryType(HistoryTypeBuffer(1000)); + + session->setDarkBackground(true); + + session->setKeyBindings(""); + return session; +} + +TerminalDisplay *TermWidgetImpl::createTerminalDisplay(Session *session, QWidget* parent) +{ +// TerminalDisplay* display = new TerminalDisplay(this); + TerminalDisplay* display = new TerminalDisplay(parent); + + display->setBellMode(TerminalDisplay::NotifyBell); + display->setTerminalSizeHint(true); + display->setTripleClickMode(TerminalDisplay::SelectWholeLine); + display->setTerminalSizeStartup(true); + + display->setRandomSeed(session->sessionId() * 31); + + return display; +} + + +QTerminalWidget::QTerminalWidget(int startnow, QWidget *parent) +:QWidget(parent) +{ + m_impl = new TermWidgetImpl(this); + + init(); + + if (startnow && m_impl->m_session) { + m_impl->m_session->run(); + } + + this->setFocus( Qt::OtherFocusReason ); + m_impl->m_terminalDisplay->resize(this->size()); + + this->setFocusProxy(m_impl->m_terminalDisplay); +} + +void QTerminalWidget::startShellProgram() +{ + if ( m_impl->m_session->isRunning() ) + return; + + m_impl->m_session->run(); +} + +void QTerminalWidget::init() +{ + m_impl->m_terminalDisplay->setSize(80, 40); + + QFont font = QApplication::font(); + font.setFamily("Monospace"); + font.setPointSize(10); + font.setStyleHint(QFont::TypeWriter); + setTerminalFont(font); + setScrollBarPosition(NoScrollBar); + + m_impl->m_session->addView(m_impl->m_terminalDisplay); + + connect(m_impl->m_session, SIGNAL(finished()), this, SLOT(sessionFinished())); +} + + +QTerminalWidget::~QTerminalWidget() +{ + emit destroyed(); +} + + +void QTerminalWidget::setTerminalFont(QFont &font) +{ + if (!m_impl->m_terminalDisplay) + return; + m_impl->m_terminalDisplay->setVTFont(font); +} + +void QTerminalWidget::setShellProgram(QString &progname) +{ + if (!m_impl->m_session) + return; + m_impl->m_session->setProgram(progname); +} + +void QTerminalWidget::setArgs(QStringList &args) +{ + if (!m_impl->m_session) + return; + m_impl->m_session->setArguments(args); +} + +void QTerminalWidget::setTextCodec(QTextCodec *codec) +{ + if (!m_impl->m_session) + return; + m_impl->m_session->setCodec(codec); +} + +void QTerminalWidget::setColorScheme(int scheme) +{ + switch(scheme) { + case COLOR_SCHEME_WHITE_ON_BLACK: + m_impl->m_terminalDisplay->setColorTable(whiteonblack_color_table); + break; + case COLOR_SCHEME_GREEN_ON_BLACK: + m_impl->m_terminalDisplay->setColorTable(greenonblack_color_table); + break; + case COLOR_SCHEME_BLACK_ON_LIGHT_YELLOW: + m_impl->m_terminalDisplay->setColorTable(blackonlightyellow_color_table); + break; + default: //do nothing + break; + }; +} + +void QTerminalWidget::setSize(int h, int v) +{ + if (!m_impl->m_terminalDisplay) + return; + m_impl->m_terminalDisplay->setSize(h, v); +} + +void QTerminalWidget::setHistorySize(int lines) +{ + if (lines < 0) + m_impl->m_session->setHistoryType(HistoryTypeFile()); + else + m_impl->m_session->setHistoryType(HistoryTypeBuffer(lines)); +} + +void QTerminalWidget::setScrollBarPosition(ScrollBarPosition pos) +{ + if (!m_impl->m_terminalDisplay) + return; + m_impl->m_terminalDisplay->setScrollBarPosition((TerminalDisplay::ScrollBarPosition)pos); +} + +void QTerminalWidget::sendText(QString &text) +{ + m_impl->m_session->sendText(text); +} + +void QTerminalWidget::resizeEvent(QResizeEvent*) +{ +//qDebug("global window resizing...with %d %d", this->size().width(), this->size().height()); + m_impl->m_terminalDisplay->resize(this->size()); +} + + + +void QTerminalWidget::sessionFinished() +{ + emit finished(); +} + + +//#include "moc_consoleq.cpp" +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui//QTerminalWidget.h Thu Apr 07 12:17:53 2011 +0200 @@ -0,0 +1,108 @@ +/* Copyright (C) 2008 e_k (e_k@users.sourceforge.net) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + + +#ifndef _Q_TERM_WIDGET +#define _Q_TERM_WIDGET + +#include <QtGui> + +struct TermWidgetImpl; + +enum COLOR_SCHEME { COLOR_SCHEME_WHITE_ON_BLACK = 1, + COLOR_SCHEME_GREEN_ON_BLACK, + COLOR_SCHEME_BLACK_ON_LIGHT_YELLOW }; + +class QTerminalWidget : public QWidget +{ + Q_OBJECT +public: + + enum ScrollBarPosition + { + /** Do not show the scroll bar. */ + NoScrollBar=0, + /** Show the scroll bar on the left side of the display. */ + ScrollBarLeft=1, + /** Show the scroll bar on the right side of the display. */ + ScrollBarRight=2 + }; + + + //Creation of widget + QTerminalWidget(int startnow = 1, //start shell programm immediatelly + QWidget *parent = 0); + ~QTerminalWidget(); + + //start shell program if it was not started in constructor + void startShellProgram(); + + //look-n-feel, if you don`t like defaults + + // Terminal font + // Default is application font with family Monospace, size 10 + void setTerminalFont(QFont &font); + + // Shell program, default is /bin/bash + void setShellProgram(QString &progname); + + // Shell program args, default is none + void setArgs(QStringList &args); + + //Text codec, default is UTF-8 + void setTextCodec(QTextCodec *codec); + + //Color scheme, default is white on black + void setColorScheme(int scheme); + + //set size + void setSize(int h, int v); + + // History size for scrolling + void setHistorySize(int lines); //infinite if lines < 0 + + // Presence of scrollbar + void setScrollBarPosition(ScrollBarPosition); + + // Send some text to terminal + void sendText(QString &text); + +signals: + void finished(); + +protected: + virtual void resizeEvent(QResizeEvent *); + +protected slots: + void sessionFinished(); + +private: + void init(); + TermWidgetImpl *m_impl; +}; + + +//Maybe useful, maybe not + +#ifdef __cplusplus +extern "C" +#endif +void *createTermWidget(int startnow, void *parent); + +#endif +
--- a/gui//Quint.pro Thu Apr 07 12:12:13 2011 +0200 +++ b/gui//Quint.pro Thu Apr 07 12:17:53 2011 +0200 @@ -29,7 +29,7 @@ k3processcontroller.cpp \ Session.cpp \ ShellCommand.cpp \ - qtermwidget.cpp + QTerminalWidget.cpp HEADERS += mainwindow.h \ terminal.h \ @@ -55,4 +55,4 @@ k3processcontroller.h \ Session.h \ ShellCommand.h \ - qtermwidget.h + QTerminalWidget.h
--- a/gui//qtermwidget.cpp Thu Apr 07 12:12:13 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,222 +0,0 @@ -/* Copyright (C) 2008 e_k (e_k@users.sourceforge.net) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - - -#include "qtermwidget.h" - -#include "Session.h" -#include "TerminalDisplay.h" - -using namespace Konsole; - -void *createTermWidget(int startnow, void *parent) -{ - return (void*) new QTermWidget(startnow, (QWidget*)parent); -} - -struct TermWidgetImpl -{ - TermWidgetImpl(QWidget* parent = 0); - - TerminalDisplay *m_terminalDisplay; - Session *m_session; - - Session* createSession(); - TerminalDisplay* createTerminalDisplay(Session *session, QWidget* parent); -}; - -TermWidgetImpl::TermWidgetImpl(QWidget* parent) -{ - this->m_session = createSession(); - this->m_terminalDisplay = createTerminalDisplay(this->m_session, parent); -} - - -Session *TermWidgetImpl::createSession() -{ - Session *session = new Session(); - - session->setTitle(Session::NameRole, "QTermWidget"); - session->setProgram("/bin/bash"); - QStringList args(""); - session->setArguments(args); - session->setAutoClose(true); - - session->setCodec(QTextCodec::codecForName("UTF-8")); - - session->setFlowControlEnabled(true); - session->setHistoryType(HistoryTypeBuffer(1000)); - - session->setDarkBackground(true); - - session->setKeyBindings(""); - return session; -} - -TerminalDisplay *TermWidgetImpl::createTerminalDisplay(Session *session, QWidget* parent) -{ -// TerminalDisplay* display = new TerminalDisplay(this); - TerminalDisplay* display = new TerminalDisplay(parent); - - display->setBellMode(TerminalDisplay::NotifyBell); - display->setTerminalSizeHint(true); - display->setTripleClickMode(TerminalDisplay::SelectWholeLine); - display->setTerminalSizeStartup(true); - - display->setRandomSeed(session->sessionId() * 31); - - return display; -} - - -QTermWidget::QTermWidget(int startnow, QWidget *parent) -:QWidget(parent) -{ - m_impl = new TermWidgetImpl(this); - - init(); - - if (startnow && m_impl->m_session) { - m_impl->m_session->run(); - } - - this->setFocus( Qt::OtherFocusReason ); - m_impl->m_terminalDisplay->resize(this->size()); - - this->setFocusProxy(m_impl->m_terminalDisplay); -} - -void QTermWidget::startShellProgram() -{ - if ( m_impl->m_session->isRunning() ) - return; - - m_impl->m_session->run(); -} - -void QTermWidget::init() -{ - m_impl->m_terminalDisplay->setSize(80, 40); - - QFont font = QApplication::font(); - font.setFamily("Monospace"); - font.setPointSize(10); - font.setStyleHint(QFont::TypeWriter); - setTerminalFont(font); - setScrollBarPosition(NoScrollBar); - - m_impl->m_session->addView(m_impl->m_terminalDisplay); - - connect(m_impl->m_session, SIGNAL(finished()), this, SLOT(sessionFinished())); -} - - -QTermWidget::~QTermWidget() -{ - emit destroyed(); -} - - -void QTermWidget::setTerminalFont(QFont &font) -{ - if (!m_impl->m_terminalDisplay) - return; - m_impl->m_terminalDisplay->setVTFont(font); -} - -void QTermWidget::setShellProgram(QString &progname) -{ - if (!m_impl->m_session) - return; - m_impl->m_session->setProgram(progname); -} - -void QTermWidget::setArgs(QStringList &args) -{ - if (!m_impl->m_session) - return; - m_impl->m_session->setArguments(args); -} - -void QTermWidget::setTextCodec(QTextCodec *codec) -{ - if (!m_impl->m_session) - return; - m_impl->m_session->setCodec(codec); -} - -void QTermWidget::setColorScheme(int scheme) -{ - switch(scheme) { - case COLOR_SCHEME_WHITE_ON_BLACK: - m_impl->m_terminalDisplay->setColorTable(whiteonblack_color_table); - break; - case COLOR_SCHEME_GREEN_ON_BLACK: - m_impl->m_terminalDisplay->setColorTable(greenonblack_color_table); - break; - case COLOR_SCHEME_BLACK_ON_LIGHT_YELLOW: - m_impl->m_terminalDisplay->setColorTable(blackonlightyellow_color_table); - break; - default: //do nothing - break; - }; -} - -void QTermWidget::setSize(int h, int v) -{ - if (!m_impl->m_terminalDisplay) - return; - m_impl->m_terminalDisplay->setSize(h, v); -} - -void QTermWidget::setHistorySize(int lines) -{ - if (lines < 0) - m_impl->m_session->setHistoryType(HistoryTypeFile()); - else - m_impl->m_session->setHistoryType(HistoryTypeBuffer(lines)); -} - -void QTermWidget::setScrollBarPosition(ScrollBarPosition pos) -{ - if (!m_impl->m_terminalDisplay) - return; - m_impl->m_terminalDisplay->setScrollBarPosition((TerminalDisplay::ScrollBarPosition)pos); -} - -void QTermWidget::sendText(QString &text) -{ - m_impl->m_session->sendText(text); -} - -void QTermWidget::resizeEvent(QResizeEvent*) -{ -//qDebug("global window resizing...with %d %d", this->size().width(), this->size().height()); - m_impl->m_terminalDisplay->resize(this->size()); -} - - - -void QTermWidget::sessionFinished() -{ - emit finished(); -} - - -//#include "moc_consoleq.cpp" -
--- a/gui//qtermwidget.h Thu Apr 07 12:12:13 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/* Copyright (C) 2008 e_k (e_k@users.sourceforge.net) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - - -#ifndef _Q_TERM_WIDGET -#define _Q_TERM_WIDGET - -#include <QtGui> - -struct TermWidgetImpl; - -enum COLOR_SCHEME { COLOR_SCHEME_WHITE_ON_BLACK = 1, - COLOR_SCHEME_GREEN_ON_BLACK, - COLOR_SCHEME_BLACK_ON_LIGHT_YELLOW }; - -class QTermWidget : public QWidget -{ - Q_OBJECT -public: - - enum ScrollBarPosition - { - /** Do not show the scroll bar. */ - NoScrollBar=0, - /** Show the scroll bar on the left side of the display. */ - ScrollBarLeft=1, - /** Show the scroll bar on the right side of the display. */ - ScrollBarRight=2 - }; - - - //Creation of widget - QTermWidget(int startnow = 1, //start shell programm immediatelly - QWidget *parent = 0); - ~QTermWidget(); - - //start shell program if it was not started in constructor - void startShellProgram(); - - //look-n-feel, if you don`t like defaults - - // Terminal font - // Default is application font with family Monospace, size 10 - void setTerminalFont(QFont &font); - - // Shell program, default is /bin/bash - void setShellProgram(QString &progname); - - // Shell program args, default is none - void setArgs(QStringList &args); - - //Text codec, default is UTF-8 - void setTextCodec(QTextCodec *codec); - - //Color scheme, default is white on black - void setColorScheme(int scheme); - - //set size - void setSize(int h, int v); - - // History size for scrolling - void setHistorySize(int lines); //infinite if lines < 0 - - // Presence of scrollbar - void setScrollBarPosition(ScrollBarPosition); - - // Send some text to terminal - void sendText(QString &text); - -signals: - void finished(); - -protected: - virtual void resizeEvent(QResizeEvent *); - -protected slots: - void sessionFinished(); - -private: - void init(); - TermWidgetImpl *m_impl; -}; - - -//Maybe useful, maybe not - -#ifdef __cplusplus -extern "C" -#endif -void *createTermWidget(int startnow, void *parent); - -#endif -
--- a/gui//terminal.cpp Thu Apr 07 12:12:13 2011 +0200 +++ b/gui//terminal.cpp Thu Apr 07 12:17:53 2011 +0200 @@ -10,8 +10,8 @@ void Terminal::launchTerminal() { delete m_terminalWidget; - m_terminalWidget = new QTermWidget(0, this); - m_terminalWidget->setScrollBarPosition(QTermWidget::ScrollBarRight); + m_terminalWidget = new QTerminalWidget(0, this); + m_terminalWidget->setScrollBarPosition(QTerminalWidget::ScrollBarRight); setWidget(m_terminalWidget); QString programName = "octave";
--- a/gui//terminal.h Thu Apr 07 12:12:13 2011 +0200 +++ b/gui//terminal.h Thu Apr 07 12:17:53 2011 +0200 @@ -2,7 +2,7 @@ #define TERMINAL_H #include <QMdiSubWindow> -#include "qtermwidget.h" +#include "QTerminalWidget.h" class Terminal : public QMdiSubWindow { Q_OBJECT @@ -13,7 +13,7 @@ void launchTerminal(); private: - QTermWidget *m_terminalWidget; + QTerminalWidget *m_terminalWidget; }; #endif // TERMINAL_H