|
From: Rami O. <ram...@el...> - 2004-04-20 14:25:03
|
I send my improvement suggestion again together
with patches because I have seen nothing happening
on this mail list and am worried whether my subscription
is out of order or something.
I'm using Console 3.2 with jEdit4.2pre11.
When I use scrolling the console does not follow anymore with new text =
printed to Console
before I empty the console.
Also is there seems to be no way to print to Console without line break.
This is definately something that a Console should be able to handle.
If we were to add now the normal
print() and println() methods it would not be backwards compatible =
because
print() is already used to print the message and a line :-(
Maybe we would now have to implement print() and printnoln() :-)
My proposal is to add method:
void print(Color color, String msg, boolean appendNewline);
and then make the existing method like this:
void print(Color color, String msg) {
print(color, msg, true);
}
Here is patches to Output.java and Console.java that would fix the lack =
of
print method
without newline. Since I don't have a system up for compiling jEdit I
haven't verified
the compilability but since the changes are so small that should be ok.
I do not know whether there are also other classes that implement Ouput
other
than Console (and ShellState).
Index: Console.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/jedit/plugins/Console/console/Console.java,v
retrieving revision 1.49
diff -B -b -u -r1.49 Console.java
--- Console.java 31 Dec 2003 18:55:19 -0000 1.49
+++ Console.java 14 Apr 2004 13:41:01 -0000
@@ -350,6 +350,17 @@
getOutput().print(color,msg);
} //}}}
+ //{{{ print() method
+ /**
+ * @deprecated Do not use the console as an <code>Output</code>
+ * instance, use the <code>Output</code> given to you in
+ * <code>Shell.execute()</code> instead.
+ */
+ public void print(Color color, String msg, boolean appendNewLine)
+ {
+ getOutput().print(color,msg,appendNewLine);
+ } //}}}
+
//{{{ commandDone() method
/**
* @deprecated Do not use the console as an <code>Output</code>
@@ -541,19 +552,23 @@
shell.printPrompt(Console.this,this);
}
+ public void print(Color color, String msg) {
+ print(color,msg,true);
+ }
+
//{{{ print() method
public void print(final Color color,
- final String msg)
+ final String msg, final boolean appendNewLine)
{
if(SwingUtilities.isEventDispatchThread())
- printSafely(color,msg);
+ printSafely(color,msg,appendNewLine);
else
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
- printSafely(color,msg);
+ printSafely(color,msg,appendNewLine);
}
});
}
@@ -577,7 +592,7 @@
} //}}}
//{{{ printSafely() method
- private void printSafely(Color color, String msg)
+ private void printSafely(Color color, String msg, boolean =
appendNewLine)
{
SimpleAttributeSet style =3D new SimpleAttributeSet();
@@ -593,8 +608,8 @@
{
scrollback.insertString(scrollback.getLength(),
msg,style);
- scrollback.insertString(scrollback.getLength(),
- "\n",style);
+ if (appendNewLine)
+ scrollback.insertString(scrollback.getLength(), "\n",style);
}
catch(BadLocationException bl)
{
Index: Output.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/jedit/plugins/Console/console/Output.java,v
retrieving revision 1.2
diff -B -b -u -r1.2 Output.java
--- Output.java 10 Aug 2001 08:11:11 -0000 1.2
+++ Output.java 14 Apr 2004 13:45:27 -0000
@@ -27,6 +27,14 @@
* Prints a string of text with the specified color.
* @param color The color. If null, the default color will be used
* @param msg The message
+ * @param appendNewLine whether to append a newline after the =
message.
+ */
+ void print(Color color, String msg, boolean appendNewLine);
+
+ /**
+ * Prints a string of text with the specified color and appends a new
line.
+ * @param color The color. If null, the default color will be used
+ * @param msg The message
*/
void print(Color color, String msg); |