Mercurial > hg > octave-avbm
changeset 15646:f570d3baa6fb
Removed unused code.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Fri, 27 Jan 2012 23:21:08 +0100 |
parents | f3ec6627e00d |
children | a044a259c423 |
files | libqterminal/QTerminal.cpp libqterminal/QTerminal.h libqterminal/SessionModel.cpp libqterminal/SessionModel.h libqterminal/SessionView.cpp libqterminal/SessionView.h libqterminal/ShellCommand.cpp libqterminal/ShellCommand.h libqterminal/libqterminal.pro |
diffstat | 9 files changed, 14 insertions(+), 742 deletions(-) [+] |
line wrap: on
line diff
--- a/libqterminal/QTerminal.cpp +++ b/libqterminal/QTerminal.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2008 e_k (e_k@users.sourceforge.net) + Copyright (C) 2012 Jacob Dawid <jacob.dawid@googlemail.com> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -43,24 +44,17 @@ m_sessionModel = new SessionModel(kpty); - m_sessionModel->setTitle(SessionModel::NameRole, "QTermWidget"); - m_sessionModel->setProgram("/bin/bash"); - QStringList args(""); - m_sessionModel->setArguments(args); m_sessionModel->setAutoClose(true); m_sessionModel->setCodec(QTextCodec::codecForName("UTF-8")); - m_sessionModel->setFlowControlEnabled(true); m_sessionModel->setHistoryType(HistoryTypeBuffer(1000)); m_sessionModel->setDarkBackground(true); m_sessionModel->setKeyBindings(""); - m_sessionView = new SessionView(this); m_sessionView->setBellMode(SessionView::NotifyBell); m_sessionView->setTerminalSizeHint(true); m_sessionView->setTripleClickMode(SessionView::SelectWholeLine); m_sessionView->setTerminalSizeStartup(true); - m_sessionView->setRandomSeed(m_sessionModel->sessionId() * 31); m_sessionView->setSize(80, 40); QFont font = QApplication::font(); @@ -81,7 +75,6 @@ emit destroyed(); } - void QTerminal::setTerminalFont(QFont &font) { if(!m_sessionView) @@ -89,27 +82,6 @@ m_sessionView->setVTFont(font); } -void QTerminal::setShellProgram(const QString &progname) -{ - if(!m_sessionModel) - return; - m_sessionModel->setProgram(progname); -} - -void QTerminal::setWorkingDirectory(const QString& dir) -{ - if(!m_sessionModel) - return; - m_sessionModel->setInitialWorkingDirectory(dir); -} - -void QTerminal::setArgs(QStringList &args) -{ - if (!m_sessionModel) - return; - m_sessionModel->setArguments(args); -} - void QTerminal::setTextCodec(QTextCodec *codec) { if(!m_sessionModel) @@ -137,10 +109,19 @@ m_sessionView->setReadOnly(readonly); } +void QTerminal::focusInEvent(QFocusEvent *focusEvent) +{ + Q_UNUSED(focusEvent); + m_sessionView->updateImage(); + m_sessionView->repaint(); + m_sessionView->update(); +} + void QTerminal::resizeEvent(QResizeEvent*) { m_sessionView->resize(this->size()); m_sessionView->updateImage(); + m_sessionView->repaint(); m_sessionView->update(); } @@ -159,30 +140,3 @@ m_sessionView->pasteClipboard(); } -void QTerminal::setFlowControlEnabled(bool enabled) -{ - m_sessionModel->setFlowControlEnabled(enabled); -} - -bool QTerminal::flowControlEnabled(void) -{ - return m_sessionModel->flowControlEnabled(); -} - -void QTerminal::setFlowControlWarningEnabled(bool enabled) -{ - if(flowControlEnabled()) { - m_sessionView->setFlowControlWarningEnabled(enabled); - } -} - -void QTerminal::setEnvironment(const QStringList& environment) -{ - m_sessionModel->setEnvironment(environment); -} - -void* QTerminal::getTerminalDisplay() -{ - return static_cast<void*>(m_sessionView); -} -
--- a/libqterminal/QTerminal.h +++ b/libqterminal/QTerminal.h @@ -30,36 +30,12 @@ public: QTerminal(QWidget *parent = 0); ~QTerminal(); - - void startShellProgram(); void setTerminalFont(QFont &font); - - void setEnvironment(const QStringList& environment); - - void setShellProgram(const QString &progname); - - void setWorkingDirectory(const QString& dir); - void setArgs(QStringList &args); - void setTextCodec(QTextCodec *codec); - void setSize(int h, int v); - void setHistorySize(int lines); - - void setFlowControlEnabled(bool enabled); - - bool flowControlEnabled(void); - - /** - * Sets whether the flow control warning box should be shown - * when the flow control stop key (Ctrl+S) is pressed. - */ - void setFlowControlWarningEnabled(bool enabled); - - void setReadOnly(bool); signals: @@ -69,9 +45,9 @@ void copyClipboard(); void pasteClipboard(); -protected: +protected: + void focusInEvent(QFocusEvent *focusEvent); virtual void resizeEvent(QResizeEvent *); - void *getTerminalDisplay(); protected slots: void sessionFinished();
--- a/libqterminal/SessionModel.cpp +++ b/libqterminal/SessionModel.cpp @@ -39,11 +39,8 @@ #include <QtCore> #include "SessionView.h" -#include "ShellCommand.h" #include "Vt102Emulation.h" -int SessionModel::lastSessionId = 0; - SessionModel::SessionModel(KPty *kpty) : _shellProcess(0) , _emulation(0) @@ -54,22 +51,15 @@ , _wantedClose(false) , _silenceSeconds(10) , _addToUtmp(false) - , _flowControl(true) , _fullScripting(false) - , _sessionId(0) , _hasDarkBackground(false) { _kpty = kpty; //create emulation backend _emulation = new Vt102Emulation(); - - connect( _emulation, SIGNAL( titleChanged( int, const QString & ) ), - this, SLOT( setUserTitle( int, const QString & ) ) ); connect( _emulation, SIGNAL( stateSet(int) ), this, SLOT( activityStateSet(int) ) ); - // connect( _emulation, SIGNAL( zmodemDetected() ), this , - // SLOT( fireZModemDetected() ) ); connect( _emulation, SIGNAL( changeTabTextColorRequest( int ) ), this, SIGNAL( changeTabTextColorRequest( int ) ) ); connect( _emulation, SIGNAL(profileChangeCommandReceived(const QString&)), @@ -78,12 +68,6 @@ // connect( _emulation,SIGNAL(imageSizeChanged(int,int)) , this , // SLOT(onEmulationSizeChange(int,int)) ); - //connect teletype to emulation backend - //_shellProcess->setUtf8Mode(_emulation->utf8()); - - //connect( _shellProcess,SIGNAL(receivedData(const char*,int)),this, - // SLOT(onReceiveBlock(const char*,int)) ); - _selfListener = new SelfListener(kpty->masterFd()); _selfListener->start(); connect( _selfListener, SIGNAL(recvData(const char*,int)), @@ -112,29 +96,12 @@ { return _hasDarkBackground; } -bool SessionModel::isRunning() const -{ - return true; //_shellProcess->isRunning(); -} void SessionModel::setCodec(QTextCodec* codec) { emulation()->setCodec(codec); } -void SessionModel::setProgram(const QString& program) -{ - _program = ShellCommand::expand(program); -} -void SessionModel::setInitialWorkingDirectory(const QString& dir) -{ - _initialWorkingDir = ShellCommand::expand(dir); -} -void SessionModel::setArguments(const QStringList& arguments) -{ - _arguments = ShellCommand::expand(arguments); -} - QList<SessionView*> SessionModel::views() const { return _views; @@ -223,104 +190,6 @@ emit started(); } -void SessionModel::setUserTitle( int what, const QString &caption ) -{ - //set to true if anything is actually changed (eg. old _nameTitle != new _nameTitle ) - bool modified = false; - - // (btw: what=0 changes _userTitle and icon, what=1 only icon, what=2 only _nameTitle - if ((what == 0) || (what == 2)) - { - if ( _userTitle != caption ) { - _userTitle = caption; - modified = true; - } - } - - if ((what == 0) || (what == 1)) - { - if ( _iconText != caption ) { - _iconText = caption; - modified = true; - } - } - - if (what == 11) - { - QString colorString = caption.section(';',0,0); - qDebug() << __FILE__ << __LINE__ << ": setting background colour to " << colorString; - QColor backColor = QColor(colorString); - if (backColor.isValid()){// change color via \033]11;Color\007 - if (backColor != _modifiedBackground) - { - _modifiedBackground = backColor; - - // bail out here until the code to connect the terminal display - // to the changeBackgroundColor() signal has been written - // and tested - just so we don't forget to do this. - Q_ASSERT( 0 ); - - emit changeBackgroundColorRequest(backColor); - } - } - } - - if (what == 30) - { - if ( _nameTitle != caption ) { - setTitle(SessionModel::NameRole,caption); - return; - } - } - - if (what == 31) - { - QString cwd=caption; - cwd=cwd.replace( QRegExp("^~"), QDir::homePath() ); - emit openUrlRequest(cwd); - } - - // change icon via \033]32;Icon\007 - if (what == 32) - { - if ( _iconName != caption ) { - _iconName = caption; - - modified = true; - } - } - - if (what == 50) - { - emit profileChangeCommandReceived(caption); - return; - } - - if ( modified ) - emit titleChanged(); -} - -QString SessionModel::userTitle() const -{ - return _userTitle; -} -void SessionModel::setTabTitleFormat(TabTitleContext context , const QString& format) -{ - if ( context == LocalTabTitle ) - _localTabTitleFormat = format; - else if ( context == RemoteTabTitle ) - _remoteTabTitleFormat = format; -} -QString SessionModel::tabTitleFormat(TabTitleContext context) const -{ - if ( context == LocalTabTitle ) - return _localTabTitleFormat; - else if ( context == RemoteTabTitle ) - return _remoteTabTitleFormat; - - return QString(); -} - void SessionModel::monitorTimerDone() { //FIXME: The idea here is that the notification popup will appear to tell the user than output from @@ -349,9 +218,7 @@ { if (state==NOTIFYBELL) { - QString s; s.sprintf("Bell in session '%s'",_nameTitle.toAscii().data()); - - emit bellRequest( s ); + emit bellRequest(""); } else if (state==NOTIFYACTIVITY) { @@ -463,73 +330,11 @@ return _emulation->keyBindings(); } -QStringList SessionModel::environment() const -{ - return _environment; -} - -void SessionModel::setEnvironment(const QStringList& environment) -{ - _environment = environment; -} - -int SessionModel::sessionId() const -{ - return _sessionId; -} - void SessionModel::setKeyBindings(const QString &id) { _emulation->setKeyBindings(id); } -void SessionModel::setTitle(TitleRole role , const QString& newTitle) -{ - if ( title(role) != newTitle ) - { - if ( role == NameRole ) - _nameTitle = newTitle; - else if ( role == DisplayedTitleRole ) - _displayTitle = newTitle; - - emit titleChanged(); - } -} - -QString SessionModel::title(TitleRole role) const -{ - if ( role == NameRole ) - return _nameTitle; - else if ( role == DisplayedTitleRole ) - return _displayTitle; - else - return QString(); -} - -void SessionModel::setIconName(const QString& iconName) -{ - if ( iconName != _iconName ) - { - _iconName = iconName; - emit titleChanged(); - } -} - -void SessionModel::setIconText(const QString& iconText) -{ - _iconText = iconText; -} - -QString SessionModel::iconName() const -{ - return _iconName; -} - -QString SessionModel::iconText() const -{ - return _iconText; -} - void SessionModel::setHistoryType(const HistoryType &hType) { _emulation->setHistory(hType); @@ -545,16 +350,6 @@ _emulation->clearHistory(); } -QStringList SessionModel::arguments() const -{ - return _arguments; -} - -QString SessionModel::program() const -{ - return _program; -} - // unused currently bool SessionModel::isMonitorActivity() const { return _monitorActivity; } // unused currently @@ -597,23 +392,6 @@ _addToUtmp = set; } -void SessionModel::setFlowControlEnabled(bool enabled) -{ - if (_flowControl == enabled) - return; - - _flowControl = enabled; - - //if (_shellProcess) - // _shellProcess->setXonXoff(_flowControl); - - emit flowControlEnabledChanged(enabled); -} -bool SessionModel::flowControlEnabled() const -{ - return _flowControl; -} - void SessionModel::onReceiveBlock( const char* buf, int len ) { _emulation->receiveData( buf, len );
--- a/libqterminal/SessionModel.h +++ b/libqterminal/SessionModel.h @@ -57,7 +57,6 @@ Q_OBJECT public: - Q_PROPERTY(QString name READ nameTitle) Q_PROPERTY(QString keyBindings READ keyBindings WRITE setKeyBindings) Q_PROPERTY(QSize size READ size WRITE setSize) @@ -75,11 +74,6 @@ SessionModel(KPty *kpty); ~SessionModel(); - /** - * Returns true if the session is currently running. This will be true - * after run() has been called successfully. - */ - bool isRunning() const; /** * Sets the profile associated with this session. @@ -126,76 +120,7 @@ */ Emulation* emulation() const; - /** - * Returns the environment of this session as a list of strings like - * VARIABLE=VALUE - */ - QStringList environment() const; - /** - * Sets the environment for this session. - * @p environment should be a list of strings like - * VARIABLE=VALUE - */ - void setEnvironment(const QStringList& environment); - /** Returns the unique ID for this session. */ - int sessionId() const; - - /** - * Return the session title set by the user (ie. the program running - * in the terminal), or an empty string if the user has not set a custom title - */ - QString userTitle() const; - - /** - * This enum describes the contexts for which separate - * tab title formats may be specified. - */ - enum TabTitleContext - { - /** Default tab title format */ - LocalTabTitle, - /** - * Tab title format used session currently contains - * a connection to a remote computer (via SSH) - */ - RemoteTabTitle - }; - /** - * Sets the format used by this session for tab titles. - * - * @param context The context whoose format should be set. - * @param format The tab title format. This may be a mixture - * of plain text and dynamic elements denoted by a '%' character - * followed by a letter. (eg. %d for directory). The dynamic - * elements available depend on the @p context - */ - void setTabTitleFormat(TabTitleContext context , const QString& format); - /** Returns the format used by this session for tab titles. */ - QString tabTitleFormat(TabTitleContext context) const; - - - /** Returns the arguments passed to the shell process when run() is called. */ - QStringList arguments() const; - /** Returns the program name of the shell process started when run() is called. */ - QString program() const; - - /** - * Sets the command line arguments which the session's program will be passed when - * run() is called. - */ - void setArguments(const QStringList& arguments); - /** Sets the program to be executed when run() is called. */ - void setProgram(const QString& program); - - /** Returns the session's current working directory. */ - QString initialWorkingDirectory() { return _initialWorkingDir; } - - /** - * Sets the initial working directory for the session when it is run - * This has no effect once the session has been started. - */ - void setInitialWorkingDirectory( const QString& dir ); /** * Sets the type of history store used by this session. @@ -254,33 +179,6 @@ /** Returns the name of the key bindings used by this session. */ QString keyBindings() const; - /** - * This enum describes the available title roles. - */ - enum TitleRole - { - /** The name of the session. */ - NameRole, - /** The title of the session which is displayed in tabs etc. */ - DisplayedTitleRole - }; - - /** Sets the session's title for the specified @p role to @p title. */ - void setTitle(TitleRole role , const QString& title); - /** Returns the session's title for the specified @p role. */ - QString title(TitleRole role) const; - /** Convenience method used to read the name property. Returns title(Session::NameRole). */ - QString nameTitle() const { return title(SessionModel::NameRole); } - - /** Sets the name of the icon associated with this session. */ - void setIconName(const QString& iconName); - /** Returns the name of the icon associated with this session. */ - QString iconName() const; - - /** Sets the text of the icon associated with this session. */ - void setIconText(const QString& iconText); - /** Returns the text of the icon associated with this session. */ - QString iconText() const; /** Specifies whether a utmp entry should be created for the pty used by this session. */ void setAddToUtmp(bool); @@ -292,27 +190,11 @@ void setAutoClose(bool b) { _autoClose = b; } /** - * Sets whether flow control is enabled for this terminal - * session. - */ - void setFlowControlEnabled(bool enabled); - - /** Returns whether flow control is enabled for this terminal session. */ - bool flowControlEnabled() const; - - /** * Sends @p text to the current foreground terminal program. */ void sendText(const QString& text) const; - /** - * Returns the process id of the terminal's foreground process. - * This is initially the same as processId() but can change - * as the user starts other programs inside the terminal. - */ - int foregroundProcessId() const; - /** Returns the terminal session's window size in lines and columns. */ QSize size(); /** @@ -364,13 +246,6 @@ */ void close(); - /** - * Changes the session title or other customizable aspects of the terminal - * emulation display. For a list of what may be changed see the - * Emulation::titleChanged() signal. - */ - void setUserTitle( int, const QString &caption ); - signals: /** Emitted when the terminal process starts. */ @@ -436,13 +311,6 @@ */ void profileChangeCommandReceived(const QString& text); - /** - * Emitted when the flow control state changes. - * - * @param enabled True if flow control is enabled or false otherwise. - */ - void flowControlEnabledChanged(bool enabled); - private slots: void done(int); @@ -481,27 +349,12 @@ int _silenceSeconds; - QString _nameTitle; - QString _displayTitle; - QString _userTitle; - - QString _localTabTitleFormat; - QString _remoteTabTitleFormat; - - QString _iconName; - QString _iconText; // as set by: echo -en '\033]1;IconText\007 bool _addToUtmp; - bool _flowControl; bool _fullScripting; - QString _program; - QStringList _arguments; - - QStringList _environment; - int _sessionId; int _masterFd; int _slaveFd; - QString _initialWorkingDir; + SelfListener *_selfListener; KPty * _kpty; @@ -511,9 +364,6 @@ QString _profileKey; bool _hasDarkBackground; - - static int lastSessionId; - };
--- a/libqterminal/SessionView.cpp +++ b/libqterminal/SessionView.cpp @@ -261,7 +261,6 @@ ,_possibleTripleClick(false) ,_resizeWidget(0) ,_resizeTimer(0) -,_flowControlWarningEnabled(false) ,_outputSuspendedLabel(0) ,_lineSpacing(0) ,_colorsInverted(false) @@ -2284,35 +2283,12 @@ /* */ /* ------------------------------------------------------------------------- */ -void SessionView::setFlowControlWarningEnabled( bool enable ) -{ - _flowControlWarningEnabled = enable; - - // if the dialog is currently visible and the flow control warning has - // been disabled then hide the dialog - if (!enable) - outputSuspended(false); -} - void SessionView::keyPressEvent( QKeyEvent* event ) { //qDebug("%s %d keyPressEvent and key is %d", __FILE__, __LINE__, event->key()); bool emitKeyPressSignal = true; - // XonXoff flow control - if (event->modifiers() & Qt::ControlModifier && _flowControlWarningEnabled) - { - if ( event->key() == Qt::Key_S ) { - //qDebug("%s %d keyPressEvent, output suspended", __FILE__, __LINE__); - emit flowControlKeyPressed(true /*output suspended*/); - } - else if ( event->key() == Qt::Key_Q ) { - //qDebug("%s %d keyPressEvent, output enabled", __FILE__, __LINE__); - emit flowControlKeyPressed(false /*output enabled*/); - } - } - // Keyboard-based navigation if ( event->modifiers() == Qt::ShiftModifier ) {
--- a/libqterminal/SessionView.h +++ b/libqterminal/SessionView.h @@ -418,12 +418,6 @@ * display. */ void pasteSelection(); - - /** - * Changes whether the flow control warning box should be shown when the flow control - * stop key (Ctrl+S) are pressed. - */ - void setFlowControlWarningEnabled(bool enabled); /** * Causes the widget to display or hide a message informing the user that terminal
deleted file mode 100644 --- a/libqterminal/ShellCommand.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - Copyright (C) 2007 by Robert Knight <robertknight@gmail.com> - - Rewritten for QT4 by e_k <e_k at users.sourceforge.net>, Copyright (C)2008 - - 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 2 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, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301 USA. -*/ - -// Own -#include "ShellCommand.h" - -//some versions of gcc(4.3) require explicit include -#include <cstdlib> - -// expands environment variables in 'text' -// function copied from kdelibs/kio/kio/kurlcompletion.cpp -static bool expandEnv(QString& text); - -ShellCommand::ShellCommand(const QString& fullCommand) -{ - bool inQuotes = false; - - QString builder; - - for ( int i = 0 ; i < fullCommand.count() ; i++ ) - { - QChar ch = fullCommand[i]; - - const bool isLastChar = ( i == fullCommand.count() - 1 ); - const bool isQuote = ( ch == '\'' || ch == '\"' ); - - if ( !isLastChar && isQuote ) - inQuotes = !inQuotes; - else - { - if ( (!ch.isSpace() || inQuotes) && !isQuote ) - builder.append(ch); - - if ( (ch.isSpace() && !inQuotes) || ( i == fullCommand.count()-1 ) ) - { - _arguments << builder; - builder.clear(); - } - } - } -} -ShellCommand::ShellCommand(const QString& command , const QStringList& arguments) -{ - _arguments = arguments; - - if ( !_arguments.isEmpty() ) - _arguments[0] == command; -} -QString ShellCommand::fullCommand() const -{ - return _arguments.join(QChar(' ')); -} -QString ShellCommand::command() const -{ - if ( !_arguments.isEmpty() ) - return _arguments[0]; - else - return QString(); -} -QStringList ShellCommand::arguments() const -{ - return _arguments; -} -bool ShellCommand::isRootCommand() const -{ - Q_ASSERT(0); // not implemented yet - return false; -} -bool ShellCommand::isAvailable() const -{ - Q_ASSERT(0); // not implemented yet - return false; -} -QStringList ShellCommand::expand(const QStringList& items) -{ - QStringList result; - - foreach( QString item , items ) - result << expand(item); - - return result; -} -QString ShellCommand::expand(const QString& text) -{ - QString result = text; - expandEnv(result); - return result; -} - -/* - * expandEnv - * - * Expand environment variables in text. Escaped '$' characters are ignored. - * Return true if any variables were expanded - */ -static bool expandEnv( QString &text ) -{ - // Find all environment variables beginning with '$' - // - int pos = 0; - - bool expanded = false; - - while ( (pos = text.indexOf(QLatin1Char('$'), pos)) != -1 ) { - - // Skip escaped '$' - // - if ( pos > 0 && text.at(pos-1) == QLatin1Char('\\') ) { - pos++; - } - // Variable found => expand - // - else { - // Find the end of the variable = next '/' or ' ' - // - int pos2 = text.indexOf( QLatin1Char(' '), pos+1 ); - int pos_tmp = text.indexOf( QLatin1Char('/'), pos+1 ); - - if ( pos2 == -1 || (pos_tmp != -1 && pos_tmp < pos2) ) - pos2 = pos_tmp; - - if ( pos2 == -1 ) - pos2 = text.length(); - - // Replace if the variable is terminated by '/' or ' ' - // and defined - // - if ( pos2 >= 0 ) { - int len = pos2 - pos; - QString key = text.mid( pos+1, len-1); - QString value = - QString::fromLocal8Bit( ::getenv(key.toLocal8Bit()) ); - - if ( !value.isEmpty() ) { - expanded = true; - text.replace( pos, len, value ); - pos = pos + value.length(); - } - else { - pos = pos2; - } - } - } - } - - return expanded; -}
deleted file mode 100644 --- a/libqterminal/ShellCommand.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - Copyright (C) 2007 by Robert Knight <robertknight@gmail.com> - - Rewritten for QT4 by e_k <e_k at users.sourceforge.net>, Copyright (C)2008 - - 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 2 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, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301 USA. -*/ - -#ifndef SHELLCOMMAND_H -#define SHELLCOMMAND_H - -// Qt -#include <QtCore/QStringList> - -/** - * A class to parse and extract information about shell commands. - * - * ShellCommand can be used to: - * - * <ul> - * <li>Take a command-line (eg "/bin/sh -c /path/to/my/script") and split it - * into its component parts (eg. the command "/bin/sh" and the arguments - * "-c","/path/to/my/script") - * </li> - * <li>Take a command and a list of arguments and combine them to - * form a complete command line. - * </li> - * <li>Determine whether the binary specified by a command exists in the - * user's PATH. - * </li> - * <li>Determine whether a command-line specifies the execution of - * another command as the root user using su/sudo etc. - * </li> - * </ul> - */ -class ShellCommand -{ -public: - /** - * Constructs a ShellCommand from a command line. - * - * @param fullCommand The command line to parse. - */ - ShellCommand(const QString& fullCommand); - /** - * Constructs a ShellCommand with the specified @p command and @p arguments. - */ - ShellCommand(const QString& command , const QStringList& arguments); - - /** Returns the command. */ - QString command() const; - /** Returns the arguments. */ - QStringList arguments() const; - - /** - * Returns the full command line. - */ - QString fullCommand() const; - - /** Returns true if this is a root command. */ - bool isRootCommand() const; - /** Returns true if the program specified by @p command() exists. */ - bool isAvailable() const; - - /** Expands environment variables in @p text .*/ - static QString expand(const QString& text); - - /** Expands environment variables in each string in @p list. */ - static QStringList expand(const QStringList& items); - -private: - QStringList _arguments; -}; - -#endif // SHELLCOMMAND_H -
--- a/libqterminal/libqterminal.pro +++ b/libqterminal/libqterminal.pro @@ -25,7 +25,6 @@ QTerminal.h \ Screen.h \ ScreenWindow.h \ - ShellCommand.h \ TerminalCharacterDecoder.h \ Vt102Emulation.h \ SessionModel.h \ @@ -41,7 +40,6 @@ QTerminal.cpp \ Screen.cpp \ ScreenWindow.cpp \ - ShellCommand.cpp \ TerminalCharacterDecoder.cpp \ Vt102Emulation.cpp \ SessionModel.cpp \