This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 52777
Collapse All | Expand All

(-)src/org/netbeans/core/output2/AbstractLines.java (-8 / +19 lines)
Lines 11-19 Link Here
11
 * Microsystems, Inc. All Rights Reserved.
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
12
 */
13
package org.netbeans.core.output2;
13
package org.netbeans.core.output2;
14
14
import java.awt.Color;
15
import java.util.HashSet;
16
import java.util.Set;
17
import org.openide.windows.OutputListener;
15
import org.openide.windows.OutputListener;
18
import org.openide.ErrorManager;
16
import org.openide.ErrorManager;
19
import org.openide.util.Mutex;
17
import org.openide.util.Mutex;
Lines 329-334 Link Here
329
    public OutputListener getListenerForLine (int line) {
327
    public OutputListener getListenerForLine (int line) {
330
        return (OutputListener) linesToListeners.get(line);
328
        return (OutputListener) linesToListeners.get(line);
331
    }
329
    }
330
    
331
    private IntMap linesToColors = new IntMap();
332
    public Color getLineColor (int line) {
333
        return (Color) linesToColors.get(line);
334
    }
335
    
336
    public void setLineColor(int line, Color c) {
337
        linesToColors.put (line, c);
338
    }
332
339
333
    public int firstListenerLine () {
340
    public int firstListenerLine () {
334
        if (isDisposed() || isTrouble()) return -1;
341
        if (isDisposed() || isTrouble()) return -1;
Lines 667-673 Link Here
667
        }
674
        }
668
    }
675
    }
669
    
676
    
670
    public void lineFinished(int lineLength) {
677
    public int lineFinished(int lineLength) {
678
        int lastline;
671
        synchronized (readLock()) {
679
        synchronized (readLock()) {
672
            setLastWrappedLineCount(-1);
680
            setLastWrappedLineCount(-1);
673
            setLastCharCountForWrapAboveCalculation(-1);
681
            setLastCharCountForWrapAboveCalculation(-1);
Lines 676-684 Link Here
676
            
684
            
677
            int lineCount = lineStartList.size();
685
            int lineCount = lineStartList.size();
678
            //This is the index of the getLine we just added
686
            //This is the index of the getLine we just added
679
            int lastline = lineCount-1;
687
            lastline = lineCount-1;
680
            checkLogicalLineCount(lastline);
688
            checkLogicalLineCount(lastline);
681
        }
689
        }
690
        return lastline;
682
    }
691
    }
683
    
692
    
684
    private void checkLogicalLineCount(int lastline) {
693
    private void checkLogicalLineCount(int lastline) {
Lines 710-718 Link Here
710
719
711
    }
720
    }
712
    
721
    
713
    public void lineWritten(int start, int lineLength) {
722
    public int lineWritten(int start, int lineLength) {
714
        if (Controller.verbose) Controller.log("AbstractLines.lineWritten " + start + " length:" + lineLength); //NOI18N
723
        if (Controller.verbose) Controller.log("AbstractLines.lineWritten " + start + " length:" + lineLength); //NOI18N
715
        int lineCount = 0;
724
        int lastline;
725
        int lineCount;
716
        synchronized (readLock()) {
726
        synchronized (readLock()) {
717
            setLastWrappedLineCount(-1);
727
            setLastWrappedLineCount(-1);
718
            setLastCharCountForWrapAboveCalculation(-1);
728
            setLastCharCountForWrapAboveCalculation(-1);
Lines 722-728 Link Here
722
            
732
            
723
            lineCount = lineStartList.size();
733
            lineCount = lineStartList.size();
724
            //This is the index of the getLine we just added
734
            //This is the index of the getLine we just added
725
            int lastline = lineCount-1;
735
            lastline = lineCount-1;
726
            checkLogicalLineCount(lastline);
736
            checkLogicalLineCount(lastline);
727
            
737
            
728
        }
738
        }
Lines 731-736 Link Here
731
            if (Controller.log) Controller.log("Firing initial write event");
741
            if (Controller.log) Controller.log("Firing initial write event");
732
            fire();
742
            fire();
733
        }
743
        }
744
        return lastline;
734
    }
745
    }
735
746
736
    /** Convert an index from chars to byte count (*2).  Simple math, but it
747
    /** Convert an index from chars to byte count (*2).  Simple math, but it
(-)src/org/netbeans/core/output2/ExtPlainView.java (-1 / +3 lines)
Lines 113-120 Link Here
113
        boolean hyperlink = od.getLines().isHyperlink(line);
113
        boolean hyperlink = od.getLines().isHyperlink(line);
114
        boolean important = hyperlink ? od.getLines().isImportantHyperlink(line) : false;
114
        boolean important = hyperlink ? od.getLines().isImportantHyperlink(line) : false;
115
        boolean isErr = od.getLines().isErr(line);
115
        boolean isErr = od.getLines().isErr(line);
116
        Color c = od.getLines().getLineColor(line);
117
        if (c != null) System.err.println("GOT ONE! " + c);
116
        
118
        
117
        return hyperlink ? 
119
        return c != null && !selected ? c : hyperlink ? 
118
            (important ? 
120
            (important ? 
119
                (selected ? 
121
                (selected ? 
120
                    WrappedTextView.selectedImportantLinkFg : 
122
                    WrappedTextView.selectedImportantLinkFg : 
(-)src/org/netbeans/core/output2/LineColoredOutputWriter.java (+20 lines)
Added Link Here
1
/*
2
 * LineColoredOutputWriter.java
3
 *
4
 * Created on August 30, 2005, 11:44 PM
5
 *
6
 * To change this template, choose Tools | Options and locate the template under
7
 * the Source Creation and Management node. Right-click the template and choose
8
 * Open. You can then make changes to the template in the Source Editor.
9
 */
10
11
package org.netbeans.core.output2;
12
import java.awt.Color;
13
14
/**
15
 *
16
 * @author tim
17
 */
18
public interface LineColoredOutputWriter {
19
    public void println (String line, Color c);
20
}
(-)src/org/netbeans/core/output2/Lines.java (+8 lines)
Lines 12-17 Link Here
12
 */
12
 */
13
package org.netbeans.core.output2;
13
package org.netbeans.core.output2;
14
14
15
import java.awt.Color;
15
import org.openide.windows.OutputListener;
16
import org.openide.windows.OutputListener;
16
17
17
import javax.swing.event.ChangeListener;
18
import javax.swing.event.ChangeListener;
Lines 284-287 Link Here
284
     * @return True if there is still an open stream which may write to the backing storage and no error has occured
285
     * @return True if there is still an open stream which may write to the backing storage and no error has occured
285
     */
286
     */
286
    boolean isGrowing();
287
    boolean isGrowing();
288
    
289
    /**
290
     * Get the color that was passed to LineColoredOutputWriter for a line.
291
     * @param line the line number
292
     * @return the color
293
     */
294
    Color getLineColor(int line);
287
}
295
}
(-)src/org/netbeans/core/output2/NbWriter.java (-3 / +7 lines)
Lines 13-23 Link Here
13
13
14
package org.netbeans.core.output2;
14
package org.netbeans.core.output2;
15
15
16
import java.awt.Color;
16
import org.openide.windows.OutputWriter;
17
import org.openide.windows.OutputWriter;
17
import org.openide.windows.OutputListener;
18
import org.openide.windows.OutputListener;
18
import org.openide.ErrorManager;
19
import org.openide.ErrorManager;
19
20
import javax.swing.plaf.basic.BasicTabbedPaneUI;
21
import java.io.IOException;
20
import java.io.IOException;
22
21
23
22
Lines 28-34 Link Here
28
 * which it replaces when reset() is called;  an OutputDocument is implemented directly over an 
27
 * which it replaces when reset() is called;  an OutputDocument is implemented directly over an 
29
 * OutWriter, so the immutable OutWriter lasts until the OutputDocument is destroyed.
28
 * OutWriter, so the immutable OutWriter lasts until the OutputDocument is destroyed.
30
 */
29
 */
31
class NbWriter extends OutputWriter {
30
class NbWriter extends OutputWriter implements LineColoredOutputWriter {
32
    private final NbIO owner;
31
    private final NbIO owner;
33
    /**
32
    /**
34
     * Make an output writer.
33
     * Make an output writer.
Lines 140-144 Link Here
140
        synchronized (lock) {
139
        synchronized (lock) {
141
            ((OutWriter) out).println(s);
140
            ((OutWriter) out).println(s);
142
        }
141
        }
142
    }
143
144
    public void println(String line, Color c) {
145
        OutWriter ow = (OutWriter) out;
146
        ow.println (line, c);
143
    }
147
    }
144
}
148
}
(-)src/org/netbeans/core/output2/OutWriter.java (-13 / +25 lines)
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
(-)src/org/netbeans/core/output2/WrappedTextView.java (-1 / +5 lines)
Lines 606-612 Link Here
606
        boolean hyperlink = od.getLines().isHyperlink(line);
606
        boolean hyperlink = od.getLines().isHyperlink(line);
607
        boolean important = hyperlink ? od.getLines().isImportantHyperlink(line) : false;
607
        boolean important = hyperlink ? od.getLines().isImportantHyperlink(line) : false;
608
        boolean isErr = od.getLines().isErr(line);
608
        boolean isErr = od.getLines().isErr(line);
609
        return hyperlink ? (important ? (selected ? selectedImportantLinkFg : unselectedImportantLinkFg) : 
609
        Color c = od.getLines().getLineColor(line);
610
        if (c != null) System.err.println("GOT ONE! " + c);
611
        
612
        return c != null ? c :
613
            hyperlink ? (important ? (selected ? selectedImportantLinkFg : unselectedImportantLinkFg) : 
610
                                        (selected ? selectedLinkFg : unselectedLinkFg)) :
614
                                        (selected ? selectedLinkFg : unselectedLinkFg)) :
611
                           (selected ? (isErr ? selectedErr : selectedFg) : 
615
                           (selected ? (isErr ? selectedErr : selectedFg) : 
612
                                       (isErr ? unselectedErr : unselectedFg));
616
                                       (isErr ? unselectedErr : unselectedFg));

Return to bug 52777