Mercurial > hg > octave-avbm
changeset 13568:d3bede98d798
Removed a bunch of sourcecode again.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Mon, 01 Aug 2011 11:11:55 +0200 |
parents | 395393bd2f56 |
children | 640190448fdf |
files | gui/src/terminal/Pty.cpp gui/src/terminal/Pty.h gui/src/terminal/QTerminalWidget.cpp gui/src/terminal/Session.cpp gui/src/terminal/Session.h gui/src/terminal/TerminalDisplay.cpp |
diffstat | 6 files changed, 27 insertions(+), 485 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/src/terminal/Pty.cpp +++ b/gui/src/terminal/Pty.cpp @@ -129,71 +129,13 @@ return _eraseChar; } -void -Pty::addEnvironmentVariables (const QStringList & environment) -{ - QListIterator < QString > iter (environment); - while (iter.hasNext ()) - { - QString pair = iter.next (); - - // split on the first '=' character - int pos = pair.indexOf ('='); - - if (pos >= 0) - { - QString variable = pair.left (pos); - QString value = pair.mid (pos + 1); - - setEnvironmentVariable (variable, value); - } - } -} - int Pty::start (const QString & program, - const QStringList & programArguments, - const QStringList & environment, - ulong winid, - bool addToUtmp, - const QString & dbusService, const QString & dbusSession) + const QStringList & programArguments) { - Q_UNUSED(dbusService); - Q_UNUSED(dbusSession); - Q_UNUSED(winid); clearProgram (); - - // For historical reasons, the first argument in programArguments is the - // name of the program to execute, so create a list consisting of all - // but the first argument to pass to setProgram() - Q_ASSERT (programArguments.count () >= 1); setProgram (program.toLatin1 (), programArguments.mid (1)); - addEnvironmentVariables (environment); - - //if (!dbusService.isEmpty ()) - // setEnv ("KONSOLE_DBUS_SERVICE", dbusService); - //if (!dbusSession.isEmpty ()) - // setEnv ("KONSOLE_DBUS_SESSION", dbusSession); - - //setEnv ("WINDOWID", QString::number (winid)); - - // unless the LANGUAGE environment variable has been set explicitly - // set it to a null string - // this fixes the problem where KCatalog sets the LANGUAGE environment - // variable during the application's startup to something which - // differs from LANG,LC_* etc. and causes programs run from - // the terminal to display messages in the wrong language - // - // this can happen if LANG contains a language which KDE - // does not have a translation for - // - // BR:149300 - setEnvironmentVariable ("LANGUAGE", QString (), - false /* do not overwrite existing value if any */ ); - setUseUtmp (addToUtmp); - - struct::termios ttmode; pty ()->tcGetAttr (&ttmode); if (!_xonXoff) @@ -210,7 +152,7 @@ if (_eraseChar != 0) ttmode.c_cc[VERASE] = _eraseChar; - pty()->tcSetAttr(&ttmode); + pty ()->tcSetAttr(&ttmode); pty ()->setWinSize (_windowLines, _windowColumns); KProcess::start (); @@ -274,19 +216,6 @@ emit receivedData (data.constData (), data.count ()); } -int -Pty::foregroundProcessGroup () const -{ - int pid = tcgetpgrp (pty ()->masterFd ()); - - if (pid != -1) - { - return pid; - } - - return 0; -} - void Pty::setupChildProcess () {
--- a/gui/src/terminal/Pty.h +++ b/gui/src/terminal/Pty.h @@ -81,21 +81,9 @@ * @param environment A list of key=value pairs which will be added * to the environment for the new process. At the very least this * should include an assignment for the TERM environment variable. - * @param winid Specifies the value of the WINDOWID environment variable - * in the process's environment. - * @param addToUtmp Specifies whether a utmp entry should be created for - * the pty used. See K3Process::setUsePty() - * @param dbusService Specifies the value of the KONSOLE_DBUS_SERVICE - * environment variable in the process's environment. - * @param dbusSession Specifies the value of the KONSOLE_DBUS_SESSION - * environment variable in the process's environment. */ int start (const QString & program, - const QStringList & arguments, - const QStringList & environment, - ulong winid, - bool addToUtmp, - const QString & dbusService, const QString & dbusSession); + const QStringList & arguments); /** TODO: Document me */ void setWriteable (bool writeable); @@ -125,16 +113,6 @@ /** */ char erase () const; - /** - * Returns the process id of the teletype's current foreground - * process. This is the process which is currently reading - * input sent to the terminal via. sendData() - * - * If there is a problem reading the foreground process group, - * 0 will be returned. - */ - int foregroundProcessGroup () const; - public slots: /** * Put the pty into UTF-8 mode on systems which support it. @@ -170,10 +148,6 @@ private: void init (); - // takes a list of key=value pairs and adds them - // to the environment for the process - void addEnvironmentVariables (const QStringList & environment); - int _windowColumns; int _windowLines; char _eraseChar;
--- a/gui/src/terminal/QTerminalWidget.cpp +++ b/gui/src/terminal/QTerminalWidget.cpp @@ -27,15 +27,14 @@ TerminalDisplay *m_terminalDisplay; Session *m_session; Session *createSession (); - TerminalDisplay *createTerminalDisplay (Session * session, - QWidget * parent); + TerminalDisplay *createTerminalDisplay (QWidget * parent); }; TermWidgetImpl::TermWidgetImpl (QWidget * parent) { QPalette palette = QApplication::palette (); m_session = createSession (); - m_terminalDisplay = createTerminalDisplay (this->m_session, parent); + m_terminalDisplay = createTerminalDisplay (parent); m_terminalDisplay->setBackgroundColor (palette.color (QPalette::Base)); m_terminalDisplay->setForegroundColor (palette.color (QPalette::Text)); } @@ -57,14 +56,13 @@ } TerminalDisplay * -TermWidgetImpl::createTerminalDisplay (Session * session, QWidget * parent) +TermWidgetImpl::createTerminalDisplay (QWidget * parent) { 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; } @@ -111,8 +109,8 @@ void QTerminalWidget::openTeletype (int fd) { - if (m_impl->m_session->isRunning ()) - return; + //if (m_impl->m_session->isRunning ()) + // return; m_impl->m_session->openTeletype (fd); }
--- a/gui/src/terminal/Session.cpp +++ b/gui/src/terminal/Session.cpp @@ -97,13 +97,9 @@ Session::Session (QObject * parent): QObject (parent), _shellProcess (0), _emulation (0), _monitorActivity (false), _monitorSilence (false), _notifiedActivity (false), _autoClose (true), -_wantedClose (false), _silenceSeconds (10), _addToUtmp (true), +_wantedClose (false), _silenceSeconds (10), _flowControl (true), _fullScripting (false), _sessionId (0), -/*_sessionProcessInfo (0), _foregroundProcessInfo (0),*/ _foregroundPid (0) - //, _zmodemBusy(false) - //, _zmodemProc(0) - //, _zmodemProgress(0) - , _hasDarkBackground (false) +_hasDarkBackground (false) { _uniqueIdentifier = createUuid (); @@ -170,36 +166,6 @@ SLOT (updateWindowSize (int, int))); } -WId -Session::windowId () const -{ - // Returns a window ID for this session which is used - // to set the WINDOWID environment variable in the shell - // process. - // - // Sessions can have multiple views or no views, which means - // that a single ID is not always going to be accurate. - // - // If there are no views, the window ID is just 0. If - // there are multiple views, then the window ID for the - // top-level window which contains the first view is - // returned - - if (_views.count () == 0) - return 0; - else - { - QWidget *window = _views.first (); - - Q_ASSERT (window); - - while (window->parentWidget () != 0) - window = window->parentWidget (); - - return window->winId (); - } -} - void Session::setDarkBackground (bool darkBackground) { @@ -378,15 +344,6 @@ _emulation->receiveData (redPenOff, strlen (redPenOff)); } -QString -Session::shellSessionId () const -{ - QString friendlyUuid (_uniqueIdentifier.toString ()); - friendlyUuid.remove ('-').remove ('{').remove ('}'); - - return friendlyUuid; -} - void Session::run () { @@ -439,8 +396,6 @@ QStringList arguments = _arguments.join (QChar (' ')).isEmpty ()? QStringList () << exec : _arguments; - // JPS: commented out for lack of DBUS support by default on OSX - QString dbusService = ""; //QDBusConnection::sessionBus().baseService(); if (!_initialWorkingDir.isEmpty ()) _shellProcess->setWorkingDirectory (_initialWorkingDir); else @@ -456,16 +411,9 @@ QString backgroundColorHint = _hasDarkBackground ? "COLORFGBG=15;0" : "COLORFGBG=0;15"; _environment << backgroundColorHint; - _environment << QString ("SHELL_SESSION_ID=%1").arg (shellSessionId ()); int result = _shellProcess->start (exec, - arguments, - _environment, - windowId (), - _addToUtmp, - dbusService, - (QLatin1String ("/Sessions/") + - QString::number (_sessionId))); + arguments); if (result < 0) { @@ -565,26 +513,6 @@ } void -Session::setTabTitleFormat (TabTitleContext context, const QString & format) -{ - if (context == LocalTabTitle) - _localTabTitleFormat = format; - else if (context == RemoteTabTitle) - _remoteTabTitleFormat = format; -} - -QString -Session::tabTitleFormat (TabTitleContext context) const -{ - if (context == LocalTabTitle) - return _localTabTitleFormat; - else if (context == RemoteTabTitle) - return _remoteTabTitleFormat; - - return QString (); -} - -void Session::monitorTimerDone () { //FIXME: The idea here is that the notification popup will appear to tell the user than output from @@ -636,8 +564,7 @@ { if (state == NOTIFYBELL) { - emit bellRequest (QString ("Bell in session '%1'"). - arg (_nameTitle.toLatin1 ().data ())); + // empty } else if (state == NOTIFYACTIVITY) { @@ -871,12 +798,6 @@ _environment = environment; } -int -Session::sessionId () const -{ - return _sessionId; -} - void Session::setKeyBindings (const QString & id) { @@ -966,62 +887,6 @@ return _program; } -// unused currently -bool -Session::isMonitorActivity () const -{ - return _monitorActivity; -} - -// unused currently -bool -Session::isMonitorSilence () const -{ - return _monitorSilence; -} - -void -Session::setMonitorActivity (bool _monitor) -{ - _monitorActivity = _monitor; - _notifiedActivity = false; - - activityStateSet (NOTIFYNORMAL); -} - -void -Session::setMonitorSilence (bool _monitor) -{ - if (_monitorSilence == _monitor) - return; - - _monitorSilence = _monitor; - if (_monitorSilence) - { - _monitorTimer->start (_silenceSeconds * 1000); - } - else - _monitorTimer->stop (); - - activityStateSet (NOTIFYNORMAL); -} - -void -Session::setMonitorSilenceSeconds (int seconds) -{ - _silenceSeconds = seconds; - if (_monitorSilence) - { - _monitorTimer->start (_silenceSeconds * 1000); - } -} - -void -Session::setAddToUtmp (bool set) -{ - _addToUtmp = set; -} - void Session::setFlowControlEnabled (bool enabled) { @@ -1063,12 +928,6 @@ emit resizeRequest (size); } -int -Session::processId () const -{ - return _shellProcess->pid (); -} - void Session::setTitle (int role, const QString & title) { @@ -1097,34 +956,6 @@ } } -void -Session::setTabTitleFormat (int context, const QString & format) -{ - switch (context) - { - case (0): - this->setTabTitleFormat (Session::LocalTabTitle, format); - break; - case (1): - this->setTabTitleFormat (Session::RemoteTabTitle, format); - break; - } -} - -QString -Session::tabTitleFormat (int context) const -{ - switch (context) - { - case (0): - return this->tabTitleFormat (Session::LocalTabTitle); - case (1): - return this->tabTitleFormat (Session::RemoteTabTitle); - default: - return QString (); - } -} - SessionGroup::SessionGroup (QObject * parent):QObject (parent), _masterMode (0) { }
--- a/gui/src/terminal/Session.h +++ b/gui/src/terminal/Session.h @@ -35,11 +35,9 @@ #include "History.h" class KProcess; -class KUrl; class Emulation; class Pty; class TerminalDisplay; - //class ZModemDialog; /** * Represents a terminal session consisting of a pseudo-teletype and a terminal emulation. * The pseudo-teletype (or PTY) handles I/O between the terminal process and Konsole. @@ -53,11 +51,8 @@ */ class Session:public QObject { -Q_OBJECT Q_CLASSINFO ("D-Bus Interface", "org.kde.konsole.Session") public: - Q_PROPERTY (QString name READ nameTitle) - Q_PROPERTY (int processId READ processId) - Q_PROPERTY (QString keyBindings READ keyBindings WRITE setKeyBindings) - Q_PROPERTY (QSize size READ size WRITE setSize) +Q_OBJECT +public: /** * Constructs a new session. * @@ -121,44 +116,6 @@ */ Emulation *emulation () const; - /** Returns the unique ID for this session. */ - int sessionId () 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 - }; - - /** - * Returns true if the session currently contains a connection to a - * remote computer. It currently supports ssh. - */ - bool isRemote (); - - /** - * 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. */ @@ -185,11 +142,6 @@ void setInitialWorkingDirectory (const QString & dir); /** - * Returns the current directory of the foreground process in the session - */ - //QString currentWorkingDirectory (); - - /** * Sets the type of history store used by this session. * Lines of output produced by the terminal are added * to the history store. The type of history store @@ -242,16 +194,12 @@ { return title (Session::NameRole); } - /** Returns a title generated from tab format and process information. */ - QString getDynamicTitle (); /** 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; - /** Return URL for the session. */ - //KUrl getUrl(); /** Sets the text of the icon associated with this session. */ void setIconText (const QString & iconText); @@ -264,12 +212,6 @@ /** Returns the session's title for the specified @p role. */ QString title (TitleRole role) const; - /** - * Specifies whether a utmp entry should be created for the pty used by this session. - * If true, KPty::login() is called when the session is started. - */ - void setAddToUtmp (bool); - /** * Specifies whether to close the session automatically when the terminal * process terminates. @@ -282,9 +224,6 @@ /** Returns true if the user has started a program in the session. */ bool isForegroundProcessActive (); - /** Returns the name of the current foreground process. */ - //QString foregroundProcessName (); - /** Returns the terminal session's window size in lines and columns. */ QSize size (); /** @@ -317,10 +256,6 @@ */ void refresh (); - // void startZModem(const QString &rz, const QString &dir, const QStringList &list); - // void cancelZModem(); - // bool isZModemBusy() { return _zmodemBusy; } - /** * Possible values of the @p what parameter for setUserTitle() * See "Operating System Controls" section on http://rtfm.etla.org/xterm/ctlseq.html @@ -339,10 +274,6 @@ // Sets the text codec used by this sessions terminal emulation. void setCodec (QTextCodec * codec); - // session management - //void saveSession(KConfigGroup& group); - //void restoreSession(KConfigGroup& group); - public slots: /** * Starts the terminal session. @@ -355,14 +286,14 @@ * Returns the environment of this session as a list of strings like * VARIABLE=VALUE */ - Q_SCRIPTABLE QStringList environment () const; + QStringList environment () const; /** * Sets the environment for this session. * @p environment should be a list of strings like * VARIABLE=VALUE */ - Q_SCRIPTABLE void setEnvironment (const QStringList & environment); + void setEnvironment (const QStringList & environment); /** * Closes the terminal session. This sends a hangup signal @@ -371,7 +302,7 @@ * then the terminal connection (the pty) is closed and Konsole waits for the * process to exit. */ - Q_SCRIPTABLE void close (); + void close (); /** * Changes the session title or other customizable aspects of the terminal @@ -384,114 +315,51 @@ void setUserTitle (int what, const QString & caption); /** - * Enables monitoring for activity in the session. - * This will cause notifySessionState() to be emitted - * with the NOTIFYACTIVITY state flag when output is - * received from the terminal. - */ - Q_SCRIPTABLE void setMonitorActivity (bool); - - /** Returns true if monitoring for activity is enabled. */ - Q_SCRIPTABLE bool isMonitorActivity () const; - - /** - * Enables monitoring for silence in the session. - * This will cause notifySessionState() to be emitted - * with the NOTIFYSILENCE state flag when output is not - * received from the terminal for a certain period of - * time, specified with setMonitorSilenceSeconds() - */ - Q_SCRIPTABLE void setMonitorSilence (bool); - - /** - * Returns true if monitoring for inactivity (silence) - * in the session is enabled. - */ - Q_SCRIPTABLE bool isMonitorSilence () const; - - /** See setMonitorSilence() */ - Q_SCRIPTABLE void setMonitorSilenceSeconds (int seconds); - - /** * Sets whether flow control is enabled for this terminal * session. */ - Q_SCRIPTABLE void setFlowControlEnabled (bool enabled); + void setFlowControlEnabled (bool enabled); /** Returns whether flow control is enabled for this terminal session. */ - Q_SCRIPTABLE bool flowControlEnabled () const; + bool flowControlEnabled () const; /** * Sends @p text to the current foreground terminal program. */ - Q_SCRIPTABLE void sendText (const QString & text) const; + void sendText (const QString & text) const; /** * Sends a mouse event of type @p eventType emitted by button * @p buttons on @p column/@p line to the current foreground * terminal program */ - Q_SCRIPTABLE void sendMouseEvent (int buttons, int column, int line, + void sendMouseEvent (int buttons, int column, int line, int eventType); - /** - * Returns the process id of the terminal process. - * This is the id used by the system API to refer to the process. - */ - Q_SCRIPTABLE int processId () 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. - */ - //Q_SCRIPTABLE int foregroundProcessId (); - /** Sets the text codec used by this sessions terminal emulation. * Overloaded to accept a QByteArray for convenience since DBus * does not accept QTextCodec directky. */ - Q_SCRIPTABLE bool setCodec (QByteArray codec); + bool setCodec (QByteArray codec); /** Returns the codec used to decode incoming characters in this * terminal emulation */ - Q_SCRIPTABLE QByteArray codec (); + QByteArray codec (); /** Sets the session's title for the specified @p role to @p title. * This is an overloaded member function for setTitle(TitleRole, QString) * provided for convenience since enum data types may not be * exported directly through DBus */ - Q_SCRIPTABLE void setTitle (int role, const QString & title); + void setTitle (int role, const QString & title); /** Returns the session's title for the specified @p role. * This is an overloaded member function for setTitle(TitleRole) * provided for convenience since enum data types may not be * exported directly through DBus */ - Q_SCRIPTABLE QString title (int role) const; - - /** Returns the "friendly" version of the QUuid of this session. - * This is a QUuid with the braces and dashes removed, so it cannot be - * used to construct a new QUuid. The same text appears in the - * SHELL_SESSION_ID environment variable. - */ - Q_SCRIPTABLE QString shellSessionId () const; - - /** Sets the session's tab title format for the specified @p context to @p format. - * This is an overloaded member function for setTabTitleFormat(TabTitleContext, QString) - * provided for convenience since enum data types may not be - * exported directly through DBus - */ - Q_SCRIPTABLE void setTabTitleFormat (int context, const QString & format); - - /** Returns the session's tab title format for the specified @p context. - * This is an overloaded member function for tabTitleFormat(TitleRole) - * provided for convenience since enum data types may not be - * exported directly through DBus - */ - Q_SCRIPTABLE QString tabTitleFormat (int context) const; + QString title (int role) const; signals: @@ -519,9 +387,6 @@ */ void stateChanged (int state); - /** Emitted when a bell event occurs in the session. */ - void bellRequest (const QString & message); - /** * Requests that the color the text for any tabs associated with * this session should be changed; @@ -568,9 +433,8 @@ */ void flowControlEnabledChanged (bool enabled); - private slots:void done (int); - - // void fireZModemDetected(); +private slots: + void done (int); void onReceiveBlock (const char *buffer, int len); void monitorTimerDone (); @@ -582,17 +446,11 @@ //automatically detach views from sessions when view is destroyed void viewDestroyed (QObject * view); - //void zmodemReadStatus(); - //void zmodemReadAndSendBlock(); - //void zmodemRcvBlock(const char *data, int len); - //void zmodemFinished(); - void updateFlowControlState (bool suspended); void updateWindowSize (int lines, int columns); private: void updateTerminalSize (); - WId windowId () const; bool kill (int signal); // print a warning message in the terminal. This is used // if the program fails to start, or if the shell exits in @@ -628,7 +486,6 @@ QString _iconName; QString _iconText; // as set by: echo -en '\033]1;IconText\007 - bool _addToUtmp; bool _flowControl; bool _fullScripting; @@ -643,13 +500,6 @@ int _foregroundPid; - // ZModem - // bool _zmodemBusy; - // KProcess* _zmodemProc; - // ZModemDialog* _zmodemProgress; - - // Color/Font Changes by ESC Sequences - QColor _modifiedBackground; // as set by: echo -en '\033]11;Color\007 QString _profileKey; @@ -733,12 +583,3 @@ }; #endif - -/* - Local Variables: - mode: c++ - c-file-style: "stroustrup" - indent-tabs-mode: nil - tab-width: 4 - End: -*/
--- a/gui/src/terminal/TerminalDisplay.cpp +++ b/gui/src/terminal/TerminalDisplay.cpp @@ -2933,38 +2933,7 @@ void TerminalDisplay::dropEvent (QDropEvent * event) { - //KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); - QString dropText; - /* - if (!urls.isEmpty()) - { - for ( int i = 0 ; i < urls.count() ; i++ ) - { - KUrl url = KIO::NetAccess::mostLocalUrl( urls[i] , 0 ); - QString urlText; - - if (url.isLocalFile()) - urlText = url.path(); - else - urlText = url.url(); - - // in future it may be useful to be able to insert file names with drag-and-drop - // without quoting them (this only affects paths with spaces in) - urlText = KShell::quoteArg(urlText); - - dropText += urlText; - - if ( i != urls.count()-1 ) - dropText += ' '; - } - } - else - { - dropText = event->mimeData()->text(); - } - */ - if (event->mimeData ()->hasFormat ("text/plain")) { emit sendStringToEmu (dropText.toLocal8Bit ());