summaryrefslogtreecommitdiffstats
path: root/kio
diff options
context:
space:
mode:
Diffstat (limited to 'kio')
-rw-r--r--kio/kio/kurlcompletion.cpp72
-rw-r--r--kio/kio/kurlcompletion.h3
2 files changed, 74 insertions, 1 deletions
diff --git a/kio/kio/kurlcompletion.cpp b/kio/kio/kurlcompletion.cpp
index e09ce2ed8..79a939530 100644
--- a/kio/kio/kurlcompletion.cpp
+++ b/kio/kio/kurlcompletion.cpp
@@ -620,6 +620,18 @@ TQString KURLCompletion::makeCompletion(const TQString &text)
if ( urlCompletion( url, &match ) )
return match;
}
+ else if ( d->mode == SystemExeCompletion ) {
+ // Executables
+ //
+ if ( systemexeCompletion( url, &match ) )
+ return match;
+
+ // KRun can run "man:" and "info:" etc. so why not treat them
+ // as executables...
+
+ if ( urlCompletion( url, &match ) )
+ return match;
+ }
else {
// Local files, directories
//
@@ -876,6 +888,66 @@ bool KURLCompletion::exeCompletion(const MyURL &url, TQString *match)
//////////////////////////////////////////////////
//////////////////////////////////////////////////
+// System Executables
+//
+
+bool KURLCompletion::systemexeCompletion(const MyURL &url, TQString *match)
+{
+ if ( url.protocol() != "file" )
+ return false;
+
+ TQString dir = url.dir();
+
+ dir = unescape( dir ); // remove escapes
+
+ // Find directories to search for completions, either
+ //
+ // 1. complete path given in url
+ // 2. current directory (d->cwd)
+ // 3. $PATH
+ // 4. no directory at all
+
+ TQStringList dirList;
+
+ if ( !url.file().isEmpty() ) {
+ // $PATH
+ dirList = TQStringList::split(KPATH_SEPARATOR,
+ TQString::fromLocal8Bit(::getenv("PATH")));
+
+ TQStringList::Iterator it = dirList.begin();
+
+ for ( ; it != dirList.end(); it++ )
+ (*it).append('/');
+ }
+
+ // No hidden files unless the user types "."
+ bool no_hidden_files = url.file().tqat(0) != '.';
+
+ // List files if needed
+ //
+ if ( !isListedURL( CTExe, dir, url.file(), no_hidden_files ) )
+ {
+ stop();
+ clear();
+
+ setListedURL( CTExe, dir, url.file(), no_hidden_files );
+
+ *match = listDirectories( dirList, url.file(), true, false, no_hidden_files );
+ }
+ else if ( !isRunning() ) {
+ *match = finished();
+ }
+ else {
+ if ( d->dirListThread )
+ setListedURL( CTExe, dir, url.file(), no_hidden_files );
+ *match = TQString::null;
+ }
+
+ return true;
+}
+
+//////////////////////////////////////////////////
+//////////////////////////////////////////////////
// Local files
//
diff --git a/kio/kio/kurlcompletion.h b/kio/kio/kurlcompletion.h
index a06d7dc4b..2e042c3bc 100644
--- a/kio/kio/kurlcompletion.h
+++ b/kio/kio/kurlcompletion.h
@@ -50,7 +50,7 @@ public:
* are listed using KIO.
* @li DirCompletion - Same as FileCompletion but only returns directories.
*/
- enum Mode { ExeCompletion=1, FileCompletion, DirCompletion };
+ enum Mode { ExeCompletion=1, FileCompletion, DirCompletion, SystemExeCompletion };
/**
* Constructs a KURLCompletion object in FileCompletion mode.
@@ -186,6 +186,7 @@ private:
bool userCompletion(const MyURL &url, TQString *match);
bool envCompletion(const MyURL &url, TQString *match);
bool exeCompletion(const MyURL &url, TQString *match);
+ bool systemexeCompletion(const MyURL &url, TQString *match);
bool fileCompletion(const MyURL &url, TQString *match);
bool urlCompletion(const MyURL &url, TQString *match);