CTRL + D close Scilab on empty prompt line (GUI and Windows CLI only) 68/17268/2
Antoine ELIAS [Tue, 29 Sep 2015 10:39:48 +0000 (12:39 +0200)]
Change-Id: I923cd55c1e11fe5f73becbb369403433065acffc

scilab/modules/console/src/c/core_Import.def
scilab/modules/console/src/c/windows/TermConsole.c
scilab/modules/console/src/c/windows/TermLine.c
scilab/modules/console/src/java/org/scilab/modules/console/DelNextCharAction.java

index 66b5aa0..d49d2d3 100644 (file)
@@ -10,6 +10,7 @@ createvar_
 vartype_
 with_module
 StoreCommand
+StorePrioritaryCommand
 ismenu
 iop_
 freeArrayOfString
index 06549c7..f877210 100644 (file)
@@ -22,7 +22,6 @@
 #include "TermLine.h"
 #include "scilines.h"
 #include "HistoryManager.h"
-#include "storeCommand.h" /* ismenu */
 #include "localization.h"
 /*--------------------------------------------------------------------------*/
 #ifdef CR_1
index 4bc4400..24194b0 100644 (file)
@@ -23,6 +23,7 @@
 #include "TermPosition.h"
 #include "../../../windows_tools/src/c/scilab_windows/console.h"
 #include "os_string.h"
+#include "storeCommand.h"
 /*--------------------------------------------------------------------------*/
 static int CURRENT_MAX_LINE_SIZE = bsiz;
 static char *cur_line = NULL;  /* current contents of the line */
@@ -200,7 +201,7 @@ void deleteCurrentChar(void)
     reallocLineBuffer();
     if (max_pos == 0)
     {
-        TerminalBeep();
+        StorePrioritaryCommand("exit");
     }
     else
     {
index 49f9886..1899312 100644 (file)
@@ -17,6 +17,7 @@ import java.awt.event.ActionEvent;
 import javax.swing.text.BadLocationException;
 
 import com.artenum.rosetta.core.action.AbstractConsoleAction;
+import org.scilab.modules.action_binding.InterpreterManagement;
 
 /**
  * Delete character following the caret when an event occurs (equivalent of a SUPPR key press)
@@ -40,10 +41,16 @@ public class DelNextCharAction extends AbstractConsoleAction {
      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
      */
     public void actionPerformed(ActionEvent e) {
+        int len = configuration.getInputCommandViewStyledDocument().getLength();
+        /*CTRL + D on empty line, send exit command to Scilab*/
+        if (len == 0) {
+            InterpreterManagement.requestScilabExec("exit");
+            return;
+        }
         int currentPosition = configuration.getInputCommandView().getCaretPosition();
 
         /* Do not try to remove an non-existing item */
-        if (currentPosition < configuration.getInputCommandViewStyledDocument().getLength()) {
+        if (currentPosition < len) {
             try {
                 configuration.getInputCommandViewStyledDocument().remove(currentPosition, 1);
             } catch (BadLocationException e1) {