Revision: 22716
http://jedit.svn.sourceforge.net/jedit/?rev=22716&view=rev
Author: ezust
Date: 2013-01-25 05:14:20 +0000 (Fri, 25 Jan 2013)
Log Message:
-----------
Removing vt100 colors from console5 branch.
Modified Paths:
--------------
plugins/SshConsole/branches/Console5/SshConsole.props
plugins/SshConsole/branches/Console5/console/ssh/Connection.java
plugins/SshConsole/branches/Console5/console/ssh/StreamThread.java
plugins/SshConsole/branches/Console5/index.html
Modified: plugins/SshConsole/branches/Console5/SshConsole.props
===================================================================
--- plugins/SshConsole/branches/Console5/SshConsole.props 2013-01-25 00:05:02 UTC (rev 22715)
+++ plugins/SshConsole/branches/Console5/SshConsole.props 2013-01-25 05:14:20 UTC (rev 22716)
@@ -9,7 +9,7 @@
plugin.console.ssh.SshConsolePlugin.depend.1=jedit 05.00.99.00
plugin.console.ssh.SshConsolePlugin.depend.2=plugin errorlist.ErrorListPlugin 2.1
plugin.console.ssh.SshConsolePlugin.depend.3=plugin ftp.FtpPlugin 1.0.2
-plugin.console.ssh.SshConsolePlugin.depend.4=plugin console.ConsolePlugin 5.1
+plugin.console.ssh.SshConsolePlugin.depend.4=plugin console.ConsolePlugin 5.0
plugin.console.ssh.SshConsolePlugin.menu=open-sftp console.shell.ssh-show console.ssh.close-connections
plugin.console.ssh.SshConsolePlugin.usePluginHome=true
Modified: plugins/SshConsole/branches/Console5/console/ssh/Connection.java
===================================================================
--- plugins/SshConsole/branches/Console5/console/ssh/Connection.java 2013-01-25 00:05:02 UTC (rev 22715)
+++ plugins/SshConsole/branches/Console5/console/ssh/Connection.java 2013-01-25 05:14:20 UTC (rev 22716)
@@ -101,7 +101,6 @@
console.getOutput(),
console.getPlainColor()
);
- stout.setStatus("ssh " + info.toString());
ThreadUtilities.runInBackground(stout);
pos = new PipedOutputStream();
@@ -130,7 +129,6 @@
console.getOutput(),
console.getPlainColor()
);
- stout.setStatus("ssh " + info.toString());
ThreadUtilities.runInBackground(stout);
}
}// }}}
Modified: plugins/SshConsole/branches/Console5/console/ssh/StreamThread.java
===================================================================
--- plugins/SshConsole/branches/Console5/console/ssh/StreamThread.java 2013-01-25 00:05:02 UTC (rev 22715)
+++ plugins/SshConsole/branches/Console5/console/ssh/StreamThread.java 2013-01-25 05:14:20 UTC (rev 22716)
@@ -2,7 +2,7 @@
Version 4, October 2012
Based on the wtfpl: http://sam.zoy.org/wtfpl/
- Copyright © 2012 Alan Ezust, Artem Bryantsev
+ Copyright © 2012 Alan Ezust
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
@@ -19,58 +19,208 @@
// {{{ Imports
import java.awt.Color;
+import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import javax.swing.text.AttributeSet;
+import org.gjt.sp.jedit.jEdit;
+import org.gjt.sp.util.Log;
+
import console.CommandOutputParser;
import console.Console;
+import console.ConsolePane;
+import console.ErrorOutput;
import console.Output;
-import console.ParsingOutputStreamTask;
-import console.SimpleOutputStreamTask.WLTypes;
-
import errorlist.DefaultErrorSource;
// }}}
+
+// {{{ class StreamThread
/**
* Thread for handing output of running remote ssh commands
+ * Based on the now-deprecated StreamThread.java from Console plugin:
* StreamThread.java * 10982 2007-11-06 05:02:42Z.
*
+ * TODO: deprecate this class and rewrite SshConsole to use console.OutputStreamTask
+ *
* @version $Id$
*/
-class StreamThread extends ParsingOutputStreamTask
+class StreamThread extends Thread
{
- private String status;
+ // {{{ data members
+ private boolean aborted;
+ private Console console;
+ private InputStream in;
+ CommandOutputParser copt = null;
+ // Console output
+ Output output;
+ private StringBuilder lineBuffer;
+ private boolean pendingCr;
+ private int uncoloredWritten;
+ // }}}
+
+ // {{{ StreamThread constructor
/**
* @param in - a stream to read things from, that we want to display.
*/
public StreamThread(Console console, InputStream in, Output output, Color defaultColor)
{
- super(in, output, defaultColor, console.getConsolePane().getBackground(), null, null);
-
- setWaitingLoop(WLTypes.blockWL);
-
+ this.in = in;
+ this.output = output;
+ this.console = console;
ConsoleState cs = ConnectionManager.getConsoleState(console);
String currentDirectory = cs.getPath();
DefaultErrorSource es = new SecureErrorSource(cs, console.getView());
- CommandOutputParser copt = new CommandOutputParser(console.getView(), es, defaultColor);
+ copt = new CommandOutputParser(console.getView(), es, defaultColor);
copt.setDirectory(currentDirectory);
- cs.setDirectoryChangeListener(copt);
-
- setErrorParser(copt);
- setAnsiParser(defaultColor, console.getConsolePane().getBackground());
- status = "sshconsole";
- }
-
- public void setStatus(String newStatus) {
- status = newStatus;
- }
-
- public String getStatus() {
- return status;
- }
-
- public String toString() {
- return status;
- }
-}
+ cs.setDirectoryChangeListener( copt);
+ lineBuffer = new StringBuilder(100);
+ pendingCr = false;
+ uncoloredWritten = 0;
+ } // }}}
+ // {{{ run() method
+ public void run()
+ {
+ InputStreamReader isr = null;
+ try
+ {
+ isr = new InputStreamReader(in, jEdit.getProperty("console.encoding") );
+ }
+ catch (UnsupportedEncodingException uee)
+ {
+ throw new RuntimeException(uee);
+ }
+
+
+ try
+ {
+ char[] input = new char[1024];
+ while (!aborted)
+ {
+ int read = isr.read(input, 0, input.length);
+// Log.log(Log.MESSAGE, this, input);
+ if (aborted)
+ {
+ break;
+ }
+ else if (read == -1)
+ {
+ if (pendingCr)
+ {
+ flushLine(output, "\r");
+ }
+ else if (lineBuffer.length() > 0)
+ {
+ flushLine(output, "");
+ }
+ break;
+ }
+
+ for (int i = 0; i < read; i++)
+ {
+ char c = input[i];
+ if (c == '\n')
+ {
+ if (pendingCr)
+ {
+ flushLine(output, "\r\n");
+ }
+ else
+ {
+ flushLine(output, "\n");
+ }
+ }
+ else
+ {
+ if (pendingCr)
+ {
+ flushLine(output, "\r");
+ }
+
+ if (c == '\r')
+ {
+ pendingCr = true;
+ }
+ else
+ {
+ lineBuffer.append(c);
+ }
+ }
+ }
+
+ // Following output shows unterminated lines
+ // such as prompt of interactive programs.
+ if (lineBuffer.length() > uncoloredWritten)
+ {
+ String tail = lineBuffer.substring(uncoloredWritten);
+ output.writeAttrs(null, tail);
+ uncoloredWritten += tail.length();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ if (!aborted)
+ {
+ Log.log(Log.ERROR, e, e);
+ Output error = new ErrorOutput(console);
+ if (console != null)
+ {
+ String[] args = { e.toString() };
+ error.print(console.getErrorColor(), jEdit.getProperty(
+ "console.shell.error", args));
+ }
+ }
+ }
+ finally
+ {
+ copt.finishErrorParsing();
+ try
+ {
+ in.close();
+ }
+ catch (IOException e2)
+ {
+ }
+
+ }
+ } // }}}
+
+ // {{{ abort() method
+ void abort()
+ {
+ aborted = true;
+ interrupt();
+ } // }}}
+
+ // {{{ flushLine() method
+ private void flushLine(Output output, String eol)
+ {
+ // we need to write the line break to the output, but we
+ // can't pass it to the "processLine()" method or the
+ // regexps won't recognize anything.
+ String line = lineBuffer.toString();
+ copt.processLine(line);
+ AttributeSet color = ConsolePane.colorAttributes(copt.getColor());
+ if (uncoloredWritten > 0)
+ {
+ output.setAttrs(uncoloredWritten, color);
+ output.writeAttrs(color,
+ lineBuffer.substring(uncoloredWritten) + eol);
+ }
+ else
+ {
+ output.writeAttrs(color, line + eol);
+ }
+
+ lineBuffer.setLength(0);
+ pendingCr = false;
+ uncoloredWritten = 0;
+ } //}}}
+
+} // }}}
+
// :folding=explicit:
\ No newline at end of file
Modified: plugins/SshConsole/branches/Console5/index.html
===================================================================
--- plugins/SshConsole/branches/Console5/index.html 2013-01-25 00:05:02 UTC (rev 22715)
+++ plugins/SshConsole/branches/Console5/index.html 2013-01-25 05:14:20 UTC (rev 22716)
@@ -182,9 +182,8 @@
<h2> History </h2>
<ul>
- <li> <b>Version 1.0.4</b> - Requires JDK 1.6, jEdit 5.0, ErrorList 2.1, Ftp 1.0.2, Console 5.0.1.
+ <li> <b>Version 1.0.4</b> - Requires JDK 1.6, jEdit 5.0, ErrorList 2.1, Ftp 1.0.2, Console 5.0.
<ul>
- <li> Parses Vt100 colors (Artem Bryantsev) </li>
<li> Displays open connections as long-running tasks in task monitor </li>
<li> Fix #2873889: Stop leaking connections and properly close them. </li>
<li> Enable x11 forwarding </li>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|