Much better! Now i can run python interactive help() inside jedit's
console, and also gdb. Thanks again!
--alan
On 1/30/07, vanza@... <vanza@...> wrote:
> Revision: 8820
> http://svn.sourceforge.net/jedit/?rev=8820&view=rev
> Author: vanza
> Date: 2007-01-30 22:21:39 -0800 (Tue, 30 Jan 2007)
>
> Log Message:
> -----------
> now yes, a proper fix to the jerkiness problem in Console's output that doesn't break applications that sometimes don't write full lines (e.g., a prompt in an interactive app). To try out the improvement, run "gdb" and type "help" and see it scroll. Or run ant on a project that prints a lot of stuff.
>
> Modified Paths:
> --------------
> plugins/Console/trunk/console/StreamThread.java
>
> Modified: plugins/Console/trunk/console/StreamThread.java
> ===================================================================
> --- plugins/Console/trunk/console/StreamThread.java 2007-01-30 21:51:05 UTC (rev 8819)
> +++ plugins/Console/trunk/console/StreamThread.java 2007-01-31 06:21:39 UTC (rev 8820)
> @@ -90,29 +90,35 @@
> try
> {
> StringBuilder lb = new StringBuilder();
> - do
> + char[] input = new char[1024];
> + int written = 0;
> + while (!aborted)
> {
> - int dat = isr.read();
> - if(dat == -1 || aborted) break;
> + int read = isr.read(input, 0, input.length);
> + if (read == -1 || aborted) break;
> + for (int i = 0; i < read; i++)
> + {
> + char c = input[i];
> + if (oldchar != '\r' || c != '\n')
> + {
> + lb.append(c);
> + }
> + if((c == '\n' && oldchar != '\r') || c == '\r')
> + {
>
> - char c = (char)dat;
> -
> - if((c == '\n' && oldchar != '\r') || c == '\r')
> + process(lb, output, written);
> + written = 0;
> + }
> + oldchar = c;
> + }
> + if (lb.length() > 0)
> {
> - String _line = lb.toString();
> - copt.processLine(_line);
> - int length = _line.length();
> - output.setAttrs(length, ConsolePane.colorAttributes(copt.getColor()));
> - lb = new StringBuilder();
> + process(lb, output, written);
> + written = lb.length();
> }
>
> - if(c != '\r')
> - {
> - if(c != '\n') lb.append(c);
> - output.writeAttrs(null, "" + c);
> - }
> - oldchar = c;
> - } while (!aborted);
> + }
> +
> }
> catch (Exception e)
> {
> @@ -151,5 +157,40 @@
> aborted = true;
> interrupt();
> } // }}}
> +
> + // {{{ process() method
> + private void process(StringBuilder buf, Output output, int written)
> + {
> + assert (buf != null && buf.length() > 0) : "buffer is empty";
> + String _line = buf.toString();
> + int length = _line.length();
> + int end = length;
> +
> + // 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.
> + if (_line.charAt(length -1) == '\n' || _line.charAt(length -1) == '\r')
> + {
> + end--;
> + }
> +
> + if (end == length)
> + {
> + copt.processLine(_line);
> + }
> + else
> + {
> + copt.processLine(_line.substring(0, end));
> + }
> +
> + output.writeAttrs(null, _line.substring(written));
> + output.setAttrs(end, ConsolePane.colorAttributes(copt.getColor()));
> + if (end != length)
> + {
> + // empty the buffer if we've read a line.
> + buf.setLength(0);
> + }
> + } //}}}
> +
> } // }}}
>
>
>
> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> jEdit-CVS mailing list
> jEdit-CVS@...
> https://lists.sourceforge.net/lists/listinfo/jedit-cvs
>
|