Author: koen.aers(a)jboss.com
Date: 2011-02-14 10:33:23 -0500 (Mon, 14 Feb 2011)
New Revision: 29137
Added:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleText.java
Modified:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsoleInputStream.java
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsolePartition.java
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsolePartitioner.java
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleViewer.java
Log:
trying to get history and backspace to work
Modified:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsoleInputStream.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsoleInputStream.java 2011-02-14
15:30:07 UTC (rev 29136)
+++
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsoleInputStream.java 2011-02-14
15:33:23 UTC (rev 29137)
@@ -11,9 +11,6 @@
private boolean eofSent = false;
private boolean closed = false;
- ConsoleInputStream() {
- }
-
public synchronized int read() throws IOException {
waitForData();
if (available() == -1) {
Modified:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsolePartition.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsolePartition.java 2011-02-14
15:30:07 UTC (rev 29136)
+++
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsolePartition.java 2011-02-14
15:33:23 UTC (rev 29137)
@@ -5,11 +5,6 @@
import org.eclipse.swt.graphics.Color;
import org.eclipse.ui.console.ConsolePlugin;
-/**
- * A region in an IOConsole's document.
- *
- * @since 3.1
- */
public class ConsolePartition implements ITypedRegion {
public static final String OUTPUT_PARTITION_TYPE = ConsolePlugin.getUniqueIdentifier() +
".io_console_output_partition_type"; //$NON-NLS-1$
public static final String INPUT_PARTITION_TYPE = ConsolePlugin.getUniqueIdentifier() +
".io_console_input_partition_type"; //$NON-NLS-1$
@@ -133,34 +128,6 @@
}
/**
- * Returns the font of the input stream if the type of the partition
- * is <code>INPUT_PARTITION_TYPE</code>, otherwise it returns the output
- * stream font
- *
- * @return the font of one of the backing streams
- */
-// private int getFontStyle() {
-// if (type.equals(INPUT_PARTITION_TYPE)) {
-// return inputStream.getFontStyle();
-// }
-// return outputStream.getFontStyle();
-// }
-
- /**
- * Returns the colour of the input stream if the type of the partition
- * is <code>INPUT_PARTITION_TYPE</code>, otherwise it returns the output
- * stream colour
- *
- * @return the colour of one of the backing streams
- */
-// public Color getColor() {
-// if (type.equals(INPUT_PARTITION_TYPE)) {
-// return inputStream.getColor();
-// }
-// return outputStream.getColor();
-// }
-
- /**
* Returns if this partition is read-only.
*
* @see org.eclipse.ui.console.IConsoleDocumentPartitioner#isReadOnly(int)
Modified:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsolePartitioner.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsolePartitioner.java 2011-02-14
15:30:07 UTC (rev 29136)
+++
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/ConsolePartitioner.java 2011-02-14
15:33:23 UTC (rev 29137)
@@ -312,6 +312,7 @@
* @see
org.eclipse.jface.text.IDocumentPartitionerExtension#documentChanged2(org.eclipse.jface.text.DocumentEvent)
*/
public IRegion documentChanged2(DocumentEvent event) {
+ System.out.println("documentChanged2 : " + event.fText);
if (document == null) {
return null; //another thread disconnected the partitioner
}
@@ -439,6 +440,8 @@
* @param s The string that should be appended to the document.
*/
public void streamAppended(ConsoleOutputStream stream, String s) throws IOException {
+ System.out.println("streamAppended : " + s);
+ if (s.indexOf('\t') != -1) System.out.println("Got a tab!");
if (document == null) {
throw new IOException("Document is closed"); //$NON-NLS-1$
}
Added:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleText.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleText.java
(rev 0)
+++
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleText.java 2011-02-14
15:33:23 UTC (rev 29137)
@@ -0,0 +1,41 @@
+package org.jboss.tools.seam.forge.view;
+
+import org.eclipse.swt.custom.ST;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.widgets.Composite;
+
+public class ConsoleText extends StyledText {
+
+ public ConsoleText(Composite parent, int style) {
+ super(parent, style);
+ }
+
+ public void invokeAction(int action) {
+ checkWidget();
+ switch (action) {
+ // Navigation
+ case ST.LINE_UP:
+ doLineUp();
+ break;
+ case ST.LINE_DOWN:
+ doLineDown();
+ break;
+ case ST.DELETE_PREVIOUS:
+ doDeletePrevious();
+ break;
+ default:
+ super.invokeAction(action);
+ }
+ }
+
+ private void doLineUp() {
+ System.out.println("Line up");
+ }
+ private void doLineDown() {
+ System.out.println("Line down");
+ }
+ private void doDeletePrevious() {
+ System.out.println("Backspace");
+ }
+
+}
Property changes on:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleText.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleViewer.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleViewer.java 2011-02-14
15:30:07 UTC (rev 29136)
+++
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleViewer.java 2011-02-14
15:33:23 UTC (rev 29137)
@@ -2,7 +2,10 @@
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocumentListener;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -10,6 +13,10 @@
import org.jboss.tools.seam.forge.console.Console;
public class ConsoleViewer extends TextConsoleViewer {
+
+ private static String BACKSPACE = new String(new byte[] {'\b'});
+ private static String UP_ARROW = new String(new byte[] { 0x1b, 0x5b, 0x41 });
+ private static String DOWN_ARROW = new String(new byte[] { 0x1b, 0x5b, 0x42 });
private Console console = null;
@@ -20,14 +27,37 @@
}
protected void handleVerifyEvent(VerifyEvent e) {
- console.getInputStream().appendData(e.text);
- e.doit = false;
+ console.getInputStream().appendData(e.text);
+ e.doit = false;
}
- private class DocumentListener implements IDocumentListener {
+ private void handleBackspace() {
+ System.out.println("handle backspace");
+// console.getInputStream().appendData(BACKSPACE);
+ }
+
+ private void handleArrowUp() {
+ System.out.println("handle arrow up");
+// console.getInputStream().appendData(UP_ARROW);
+ }
+
+ private void handleArrowDown() {
+ System.out.println("handle arrow down");
+// console.getInputStream().appendData(DOWN_ARROW);
+ }
+
+ protected StyledText createTextWidget(Composite parent, int styles) {
+ ConsoleText styledText= new ConsoleText(parent, styles);
+ styledText.setLeftMargin(Math.max(styledText.getLeftMargin(), 2));
+ styledText.addKeyListener(new ConsoleKeyListener());
+ return styledText;
+ }
+
+ private class DocumentListener implements IDocumentListener {
public void documentAboutToBeChanged(DocumentEvent event) {
}
+
public void documentChanged(DocumentEvent event) {
revealEndOfDocument();
@@ -38,5 +68,22 @@
}
}
}
+
+ private class ConsoleKeyListener implements KeyListener {
+
+ public void keyPressed(KeyEvent e) {
+ }
+
+ public void keyReleased(KeyEvent e) {
+ if (e.keyCode == SWT.BS) {
+ handleBackspace();
+ } else if (e.keyCode == SWT.ARROW_UP) {
+ handleArrowUp();
+ } else if (e.keyCode == SWT.ARROW_DOWN) {
+ handleArrowDown();
+ }
+ }
+
+ }
}
Show replies by date