lines(-1) reset vertical paging to current size of the window 95/4295/7
Allan CORNET [Thu, 23 Jun 2011 11:23:29 +0000 (13:23 +0200)]
Change-Id: I8563d9a73e4942b0d8812255416104e8e19d9094

14 files changed:
SEP/INDEX
SEP/SEP_067_lines_default_value.odt [new file with mode: 0644]
scilab/CHANGES_5.4.X
scilab/Scilab.sln
scilab/Scilab_f2c.sln
scilab/etc/scilab.start
scilab/modules/console/src/noconsole/noconsole.c
scilab/modules/shell/Makefile.am
scilab/modules/shell/Makefile.in
scilab/modules/shell/help/en_US/lines.xml
scilab/modules/shell/sci_gateway/c/sci_lines.c
scilab/modules/shell/src/c/sciconsole_Import.def
scilab/modules/shell/src/c/shell.vcxproj
scilab/modules/shell/tests/unit_tests/lines.tst [new file with mode: 0644]

index 879ea55..e2f3216 100644 (file)
--- a/SEP/INDEX
+++ b/SEP/INDEX
@@ -63,3 +63,4 @@ SEP #063: User block wizard
 SEP #064: HDF5 Scilab specification
 SEP #065: load and save based on HDF5
 SEP #066: Xcos compilation hooks
+SEP #067: lines() default value
\ No newline at end of file
diff --git a/SEP/SEP_067_lines_default_value.odt b/SEP/SEP_067_lines_default_value.odt
new file mode 100644 (file)
index 0000000..d0eb9a5
Binary files /dev/null and b/SEP/SEP_067_lines_default_value.odt differ
index 64985ad..4e93818 100644 (file)
@@ -58,7 +58,7 @@ Xcos:
 * bug 9336 fixed - SuperBlock with non connected ports produced an invalid
                    index error.
 
-* bug 9390 fixed - FROMWSB_c block does not reset to the default values on 
+* bug 9390 fixed - FROMWSB_c block does not reset to the default values on
                    ReInitialization execution.
 
 * bug 9478 fixed - Block structure was not checked while adding them to a new
@@ -126,7 +126,7 @@ Optimization:
             Defined a printing system by overloading for MPS structure.
             Updated the help page.
 
-* Bug 7093 fixed - The data structure generated by neldermead_new could not 
+* Bug 7093 fixed - The data structure generated by neldermead_new could not
                    be saved and reloaded.
 
 * Bug 7889 fixed - The tolerance on x for neldermead was too small.
@@ -137,13 +137,13 @@ Optimization:
 
 * Bug 9567 fixed - The neldermead Overview had a TODO section.
 
-* Bug 8542 fixed - In neldermead, there were undocumented default options. 
+* Bug 8542 fixed - In neldermead, there were undocumented default options.
                    Same changes applied to the help of optimbase.
 
-* Bug 8543 fixed - In neldermead, the help page presents a wrong order 
+* Bug 8543 fixed - In neldermead, the help page presents a wrong order
                    for the options.
 
-* Bug 8545 fixed - In neldermead, the printing system displays too long 
+* Bug 8545 fixed - In neldermead, the printing system displays too long
                    messages.
 
 * Bug 8546 fixed - The neldermead functions may call f outside the bounds.
@@ -155,10 +155,10 @@ Optimization:
 * Bug 9323 fixed - The messages in optimbase_checkbounds were not localized.
                    Same changes applied to optimbase_checkx0.
 
-* Bug 9576 fixed - The neldermead component did not check the bounds 
+* Bug 9576 fixed - The neldermead component did not check the bounds
                    of some input parameters.
 
-* Bug 9578 fixed - The optimbase_configure function does not check the 
+* Bug 9578 fixed - The optimbase_configure function does not check the
                    values of input arguments.
 
 
@@ -237,6 +237,8 @@ Misc:
 
 * Change the buffering display mode.
 
+* SEP 67: lines(0) by default at startup.
+
 
 Bug fixes:
 ==========
index 32e7158..56da50f 100644 (file)
@@ -376,6 +376,9 @@ EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "norandlib", "modules\randlib\src\norandlib\norandlib.vcxproj", "{E5038304-761D-448C-B358-48CA2883778A}"
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shell", "modules\shell\src\c\shell.vcxproj", "{805AA73F-EF7B-4177-BF46-200B72D8F83A}"
+       ProjectSection(ProjectDependencies) = postProject
+               {43C5BAB1-1DCA-4743-A183-77E0D42FE7D0} = {43C5BAB1-1DCA-4743-A183-77E0D42FE7D0}
+       EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjvm-Ant", "modules\jvm\src\java\jvm-JAVA.vcxproj", "{E9783492-017E-4811-9CC7-6B71856F847C}"
 EndProject
index 931f82c..66af633 100644 (file)
@@ -1,5 +1,5 @@
 Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual C++ Express 2010
+# Visual Studio 2010
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WScilex", "modules\windows_tools\src\c\WScilex\WScilex.vcxproj", "{CCD80549-EB9C-42AA-9B86-D687377E94F6}"
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BuildMacros", "modules\functions\scripts\buildmacros\BuildMacros.vcxproj", "{66F2FB48-5D68-4445-A856-119F685A371B}"
@@ -187,6 +187,9 @@ EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "norandlib", "modules\randlib\src\norandlib\norandlib.vcxproj", "{E5038304-761D-448C-B358-48CA2883778A}"
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shell", "modules\shell\src\c\shell.vcxproj", "{805AA73F-EF7B-4177-BF46-200B72D8F83A}"
+       ProjectSection(ProjectDependencies) = postProject
+               {43C5BAB1-1DCA-4743-A183-77E0D42FE7D0} = {43C5BAB1-1DCA-4743-A183-77E0D42FE7D0}
+       EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjvm-Ant", "modules\jvm\src\java\jvm-JAVA.vcxproj", "{E9783492-017E-4811-9CC7-6B71856F847C}"
 EndProject
index 1434307..f93dad7 100644 (file)
@@ -98,13 +98,7 @@ end
 // Protect variable previously defined  ================================
 predef("all");
 
-// At startup, no interactive vertical paging is authorized.===========
-// Note :
-// This may happen when the .scilab startup configuration file is loaded.
-// This may freeze a unit test, for which the .scilab file is so long 
-// that an interactive action is required ; but that interactive
-// action cannot occur, since it is during a unit test.
-_DEFAULT_LN_ = lines();
+// At startup, no interactive vertical paging by default. ==============
 lines(0);
 
 // load contrib menu if present ========================================
@@ -165,8 +159,5 @@ if getscilabmode() == "STD" then
   toolbar(-1, "on");
 end
 
-// Restore initial lines mode ==========================================
-lines(_DEFAULT_LN_(2),_DEFAULT_LN_(1));
-clear _DEFAULT_LN_;
-
+// ====================================================================
 clear ans
index 719a152..50d2c25 100644 (file)
@@ -21,6 +21,7 @@
 #include "InitializeConsole.h"
 #include "PromptToHome.h"
 #include "MALLOC.h"
+#include "ScilabLinesUpdate.h"
 #include "GetCharWithoutOutput.h"
 #include "ConsoleIsWaitingForInput.h"
 /*--------------------------------------------------------------------------*/
@@ -70,3 +71,8 @@ BOOL ConsoleIsWaitingForInput(void)
     return FALSE;
 }
 /*--------------------------------------------------------------------------*/
+BOOL ScilabLinesUpdate(void)
+{
+  return FALSE;
+}
+/*--------------------------------------------------------------------------*/
index a57b26a..5f08082 100644 (file)
@@ -78,10 +78,12 @@ INCLUDE_FLAGS = $(libscishell_la_CFLAGS)
 
 ## Libraries necessary
 # cyclic dep $(top_builddir)/modules/console/libsciconsole.la
-libscishell_la_LIBADD = libscishell-algo.la    $(top_builddir)/modules/history_manager/libscihistory_manager.la \
-                                                       $(top_builddir)/libs/MALLOC/libscimalloc.la \
-                                                       $(top_builddir)/modules/output_stream/libscioutput_stream.la 
-# $(top_builddir)/modules/completion/libscicompletion.la
+libscishell_la_LIBADD = libscishell-algo.la \
+       $(top_builddir)/modules/history_manager/libscihistory_manager.la \
+       $(top_builddir)/libs/MALLOC/libscimalloc.la \
+       $(top_builddir)/modules/output_stream/libscioutput_stream.la
+
+
 modulename=shell
 
 #### shell : Conf files ####
index e82573a..2d7f962 100644 (file)
@@ -483,11 +483,11 @@ CHECK_SRC = $(libscishell_la_SOURCES)
 INCLUDE_FLAGS = $(libscishell_la_CFLAGS)
 
 # cyclic dep $(top_builddir)/modules/console/libsciconsole.la
-libscishell_la_LIBADD = libscishell-algo.la    $(top_builddir)/modules/history_manager/libscihistory_manager.la \
-                                                       $(top_builddir)/libs/MALLOC/libscimalloc.la \
-                                                       $(top_builddir)/modules/output_stream/libscioutput_stream.la 
+libscishell_la_LIBADD = libscishell-algo.la \
+       $(top_builddir)/modules/history_manager/libscihistory_manager.la \
+       $(top_builddir)/libs/MALLOC/libscimalloc.la \
+       $(top_builddir)/modules/output_stream/libscioutput_stream.la
 
-# $(top_builddir)/modules/completion/libscicompletion.la
 modulename = shell
 
 #### shell : Conf files ####
index a3a5f93..15d772c 100644 (file)
@@ -27,9 +27,12 @@ ncl=lines()</synopsis>
     <title>Arguments</title>
     <variablelist>
       <varlistentry>
-        <term>nl : an integer, the number of lines for vertical paging control. If 0</term>
+        <term>nl : an integer, the number of lines for vertical paging control.</term>
         <listitem>
-          <para>no vertical paging control is done.</para>
+          <para> If 0 : no vertical paging control is done.</para>
+        </listitem>
+        <listitem>
+          <para> If -1 : reset vertical paging control to current size of the window.</para>
         </listitem>
       </varlistentry>
       <varlistentry>
@@ -62,7 +65,7 @@ ncl=lines()</synopsis>
     parameters are also automatically modified when the window is resized.</para>
   </refsection>
   <refsection role="see also">
-<title>See Also</title>
+    <title>See Also</title>
     <simplelist type="inline">
       <member>
         <link linkend="disp">disp</link>
@@ -72,4 +75,13 @@ ncl=lines()</synopsis>
       </member>
     </simplelist>
   </refsection>
+  <refsection>
+    <title>History</title>
+    <revhistory>
+      <revision>
+        <revnumber>5.4.0</revnumber>
+        <revremark>lines is set by default to 0. Argument -1 added. See SEP 67 for more information.</revremark>
+      </revision>
+    </revhistory>
+  </refsection>
 </refentry>
index 8225007..728bc79 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2007 - INRIA - Allan CORNET 
+ * Copyright (C) 2011 - 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
 /*--------------------------------------------------------------------------*/
 #include "gw_core.h"
 #include "stack-c.h"
+#include "api_scilab.h"
 #include "scilines.h"
 #include "Scierror.h"
 #include "localization.h"
 #include "MALLOC.h"
 #include "gw_shell.h"
+#include "ScilabLinesUpdate.h"
+#include "scilabmode.h"
+/*--------------------------------------------------------------------------*/
+static int sci_lines_no_rhs(char *fname);
+static int sci_lines_one_rhs(char *fname);
+static int sci_lines_two_rhs(char *fname);
 /*--------------------------------------------------------------------------*/
 int sci_lines(char *fname,unsigned long fname_len)
 {
-       CheckRhs(0,2);
-       CheckLhs(1,1);
-
-       if (Rhs ==  0)
-       {
-               int n1 = 0,m1 = 0;
-               int *paramoutINT = NULL;
-               paramoutINT=(int*)MALLOC(sizeof(int)*2);
-
-               paramoutINT[0] = getColumnsSize();
-               paramoutINT[1] = getLinesSize();
-
-               n1=1; m1=2;
-               CreateVarFromPtr(Rhs+1,MATRIX_OF_INTEGER_DATATYPE, &n1, &m1, &paramoutINT);
-
-               LhsVar(1) = Rhs+1;
-               C2F(putlhsvar)();
-
-               if (paramoutINT) { FREE(paramoutINT); paramoutINT = NULL;}
-       }
-       else
-       {
-               if (Rhs == 2)
-               {
-                       if ( GetType(2) == sci_matrix )
-                       {
-                               int l2 = 0,n2 = 0, m2 = 0;
-
-                               GetRhsVar(2,MATRIX_OF_DOUBLE_DATATYPE,&m2,&n2,&l2);
-                               setColumnsSize((int)*stk(l2));
-                       }
-                       else
-                       {
-                               Scierror(999,_("%s: Wrong type for input argument #%d: Matrix expected.\n"),fname,2);
-                               return 0;
-                       }
-               }
-
-               if ( GetType(1) == sci_matrix )
-               {
-                       int l1 = 0,n1 = 0, m1 = 0;
-
-                       GetRhsVar(1,MATRIX_OF_DOUBLE_DATATYPE,&m1,&n1,&l1);
-                       setLinesSize((int)*stk(l1));
-               }
-               else
-               {
-                       Scierror(999,_("%s: Wrong type for input argument #%d: Matrix expected.\n"),fname,1);
-                       return 0;
-               }
-
-               LhsVar(1) = 0;
-               C2F(putlhsvar)();
-       }
-       return 0;
+    CheckRhs(0,2);
+    CheckLhs(1,1);
+
+    switch(Rhs)
+    {
+    case 0:
+        sci_lines_no_rhs(fname);
+        break;
+    case 1:
+        sci_lines_one_rhs(fname);
+        break;
+    case 2:
+        sci_lines_two_rhs(fname);
+        break;
+    }
+    return 0;
+}
+/*--------------------------------------------------------------------------*/
+static int sci_lines_no_rhs(char *fname)
+{
+    /* ncl = lines() */
+    /* with ncl a 1x2 vector [nc , nl] */
+    /* for compatibility BUT order should be [nl, nc] */
+    /* input/output not coherents */
+    SciErr sciErr;
+    int n1 = 0,m1 = 0;
+    int *paramoutINT = NULL;
+    paramoutINT = (int*)MALLOC(sizeof(int)*2);
+    if (paramoutINT)
+    {
+        paramoutINT[0] = getColumnsSize();
+        paramoutINT[1] = getLinesSize();
+
+        n1 = 1; m1 = 2;
+        sciErr = createMatrixOfInteger32(pvApiCtx, Rhs + 1, n1, m1, paramoutINT);
+
+        FREE(paramoutINT);
+        paramoutINT = NULL;
+
+        if (sciErr.iErr)
+        {
+            printError(&sciErr, 0);
+            return 0;
+        }
+
+        LhsVar(1) = Rhs + 1;
+    }
+    PutLhsVar();
+
+    return 0;
+}
+/*--------------------------------------------------------------------------*/
+static int sci_lines_one_rhs(char *fname)
+{
+    /* lines(nb_lines) */
+    /* nb_lines == -1 auto */
+    /* nb_lines == 0 no stop on display */
+    /* nb_lines > 0 set value */
+    SciErr sciErr;
+    int *piAddressVarOne = NULL;
+    int iParam1 = 0;
+
+    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
+    if(sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 0;
+    }
+
+    /* compatibility with previous version manages int32 and double */
+    if (!(isDoubleType(pvApiCtx, piAddressVarOne) || isIntegerType(pvApiCtx, piAddressVarOne)))
+    {
+        Scierror(999,_("%s: Wrong type for input argument #%d: A scalar expected.\n"),fname, 1);
+        return 0;
+    }
+
+    if (!isScalar(pvApiCtx, piAddressVarOne))
+    {
+        Scierror(999,_("%s: Wrong size for input argument #%d: A scalar expected.\n"),fname, 1);
+        return 0;
+    }
+
+    if (isIntegerType(pvApiCtx, piAddressVarOne))
+    {
+        if (getScalarInteger32(pvApiCtx, piAddressVarOne, &iParam1) != 0)
+        {
+            Scierror(999,_("%s: Wrong type for input argument #%d: A scalar expected.\n"),fname, 1);
+            return 0;
+        }
+    }
+    else // double
+    {
+        double dParam1 = 0.;
+        if (getScalarDouble(pvApiCtx,piAddressVarOne, &dParam1) == 0)
+        {
+            iParam1 = (int)dParam1;
+        }
+    }
+
+    if (iParam1 == -1)
+    {
+        scilinesdefault();
+        if (getScilabMode() == SCILAB_STD)
+        {
+            ScilabLinesUpdate();
+        }
+    }
+    else
+    {
+        if (iParam1 < 0)
+        {
+            Scierror(999,_("%s: Wrong value for input argument #%d: A scalar (>= 0) expected.\n"),fname, 1);
+            return 0;
+        }
+        else
+        {
+            setLinesSize(iParam1);
+        }
+    }
+
+    LhsVar(1) = 0;
+    PutLhsVar();
+    return 0;
+}
+/*--------------------------------------------------------------------------*/
+static int sci_lines_two_rhs(char *fname)
+{
+    /* lines (nl, nc) */
+    SciErr sciErr;
+    int *piAddressVarOne = NULL;
+    int *piAddressVarTwo = NULL;
+
+    int iParam1 = 0;
+    int iParam2 = 0;
+
+    sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddressVarTwo);
+    if(sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 0;
+    }
+
+    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
+    if(sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 0;
+    }
+
+    /* compatibility with previous version manages int32 and double */
+    if (!(isDoubleType(pvApiCtx, piAddressVarOne) || isIntegerType(pvApiCtx, piAddressVarOne)))
+    {
+        Scierror(999,_("%s: Wrong type for input argument #%d: A scalar expected.\n"),fname, 1);
+        return 0;
+    }
+
+    if (!(isDoubleType(pvApiCtx, piAddressVarTwo) || isIntegerType(pvApiCtx, piAddressVarTwo)))
+    {
+        Scierror(999,_("%s: Wrong type for input argument #%d: A scalar expected.\n"),fname, 2);
+        return 0;
+    }
+
+    if (!isScalar(pvApiCtx, piAddressVarOne))
+    {
+        Scierror(999,_("%s: Wrong size for input argument #%d: A scalar expected.\n"),fname, 1);
+        return 0;
+    }
+
+    if (!isScalar(pvApiCtx, piAddressVarTwo))
+    {
+        Scierror(999,_("%s: Wrong size for input argument #%d: A scalar expected.\n"),fname, 2);
+        return 0;
+    }
+
+    if (isIntegerType(pvApiCtx, piAddressVarOne))
+    {
+        if (getScalarInteger32(pvApiCtx, piAddressVarOne, &iParam1) != 0)
+        {
+            Scierror(999,_("%s: Wrong type for input argument #%d: A scalar expected.\n"),fname, 1);
+            return 0;
+        }
+    }
+    else // double
+    {
+        double dParam1 = 0.;
+        if (getScalarDouble(pvApiCtx,piAddressVarOne, &dParam1) == 0)
+        {
+            iParam1 = (int)dParam1;
+        }
+    }
+
+    if (isIntegerType(pvApiCtx, piAddressVarTwo))
+    {
+        if (getScalarInteger32(pvApiCtx, piAddressVarTwo, &iParam2) != 0)
+        {
+            Scierror(999,_("%s: Wrong type for input argument #%d: A scalar expected.\n"),fname, 2);
+            return 0;
+        }
+    }
+    else // double
+    {
+        double dParam2 = 0.;
+        if (getScalarDouble(pvApiCtx,piAddressVarTwo, &dParam2) == 0)
+        {
+            iParam2 = (int)dParam2;
+        }
+    }
+
+
+    if (iParam1 == -1)
+    {
+        scilinesdefault();
+        if (getScilabMode() == SCILAB_STD)
+        {
+            ScilabLinesUpdate();
+        }
+    }
+    else
+    {
+        if (iParam1 < 0)
+        {
+            Scierror(999,_("%s: Wrong value for input argument #%d: A scalar (>= 0) expected.\n"),fname, 1);
+            return 0;
+        }
+        else
+        {
+            setLinesSize(iParam1);
+        }
+    }
+
+    if (iParam2 > 0)
+    {
+        setColumnsSize(iParam2);
+    }
+    else
+    {
+        Scierror(999,_("%s: Wrong value for input argument #%d: A scalar (>= 0) expected.\n"),fname, 2);
+        return 0;
+    }
+
+    LhsVar(1) = 0;
+    PutLhsVar();
+    return 0;
 }
 /*--------------------------------------------------------------------------*/
index 190ebe9..02d72be 100644 (file)
@@ -9,4 +9,5 @@ SetConsolePrompt
 GetCharWithoutOutput
 ConsolePrintf
 ConsoleIsWaitingForInput
-PromptToHome
\ No newline at end of file
+PromptToHome
+ScilabLinesUpdate
index e5bd2ad..9f13391 100644 (file)
@@ -352,6 +352,9 @@ lib /DEF:"$(ProjectDir)ui_data_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platfor
       <Project>{3170e4c2-1173-4264-a222-7ee8ccb3ddf7}</Project>
       <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
     </ProjectReference>
+    <ProjectReference Include="..\..\..\api_scilab\api_scilab.vcxproj">
+      <Project>{43c5bab1-1dca-4743-a183-77e0d42fe7d0}</Project>
+    </ProjectReference>
     <ProjectReference Include="..\..\..\history_manager\src\c\history_manager.vcxproj">
       <Project>{1b98dc87-44f5-48ae-b5d0-29dd8ad86f5e}</Project>
       <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
diff --git a/scilab/modules/shell/tests/unit_tests/lines.tst b/scilab/modules/shell/tests/unit_tests/lines.tst
new file mode 100644 (file)
index 0000000..90fc079
--- /dev/null
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Allan CORNET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- INTERACTIVE TEST -->
+// =============================================================================
+// start scilab (STD and NW mode)
+//
+r1 = lines();
+lines(0)
+r2 = lines();
+assert_checkequal(r2(2),int32(0));
+lines(-1)
+r3 = lines();
+assert_checkequal(r1, r3);
+
+// resize window (on STD)
+// and do same commands
+
+// =============================================================================