Commits

Anonymous committed 9df9312

- prompt shows package we are in

  • Participants
  • Parent commits da7d18b

Comments (0)

Files changed (3)

File src/org/lispdev/repl/AbstractRepl.java

   public abstract void appendIn(String text);
   public abstract void appendOut(String text);
   public abstract void appendOutInspectable(String text, String id);
-  public abstract void checkSwitchPackage(String command);
+  public abstract void packageChanged(String command);
   public abstract void saveCommandToHistory(String command);
   /**
    * repl suspended to let user perform input - might need to know state
    */
   public abstract void doInput();
   public abstract void disconnected();
+  public abstract void disconnecting();
   public abstract void connected();
   public abstract void connecting();
 
   protected abstract void applyState(IState s);
   protected void eval(String cmd)
   {
-    if (!cmd.endsWith("\n")) {
+    if (!cmd.endsWith("\n"))
+    {
       cmd = cmd + "\n";
     }
     String cleanCmd = cmd.replace("\r", "");

File src/org/lispdev/repl/EvalState.java

       {
         return false;
       }
+      repl.packageChanged(repl.swank.getCurrPackage());
       repl.connected();
     }
+
+    if( cleanCommand.toLowerCase().startsWith("(in-package ") )
+    {
+      int i0 = cleanCommand.indexOf(':');
+      int i1 = cleanCommand.indexOf(')');
+      if( i0 < 0 || i1 < 0 )
+      {
+        System.out.println("Bad format of in-package: " + cleanCommand);
+      }
+      else
+      {
+        final String pkg = cleanCommand.substring(i0+1, i1).trim().toUpperCase();
+        repl.swank.setPackage(pkg);
+        repl.packageChanged(pkg);
+      }
+    }
+    else if( cleanCommand.toLowerCase().matches("\\(\\s*quit\\s*\\)\\s*") )
+    {
+      repl.disconnecting();
+    }
     repl.swank.sendEval(cleanCommand, new EvalStateHandler(repl));
 
-    repl.checkSwitchPackage(command);
-
     return false;
   }
 

File src/org/lispdev/repl/EvalStateHandler.java

   public void run()
   {
     LispNode returns = result.getf(":return").getf(":ok").getf(":present");
+
     for(LispNode r : returns.getParams())
     {
       String res = r.get(0).value;
       repl.appendOut(res + "\n");
     }
+
     repl.doInput();
   }