bug 3051
Allan CORNET [Wed, 10 Dec 2008 16:08:34 +0000 (17:08 +0100)]
12 files changed:
scilab/modules/completion/includes/getCommonPart.h [new file with mode: 0644]
scilab/modules/completion/src/c/completion.c
scilab/modules/completion/src/c/completion.vcproj
scilab/modules/completion/src/c/getCommonPart.c [new file with mode: 0644]
scilab/modules/completion/src/c/getPartLine.c
scilab/modules/completion/src/c/getfilesdictionary.c
scilab/modules/completion/src/c/toolsdictionary.h
scilab/modules/completion/src/java/completion-JAVA.vcproj
scilab/modules/console/.checkstyle
scilab/modules/console/src/java/org/scilab/modules/console/CompletionAction.java
scilab/modules/shell/src/c/scicompletion_Import.def
scilab/modules/shell/src/c/windows/TermCompletion.c

diff --git a/scilab/modules/completion/includes/getCommonPart.h b/scilab/modules/completion/includes/getCommonPart.h
new file mode 100644 (file)
index 0000000..1794495
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2008 - DIGITEO - Allan CORNET
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+
+/*--------------------------------------------------------------------------*/
+#ifndef __GETCOMMONPART_H__
+#define __GETCOMMONPART_H__
+
+/**
+* get common part of words
+* example gethistory, gethistoryfile, gethist
+* it will return : gethist
+* @param[in] matrix of strings
+* @param[in] size of array
+* @return a string common part
+*/
+char *getCommonPart(char **dictionary, int sizeDictionary);
+
+#endif /* __GETCOMMONPART_H__ */
+
+/*--------------------------------------------------------------------------*/
index b04b171..7b5d370 100644 (file)
@@ -215,7 +215,7 @@ char **completionOnVariablesWithoutMacros(char *somechars, int *sizeArrayReturne
                                {
                                        int k = 0;
 
-                                       /* do a copy of dictionnary of Variables */
+                                       /* do a copy of dictionary of Variables */
                                        for ( i = 0; i < sizedictionaryVariables; i++)
                                        {
                                                ListWordsTmp[i] = strdup(dictionaryVariables[i]);
index e8dd27a..7dd4a39 100644 (file)
                                >
                        </File>
                        <File
+                               RelativePath=".\getCommonPart.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\jni\getCommonPart_wrap.c"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\getfilesdictionary.c"
                                >
                        </File>
                                >
                        </File>
                        <File
+                               RelativePath="..\..\includes\getCommonPart.h"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\getfilesdictionary.h"
                                >
                        </File>
diff --git a/scilab/modules/completion/src/c/getCommonPart.c b/scilab/modules/completion/src/c/getCommonPart.c
new file mode 100644 (file)
index 0000000..855855c
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2008 - DIGITEO - Allan CORNET
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+
+/*--------------------------------------------------------------------------*/
+#include <string.h>
+#include <stdlib.h>
+#include "getCommonPart.h"
+#include "MALLOC.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
+/*--------------------------------------------------------------------------*/
+static int cmp( const void *a ,const void *b)
+{
+       return strcmp(*(const char **)a, *(const char **)b );
+}
+/*--------------------------------------------------------------------------*/
+static int cmpPos(char *str1,char *str2)
+{
+       if (str1 && str2)
+       {
+               int i = 0;
+               char *s1 = NULL;
+               char *s2 = NULL;
+               int lenstr1 = (int) strlen(str1);
+               int lenstr2 = (int) strlen(str2);
+
+               if (lenstr1 > lenstr2) 
+               {
+                       s1 = str2;
+                       s2 = str1;
+                       lenstr1 = (int) strlen(str1);
+                       lenstr2 = (int) strlen(str2);
+               }
+               else
+               {
+                       s1 = str1;
+                       s2 = str2;
+               }
+               for (i = 0; i < lenstr1; i++)
+               {
+                       if ( s1[i] != s2[i] ) return i;
+               }
+       }
+       return -1;
+}
+/*--------------------------------------------------------------------------*/
+char *getCommonPart(char **dictionary, int sizeDictionary)
+{
+       char *commonpart = NULL;
+
+       if (sizeDictionary == 1)
+       {
+               return strdup(dictionary[0]);
+       }
+
+       if (sizeDictionary >= 2)
+       {
+               int i = 0;
+               int r = 0;
+               char *currentstr = dictionary[0];
+               qsort(dictionnary, sizeof dictionary / sizeof dictionary[0], sizeof dictionary[0], cmp);
+
+               r = cmpPos(currentstr, dictionnary[1]);
+               for (i = 1; i < sizeDictionnary - 1; i++)
+               {
+                       int current_r = cmpPos(currentstr, dictionary[i+1]);
+                       if (r > current_r  )
+                       {
+                               r = current_r;
+                               currentstr = dictionary[i+1];
+                       }
+               }
+               
+               commonpart = strdup(currentstr);
+               commonpart[r] = '\0';
+       }
+       return commonpart;
+}
+/*--------------------------------------------------------------------------*/
index 92700cf..d5550ca 100644 (file)
@@ -137,4 +137,4 @@ char *getFilePartLevel(char *line)
 
        return strdup(&linebis[index]);
 }
-/*--------------------------------------------------------------------------*/
\ No newline at end of file
+/*--------------------------------------------------------------------------*/
index d52734e..62cb978 100644 (file)
@@ -11,6 +11,7 @@
  */
 #include <string.h> /* strcmp */
 #include <stdio.h> /* sprintf */
+#include <stdlib.h> /* qsort */
 #include "getfilesdictionary.h"
 #include "PATH_MAX.h"
 #include "../../../core/src/c/scicurdir.h" /* scigetcwd */
@@ -24,6 +25,11 @@ static void splitpath(char *composite,  char *path,  char *fname);
 static char **addPath(char **dictionary, int sizearray, char *path);
 static char **addDirSeparator(char **dictionary, int sizearray, char *path);
 /*--------------------------------------------------------------------------*/ 
+static int cmpfiles( const void *a ,const void *b)
+{
+       return strcmp(*(const char **)a, *(const char **)b );
+}
+/*--------------------------------------------------------------------------*/ 
 char **getfilesdictionary(char *somechars,int *sizearray,BOOL fullpath)
 {
        char **dictionary = NULL;
@@ -90,6 +96,7 @@ char **getfilesdictionary(char *somechars,int *sizearray,BOOL fullpath)
         {
                        dictionary = (char**)REALLOC(dictionary,sizeof(char*)*(sizeListReturned+1));
                        dictionary[sizeListReturned] = NULL;
+                       qsort(dictionary, sizeof dictionary / sizeof dictionary[0], sizeof dictionary[0], cmpfiles);
                }
        }
        else
index 1f39f86..c430a6b 100644 (file)
@@ -28,7 +28,7 @@ BOOL appendDictionary(char ***dictionary,int *i,char ***datas,int *sizedatas);
 /**
 * sort dictionary
 * @param strings wto sort
-* @param  size of new dictionnary
+* @param  size of new dictionary
 * @return result
 */
 char **SortDictionary(char **Strings,int SizeStrings);
@@ -36,7 +36,7 @@ char **SortDictionary(char **Strings,int SizeStrings);
 /**
 * Remove duplicate words in a dictionary
 * @param strings where to search
-* @param[out] size of new dictionnary
+* @param[out] size of new dictionary
 * @return result
 */
 char ** RemoveDuplicateDictionary(char **Strings,int *SizeStrings);
index 0ad7287..56d8e8c 100644 (file)
@@ -1,11 +1,12 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
        ProjectType="Visual C++"
-       Version="9.00"
+       Version="9,00"
        Name="completion-Ant"
        ProjectGUID="{B5E4D0C2-8C6A-4437-81BF-DBFA95900C9D}"
        RootNamespace="completion-Ant"
        Keyword="MakeFileProj"
+       TargetFrameworkVersion="0"
        >
        <Platforms>
                <Platform
                                RelativePath=".\org\scilab\modules\completion\CompletionJNI.java"
                                >
                        </File>
+                       <File
+                               RelativePath=".\org\scilab\modules\completion\GetPartLine.java"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\org\scilab\modules\completion\GetPartLineJNI.java"
+                               >
+                       </File>
                </Filter>
                <File
                        RelativePath="..\..\..\build.xml"
index d64a0e0..36f4c37 100644 (file)
@@ -1,7 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <fileset-config file-format-version="1.2.0" simple-config="true">
     <local-check-config name="Scilab CheckStyle" location="internal_config__1181381231358.xml" type="internal" description=""/>
-    <fileset name="tous" enabled="true" check-config-name="Scilab CheckStyle" local="true">
+    <local-check-config name="tet" location="D:\GIT-scilab-master\scilab\scilab\checkstyle\scilab_checkstyle_convention.xml" type="external" description="">
+        <additional-data name="protect-config-file" value="false"/>
+    </local-check-config>
+    <fileset name="tous" enabled="true" check-config-name="tet" local="true">
         <file-match-pattern match-pattern="." include-pattern="true"/>
     </fileset>
 </fileset-config>
index 6905f88..419dc94 100644 (file)
@@ -15,13 +15,17 @@ package org.scilab.modules.console;
 import java.awt.Point;
 import java.awt.event.ActionEvent;
 import java.util.List;
+import java.util.Iterator;
 
 import com.artenum.rosetta.core.action.AbstractConsoleAction;
 import com.artenum.rosetta.interfaces.core.CompletionItem;
 
+import org.scilab.modules.completion.GetCommonPart;
+
 /**
  * Class used when Scilab user asks for completion on the current edited line
  * @author Vincent COUVERT
+ * @author Allan CORNET 
  */
 public class CompletionAction extends AbstractConsoleAction {
        private static final long serialVersionUID = 1L;
@@ -48,6 +52,18 @@ public class CompletionAction extends AbstractConsoleAction {
                        configuration.getInputParsingManager().writeCompletionPart(configuration.getCompletionWindow().getCompletionResult());
                        ((SciCompletionWindow) configuration.getCompletionWindow()).setVisible(false);
                } else if (completionItems != null && completionItems.size() != 0) {
+                       String [] completionArray = new String [completionItems.size()];
+                       int i = 0;
+                       Iterator < CompletionItem >  it = completionItems.iterator(); 
+                       while  (it.hasNext()) {  
+                               CompletionItem currentItem = it.next();  
+                               completionArray[i] = currentItem.getReturnValue();
+                               i++;
+                       }
+           
+                       java.util.Arrays.sort(completionArray);
+                       configuration.getInputParsingManager().writeCompletionPart(
+                                       GetCommonPart.getCommonPart(completionArray, completionItems.size()));
                        configuration.getCompletionWindow().show(completionItems, location);
                }
        }
index 7586939..81e9602 100644 (file)
@@ -9,4 +9,5 @@ completionOnMacros
 completionOnCommandWords
 completionOnFunctions
 getPartLevel
-getFilePartLevel
\ No newline at end of file
+getFilePartLevel
+getCommonPart
\ No newline at end of file
index 00e4b03..7cf9039 100644 (file)
@@ -12,6 +12,7 @@
 
 /*--------------------------------------------------------------------------*/
 #include <string.h>
+#include <stdlib.h>
 #include "TermCompletion.h"
 #include "MALLOC.h"
 #include "freeArrayOfString.h"
 #include "TermLine.h"
 #include "TermConsole.h"
 #include "getPartLine.h"
+#include "getCommonPart.h"
 #include "completion.h"
 #include "scilines.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*--------------------------------------------------------------------------*/
 static void displayCompletionDictionary(char **dictionary,int sizedictionary, char *namedictionary);
+static char **concatenateStrings(int *sizearrayofstring, char *string1,
+                                                                char *string2, char *string3,
+                                                                char *string4, char *string5);
+static void TermCompletionOnFiles(char **dictionaryFiles, int sizedictionaryFiles,
+                                                                 char *currentline, char *filePattern, char *defaultPattern);
+static void TermCompletionOnAll(char *currentline, char *defaultPattern);
 /*--------------------------------------------------------------------------*/
-void TermCompletion(void)
+static void TermCompletionOnFiles(char **dictionaryFiles, int sizedictionaryFiles,
+                                                                 char *currentline, char *filePattern, char *defaultPattern)
 {
-       char *CurrentLine = getCurrentLine();
-       char *fileSearchedPattern = getFilePartLevel(CurrentLine);
-       char *SearchedPattern = getPartLevel(CurrentLine);
-       char **completionDictionaryFiles = NULL;
-       int sizecompletionDictionaryFiles = 0;
-
-       completionDictionaryFiles = completionOnFiles(fileSearchedPattern, &sizecompletionDictionaryFiles);
-
-       if (completionDictionaryFiles)
+       if (dictionaryFiles)
        {
-               if (sizecompletionDictionaryFiles == 1)
+               if (sizedictionaryFiles == 1)
                {
-                       char *result = completionDictionaryFiles[0];
-                       char *partResult = &result[strlen(SearchedPattern)];
-                       char *newline = (char*)MALLOC(sizeof(char)*(strlen(CurrentLine)+ strlen(partResult)));
-
-                       if (newline)
+                       if ( strcmp(defaultPattern,"") )
                        {
-                               strcpy(newline,CurrentLine);
-                               strcat(newline,partResult);
-                               clearCurrentLine();
-                               copyLine(newline);
-                               FREE(newline);
+                               char *ptr_strrchar1 = NULL;
+
+                               ptr_strrchar1 = strrchr(dictionaryFiles[0], defaultPattern[0]);
+                               if (ptr_strrchar1) 
+                               {
+                                       char *ptr_strrchar2 = NULL;
+                                       char *newline = NULL;
+                                       ptr_strrchar2 = strrchr(currentline, defaultPattern[0]);
+                                       newline = (char*)MALLOC(sizeof(char)*(strlen(currentline)+ strlen(dictionaryFiles[0])));
+
+                                       if (newline)
+                                       {
+                                               int l = strlen(currentline)- strlen(ptr_strrchar2);
+                                               if (l < 0) l = 0 - l;
+
+                                               strncpy(newline,currentline, l);
+                                               /* special case with files begin with a '.' */
+                                               if (newline[l-1] == '.') strcat(newline, &(dictionaryFiles[0][1]));
+                                               else strcat(newline, ptr_strrchar1);
+
+                                               clearCurrentLine();
+                                               copyLine(newline);
+                                               FREE(newline);
+                                               return;
+                                       }
+                               }
                        }
                }
                else
                {
-                       displayCompletionDictionary(completionDictionaryFiles,sizecompletionDictionaryFiles,gettext("File or Directory"));
+                       char *common = getCommonPart(dictionaryFiles, sizedictionaryFiles);
+
+                       displayCompletionDictionary(dictionaryFiles, 
+                               sizedictionaryFiles, gettext("File or Directory"));
+
                        displayPrompt();
                        newLine();
-                       copyLine(CurrentLine);
+
+                       if (defaultPattern[0] == 0)
+                       {
+                               clearCurrentLine();
+                               copyLine(currentline);
+                       }
+                       else if (common)
+                       {
+                               char *ptr_strrchar1 = NULL;
+
+                               ptr_strrchar1 = strrchr(common, defaultPattern[0]);
+                               if (ptr_strrchar1) 
+                               {
+                                       char *ptr_strrchar2 = NULL;
+                                       char *newline = NULL;
+                                       ptr_strrchar2 = strrchr(currentline, defaultPattern[0]);
+                                       newline = (char*)MALLOC(sizeof(char)*(strlen(currentline)+ strlen(ptr_strrchar1)));
+
+                                       if (newline)
+                                       {
+                                               int l = strlen(currentline)- strlen(ptr_strrchar2);
+                                               if (l < 0) l = 0 - l;
+
+                                               strncpy(newline,currentline, l);
+                                               strcat(newline, ptr_strrchar1);
+
+                                               clearCurrentLine();
+                                               copyLine(newline);
+                                               FREE(newline);
+                                       }
+                               }
+                               else
+                               {
+                                       clearCurrentLine();
+                                       copyLine(currentline);
+                               }
+                               FREE(common);
+                               common = NULL;
+                       }
                }
-               FREE(CurrentLine);
-               FREE(fileSearchedPattern);
-               FREE(SearchedPattern);
-               freeArrayOfString(completionDictionaryFiles,sizecompletionDictionaryFiles);
-               return;
        }
-       else
+}
+/*--------------------------------------------------------------------------*/
+static void TermCompletionOnAll(char *currentline, char *defaultPattern)
+{
+       if ( defaultPattern && strcmp(defaultPattern, "") )
        {
                int numberWordFound = 0;
 
@@ -80,39 +142,29 @@ void TermCompletion(void)
                char **completionDictionaryVariables = NULL;
                int sizecompletionDictionaryVariables = 0;
 
-               char **completionDictionaryFiles = NULL;
-               int sizecompletionDictionaryFiles = 0;
-
                char **completionDictionaryHandleGraphicsProperties = NULL;
                int sizecompletionDictionaryHandleGraphicsProperties = 0;
 
-               if ( SearchedPattern && strcmp(SearchedPattern,"") )
-               {
-
-               completionDictionaryFunctions = completionOnFunctions(SearchedPattern, 
+               completionDictionaryFunctions = completionOnFunctions(defaultPattern, 
                        &sizecompletionDictionaryFunctions);
 
-               completionDictionaryCommandWords = completionOnCommandWords(SearchedPattern, 
+               completionDictionaryCommandWords = completionOnCommandWords(defaultPattern, 
                        &sizecompletionDictionaryCommandWords);
 
-               completionDictionaryMacros = completionOnMacros(SearchedPattern, 
+               completionDictionaryMacros = completionOnMacros(defaultPattern, 
                        &sizecompletionDictionaryMacros);
 
-               completionDictionaryVariables = completionOnVariablesWithoutMacros(SearchedPattern, 
+               completionDictionaryVariables = completionOnVariablesWithoutMacros(defaultPattern, 
                        &sizecompletionDictionaryVariables);
 
-               completionDictionaryFiles = completionOnFiles(SearchedPattern, 
-                       &sizecompletionDictionaryFiles);
-
-               completionDictionaryHandleGraphicsProperties = completionOnHandleGraphicsProperties(SearchedPattern, 
+               completionDictionaryHandleGraphicsProperties = completionOnHandleGraphicsProperties(defaultPattern, 
                        &sizecompletionDictionaryHandleGraphicsProperties);
-               }
 
                numberWordFound = sizecompletionDictionaryFunctions + sizecompletionDictionaryCommandWords +
                        sizecompletionDictionaryMacros + sizecompletionDictionaryVariables +
                        sizecompletionDictionaryHandleGraphicsProperties;
 
-               if (numberWordFound)
+               if (numberWordFound > 0)
                {
                        if (numberWordFound == 1)
                        {
@@ -128,13 +180,13 @@ void TermCompletion(void)
                                if (completionDictionaryHandleGraphicsProperties) completionDictionary = completionDictionaryHandleGraphicsProperties;
 
                                result = completionDictionary[0];
-                               partResult = &result[strlen(SearchedPattern)];
-                               newline = (char*)MALLOC(sizeof(char)*(strlen(CurrentLine)+ strlen(partResult)));
+                               partResult = &result[strlen(defaultPattern)];
+                               newline = (char*)MALLOC(sizeof(char)*(strlen(currentline)+ strlen(partResult)));
 
                                if (newline)
                                {
-                                       strcpy(newline,CurrentLine);
-                                       strcat(newline,partResult);
+                                       strcpy(newline, currentline);
+                                       strcat(newline, partResult);
                                        clearCurrentLine();
                                        copyLine(newline);
                                        FREE(newline);
@@ -142,35 +194,99 @@ void TermCompletion(void)
                        }
                        else
                        {
-                               displayCompletionDictionary(completionDictionaryFunctions,sizecompletionDictionaryFunctions,gettext("Scilab Function"));
+                               char *commonFunctions = getCommonPart(completionDictionaryFunctions,sizecompletionDictionaryFunctions);
+                               char *commonCommandWords = getCommonPart(completionDictionaryCommandWords,sizecompletionDictionaryCommandWords);
+                               char *commonMacros = getCommonPart(completionDictionaryMacros,sizecompletionDictionaryMacros);
+                               char *commonVariables = getCommonPart(completionDictionaryVariables,sizecompletionDictionaryVariables);
+                               char *commonHandleGraphicsProperties = getCommonPart(completionDictionaryHandleGraphicsProperties,sizecompletionDictionaryHandleGraphicsProperties);
+
+                               char *commonAll = NULL;
+
+                               int sizecommonsDictionary = 0;
+                               char **commonsDictionary = concatenateStrings(&sizecommonsDictionary, commonFunctions,
+                                       commonMacros, commonCommandWords, commonVariables, commonHandleGraphicsProperties);
+
+                               if (sizecommonsDictionary > 0)
+                               {
+                                       if (sizecommonsDictionary == 1)
+                                       {
+                                               commonAll = strdup(commonsDictionary[0]);
+                                       }
+                                       else
+                                       {
+                                               commonAll = getCommonPart(commonsDictionary, sizecommonsDictionary);
+                                       }
+                                       freeArrayOfString(commonsDictionary, sizecommonsDictionary);
+                               }
+
+                               displayCompletionDictionary(completionDictionaryFunctions, sizecompletionDictionaryFunctions,gettext("Scilab Function"));
                                displayCompletionDictionary(completionDictionaryCommandWords, sizecompletionDictionaryCommandWords,gettext("Scilab Command"));
-                               displayCompletionDictionary(completionDictionaryMacros,sizecompletionDictionaryMacros,gettext("Scilab Macro"));
-                               displayCompletionDictionary(completionDictionaryVariables,sizecompletionDictionaryVariables,gettext("Scilab Variable"));
-                               displayCompletionDictionary(completionDictionaryHandleGraphicsProperties,sizecompletionDictionaryHandleGraphicsProperties,gettext("Graphics handle field"));
+                               displayCompletionDictionary(completionDictionaryMacros, sizecompletionDictionaryMacros,gettext("Scilab Macro"));
+                               displayCompletionDictionary(completionDictionaryVariables, sizecompletionDictionaryVariables,gettext("Scilab Variable"));
+                               displayCompletionDictionary(completionDictionaryHandleGraphicsProperties, sizecompletionDictionaryHandleGraphicsProperties,gettext("Graphics handle field"));
 
                                displayPrompt();
                                newLine();
-                               copyLine(CurrentLine);
+
+                               if (commonAll)
+                               {
+                                       char *result = NULL;
+                                       char *partResult = NULL;
+                                       char *newline = NULL;
+
+                                       result = commonAll;
+                                       partResult = &result[strlen(defaultPattern)];
+                                       newline = (char*)MALLOC(sizeof(char)*(strlen(currentline)+ strlen(partResult)));
+
+                                       if (newline)
+                                       {
+                                               strcpy(newline, currentline);
+                                               strcat(newline,partResult);
+                                               clearCurrentLine();
+                                               copyLine(newline);
+                                               FREE(newline);
+                                       }
+                                       FREE(commonAll);
+                                       commonAll = NULL;
+                               }
                        }
+
                        freeArrayOfString(completionDictionaryFunctions,sizecompletionDictionaryFunctions);
                        freeArrayOfString(completionDictionaryCommandWords,sizecompletionDictionaryCommandWords);
                        freeArrayOfString(completionDictionaryMacros,sizecompletionDictionaryMacros);
                        freeArrayOfString(completionDictionaryVariables,sizecompletionDictionaryVariables);
-                       freeArrayOfString(completionDictionaryFiles,sizecompletionDictionaryFiles);
                        freeArrayOfString(completionDictionaryHandleGraphicsProperties,sizecompletionDictionaryHandleGraphicsProperties);
-                       FREE(CurrentLine);
-                       FREE(fileSearchedPattern);
-                       FREE(SearchedPattern);
-               }
-               else
-               {
-                       FREE(CurrentLine);
-                       FREE(fileSearchedPattern);
-                       FREE(SearchedPattern);
                }
        }
 }
 /*--------------------------------------------------------------------------*/
+void TermCompletion(void)
+{
+       char *CurrentLine = getCurrentLine();
+       char *fileSearchedPattern = getFilePartLevel(CurrentLine);
+       char *SearchedPattern = getPartLevel(CurrentLine);
+
+       char **completionDictionaryFiles = NULL;
+       int sizecompletionDictionaryFiles = 0;
+
+       completionDictionaryFiles = completionOnFiles(fileSearchedPattern, &sizecompletionDictionaryFiles);
+       if (completionDictionaryFiles)
+       {
+               TermCompletionOnFiles(completionDictionaryFiles, sizecompletionDictionaryFiles,
+                                                               CurrentLine, fileSearchedPattern, SearchedPattern);
+
+               freeArrayOfString(completionDictionaryFiles, sizecompletionDictionaryFiles);
+       }
+       else
+       {
+               TermCompletionOnAll(CurrentLine, SearchedPattern);
+       }
+
+       if (CurrentLine) FREE(CurrentLine);
+       if (fileSearchedPattern) FREE(fileSearchedPattern);
+       if (SearchedPattern) FREE(SearchedPattern);
+}
+/*--------------------------------------------------------------------------*/
 static void displayCompletionDictionary(char **dictionary,int sizedictionary, char *namedictionary)
 {
        if (dictionary)
@@ -203,3 +319,38 @@ static void displayCompletionDictionary(char **dictionary,int sizedictionary, ch
        }
 }
 /*--------------------------------------------------------------------------*/
+static char **concatenateStrings(int *sizearrayofstring, char *string1,
+                                                                char *string2, char *string3,
+                                                                char *string4, char *string5)
+{
+       int newsize = 0;
+       char **arrayOfString = NULL;
+       *sizearrayofstring = 0;
+
+       if (string1) newsize++;
+       if (string2) newsize++;
+       if (string3) newsize++;
+       if (string4) newsize++;
+       if (string5) newsize++;
+
+       if (newsize > 0)
+       {
+               arrayOfString = (char**)MALLOC(sizeof(char*) *(newsize));
+               if (arrayOfString)
+               {
+                       int i = 0;
+                       if (string1) {arrayOfString[i] = string1; i++;}
+                       if (string2) {arrayOfString[i] = string2; i++;}
+                       if (string3) {arrayOfString[i] = string3; i++;}
+                       if (string4) {arrayOfString[i] = string4; i++;}
+                       if (string5) {arrayOfString[i] = string5; i++;}
+                       *sizearrayofstring = i;
+               }
+               else
+               {
+                       *sizearrayofstring = 0;
+               }
+       }
+       return arrayOfString;
+}
+/*--------------------------------------------------------------------------*/