Lines 18-23
Link Here
|
18 |
|
18 |
|
19 |
package org.netbeans.core.output2; |
19 |
package org.netbeans.core.output2; |
20 |
|
20 |
|
|
|
21 |
import java.awt.Color; |
21 |
import org.openide.ErrorManager; |
22 |
import org.openide.ErrorManager; |
22 |
import org.openide.util.Mutex; |
23 |
import org.openide.util.Mutex; |
23 |
import org.openide.util.NbBundle; |
24 |
import org.openide.util.NbBundle; |
Lines 43-49
Link Here
|
43 |
* |
44 |
* |
44 |
* @author Tim Boudreau |
45 |
* @author Tim Boudreau |
45 |
*/ |
46 |
*/ |
46 |
class OutWriter extends PrintWriter { |
47 |
class OutWriter extends PrintWriter implements LineColoredOutputWriter { |
47 |
/** A flag indicating an io exception occured */ |
48 |
/** A flag indicating an io exception occured */ |
48 |
private boolean trouble = false; |
49 |
private boolean trouble = false; |
49 |
|
50 |
|
Lines 128-134
Link Here
|
128 |
return "OutWriter@" + System.identityHashCode(this) + " for " + owner + " closed "; |
129 |
return "OutWriter@" + System.identityHashCode(this) + " for " + owner + " closed "; |
129 |
} |
130 |
} |
130 |
|
131 |
|
131 |
private int doPrintln (String s) { |
132 |
private int doPrintln (String s, Color color) { |
132 |
try { |
133 |
try { |
133 |
int idx = s.indexOf("\n"); |
134 |
int idx = s.indexOf("\n"); |
134 |
int result = 1; |
135 |
int result = 1; |
Lines 141-153
Link Here
|
141 |
String token = tok.nextToken(); |
142 |
String token = tok.nextToken(); |
142 |
if (token.equals("\n")) { |
143 |
if (token.equals("\n")) { |
143 |
if (lastWasNewLine) { |
144 |
if (lastWasNewLine) { |
144 |
doPrintln(""); |
145 |
doPrintln("", color); |
145 |
result++; |
146 |
result++; |
146 |
} |
147 |
} |
147 |
lastWasNewLine = true; |
148 |
lastWasNewLine = true; |
148 |
} else { |
149 |
} else { |
149 |
lastWasNewLine = false; |
150 |
lastWasNewLine = false; |
150 |
doPrintln(token); |
151 |
doPrintln(token, color); |
151 |
result++; |
152 |
result++; |
152 |
} |
153 |
} |
153 |
} |
154 |
} |
Lines 173-179
Link Here
|
173 |
buf = getStorage().getWriteBuffer(AbstractLines.toByteIndex(s.length())); |
174 |
buf = getStorage().getWriteBuffer(AbstractLines.toByteIndex(s.length())); |
174 |
buf.asCharBuffer().put(s); |
175 |
buf.asCharBuffer().put(s); |
175 |
buf.position (buf.position() + AbstractLines.toByteIndex(s.length())); |
176 |
buf.position (buf.position() + AbstractLines.toByteIndex(s.length())); |
176 |
write (buf, true); |
177 |
write (buf, true, color); |
177 |
} |
178 |
} |
178 |
} |
179 |
} |
179 |
return result; |
180 |
return result; |
Lines 209-215
Link Here
|
209 |
* @param bb |
210 |
* @param bb |
210 |
* @throws IOException |
211 |
* @throws IOException |
211 |
*/ |
212 |
*/ |
212 |
public synchronized void write(ByteBuffer bb, boolean completeLine) throws IOException { |
213 |
public synchronized void write(ByteBuffer bb, boolean completeLine, Color color) throws IOException { |
213 |
if (checkError() || terminated) { |
214 |
if (checkError() || terminated) { |
214 |
return; |
215 |
return; |
215 |
} |
216 |
} |
Lines 256-265
Link Here
|
256 |
if (lineStart >= 0 && !terminated && lines != null) { |
257 |
if (lineStart >= 0 && !terminated && lines != null) { |
257 |
if (Controller.verbose) Controller.log (this + ": Wrote " + |
258 |
if (Controller.verbose) Controller.log (this + ": Wrote " + |
258 |
((ByteBuffer)bb.flip()).asCharBuffer() + " at " + start); |
259 |
((ByteBuffer)bb.flip()).asCharBuffer() + " at " + start); |
|
|
260 |
int line; |
259 |
if (startedNow) { |
261 |
if (startedNow) { |
260 |
lines.lineWritten (lineStart, lineLength); |
262 |
line = lines.lineWritten (lineStart, lineLength); |
261 |
} else { |
263 |
} else { |
262 |
lines.lineFinished(lineLength); |
264 |
line = lines.lineFinished(lineLength); |
263 |
} |
265 |
} |
264 |
lineStart = -1; |
266 |
lineStart = -1; |
265 |
lineLength = 0; |
267 |
lineLength = 0; |
Lines 267-272
Link Here
|
267 |
owner.setStreamClosed(false); |
269 |
owner.setStreamClosed(false); |
268 |
lines.fire(); |
270 |
lines.fire(); |
269 |
} |
271 |
} |
|
|
272 |
if (color != null) { |
273 |
lines.setLineColor(line, color); |
274 |
} |
270 |
} |
275 |
} |
271 |
} else { |
276 |
} else { |
272 |
if (startedNow && lineStart >= 0 && !terminated && lines != null) { |
277 |
if (startedNow && lineStart >= 0 && !terminated && lines != null) { |
Lines 384-390
Link Here
|
384 |
if (checkError()) { |
389 |
if (checkError()) { |
385 |
return; |
390 |
return; |
386 |
} |
391 |
} |
387 |
doPrintln(s); |
392 |
doPrintln(s, null); |
388 |
} |
393 |
} |
389 |
|
394 |
|
390 |
public synchronized void flush() { |
395 |
public synchronized void flush() { |
Lines 418-424
Link Here
|
418 |
ByteBuffer buf = getStorage().getWriteBuffer(AbstractLines.toByteIndex(1)); |
423 |
ByteBuffer buf = getStorage().getWriteBuffer(AbstractLines.toByteIndex(1)); |
419 |
buf.asCharBuffer().put((char)c); |
424 |
buf.asCharBuffer().put((char)c); |
420 |
buf.position (buf.position() + AbstractLines.toByteIndex(1)); |
425 |
buf.position (buf.position() + AbstractLines.toByteIndex(1)); |
421 |
write (buf, false); |
426 |
write (buf, false, null); |
422 |
} catch (IOException ioe) { |
427 |
} catch (IOException ioe) { |
423 |
handleException (ioe); |
428 |
handleException (ioe); |
424 |
} |
429 |
} |
Lines 469-475
Link Here
|
469 |
ByteBuffer buf = getStorage().getWriteBuffer(AbstractLines.toByteIndex(lenght)); |
474 |
ByteBuffer buf = getStorage().getWriteBuffer(AbstractLines.toByteIndex(lenght)); |
470 |
buf.asCharBuffer().put(data, start, lenght); |
475 |
buf.asCharBuffer().put(data, start, lenght); |
471 |
buf.position(buf.position() + AbstractLines.toByteIndex(lenght)); |
476 |
buf.position(buf.position() + AbstractLines.toByteIndex(lenght)); |
472 |
write(buf, false); |
477 |
write(buf, false, null); |
473 |
} |
478 |
} |
474 |
} catch (IOException ioe) { |
479 |
} catch (IOException ioe) { |
475 |
handleException(ioe); |
480 |
handleException(ioe); |
Lines 482-488
Link Here
|
482 |
} |
487 |
} |
483 |
|
488 |
|
484 |
public synchronized void println() { |
489 |
public synchronized void println() { |
485 |
doPrintln(""); |
490 |
doPrintln("", null); |
486 |
} |
491 |
} |
487 |
|
492 |
|
488 |
/** |
493 |
/** |
Lines 509-515
Link Here
|
509 |
if (checkError()) { |
514 |
if (checkError()) { |
510 |
return; |
515 |
return; |
511 |
} |
516 |
} |
512 |
int addedCount = doPrintln (s); |
517 |
int addedCount = doPrintln (s, null); |
513 |
int newCount = lines.getLineCount(); |
518 |
int newCount = lines.getLineCount(); |
514 |
for (int i=newCount - addedCount; i < newCount; i++) { |
519 |
for (int i=newCount - addedCount; i < newCount; i++) { |
515 |
lines.addListener (i, l, important); |
520 |
lines.addListener (i, l, important); |
Lines 518-523
Link Here
|
518 |
lines.fire(); |
523 |
lines.fire(); |
519 |
} |
524 |
} |
520 |
} |
525 |
} |
|
|
526 |
|
527 |
public void println(String line, Color c) { |
528 |
if (checkError()) { |
529 |
return; |
530 |
} |
531 |
doPrintln (line, c); |
532 |
} |
521 |
|
533 |
|
522 |
/** |
534 |
/** |
523 |
* A useless writer object to pass to the superclass constructor. We override all methods |
535 |
* A useless writer object to pass to the superclass constructor. We override all methods |