Index: trunk/src/lib/shell/shell_completion.cc
===================================================================
--- trunk/src/lib/shell/shell_completion.cc	(revision 5191)
+++ trunk/src/lib/shell/shell_completion.cc	(revision 5192)
@@ -69,4 +69,6 @@
   tList<BaseObject>* objectList;   //< the list of Objects stored in classID
   bool emptyComplete = false;      //< if the completion input is empty string. e.g ""
+  SHELLC_TYPE firstType = SHELLC_NONE;
+  SHELLC_TYPE secondType = SHELLC_NONE;
 
 
@@ -101,5 +103,4 @@
     PRINTF(5)("Listing all Classes\n");
     this->objectComplete("", CL_SHELL_COMMAND_CLASS);
-    return false;
   }
   else if (inputSplits.getCount() == 1 && emptyComplete == false)
@@ -110,47 +111,29 @@
 
   // OBJECT/FUNCTION COMPLETIONS
-  else if ( (inputSplits.getCount() == 1 && emptyComplete == true ) ||
-             (inputSplits.getCount() == 2 && emptyComplete == false))
+  else if ((inputSplits.getCount() == 1 && emptyComplete == true) ||
+            (inputSplits.getCount() == 2 && emptyComplete == false))
   {
     classID = ClassList::StringToID(inputSplits.getString(0));
     if (classID == CL_NULL)
+    {
       return false;
-    if (inputSplits.getCount()==2)
-    {
-      if  (completionLine[strlen(completionLine)-1] != ' ')
-       this->objectComplete(inputSplits.getString(1), classID);
     }
     else
-      this->objectComplete("", classID);
-  }
-//  else if (inputSplits.getCount() <= 3 )
-
-/*  completionLine = new char[strlen(this->input->getText())+1];
-  strcpy(completionLine, this->input->getText());
-
-  char* commandBegin = strrchr(completionLine, ' ');
-  if (commandBegin == NULL)
-    commandBegin = completionLine;
+    {
+      firstType = SHELLC_CLASS;
+      if (inputSplits.getCount() == 2)
+      {
+        if  (completionLine[strlen(completionLine)-1] != ' ')
+          this->objectComplete(inputSplits.getString(1), classID);
+      }
+      else
+        this->objectComplete("", classID);
+    }
+  }
+
+  if (emptyComplete == false)
+    this->generalComplete(inputSplits.getString(inputSplits.getCount()-1));
   else
-  {
-    if(commandBegin >= completionLine + strlen(completionLine))
-      commandBegin = completionLine + strlen(completionLine);
-    else
-      commandBegin++;
-  }
-
-  char* objectStart;
-  if (objectStart = strstr(commandBegin, "::"))
-  {
-    char* classIdentity = new char[objectStart - commandBegin +1];
-    strncpy(classIdentity, commandBegin, objectStart - commandBegin);
-    classIdentity[objectStart - commandBegin] = '\0';
-    this->objectComplete(objectStart+2, ClassList::StringToID(classIdentity));
-    delete[] classIdentity;
-  }
-  else
-    this->classComplete(commandBegin);
-
-  delete[] completionLine;*/
+    this->generalComplete("");
 }
 
@@ -167,10 +150,6 @@
   if (clList != NULL)
   {
-    const tList<ShellC_Element>* classList = this->addToCompleteList(clList, classBegin);
-    if (classList != NULL)
-      this->generalComplete(classList, classBegin, "CL: %s ");
-    else
+    if (!this->addToCompleteList(clList, classBegin))
       return false;
-    delete classList;
   }
   else
@@ -193,8 +172,5 @@
   {
     //printf("%s\n", boList->firstElement()->getName());
-    const tList<ShellC_Element>* objectList = this->addToCompleteList(boList, objectBegin);
-    if (objectList != NULL)
-      this->generalComplete(objectList, objectBegin, "%s ");
-    else
+    if (!this->addToCompleteList(boList, objectBegin))
       return false;
   }
@@ -214,5 +190,4 @@
 /**
  * completes the inputline on grounds of an inputList
- * @param stringList the List to parse through
  * @param begin the String to search in the inputList, and to extend with it.
  * @param displayAs how to display the found value to the user, printf-style, !!with only one %s!! ex.: "::%s::"
@@ -221,12 +196,12 @@
  * @return true if ok, false otherwise
  */
-bool ShellCompletion::generalComplete(const tList<ShellC_Element>* stringList, const char* begin, const char* displayAs, const char* addBack, const char* addFront)
-{
-  if (stringList == NULL || this->input == NULL )
-    return false;
-  if (stringList->getSize() == 0)
-    return false;
-
-  ShellC_Element* addElem = stringList->firstElement();
+bool ShellCompletion::generalComplete(const char* begin, const char* displayAs, const char* addBack, const char* addFront)
+{
+  if (completionList == NULL || this->input == NULL )
+    return false;
+  if (completionList->getSize() == 0)
+    return false;
+
+  ShellC_Element* addElem = completionList->firstElement();
   const char* addString = addElem->name;
   unsigned int addLength = 0;
@@ -236,5 +211,5 @@
   if (addString != NULL)
     addLength = strlen(addString);
-  tIterator<ShellC_Element>* charIterator = stringList->getIterator();
+  tIterator<ShellC_Element>* charIterator = completionList->getIterator();
   ShellC_Element* charElem = charIterator->firstElement();
   while (charElem != NULL)
@@ -262,5 +237,5 @@
      this->input->addCharacters(adder);
 
-      if (stringList->getSize() == 1)
+      if (completionList->getSize() == 1)
       {
         if ( addBack != NULL )
@@ -280,8 +255,8 @@
  * !! The strings MUST NOT be deleted !!
  */
-const tList<ShellC_Element>* ShellCompletion::addToCompleteList(const tList<const char>* inputList, const char* completionBegin)
+bool ShellCompletion::addToCompleteList(const tList<const char>* inputList, const char* completionBegin)
 {
   if (inputList == NULL || completionBegin == NULL)
-    return NULL;
+    return false;
   unsigned int searchLength = strlen(completionBegin);
 
@@ -302,5 +277,5 @@
   delete iterator;
 
-  return this->completionList;
+  return true;
 }
 
@@ -311,8 +286,8 @@
  * !! The strings MUST NOT be deleted !!
  */
-const tList<ShellC_Element>* ShellCompletion::addToCompleteList(const tList<BaseObject>* inputList, const char* completionBegin)
+bool ShellCompletion::addToCompleteList(const tList<BaseObject>* inputList, const char* completionBegin)
 {
   if (inputList == NULL || completionBegin == NULL)
-    return NULL;
+    return false;
   unsigned int searchLength = strlen(completionBegin);
 
@@ -334,5 +309,5 @@
   delete iterator;
 
-  return this->completionList;
+  return true;
 }
 
