diff options
author | Uwe Stieber | 2011-10-18 17:22:53 +0000 |
---|---|---|
committer | Uwe Stieber | 2011-10-18 17:22:53 +0000 |
commit | 937d7b5b7d49004a7300930066ac5620292eeb61 (patch) | |
tree | 6f665d1c333fa09b2d941fd8c68897ed9eb48323 | |
parent | 5e064e1ea77bf35079ebd8940392d400ada1aa7a (diff) | |
download | org.eclipse.tcf-937d7b5b7d49004a7300930066ac5620292eeb61.tar.gz org.eclipse.tcf-937d7b5b7d49004a7300930066ac5620292eeb61.tar.xz org.eclipse.tcf-937d7b5b7d49004a7300930066ac5620292eeb61.zip |
Target Explorer: Filter Shift-Out and Shift-In from streams going to the terminal widget
3 files changed, 53 insertions, 3 deletions
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/.options b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/.options index 2ad378b66..149ccb08d 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/.options +++ b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/.options @@ -1 +1,2 @@ org.eclipse.tm.te.ui.terminals/debugmode = 0 +org.eclipse.tm.te.ui.terminals/trace/outputStreamMonitor = false diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/internal/tracing/ITraceIds.java b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/internal/tracing/ITraceIds.java new file mode 100644 index 000000000..8d05b627f --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/internal/tracing/ITraceIds.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.te.ui.terminals.internal.tracing; + +/** + * Core plug-in trace slot identifiers. + */ +public interface ITraceIds { + + /** + * If activated, tracing information about the terminals output stream monitor is printed out. + */ + public static final String TRACE_OUTPUT_STREAM_MONITOR = "trace/outputStreamMonitor"; //$NON-NLS-1$ +} diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/OutputStreamMonitor.java b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/OutputStreamMonitor.java index ff135dd70..31bcf2e07 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/OutputStreamMonitor.java +++ b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/streams/OutputStreamMonitor.java @@ -22,6 +22,7 @@ import org.eclipse.osgi.util.NLS; import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl; import org.eclipse.tm.te.runtime.services.interfaces.constants.ILineSeparatorConstants; import org.eclipse.tm.te.ui.terminals.activator.UIPlugin; +import org.eclipse.tm.te.ui.terminals.internal.tracing.ITraceIds; import org.eclipse.tm.te.ui.terminals.nls.Messages; import org.eclipse.ui.services.IDisposable; @@ -223,12 +224,39 @@ public class OutputStreamMonitor implements IDisposable { protected byte[] onContentReadFromStream(byte[] byteBuffer, int bytesRead) { Assert.isNotNull(byteBuffer); - if (lineSeparator != null && !ILineSeparatorConstants.LINE_SEPARATOR_CRLF.equals(lineSeparator)) { - String text = new String(byteBuffer, 0, bytesRead); + // If tracing is enabled, print out the decimal byte values read + if (UIPlugin.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_OUTPUT_STREAM_MONITOR)) { + StringBuilder debug = new StringBuilder("byteBuffer [decimal, " + bytesRead + " bytes] : "); //$NON-NLS-1$ //$NON-NLS-2$ + for (int i = 0; i < bytesRead; i++) { + debug.append(Byte.valueOf(byteBuffer[i]).intValue()); + debug.append(' '); + } + System.out.println(debug.toString()); + } + + // Remember if the text got changed. + boolean changed = false; + + // How can me make sure that we don't mess with the encoding here? + String text = new String(byteBuffer, 0, bytesRead); + + // Shift-In (14) and Shift-Out(15) confuses the terminal widget + if (text.indexOf(14) != -1 || text.indexOf(15) != -1) { + text = text.replaceAll("\\x0e", "").replaceAll("\\x0f", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + changed = true; + } + + // Check on the line separator setting + if (lineSeparator != null + && !ILineSeparatorConstants.LINE_SEPARATOR_CRLF.equals(lineSeparator) + && text.contains(lineSeparator)) { text = text.replaceAll(lineSeparator, "\r\n"); //$NON-NLS-1$ - byteBuffer = text.getBytes(); + changed = true; } + // If changed, get the new bytes array + if (changed) byteBuffer = text.getBytes(); + return byteBuffer; } } |