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 268941
Collapse All | Expand All

(-)a/core.output2/src/org/netbeans/core/output2/AbstractLines.java (-2 / +8 lines)
Lines 1157-1167 Link Here
1157
                    }
1157
                    }
1158
                }
1158
                }
1159
                if (leadingCnt > 0) {
1159
                if (leadingCnt > 0) {
1160
                    info.addSegment(curEnd + leadingCnt, OutputKind.OUT, null, null, null, false);
1160
                    if (info.segments.size() > 0) {
1161
                        // do not undeline leading spaces only in the first segment
1162
                        info.addSegment(curEnd + leadingCnt, outKind, l, c, b, important);
1163
                    } else {
1164
                        info.addSegment(curEnd + leadingCnt, OutputKind.OUT, null, null, null, false);
1165
                    }
1161
                }
1166
                }
1162
                info.addSegment(endPos - trailingCnt, outKind, l, c, b, important);
1167
                info.addSegment(endPos - trailingCnt, outKind, l, c, b, important);
1163
                if (trailingCnt > 0) {
1168
                if (trailingCnt > 0) {
1164
                    info.addSegment(endPos, OutputKind.OUT, null, null, null, false);
1169
                    // have to underline all trailing spaces (we cannot know if there are more segments)
1170
                    info.addSegment(endPos, outKind, l, c, b, important);
1165
                }
1171
                }
1166
                registerLineWithListener(lineIdx, info, important);
1172
                registerLineWithListener(lineIdx, info, important);
1167
            } else {
1173
            } else {
(-)a/core.output2/src/org/netbeans/core/output2/OutWriter.java (-15 / +15 lines)
Lines 341-347 Link Here
341
341
342
    @Override
342
    @Override
343
    public synchronized void println(String s) {
343
    public synchronized void println(String s) {
344
        doWrite(s, 0, s.length());
344
        doWrite(s, null, 0, s.length());
345
        println();
345
        println();
346
    }
346
    }
347
347
Lines 399-405 Link Here
399
399
400
    @Override
400
    @Override
401
    public synchronized void write(int c) {
401
    public synchronized void write(int c) {
402
        doWrite(new String(new char[]{(char)c}), 0, 1);
402
        doWrite(new String(new char[]{(char)c}), null, 0, 1);
403
        checkLimits();
403
        checkLimits();
404
    }
404
    }
405
405
Lines 412-430 Link Here
412
    
412
    
413
    @Override
413
    @Override
414
    public synchronized void write(char data[], int off, int len) {
414
    public synchronized void write(char data[], int off, int len) {
415
        doWrite(new CharArrayWrapper(data), off, len);
415
        doWrite(new CharArrayWrapper(data), null, off, len);
416
        checkLimits();
416
        checkLimits();
417
    }
417
    }
418
    
418
    
419
    /** write buffer size in chars */
419
    /** write buffer size in chars */
420
    private static final int WRITE_BUFF_SIZE = 16*1024;
420
    private static final int WRITE_BUFF_SIZE = 16*1024;
421
    private synchronized void doWrite(CharSequence s, int off, int len) {
421
    private synchronized void doWrite(CharSequence s, OutputListener l, int off, int len) {
422
        if (checkError() || len == 0) {
422
        if (checkError() || len == 0) {
423
            return;
423
            return;
424
        }
424
        }
425
        
425
        
426
        // XXX will not pick up ANSI sequences broken across write blocks, but this is likely rare
426
        // XXX will not pick up ANSI sequences broken across write blocks, but this is likely rare
427
        if (printANSI(s.subSequence(off, off + len), false, OutputKind.OUT, false)) {
427
        if (printANSI(s.subSequence(off, off + len), l, false, OutputKind.OUT, false)) {
428
            return;
428
            return;
429
        }
429
        }
430
        /* XXX causes stack overflow
430
        /* XXX causes stack overflow
Lines 546-552 Link Here
546
546
547
    @Override
547
    @Override
548
    public synchronized void write(char data[]) {
548
    public synchronized void write(char data[]) {
549
        doWrite(new CharArrayWrapper(data), 0, data.length);
549
        doWrite(new CharArrayWrapper(data), null, 0, data.length);
550
        checkLimits();
550
        checkLimits();
551
    }
551
    }
552
552
Lines 557-563 Link Here
557
    }
557
    }
558
558
559
    private void printLineEnd() {
559
    private void printLineEnd() {
560
        doWrite("\n", 0, 1);
560
        doWrite("\n", null, 0, 1);
561
    }
561
    }
562
562
563
    /**
563
    /**
Lines 568-580 Link Here
568
     */
568
     */
569
    @Override
569
    @Override
570
    public synchronized void write(String s, int off, int len) {
570
    public synchronized void write(String s, int off, int len) {
571
        doWrite(s, off, len);
571
        doWrite(s, null, off, len);
572
        checkLimits();
572
        checkLimits();
573
    }
573
    }
574
574
575
    @Override
575
    @Override
576
    public synchronized void write(String s) {
576
    public synchronized void write(String s) {
577
        doWrite(s, 0, s.length());
577
        doWrite(s, null, 0, s.length());
578
        checkLimits();
578
        checkLimits();
579
    }
579
    }
580
580
Lines 588-601 Link Here
588
588
589
    synchronized void print(CharSequence s, OutputListener l, boolean important, Color c, Color b, OutputKind outKind, boolean addLS) {
589
    synchronized void print(CharSequence s, OutputListener l, boolean important, Color c, Color b, OutputKind outKind, boolean addLS) {
590
        if (c == null) {
590
        if (c == null) {
591
            if (l == null && printANSI(s, important, outKind, addLS)) {
591
            if (l == null && printANSI(s, null, important, outKind, addLS)) {
592
                return;
592
                return;
593
            }
593
            }
594
            c = ansiColor; // carry over from previous line
594
            c = ansiColor; // carry over from previous line
595
        }
595
        }
596
        int lastLine = lines.getLineCount() - 1;
596
        int lastLine = lines.getLineCount() - 1;
597
        int lastPos = lines.getCharCount();
597
        int lastPos = lines.getCharCount();
598
        doWrite(s, 0, s.length());
598
        doWrite(s, l, 0, s.length());
599
        if (addLS) {
599
        if (addLS) {
600
            printLineEnd();
600
            printLineEnd();
601
        }
601
        }
Lines 628-634 Link Here
628
        new Color(0, 255, 255),
628
        new Color(0, 255, 255),
629
        new Color(255, 255, 255),
629
        new Color(255, 255, 255),
630
    };
630
    };
631
    private boolean printANSI(CharSequence s, boolean important, OutputKind outKind, boolean addLS) { // #192779
631
    private boolean printANSI(CharSequence s, OutputListener l, boolean important, OutputKind outKind, boolean addLS) { // #192779
632
        int len = s.length();
632
        int len = s.length();
633
        boolean hasEscape = false; // fast initial check
633
        boolean hasEscape = false; // fast initial check
634
        for (int i = 0; i < len - 1; i++) {
634
        for (int i = 0; i < len - 1; i++) {
Lines 645-651 Link Here
645
        while (m.find()) {
645
        while (m.find()) {
646
            int esc = m.start();
646
            int esc = m.start();
647
            if (esc > text) {
647
            if (esc > text) {
648
                print(s.subSequence(text, esc), null, important, ansiColor, ansiBackground, outKind, false);
648
                print(s.subSequence(text, esc), l, important, ansiColor, ansiBackground, outKind, false);
649
            }
649
            }
650
            text = m.end();
650
            text = m.end();
651
            if ("K".equals(m.group(3)) && "2".equals(m.group(1))) {     //NOI18N
651
            if ("K".equals(m.group(3)) && "2".equals(m.group(1))) {     //NOI18N
Lines 709-715 Link Here
709
            return false;
709
            return false;
710
        }
710
        }
711
        if (text < len) { // final segment
711
        if (text < len) { // final segment
712
            print(s.subSequence(text, len), null, important, ansiColor, ansiBackground, outKind, addLS);
712
            print(s.subSequence(text, len), l, important, ansiColor, ansiBackground, outKind, addLS);
713
        } else if (addLS) { // line ended w/ control seq
713
        } else if (addLS) { // line ended w/ control seq
714
            printLineEnd();
714
            printLineEnd();
715
        }
715
        }
Lines 734-740 Link Here
734
734
735
    synchronized void print(CharSequence s, LineInfo info, boolean important) {
735
    synchronized void print(CharSequence s, LineInfo info, boolean important) {
736
        int line = lines.getLineCount() - 1;
736
        int line = lines.getLineCount() - 1;
737
        doWrite(s, 0, s.length());
737
        doWrite(s, null, 0, s.length());
738
        if (info != null) {
738
        if (info != null) {
739
            lines.addLineInfo(line, info, important);
739
            lines.addLineInfo(line, info, important);
740
        }
740
        }

Return to bug 268941