# HG changeset patch # User Alexander Simon # Date 1491306717 -10800 # Tue Apr 04 14:51:57 2017 +0300 # Branch release82 # Node ID 34e77e85b4e84d38ea97b78f566ab0e133e6435d # Parent 4955ec95dd1dacc2fe20491adb2ef5f09a813141 fixed Bug #268941 Missing support for gcc -fdiagnostics-color=always in output window diff --git a/core.output2/src/org/netbeans/core/output2/AbstractLines.java b/core.output2/src/org/netbeans/core/output2/AbstractLines.java --- a/core.output2/src/org/netbeans/core/output2/AbstractLines.java +++ b/core.output2/src/org/netbeans/core/output2/AbstractLines.java @@ -1157,11 +1157,17 @@ } } if (leadingCnt > 0) { - info.addSegment(curEnd + leadingCnt, OutputKind.OUT, null, null, null, false); + if (info.segments.size() > 0) { + // do not undeline leading spaces only in the first segment + info.addSegment(curEnd + leadingCnt, outKind, l, c, b, important); + } else { + info.addSegment(curEnd + leadingCnt, OutputKind.OUT, null, null, null, false); + } } info.addSegment(endPos - trailingCnt, outKind, l, c, b, important); if (trailingCnt > 0) { - info.addSegment(endPos, OutputKind.OUT, null, null, null, false); + // have to underline all trailing spaces (we cannot know if there are more segments) + info.addSegment(endPos, outKind, l, c, b, important); } registerLineWithListener(lineIdx, info, important); } else { diff --git a/core.output2/src/org/netbeans/core/output2/OutWriter.java b/core.output2/src/org/netbeans/core/output2/OutWriter.java --- a/core.output2/src/org/netbeans/core/output2/OutWriter.java +++ b/core.output2/src/org/netbeans/core/output2/OutWriter.java @@ -341,7 +341,7 @@ @Override public synchronized void println(String s) { - doWrite(s, 0, s.length()); + doWrite(s, null, 0, s.length()); println(); } @@ -399,7 +399,7 @@ @Override public synchronized void write(int c) { - doWrite(new String(new char[]{(char)c}), 0, 1); + doWrite(new String(new char[]{(char)c}), null, 0, 1); checkLimits(); } @@ -412,19 +412,19 @@ @Override public synchronized void write(char data[], int off, int len) { - doWrite(new CharArrayWrapper(data), off, len); + doWrite(new CharArrayWrapper(data), null, off, len); checkLimits(); } /** write buffer size in chars */ private static final int WRITE_BUFF_SIZE = 16*1024; - private synchronized void doWrite(CharSequence s, int off, int len) { + private synchronized void doWrite(CharSequence s, OutputListener l, int off, int len) { if (checkError() || len == 0) { return; } // XXX will not pick up ANSI sequences broken across write blocks, but this is likely rare - if (printANSI(s.subSequence(off, off + len), false, OutputKind.OUT, false)) { + if (printANSI(s.subSequence(off, off + len), l, false, OutputKind.OUT, false)) { return; } /* XXX causes stack overflow @@ -546,7 +546,7 @@ @Override public synchronized void write(char data[]) { - doWrite(new CharArrayWrapper(data), 0, data.length); + doWrite(new CharArrayWrapper(data), null, 0, data.length); checkLimits(); } @@ -557,7 +557,7 @@ } private void printLineEnd() { - doWrite("\n", 0, 1); + doWrite("\n", null, 0, 1); } /** @@ -568,13 +568,13 @@ */ @Override public synchronized void write(String s, int off, int len) { - doWrite(s, off, len); + doWrite(s, null, off, len); checkLimits(); } @Override public synchronized void write(String s) { - doWrite(s, 0, s.length()); + doWrite(s, null, 0, s.length()); checkLimits(); } @@ -588,14 +588,14 @@ synchronized void print(CharSequence s, OutputListener l, boolean important, Color c, Color b, OutputKind outKind, boolean addLS) { if (c == null) { - if (l == null && printANSI(s, important, outKind, addLS)) { + if (l == null && printANSI(s, null, important, outKind, addLS)) { return; } c = ansiColor; // carry over from previous line } int lastLine = lines.getLineCount() - 1; int lastPos = lines.getCharCount(); - doWrite(s, 0, s.length()); + doWrite(s, l, 0, s.length()); if (addLS) { printLineEnd(); } @@ -628,7 +628,7 @@ new Color(0, 255, 255), new Color(255, 255, 255), }; - private boolean printANSI(CharSequence s, boolean important, OutputKind outKind, boolean addLS) { // #192779 + private boolean printANSI(CharSequence s, OutputListener l, boolean important, OutputKind outKind, boolean addLS) { // #192779 int len = s.length(); boolean hasEscape = false; // fast initial check for (int i = 0; i < len - 1; i++) { @@ -645,7 +645,7 @@ while (m.find()) { int esc = m.start(); if (esc > text) { - print(s.subSequence(text, esc), null, important, ansiColor, ansiBackground, outKind, false); + print(s.subSequence(text, esc), l, important, ansiColor, ansiBackground, outKind, false); } text = m.end(); if ("K".equals(m.group(3)) && "2".equals(m.group(1))) { //NOI18N @@ -709,7 +709,7 @@ return false; } if (text < len) { // final segment - print(s.subSequence(text, len), null, important, ansiColor, ansiBackground, outKind, addLS); + print(s.subSequence(text, len), l, important, ansiColor, ansiBackground, outKind, addLS); } else if (addLS) { // line ended w/ control seq printLineEnd(); } @@ -734,7 +734,7 @@ synchronized void print(CharSequence s, LineInfo info, boolean important) { int line = lines.getLineCount() - 1; - doWrite(s, 0, s.length()); + doWrite(s, null, 0, s.length()); if (info != null) { lines.addLineInfo(line, info, important); }