changeset 13484:3bfe83d853ca

Cleaned up code.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Wed, 27 Apr 2011 10:06:17 +0200
parents 799c03ea7004
children 59d266f7ed89
files gui//src/BlockArray.cpp gui//src/BlockArray.h gui//src/CharacterColor.h gui//src/Emulation.cpp gui//src/Filter.cpp gui//src/ProcessInfo.cpp gui//src/ProcessInfo.h gui//src/Pty.cpp gui//src/Screen.cpp gui//src/Session.cpp gui//src/SyntaxHighlighter.cpp gui//src/TerminalCharacterDecoder.cpp gui//src/TerminalDisplay.cpp gui//src/Vt102Emulation.cpp gui//src/kprocess.cpp gui//src/kpty.cpp gui//src/kpty_p.h gui//src/kptydevice.cpp gui//src/kptyprocess.cpp
diffstat 19 files changed, 2 insertions(+), 300 deletions(-) [+]
line wrap: on
line diff
--- a/gui//src/BlockArray.cpp	Tue Apr 26 23:01:38 2011 +0200
+++ b/gui//src/BlockArray.cpp	Wed Apr 27 10:06:17 2011 +0200
@@ -28,10 +28,6 @@
 #include <unistd.h>
 #include <stdio.h>
 
-// KDE
-//#include <kde_file.h>
-//#include <kdebug.h>
-
 #define KDE_fseek ::fseek
 #define KDE_lseek ::lseek
 
--- a/gui//src/BlockArray.h	Tue Apr 26 23:01:38 2011 +0200
+++ b/gui//src/BlockArray.h	Wed Apr 27 10:06:17 2011 +0200
@@ -23,8 +23,6 @@
 
 #include <unistd.h>
 
-//#error Do not use in KDE 2.1
-
 #define BlockSize (1 << 12)
 #define ENTRIES   ((BlockSize - sizeof(size_t) ) / sizeof(unsigned char))
 
--- a/gui//src/CharacterColor.h	Tue Apr 26 23:01:38 2011 +0200
+++ b/gui//src/CharacterColor.h	Wed Apr 27 10:06:17 2011 +0200
@@ -26,9 +26,6 @@
 // Qt
 #include <QtGui/QColor>
 
-//#include <kdemacros.h>
-#define KDE_NO_EXPORT
-
 /** 
  * An entry in a terminal display's color palette. 
  *
@@ -115,7 +112,7 @@
 //a standard set of colors using black text on a white background.
 //defined in TerminalDisplay.cpp
 
-extern const ColorEntry base_color_table[TABLE_COLORS] KDE_NO_EXPORT;
+extern const ColorEntry base_color_table[TABLE_COLORS];
 
 /* CharacterColor is a union of the various color spaces.
 
--- a/gui//src/Emulation.cpp	Tue Apr 26 23:01:38 2011 +0200
+++ b/gui//src/Emulation.cpp	Wed Apr 27 10:06:17 2011 +0200
@@ -39,9 +39,6 @@
 
 #include <QtCore/QTime>
 
-// KDE
-//#include <kdebug.h>
-
 // Konsole
 #include "KeyboardTranslator.h"
 #include "Screen.h"
@@ -238,55 +235,6 @@
     }
 }
 
-//OLDER VERSION
-//This version of onRcvBlock was commented out because
-//    a)  It decoded incoming characters one-by-one, which is slow in the current version of Qt (4.2 tech preview)
-//    b)  It messed up decoding of non-ASCII characters, with the result that (for example) chinese characters
-//        were not printed properly.
-//
-//There is something about stopping the _decoder if "we get a control code halfway a multi-byte sequence" (see below)
-//which hasn't been ported into the newer function (above).  Hopefully someone who understands this better
-//can find an alternative way of handling the check.  
-
-
-/*void Emulation::onRcvBlock(const char *s, int len)
-{
-  emit notifySessionState(NOTIFYACTIVITY);
-  
-  bufferedUpdate();
-  for (int i = 0; i < len; i++)
-  {
-
-    QString result = _decoder->toUnicode(&s[i],1);
-    int reslen = result.length();
-
-    // If we get a control code halfway a multi-byte sequence
-    // we flush the _decoder and continue with the control code.
-    if ((s[i] < 32) && (s[i] > 0))
-    {
-       // Flush _decoder
-       while(!result.length())
-          result = _decoder->toUnicode(&s[i],1);
-       reslen = 1;
-       result.resize(reslen);
-       result[0] = QChar(s[i]);
-    }
-
-    for (int j = 0; j < reslen; j++)
-    {
-      if (result[j].characterategory() == QChar::Mark_NonSpacing)
-         _currentScreen->compose(result.mid(j,1));
-      else
-         onRcvChar(result[j].unicode());
-    }
-    if (s[i] == '\030')
-    {
-      if ((len-i-1 > 3) && (strncmp(s+i+1, "B00", 3) == 0))
-          emit zmodemDetected();
-    }
-  }
-}*/
-
 void Emulation::writeToStream( TerminalCharacterDecoder* _decoder , 
                                int startLine ,
                                int endLine) 
--- a/gui//src/Filter.cpp	Tue Apr 26 23:01:38 2011 +0200
+++ b/gui//src/Filter.cpp	Wed Apr 27 10:06:17 2011 +0200
@@ -32,10 +32,6 @@
 #include <QtCore/QSharedData>
 #include <QtCore/QFile>
 
-// KDE
-//#include <KLocale>
-//#include <KRun>
-
 // Konsole
 #include "TerminalCharacterDecoder.h"
 #include "konsole_wcwidth.h"
--- a/gui//src/ProcessInfo.cpp	Tue Apr 26 23:01:38 2011 +0200
+++ b/gui//src/ProcessInfo.cpp	Wed Apr 27 10:06:17 2011 +0200
@@ -19,7 +19,6 @@
 
 // Own
 #include "ProcessInfo.h"
-//#include <config-konsole.h>
 
 // Unix
 #include <sys/socket.h>
@@ -29,21 +28,15 @@
 #include <pwd.h>
 
 // Qt
-//#include <KDebug>
 #include <QtCore/QDir>
 #include <QtCore/QFileInfo>
 #include <QtCore/QRegExp>
 #include <QtCore/QTextStream>
 #include <QtCore/QStringList>
 #include <QtCore/QSet>
-//#include "kdebug.h"
 
 // KDE
 #include "konsole_export.h"
-//#include <KConfigGroup>
-//#include <KGlobal>
-//#include <KSharedConfig>
-//#include <KUser>
 
 #if defined(Q_OS_MAC)
 #include <sys/sysctl.h>
@@ -139,7 +132,7 @@
       }
       output.replace("%D", tempDir);
    }
-   output.replace("%d",formatShortDir(dir));
+   output.replace("%d", dir);
    
    // remove any remaining %[LETTER] sequences
    // output.replace(QRegExp("%\\w"), QString());
@@ -158,66 +151,6 @@
     return QStringList(QList<QString>::fromVector(arguments)).join(" ");
 }
 
-QSet<QString> ProcessInfo::_commonDirNames;
-
-QSet<QString> ProcessInfo::commonDirNames() 
-{
-  // JPS: Don't know of a good replacement for this in QT
-  /*
-    if ( _commonDirNames.isEmpty() )
-    {
-        KSharedConfigPtr config = KGlobal::config();
-        KConfigGroup configGroup = config->group("ProcessInfo");
-
-        QStringList defaults = QStringList() 
-                             << "src" << "build" << "debug" << "release" 
-                             << "bin" << "lib"   << "libs"  << "tmp" 
-                             << "doc" << "docs"  << "data"  << "share"
-                             << "examples" << "icons" << "pics" << "plugins" 
-                             << "tests" << "media" << "l10n" << "include" 
-                             << "includes" << "locale" << "ui";
-
-        _commonDirNames = QSet<QString>::fromList(configGroup.readEntry("CommonDirNames",defaults));
-
-    }
-  */
-    return _commonDirNames;
-}
-
-QString ProcessInfo::formatShortDir(const QString& input) const
-{
-    QString result;
-
-    QStringList parts = input.split( QDir::separator() );
-
-    // temporarily hard-coded
-    QSet<QString> dirNamesToShorten = commonDirNames();
-
-    QListIterator<QString> iter(parts);
-    iter.toBack();
-
-    // go backwards through the list of the path's parts
-    // adding abbreviations of common directory names
-    // and stopping when we reach a dir name which is not
-    // in the commonDirNames set
-    while ( iter.hasPrevious() )
-    {
-        QString part = iter.previous();
-
-        if ( dirNamesToShorten.contains(part) )
-        {
-            result.prepend(QDir::separator() + part[0]);
-        }
-        else
-        {
-            result.prepend(part);
-            break;
-        }
-    }
-
-    return result;
-}
-
 QVector<QString> ProcessInfo::arguments(bool* ok) const
 {
     *ok = _fields & ARGUMENTS;
--- a/gui//src/ProcessInfo.h	Tue Apr 26 23:01:38 2011 +0200
+++ b/gui//src/ProcessInfo.h	Wed Apr 27 10:06:17 2011 +0200
@@ -272,11 +272,6 @@
     void addEnvironmentBinding(const QString& name , const QString& value);
 
 private:
-    // takes a full directory path and returns a
-    // shortened version suitable for display in 
-    // space-constrained UI elements (eg. tabs)
-    QString formatShortDir(const QString& dirPath) const;
-
     enum CommandFormat
     {
         ShortCommandFormat,
@@ -320,9 +315,6 @@
 
     QVector<QString> _arguments;
     QMap<QString,QString> _environment;
-
-    static QSet<QString> commonDirNames();
-    static QSet<QString> _commonDirNames;
 };
 
 /** 
--- a/gui//src/Pty.cpp	Tue Apr 26 23:01:38 2011 +0200
+++ b/gui//src/Pty.cpp	Wed Apr 27 10:06:17 2011 +0200
@@ -34,16 +34,6 @@
 // Qt
 #include <QtCore/QStringList>
 
-// KDE
-//#include <KStandardDirs>
-//#include <KLocale>
-//#include <KDebug>
-//#include <KPty>
-//#include <KPtyDevice>
-//#include <kde_file.h>
-
-//#include "kdebug.h"
-
 #include "kpty.h"
 #include "kptydevice.h"
 
--- a/gui//src/Screen.cpp	Tue Apr 26 23:01:38 2011 +0200
+++ b/gui//src/Screen.cpp	Wed Apr 27 10:06:17 2011 +0200
@@ -35,8 +35,6 @@
 #include <QtCore/QTextStream>
 #include <QtCore/QDate>
 
-// KDE
-//#include <kdebug.h>
 
 // Konsole
 #include "konsole_wcwidth.h"
--- a/gui//src/Session.cpp	Tue Apr 26 23:01:38 2011 +0200
+++ b/gui//src/Session.cpp	Wed Apr 27 10:06:17 2011 +0200
@@ -36,35 +36,16 @@
 #include <QtCore/QFile>
 #include <QtCore/QRegExp>
 #include <QtCore/QStringList>
-//#include <QtDBus/QtDBus>
 #include <QtCore/QDate>
 
-
-// KDE
-//#include <KDebug>
-//#include <KLocale>
-//#include <KMessageBox>
-//#include <KNotification>
-//#include <KProcess>
-//#include <KRun>
-//#include <kshell.h>
-//#include <KStandardDirs>
-//#include <KPtyDevice>
-//#include <KUrl>
 #include "kprocess.h"
 #include "kptydevice.h"
-//#include "kdebug.h"
-
-// Konsole
-//#include <config-konsole.h>
-//#include <sessionadaptor.h>
 
 #include "ProcessInfo.h"
 #include "Pty.h"
 #include "TerminalDisplay.h"
 #include "ShellCommand.h"
 #include "Vt102Emulation.h"
-//#include "ZModemDialog.h"
 
 int Session::lastSessionId = 0;
 
@@ -363,20 +344,6 @@
       exec = qgetenv("SHELL");
   if ( exec.isEmpty() )
         exec = "/bin/sh";
-
-  // JPS: commented out to get rid of KShell and KRun
-  /*
-  exec = KRun::binaryName(exec, false);
-  exec = KShell::tildeExpand(exec);
-  QString pexec = KGlobal::dirs()->findExe(exec);
-  if ( pexec.isEmpty() ) 
-  {
-      kError() << i18n("Could not find binary: ") << exec;
-    return QString();
-  }
-
-  return exec;
-  */
   return program;
 }
 
--- a/gui//src/SyntaxHighlighter.cpp	Tue Apr 26 23:01:38 2011 +0200
+++ b/gui//src/SyntaxHighlighter.cpp	Wed Apr 27 10:06:17 2011 +0200
@@ -18,8 +18,6 @@
 
 
 #include "SyntaxHighlighter.h"
-
-
 #include <QXmlStreamReader>
 #include <QStack>
 #include <QFile>
--- a/gui//src/TerminalCharacterDecoder.cpp	Tue Apr 26 23:01:38 2011 +0200
+++ b/gui//src/TerminalCharacterDecoder.cpp	Wed Apr 27 10:06:17 2011 +0200
@@ -25,9 +25,6 @@
 // Qt
 #include <QtCore/QTextStream>
 
-// KDE
-//#include <kdebug.h>
-
 // Konsole
 #include "konsole_wcwidth.h"
 
--- a/gui//src/TerminalDisplay.cpp	Tue Apr 26 23:01:38 2011 +0200
+++ b/gui//src/TerminalDisplay.cpp	Wed Apr 27 10:06:17 2011 +0200
@@ -42,21 +42,6 @@
 #include <QtGui/QToolTip>
 #include <QtCore/QTextStream>
 
-// KDE
-//#include <kshell.h>
-//#include <KColorScheme>
-//#include <KCursor>
-//#include <kdebug.h>
-//#include <KLocale>
-//#include <KMenu>
-//#include <KNotification>
-//#include <KGlobalSettings>
-//#include <KShortcut>
-//#include <KIO/NetAccess>
-//#include "kdebug.h"
-
-// Konsole
-//#include <config-apps.h>
 #include "Filter.h"
 #include "konsole_wcwidth.h"
 #include "ScreenWindow.h"
--- a/gui//src/Vt102Emulation.cpp	Tue Apr 26 23:01:38 2011 +0200
+++ b/gui//src/Vt102Emulation.cpp	Wed Apr 27 10:06:17 2011 +0200
@@ -23,8 +23,6 @@
 // Own
 #include "Vt102Emulation.h"
 
-// XKB
-//#include <config-konsole.h>
 
 // this allows konsole to be compiled without XKB and XTEST extensions
 // even though it might be available on a particular system.
@@ -47,10 +45,6 @@
 #include <QtGui/QKeyEvent>
 #include <QtCore/QByteRef>
 
-// KDE
-//#include <kdebug.h>
-//#include <klocale.h>
-
 // Konsole
 #include "KeyboardTranslator.h"
 #include "Screen.h"
--- a/gui//src/kprocess.cpp	Tue Apr 26 23:01:38 2011 +0200
+++ b/gui//src/kprocess.cpp	Wed Apr 27 10:06:17 2011 +0200
@@ -21,12 +21,6 @@
 
 #include "kprocess_p.h"
 
-//#include <kstandarddirs.h>
-//#include <kshell.h>
-//#ifdef Q_OS_WIN
-//# include <kshell_p.h>
-//#endif
-
 #include <qfile.h>
 
 #ifdef Q_OS_WIN
@@ -265,74 +259,9 @@
 void KProcess::setShellCommand(const QString &cmd)
 {
     Q_D(KProcess);
-
-    // JPS: commented out because I didn't want to pull in KShell also.  It
-    // seems this is mostly for handling program arguments, which I won't be
-    // using.
-    /*
-    KShell::Errors err;
-    d->args = KShell::splitArgs(
-            cmd, KShell::AbortOnMeta | KShell::TildeExpand, &err);
-    if (err == KShell::NoError && !d->args.isEmpty()) {
-        d->prog = KStandardDirs::findExe(d->args[0]);
-        if (!d->prog.isEmpty()) {
-            d->args.removeFirst();
-#ifdef Q_OS_WIN
-            setNativeArguments(QString());
-#endif
-            return;
-        }
-    }
-    */
-
     d->args.clear();
-
-#ifdef Q_OS_UNIX
-// #ifdef NON_FREE // ... as they ship non-POSIX /bin/sh
-# if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__GNU__)
-    // If /bin/sh is a symlink, we can be pretty sure that it points to a
-    // POSIX shell - the original bourne shell is about the only non-POSIX
-    // shell still in use and it is always installed natively as /bin/sh.
-    /*
-    d->prog = QFile::symLinkTarget(QString::fromLatin1("/bin/sh"));
-    if (d->prog.isEmpty()) {
-        // Try some known POSIX shells.
-        d->prog = KStandardDirs::findExe(QString::fromLatin1("ksh"));
-        if (d->prog.isEmpty()) {
-            d->prog = KStandardDirs::findExe(QString::fromLatin1("ash"));
-            if (d->prog.isEmpty()) {
-                d->prog = KStandardDirs::findExe(QString::fromLatin1("bash"));
-                if (d->prog.isEmpty()) {
-                    d->prog = KStandardDirs::findExe(QString::fromLatin1("zsh"));
-                    if (d->prog.isEmpty())
-                        // We're pretty much screwed, to be honest ...
-                        d->prog = QString::fromLatin1("/bin/sh");
-                }
-            }
-        }
-     }
-*/
-# else
     d->prog = QString::fromLatin1("/bin/sh");
-# endif
-
     d->args << QString::fromLatin1("-c") << cmd;
-#else // Q_OS_UNIX
-    // KMacroExpander::expandMacrosShellQuote(), KShell::quoteArg() and
-    // KShell::joinArgs() may generate these for security reasons.
-    setEnv(PERCENT_VARIABLE, QLatin1String("%"));
-
-#ifndef _WIN32_WCE
-    WCHAR sysdir[MAX_PATH + 1];
-    UINT size = GetSystemDirectoryW(sysdir, MAX_PATH + 1);
-    d->prog = QString::fromUtf16((const ushort *) sysdir, size);
-    d->prog += QLatin1String("\\cmd.exe");
-    setNativeArguments(QLatin1String("/V:OFF /S /C \"") + cmd + QLatin1Char('"'));
-#else
-    d->prog = QLatin1String("\\windows\\cmd.exe");
-    setNativeArguments(QLatin1String("/S /C \"") + cmd + QLatin1Char('"'));
-#endif
-#endif
 }
 
 QStringList KProcess::program() const
--- a/gui//src/kpty.cpp	Tue Apr 26 23:01:38 2011 +0200
+++ b/gui//src/kpty.cpp	Wed Apr 27 10:06:17 2011 +0200
@@ -24,8 +24,6 @@
 
 #include "kpty_p.h"
 
-//#include <config.h>
-
 #ifdef __sgi
 #define __svr4__
 #endif
@@ -132,10 +130,6 @@
 # endif
 #endif
 
-//#include <kdebug.h>
-//#include <kstandarddirs.h>	// findExe
-//#include <kde_file.h>
-
 #include <QtCore/Q_PID>
 
 #define TTY_GROUP "tty"
--- a/gui//src/kpty_p.h	Tue Apr 26 23:01:38 2011 +0200
+++ b/gui//src/kpty_p.h	Wed Apr 27 10:06:17 2011 +0200
@@ -23,7 +23,6 @@
 
 #include "kpty.h"
 
-//#include <config-pty.h>
 #if defined(Q_OS_MAC)
 #define HAVE_UTIL_H
 #define HAVE_UTMPX
--- a/gui//src/kptydevice.cpp	Tue Apr 26 23:01:38 2011 +0200
+++ b/gui//src/kptydevice.cpp	Wed Apr 27 10:06:17 2011 +0200
@@ -23,16 +23,10 @@
 
 #include "kptydevice.h"
 #include "kpty_p.h"
-
-//#include <config.h>
-//#include <config-pty.h>
-
 #define i18n
 
 #include <QtCore/QSocketNotifier>
 
-//#include <klocale.h>
-
 #include <unistd.h>
 #include <errno.h>
 #include <signal.h>
--- a/gui//src/kptyprocess.cpp	Tue Apr 26 23:01:38 2011 +0200
+++ b/gui//src/kptyprocess.cpp	Wed Apr 27 10:06:17 2011 +0200
@@ -22,7 +22,6 @@
 #include "kptyprocess.h"
 #include "kprocess.h"
 
-//#include <kuser.h>
 #include "kptydevice.h"
 
 #include <stdlib.h>
@@ -32,8 +31,6 @@
 // private data //
 //////////////////
 
-
-
 KPtyProcess::KPtyProcess(QObject *parent) :
     KProcess(new KPtyProcessPrivate, parent)
 {