Commits

Anonymous committed adcac76

Created simple replview which connects console with swank.

Comments (0)

Files changed (10)

+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.lispdev.replview</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

.settings/org.eclipse.jdt.core.prefs

+#Sun Jun 27 20:41:25 CDT 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6

META-INF/MANIFEST.MF

+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Replview
+Bundle-SymbolicName: org.lispdev.replview;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.lispdev.replview.ReplViewPlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.lispdev.console;bundle-version="1.0.0",
+ org.lispdev.swank;bundle-version="1.0.0",
+ org.eclipse.jface.text;bundle-version="3.5.2"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+   <extension
+         point="org.eclipse.ui.views">
+      <view
+            allowMultiple="true"
+            class="org.lispdev.replview.ReplView"
+            id="org.lispdev.replview.view"
+            name="Repl"
+            restorable="true">
+      </view>
+   </extension>
+
+</plugin>

src/org/lispdev/replview/InputListener.java

+package org.lispdev.replview;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.widgets.Label;
+import org.lispdev.console.IConsoleInputListener;
+import org.lispdev.console.LispConsole;
+import org.lispdev.console.PartitionData;
+import org.lispdev.swank.SBCLImplementation;
+import org.lispdev.swank.SwankInterface;
+
+public class InputListener implements IConsoleInputListener
+{
+  private final SwankInterface swank;
+  private final Label info;
+  private final LispConsole repl;
+
+  public InputListener(LispConsole repl, SwankInterface s, Label info)
+  {
+    Assert.isNotNull(s);
+    Assert.isNotNull(repl);
+    swank = s;
+    this.info = info;
+    this.repl = repl;
+  }
+
+  @Override
+  public void run(String msg, int offset, PartitionData pd, VerifyEvent event)
+  {
+    if( !swank.isConnected() )
+    {
+      final String dir = "D:\\projects\\lispdev\\ws\\org.lispdev.swank\\";
+      swank.initParams(new SwankRunnableDriver(), dir,
+          SBCLImplementation.findImplementation(dir));
+      swank.connect();
+      if( info != null )
+      {
+        info.setText(swank.getLispVersion());
+      }
+    }
+    if( msg.trim().equalsIgnoreCase("(quit)") )
+    {
+      swank.disconnect();
+      if( info != null )
+      {
+        info.setText("disconnected");
+      }
+    }
+    repl.stopEdit();
+    String res = swank.sendEvalAndGrab(msg, 1000);
+    repl.appendText(res, "swank_result", "", null, true);
+    repl.startEdit();
+  }
+
+}

src/org/lispdev/replview/ReplView.java

+package org.lispdev.replview;
+
+import org.eclipse.jface.text.source.VerticalRuler;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.part.ViewPart;
+import org.lispdev.console.ConsoleEnterTrigger;
+import org.lispdev.console.ConsoleInputTrigger;
+import org.lispdev.console.LispConsole;
+import org.lispdev.console.Prompt;
+import org.lispdev.swank.SwankInterface;
+
+public class ReplView extends ViewPart
+{
+  public static final String ID = "org.lispdev.replview.view";
+
+  private LispConsole repl;
+  private Label info;
+  private SwankInterface swank;
+
+  public ReplView()
+  {
+  }
+
+  @Override
+  public void createPartControl(Composite parent)
+  {
+    GridLayout layout = new GridLayout(1, false);
+    layout.marginLeft = 1;
+    layout.marginTop = 1;
+    layout.marginRight = 1;
+    layout.marginBottom = 1;
+    parent.setLayout(layout);
+
+    GridData gd;
+
+    info = new Label(parent, SWT.BORDER);
+    gd = new GridData();
+    gd.horizontalAlignment = GridData.FILL;
+    gd.grabExcessHorizontalSpace = true;
+    gd.grabExcessVerticalSpace = false;
+    info.setLayoutData(gd);
+    info.setText("Status label for Repl");
+
+    // Put a border around our text viewer
+    Composite comp = new Composite(parent, SWT.BORDER);
+    layout = new GridLayout(1, false);
+    layout.marginLeft = 0;
+    layout.marginTop = 0;
+    layout.marginRight = 0;
+    layout.marginBottom = 0;
+    layout.horizontalSpacing = 0;
+    layout.marginHeight = 0;
+    layout.marginWidth = 0;
+    comp.setLayout(layout);
+    gd = new GridData();
+    gd.horizontalAlignment = GridData.FILL;
+    gd.verticalAlignment = GridData.FILL;
+    gd.grabExcessHorizontalSpace = true;
+    gd.grabExcessVerticalSpace = true;
+    comp.setLayoutData(gd);
+
+    repl = new LispConsole(comp, new VerticalRuler(10),
+        SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.LEFT | SWT.BORDER);
+    repl.getControl().setLayoutData(gd);
+    //repl.getTextWidget().setFont(newFont);
+
+    ConsoleInputTrigger inputTrigger =
+      new ConsoleEnterTrigger(repl,SWT.SHIFT,LispConsole.BEFORE);
+    swank = new SwankInterface();
+    InputListener input = new InputListener(repl, swank, info);
+    inputTrigger.addInputListener(input);
+    //repl.appendVerifyKeyListener(inputTrigger);
+    repl.getTextWidget().addVerifyKeyListener(inputTrigger);
+    //"Echo>","echo_prompt","0"
+    repl.setPrompt(new Prompt("Echo>","echo_prompt","0",null,null,SWT.BOLD,true));
+    repl.startEdit();
+  }
+
+  @Override
+  public void setFocus()
+  {
+  }
+
+}

src/org/lispdev/replview/ReplViewPlugin.java

+package org.lispdev.replview;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ReplViewPlugin extends AbstractUIPlugin {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "org.lispdev.replview";
+
+	// The shared instance
+	private static ReplViewPlugin plugin;
+	
+	/**
+	 * The constructor
+	 */
+	public ReplViewPlugin() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		super.start(context);
+		plugin = this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		plugin = null;
+		super.stop(context);
+	}
+
+	/**
+	 * Returns the shared instance
+	 *
+	 * @return the shared instance
+	 */
+	public static ReplViewPlugin getDefault() {
+		return plugin;
+	}
+
+}

src/org/lispdev/replview/SwankRunnableDriver.java

+package org.lispdev.replview;
+
+import org.eclipse.swt.widgets.Display;
+import org.lispdev.swank.IRunnableDriver;
+
+public class SwankRunnableDriver implements IRunnableDriver
+{
+
+  @Override
+  public void asyncExec(Runnable r)
+  {
+    Display.getDefault().asyncExec(r);
+  }
+
+}
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.