Anonymous avatar Anonymous committed a85f82f

Colors from REPL preference page are correctly applied to all REPL.

Comments (0)

Files changed (3)

org.lispdev.console/src/org/lispdev/console/LispConsoleViewer.java

     return editOffset;
   }
 
+  /**
+   * update colors of partitions with corresponding context
+   */
+  public void updateColors(String context, Color foreground, Color background)
+  {
+    if( partitionRegistry == null ) return;
+    for( PartitionData p : partitionRegistry )
+    {
+      if( p.context.equals(context) )
+      {
+        for( StyleRange s : p.originalStyle )
+        {
+          s.background = background;
+          s.foreground = foreground;
+        }
+        applyPartitionStyles(0, p);
+      }
+    }
+  }
 
   private Prompt prompt;
 

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

   public abstract void appendOutInspectable(String text, String id);
   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 doReadInput();
   public abstract void disconnected();
   public abstract void disconnecting();
   public abstract void connected();

org.lispdev.replview/src/org/lispdev/replview/ReplConsolePage.java

 
 public class ReplConsolePage implements IPageBookViewPage, IResetColorListener
 {
+  private static final String PROMPT_CONTEXT = "prompt";
+  private static final String INSPECTABLE_CONTEXT = "inspectable";
+  private static final String READ_PROMPT_CONTEXT = "prompt-read";
+
   private IPageSite fSite;
 
   private LispConsoleViewer replConsole; //viewer
     @Override
     public void appendOutInspectable(String text, String id)
     {
-      replConsole.appendText(text,"inspectable",id, null,
+      replConsole.appendText(text,INSPECTABLE_CONTEXT,id, null,
           ReplViewPlugin.get().getInspectableColor(),SWT.NONE, true);
     }
 
     {
       if( s instanceof ReadState )
       {
-        replConsole.setPrompt(new Prompt("", "read-context","1",null,false));
         enterTrigger.setDoIt(true);
         enterTrigger.setStateMask(SWT.NONE);
-        doInput();
+        doReadInput();
       }
     }
 
     @Override
+    public void doReadInput()
+    {
+      replConsole.setPrompt(new Prompt("", READ_PROMPT_CONTEXT,"1",null,false));
+      replConsole.startEdit();
+      setStatusMessage("Waiting for user input ...");
+    }
+
+    @Override
     public void packageChanged(String pkg)
     {
       replConsole.setPrompt(
-          new Prompt(pkg.toUpperCase()+">", pkg, "1",
+          new Prompt(pkg.toUpperCase()+">", PROMPT_CONTEXT, pkg,
               ReplViewPlugin.get().getPromptColor(),null,SWT.BOLD,false));
     }
 
     @Override
     public void run(String msg, int offset, PartitionData pd, VerifyEvent event)
     {
-      replConsole.setPrompt(
-          new Prompt(swank.getCurrPackage().toUpperCase()+">",
-              swank.getCurrPackage(), "1",
-              ReplViewPlugin.get().getPromptColor(),null,SWT.BOLD,false));
       enterTrigger.setDoIt(false);
       enterTrigger.setStateMask(SWT.SHIFT);
       eval(msg);
     @Override
     public void doInput()
     {
+      replConsole.setPrompt(
+          new Prompt(swank.getCurrPackage().toUpperCase()+">", PROMPT_CONTEXT,
+              swank.getCurrPackage(),
+              ReplViewPlugin.get().getPromptColor(),null,SWT.BOLD,false));
       replConsole.startEdit();
+      setStatusMessage("Evaluate expression in package: "
+          +swank.getCurrPackage().toUpperCase());
     }
 
     @Override
           public IVariable resolve(String txt, IPartitionData data)
           {
             if( data == null || data.getContext() == null
-                || !data.getContext().equals("inspectable") )
+                || !data.getContext().equals(INSPECTABLE_CONTEXT) )
             {
               return null;
             }
     enterTrigger.addInputListener(repl);
     replConsole.getTextWidget().addVerifyKeyListener(enterTrigger);
     replConsole.setPrompt(
-        new Prompt("CL-USER>","prompt","0",
+        new Prompt("[CL-USER]>",PROMPT_CONTEXT,"CL-USER",
             ReplViewPlugin.get().getPromptColor(),null,SWT.BOLD,false));
     replConsole.startEdit();
     repl.disconnected();
   @Override
   public void handleResetColors()
   {
-    //TODO: reset all appropriate colors in viewer
+    replConsole.updateColors(PROMPT_CONTEXT,
+        ReplViewPlugin.get().getPromptColor(), null);
+    replConsole.updateColors(INSPECTABLE_CONTEXT, null,
+        ReplViewPlugin.get().getInspectableColor());
   }
 
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.