apropos function is now available with new Java help browser
Vincent Couvert [Sat, 19 Apr 2008 13:33:10 +0000 (13:33 +0000)]
15 files changed:
scilab/modules/gui/includes/CallHelpBrowser.h
scilab/modules/gui/sci_gateway/c/sci_helpbrowser.c
scilab/modules/gui/src/cpp/CallHelpBrowser.cpp
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/CallScilabBridge.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/ScilabBridge.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/helpbrowser/SwingScilabHelpBrowser.java
scilab/modules/gui/src/java/org/scilab/modules/gui/helpbrowser/HelpBrowser.java
scilab/modules/gui/src/java/org/scilab/modules/gui/helpbrowser/ScilabHelpBrowser.java
scilab/modules/gui/src/java/org/scilab/modules/gui/helpbrowser/ScilabHelpBrowserBridge.java
scilab/modules/gui/src/java/org/scilab/modules/gui/helpbrowser/SimpleHelpBrowser.java
scilab/modules/gui/src/jni/CallScilabBridge.cpp
scilab/modules/gui/src/jni/CallScilabBridge.giws.xml
scilab/modules/gui/src/jni/CallScilabBridge.hxx
scilab/modules/helptools/macros/apropos.sci
scilab/modules/helptools/macros/help.sci

index 0e47015..8a0e977 100644 (file)
@@ -32,8 +32,9 @@ void launchHelpBrowser(char **helps, int helpsSize, char *language);
  * @param helpsSize number of entries in helps
  * @param keyword the keyword to search
  * @param language Scilab current locale
+ * @param fullText true to execute a full-text search
  */
-BOOL searchKeyword(char **helps, int helpsSize, char *keyword, char *language);
+void searchKeyword(char **helps, int helpsSize, char *keyword, char *language, BOOL fullText);
 
 #endif /* !__CALLHELPBROWSER_H__ */
 
index 32a2036..8729e96 100644 (file)
@@ -27,8 +27,9 @@ int sci_helpbrowser(char *fname,unsigned long fname_len)
   int nbRowHelp = 0, nbColHelp = 0;
   char **helpAdr = NULL;
   char **languageAdr = NULL;
+  int fullTextAdr = 0;
   
-  CheckRhs(2,3);
+  CheckRhs(2,4);
   CheckLhs(0,1);
 
   if (VarType(1) == sci_strings)
@@ -82,7 +83,7 @@ int sci_helpbrowser(char *fname,unsigned long fname_len)
           launchHelpBrowser(getStringMatrixFromStack((int)helpAdr), nbRowHelp*nbColHelp, getStringMatrixFromStack((int)languageAdr)[0]);
         }
     }
-  else
+  else if (Rhs == 4)
     {
       if (VarType(2) == sci_strings)
         {
@@ -114,20 +115,34 @@ int sci_helpbrowser(char *fname,unsigned long fname_len)
           return FALSE;
         }
       
-      if (helpAdr == NULL) /* No toolboxes loaded */
+      if (VarType(4) == sci_boolean)
         {
-          if (!searchKeyword(NULL, nbRowHelp*nbColHelp, getStringMatrixFromStack((int)keywordAdr)[0], getStringMatrixFromStack((int)languageAdr)[0]))
+          GetRhsVar(4, MATRIX_OF_BOOLEAN_DATATYPE, &nbRow, &nbCol, &fullTextAdr);
+          if (nbRow*nbCol != 1)
             {
-              sciprint(_("Could not find help page for function: %s.\n"),getStringMatrixFromStack((int)keywordAdr)[0]);
+              Scierror(999, _("%s: Wrong size for fourth input argument: Single boolean expected.\n"), "helpbrowser");
+              return FALSE;
             }
         }
       else
         {
-          if (!searchKeyword(getStringMatrixFromStack((int)helpAdr), nbRowHelp*nbColHelp, getStringMatrixFromStack((int)keywordAdr)[0], getStringMatrixFromStack((int)languageAdr)[0]))
-            {
-              sciprint(_("Could not find help page for function: %s.\n"),getStringMatrixFromStack((int)keywordAdr)[0]);
-            }
+          Scierror(999, _("%s: Wrong type for fourth second argument: Single boolean expected.\n"), "helpbrowser");
+          return FALSE;
         }
+      
+      if (helpAdr == NULL) /* No toolboxes loaded */
+        {
+          searchKeyword(NULL, nbRowHelp*nbColHelp, getStringMatrixFromStack((int)keywordAdr)[0], getStringMatrixFromStack((int)languageAdr)[0], *istk(fullTextAdr)==1);
+        }
+      else
+        {
+          searchKeyword(getStringMatrixFromStack((int)helpAdr), nbRowHelp*nbColHelp, getStringMatrixFromStack((int)keywordAdr)[0], getStringMatrixFromStack((int)languageAdr)[0], *istk(fullTextAdr)==1);
+        }
+    }
+  else
+    {
+      Scierror(999, _("%s: Wrong number of input arguments: %d or %d expected.\n"), "helpbrowser", 2, 4);
+      return FALSE;
     }
   
   LhsVar(1) = 0;
index 3e5fc02..e72e99b 100644 (file)
@@ -19,7 +19,7 @@ void launchHelpBrowser(char **helps, int helpsSize, char* language)
   CallScilabBridge::launchHelpBrowser(getScilabJavaVM(), helps, helpsSize, language);
 }
 
-BOOL searchKeyword(char **helps, int helpsSize, char *keyword, char* language)
+void searchKeyword(char **helps, int helpsSize, char *keyword, char* language, BOOL fullText)
 {
-  return CallScilabBridge::searchKeyword(getScilabJavaVM(), helps, helpsSize, keyword, language);
+  CallScilabBridge::searchKeyword(getScilabJavaVM(), helps, helpsSize, keyword, language, fullText);
 }
index 6db69c1..d1636b8 100644 (file)
@@ -1889,10 +1889,14 @@ public class CallScilabBridge {
         * @param keyword the keyword to search
         * @param helps help chapters and directories
         * @param language Scilab current language
-        * @return true if the keyword is a function name
+        * @param fullText true for a full-text search
         */
-       public static boolean searchKeyword(String[] helps, String keyword, String language) {
-               return ScilabHelpBrowser.createHelpBrowser(helps, language).searchKeywork(keyword);
+       public static void searchKeyword(String[] helps, String keyword, String language, boolean fullText) {
+               if (fullText) {
+                       ScilabHelpBrowser.createHelpBrowser(helps, language).fullTextSearch(keyword);
+               } else {
+                       ScilabHelpBrowser.createHelpBrowser(helps, language).searchKeywork(keyword);
+               }
        }
 
        /**
index c155878..1d7c607 100644 (file)
@@ -4274,13 +4274,21 @@ public class ScilabBridge {
         * Display the matching items for a specified keyword
         * @param browser the Help Browser
         * @param keyword the keyword
-        * @return true if the keyword exists
         */
-       public static boolean searchKeywork(HelpBrowser browser, String keyword) {
-               return ScilabHelpBrowserBridge.searchKeywork(browser, keyword);
+       public static void searchKeywork(HelpBrowser browser, String keyword) {
+               ScilabHelpBrowserBridge.searchKeywork(browser, keyword);
        }
        
        /**
+        * Display the result of a full-text search for a specified word
+        * @param browser the Help Browser
+        * @param keyword the keyword
+        */
+       public static void fullTextSearch(HelpBrowser browser, String keyword) {
+               ScilabHelpBrowserBridge.fullTextSearch(browser, keyword);
+       }
+
+       /**
         * Close the HelpBrowser
         * @param browser the Help Browser
         */
index 5d6840b..0bed3c9 100644 (file)
@@ -16,12 +16,19 @@ import java.io.FilenameFilter;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
+import java.util.Enumeration;
+import java.util.Locale;
 
 import javax.help.BadIDException;
 import javax.help.DefaultHelpModel;
 import javax.help.HelpSet;
 import javax.help.HelpSetException;
 import javax.help.JHelp;
+import javax.help.JHelpIndexNavigator;
+import javax.help.JHelpSearchNavigator;
+import javax.help.JHelpTOCNavigator;
+import javax.help.plaf.basic.BasicSearchNavigatorUI;
+import javax.help.search.SearchQuery;
 
 import org.scilab.modules.gui.helpbrowser.SimpleHelpBrowser;
 
@@ -36,6 +43,7 @@ public class SwingScilabHelpBrowser extends JHelp implements SimpleHelpBrowser {
        private String jarExtension = "_help.jar";
        private String mainJarPath = System.getenv("SCI") + "/modules/helptools/jar/scilab_";
        private String defaultLanguage = "en_US";
+       private String currentLanguage = "";
     private HelpSet helpSet;
 
     /**
@@ -55,8 +63,10 @@ public class SwingScilabHelpBrowser extends JHelp implements SimpleHelpBrowser {
 
            /* Main Jar file */
            File mainJar = new File(mainJarPath + language + jarExtension);
+           currentLanguage = language;
            if (!mainJar.exists()) {
                mainJar = new File(mainJarPath + defaultLanguage + jarExtension);
+               currentLanguage = defaultLanguage;
            }
            
            int nbFilesToLoad = 0;
@@ -123,7 +133,6 @@ public class SwingScilabHelpBrowser extends JHelp implements SimpleHelpBrowser {
                        }
                        this.getModel().getHelpSet().add(helpSet);
         }
-
        }
        
        /**
@@ -136,16 +145,34 @@ public class SwingScilabHelpBrowser extends JHelp implements SimpleHelpBrowser {
        /**
         * Display the matching items for a specified keyword
         * @param keyword the keyword
-        * @return true if the keyword exists
         */
-       public boolean searchKeywork(String keyword) {
+       public void searchKeywork(String keyword) {
                try {
+                       Enumeration navigators = getHelpNavigators();
+                       setCurrentNavigator((JHelpTOCNavigator) navigators.nextElement());
                        setCurrentID(keyword);
-                       return true;
                } catch (BadIDException e) {
-                       return false;
+                       fullTextSearch(keyword);
                }
        }
+    
+       /**
+        * Display the matching help pages for a specified keyword
+        * @param keyword the keyword to search
+        */
+       public void fullTextSearch(String keyword) {
+               Enumeration navigators = getHelpNavigators();
+    
+               navigators.nextElement(); // JHelpTOCNavigator
+               navigators.nextElement();       // JHelpIndexNavigator 
+               JHelpSearchNavigator searchNav = (JHelpSearchNavigator) navigators.nextElement();
+
+               setCurrentNavigator(searchNav);
+    
+               SearchQuery query = searchNav.getSearchEngine().createQuery();
+               query.addSearchListener((BasicSearchNavigatorUI) searchNav.getUI());
+               query.start(keyword, new Locale(currentLanguage));
+       }
        
        /**
         * Close the HelpBrowser
index 982a1a5..cbcc7eb 100644 (file)
@@ -32,11 +32,16 @@ public interface HelpBrowser extends Dockable {
        void display();
        
        /**
-        * Display the matching items for a specified keyword
+        * Display help page for a specified keyword
         * @param keyword the keyword
-        * @return true if the keyword exists
         */
-       boolean searchKeywork(String keyword);
+       void searchKeywork(String keyword);
+       
+       /**
+        * Display the result of a full-text search for a specified word
+        * @param keyword the keyword
+        */
+       void fullTextSearch(String keyword);
        
        /**
         * Close the HelpBrowser
index 9a1e5b1..4b512bb 100644 (file)
@@ -99,15 +99,22 @@ public class ScilabHelpBrowser extends ScilabDockable implements HelpBrowser {
        }
        
        /**
-        * Display the matching items for a specified keyword
+        * Display the help page for a specified keyword
         * @param keyword the keyword
-        * @return true if the keyword exists
         */
-       public boolean searchKeywork(String keyword) {
-               return ScilabBridge.searchKeywork(this, keyword);
+       public void searchKeywork(String keyword) {
+               ScilabBridge.searchKeywork(this, keyword);
        }
        
        /**
+        * Display the result of a full-text search for a specified word
+        * @param keyword the keyword
+        */
+       public void fullTextSearch(String keyword) {
+               ScilabBridge.fullTextSearch(this, keyword);
+       }
+
+       /**
         * Close the HelpBrowser
         */
        public void close() {
index f97e4b4..9670446 100644 (file)
@@ -48,13 +48,21 @@ public class ScilabHelpBrowserBridge {
         * Display the matching items for a specified keyword
         * @param browser the Help Browser
         * @param keyword the keyword
-        * @return true if the keyword exists
         */
-       public static boolean searchKeywork(HelpBrowser browser, String keyword) {
-               return browser.getAsSimpleHelpBrowser().searchKeywork(keyword);
+       public static void searchKeywork(HelpBrowser browser, String keyword) {
+               browser.getAsSimpleHelpBrowser().searchKeywork(keyword);
        }
 
        /**
+        * Display the result of a full-text search for a specified word
+        * @param browser the Help Browser
+        * @param keyword the keyword
+        */
+       public static void fullTextSearch(HelpBrowser browser, String keyword) {
+               browser.getAsSimpleHelpBrowser().fullTextSearch(keyword);
+       }
+       
+       /**
         * Close the HelpBrowser
         * @param browser the Help Browser
         */
index 50f2d75..5eabbc4 100644 (file)
@@ -26,11 +26,16 @@ public interface SimpleHelpBrowser {
        /**
         * Display the matching items for a specified keyword
         * @param keyword the keyword
-        * @return true if the keyword exists
         */
-       boolean searchKeywork(String keyword);
+       void searchKeywork(String keyword);
        
        /**
+        * Display the result of a full-text search for a specified word
+        * @param keyword the keyword
+        */
+       void fullTextSearch(String keyword);
+
+       /**
         * Close the HelpBrowser
         */
        void close();
index 3fcf4d5..4fc68a6 100644 (file)
@@ -234,7 +234,7 @@ voidsetWaitBarValuejintjintID=NULL;
 voiddestroyWaitBarjintID=NULL; 
 voidsetWaitBarIndeterminateModejintjbooleanID=NULL; 
 voidlaunchHelpBrowserjobjectArrayjstringID=NULL; 
-jbooleansearchKeywordjobjectArrayjstringjstringID=NULL; 
+voidsearchKeywordjobjectArrayjstringjstringjbooleanID=NULL; 
 voidsaveMainWindowSettingsID=NULL; 
 jintnewFontChooserID=NULL; 
 voidfontChooserDisplayAndWaitjintID=NULL; 
@@ -421,7 +421,7 @@ voidsetWaitBarValuejintjintID=NULL;
 voiddestroyWaitBarjintID=NULL; 
 voidsetWaitBarIndeterminateModejintjbooleanID=NULL; 
 voidlaunchHelpBrowserjobjectArrayjstringID=NULL; 
-jbooleansearchKeywordjobjectArrayjstringjstringID=NULL; 
+voidsearchKeywordjobjectArrayjstringjstringjbooleanID=NULL; 
 voidsaveMainWindowSettingsID=NULL; 
 jintnewFontChooserID=NULL; 
 voidfontChooserDisplayAndWaitjintID=NULL; 
@@ -3927,14 +3927,14 @@ curEnv->DeleteLocalRef(helps_);
 
 }
 
-bool CallScilabBridge::searchKeyword (JavaVM * jvm_, char ** helps, int helpsSize, char * keyword, char * language){
+void CallScilabBridge::searchKeyword (JavaVM * jvm_, char ** helps, int helpsSize, char * keyword, char * language, bool fullText){
 
 JNIEnv * curEnv = NULL;
 jvm_->AttachCurrentThread((void **) &curEnv, NULL);
 jclass cls = curEnv->FindClass( className().c_str() );
 
-jmethodID jbooleansearchKeywordjobjectArrayjstringjstringID = curEnv->GetStaticMethodID(cls, "searchKeyword", "([Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z" ) ;
-if (jbooleansearchKeywordjobjectArrayjstringjstringID == NULL) {
+jmethodID voidsearchKeywordjobjectArrayjstringjstringjbooleanID = curEnv->GetStaticMethodID(cls, "searchKeyword", "([Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V" ) ;
+if (voidsearchKeywordjobjectArrayjstringjstringjbooleanID == NULL) {
 std::cerr << "Could not access to the method " << "searchKeyword" << std::endl;
 exit(EXIT_FAILURE);
 }
@@ -3967,7 +3967,9 @@ jstring keyword_ = curEnv->NewStringUTF( keyword );
 
 jstring language_ = curEnv->NewStringUTF( language );
 
-                        jboolean res =  (jboolean) curEnv->CallStaticBooleanMethod(cls, jbooleansearchKeywordjobjectArrayjstringjstringID ,helps_, keyword_, language_);
+jboolean fullText_ = ((bool) fullText ? JNI_TRUE : JNI_FALSE);
+
+                         curEnv->CallStaticVoidMethod(cls, voidsearchKeywordjobjectArrayjstringjstringjbooleanID ,helps_, keyword_, language_, fullText_);
                         
 if (curEnv->ExceptionOccurred()) {
 curEnv->ExceptionDescribe() ;
@@ -3976,8 +3978,6 @@ curEnv->ExceptionDescribe() ;
                         curEnv->DeleteLocalRef(stringArrayClass);
 curEnv->DeleteLocalRef(helps_);
 
-return (res == JNI_TRUE);
-
 }
 
 void CallScilabBridge::saveMainWindowSettings (JavaVM * jvm_){
index 852fc11..2c5c5f7 100644 (file)
           <parameter type="String[]" name="helps"/>
           <parameter type="String" name="language"/>
         </method>      
-        <method name="searchKeyword" returnType="boolean" modifier="static">
+        <method name="searchKeyword" returnType="void" modifier="static">
           <parameter type="String[]" name="helps"/>
           <parameter type="String" name="keyword"/>
           <parameter type="String" name="language"/>
+          <parameter type="boolean" name="fullText"/>
         </method>
 <!-- Main settings -->
        <method name="saveMainWindowSettings" returnType="void" modifier="static">
index 120701b..e58ee61 100644 (file)
@@ -185,7 +185,7 @@ jmethodID voidsetWaitBarValuejintjintID; // cache method id
 jmethodID voiddestroyWaitBarjintID; // cache method id
 jmethodID voidsetWaitBarIndeterminateModejintjbooleanID; // cache method id
 jmethodID voidlaunchHelpBrowserjobjectArrayjstringID; // cache method id
-jmethodID jbooleansearchKeywordjobjectArrayjstringjstringID; // cache method id
+jmethodID voidsearchKeywordjobjectArrayjstringjstringjbooleanID; // cache method id
 jmethodID voidsaveMainWindowSettingsID; // cache method id
 jmethodID jintnewFontChooserID; // cache method id
 jmethodID voidfontChooserDisplayAndWaitjintID; // cache method id
@@ -520,7 +520,7 @@ static void setWaitBarIndeterminateMode(JavaVM * jvm_, long objID, bool status);
 
 static void launchHelpBrowser(JavaVM * jvm_, char ** helps, int helpsSize, char * language);
 
-static bool searchKeyword(JavaVM * jvm_, char ** helps, int helpsSize, char * keyword, char * language);
+static void searchKeyword(JavaVM * jvm_, char ** helps, int helpsSize, char * keyword, char * language, bool fullText);
 
 static void saveMainWindowSettings(JavaVM * jvm_);
 
index 1f05573..533c008 100644 (file)
@@ -1,6 +1,6 @@
 
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2008 - INRIA
+// Copyright (C) 2008 - INRIA - Vincent COUVERT
 //
 // This file must be used under the terms of the CeCILL.
 // This source file is licensed as described in the file COPYING, which
 // are also available at
 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
 
-// ==========================================================================
-// apropos
-// ==========================================================================
-
 function apropos(key)
-       
-       if argn(2)<>1 then
-               error(39);
-       end
-       
-       change_old_man()
-       INDEX=make_help_index()
-       
-       global %helps %helps_modules INDEX
-       global %browsehelp;
-       
-       [lhs,rhs]=argn(0);
-       
-       // list relevant man for key
-       if %browsehelp=="Scilab Browser" then
-               browsehelp(" ",key);
-       else
-               key=convstr(key);
-               provpath =apropos_gener(key);
-               browsehelp(provpath,key);
-       end
-       
-endfunction
 
+if argn(2)<>1 then
+  error(msprintf(gettext("%s: Wrong number of input arguments: %d expected.\n"), "apropos", 1));
+end
 
-// ==========================================================================
-// apropos_gener
-// ==========================================================================
-
-function [provpath]=apropos_gener(key)
-       
-       // generate html file for apropos key
-       // provpath is the path of generated html file
-       
-       global %helps %helps_modules INDEX
-       %HELPS=[%helps_modules,%helps]
-       
-       sep="/";
-       key1=key
-       K=[' ','(',')','[',']','{','}','""','/','\','.','<','>']
-       for k=K,key1=strsubst(key1,k,'_'),end
-       
-       l=length(key)
-       found=[];foundkey=[]
-       
-       for k=1:size(%HELPS,1)
-               [fd,ierr]=mopen(%HELPS(k,1)+sep+"whatis.htm","r");
-               if ierr==0 then
-                       whatis=mgetl(fd);mclose(fd)
-                       ind=grep(whatis,'</A>');
-                       whatis=whatis(ind);
-                       if whatis<>[] then
-                               f=grep(convstr(whatis),key);
-                               lwhatis=strsubst(whatis(f),"HREF=""", "HREF="""+%HELPS(k,1)+sep)
-                               found=[found;lwhatis];
-                               for k1=f
-                                       i=strindex(whatis(k1),">"); j=strindex(whatis(k1),"</A>")
-                                       lkey=part(whatis(k1),i(2)+1:j-1)
-                                       foundkey=[foundkey;lkey]
-                               end
-                       end
-               end
-       end
-       
-       if found==[] then
-               select getlanguage()
-               case "en"
-                       found="<H3>No man found for: "+key+"</H3>";
-               case "fr"
-                       found="<H3>Pas de manuel trouvĂ© pour : "+key+"</H3>";
-               end
-       else
-               [s,k]=sort(foundkey);
-               found= found(k);
-       end
-       
-       provpath=TMPDIR+sep+"apropos_"+key1;
-       
-       if MSDOS then
-               provpath=provpath+'.htm';
-       end
-       
-       apropos_txt =["<html>";
-               "<head>";
-               "  <meta http-equiv=""Content-Type"" content=""text/html; charset=ISO-8859-1"">";
-               "    <title>Apropos "+key+"</title>";
-               "</head>";
-               "<body bgcolor=""FFFFFF"">";
-               found;
-               "</body></html>"];
-       
-       mputl(apropos_txt,provpath)
+global %helps
+helpbrowser(%helps(:,1), key, getlanguage(), %T);
        
 endfunction
index 8ada032..cb6c51a 100644 (file)
@@ -1,6 +1,6 @@
 
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2008 - INRIA
+// Copyright (C) 2008 - INRIA - Vincent COUVERT
 //
 // This file must be used under the terms of the CeCILL.
 // This source file is licensed as described in the file COPYING, which
@@ -9,75 +9,42 @@
 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
 
 function help(key)
-       
-       //for compatibility with toolboxes making use of old cat files
-       
-       if (fileinfo('SCI/modules/helptools/help') <> []) then
-               
-               global %browsehelp
-               nwniarg=find(sciargs()=="-nwni");
-               texmacsarg=find(sciargs()=="--texmacs");
-               noguiarg=find(sciargs()=="-nogui");
-               
-               if (%browsehelp<>[])&(nwniarg == [])&(texmacsarg == [])&(noguiarg == []) then
-                       
-                       change_old_man()
-                       INDEX=make_help_index()
-                       
-                       if argn(2)==0 then
-                               global %helps
-                               helpbrowser(%helps(:,1), getlanguage());
-                               //browsehelp(INDEX,"index");
-                               return
-                       end
-                       
-                       key=stripblanks(key)
-                       
-                       if or(part(key,1)==['(',')','[',']','{','}','%','''','""',':','*','/', ...
-                               '\','.','<','>','&','^','|','~','+','-']) then
-                               key="symbols";
-                       end
-                       
-                       //path=gethelpfile(key)
-                       
-                       //if path<>[] then
-                               global %helps
-                               helpbrowser(%helps(:,1), key, getlanguage());
-                               //browsehelp(path,key)
-                       //else
-                       //      apropos(key)
-                       //end
-                       
-               else
-                       if (%browsehelp == []) then
-                               warning('%browsehelp not correctly defined. help browser disabled. ');
-                               return;
-                       end
-                       
-                       errmsg='help browser disabled in this mode : ';
-                       
-                       if ( nwniarg <> []) then
-                               errmsg=errmsg+'-nwni';
-                               warning(errmsg);
-                               return;
-                       end
-                       
-                       if ( texmacsarg <> []) then
-                               errmsg=errmsg+ '--texmacs';
-                               warning(errmsg);
-                               return;
-                       end
-                       
-                       if ( noguiarg <> [] ) then
-                               errmsg=errmsg+ '-nogui';
-                               warning(errmsg);
-                               return;
-                       end
-               end
-       else
-               warning('Help not installed');
-       end
-       
+
+if (fileinfo('SCI/modules/helptools/help') <> []) then
+  
+  if getscilabmode() <> "NWNI" then
+    
+    // No input argument: launch help browser
+    if argn(2)==0 then
+      global %helps
+      helpbrowser(%helps(:,1), getlanguage());
+      return
+    end
+    
+    // Search a function name
+    key=stripblanks(key)
+    
+    if or(part(key,1)==['(',')','[',']','{','}','%','''','""',':','*','/', ...
+           '\','.','<','>','&','^','|','~','+','-']) then
+      key="symbols";
+    end
+  
+    global %helps
+    helpbrowser(%helps(:,1), key, getlanguage(), %f);
+    
+    // If the function name does not exists then full-text search is done (See Java code)
+    
+  else
+
+    error(msprintf(gettext("%s: The help browser is disabled in %s mode.\n"), "help", getscilabmode()));
+  
+  end
+else
+
+  error(msprintf(gettext("%s: help module is not installed.\n"), "help"));
+
+end
+
 endfunction