diff options
author | Eugene Tarassov | 2012-05-10 18:51:03 +0000 |
---|---|---|
committer | Eugene Tarassov | 2012-05-10 18:51:03 +0000 |
commit | dab93ea5e58c6bc8f84fbaf6d57b53b7706eb297 (patch) | |
tree | 4da994d25165f7e64c6a05e8c50d5250594da10c | |
parent | c7509c67215869a2baba55bd7a3e2ddc05165042 (diff) | |
download | org.eclipse.tcf-dab93ea5e58c6bc8f84fbaf6d57b53b7706eb297.tar.gz org.eclipse.tcf-dab93ea5e58c6bc8f84fbaf6d57b53b7706eb297.tar.xz org.eclipse.tcf-dab93ea5e58c6bc8f84fbaf6d57b53b7706eb297.zip |
TCF Debugger: the debugger now uses monospaced font to display numbers in details pane of Expressions and Registers views
5 files changed, 61 insertions, 26 deletions
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/TestErrorsDialog.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/TestErrorsDialog.java index a9255ca92..1c70a7798 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/TestErrorsDialog.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/TestErrorsDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 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 @@ -61,11 +61,11 @@ class TestErrorsDialog extends Dialog { composite.setSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); Label label = new Label(composite, SWT.WRAP); - label.setFont(JFaceResources.getFontRegistry().get(JFaceResources.BANNER_FONT)); + label.setFont(JFaceResources.getFont(JFaceResources.BANNER_FONT)); label.setText("Connection diagnostics ended with errors:"); text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); - text.setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT)); + text.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); text.setEditable(false); text.setText(createText()); GridData data = new GridData(GridData.FILL_BOTH); diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/StyledStringBuffer.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/StyledStringBuffer.java index d2f66fdfd..a97d7aadb 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/StyledStringBuffer.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/StyledStringBuffer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2011, 2012 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 @@ -18,6 +18,15 @@ import org.eclipse.swt.graphics.RGB; class StyledStringBuffer { + /** + * The font style constants. + */ + public static final int + NORMAL = SWT.NORMAL, + BOLD = SWT.BOLD, + ITALIC = SWT.ITALIC, + MONOSPACED = 1 << 2; + private final StringBuffer bf = new StringBuffer(); private final ArrayList<Style> styles = new ArrayList<Style>(); diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFDetailPane.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFDetailPane.java index 74b39e04b..508f273a9 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFDetailPane.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFDetailPane.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2012 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 @@ -24,6 +24,8 @@ import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; +import org.eclipse.jface.resource.FontDescriptor; +import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.DocumentEvent; import org.eclipse.jface.text.IDocumentListener; @@ -40,6 +42,8 @@ import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.events.FocusAdapter; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; @@ -74,6 +78,7 @@ public class TCFDetailPane implements IDetailPane { private final HashMap<RGB,Color> colors = new HashMap<RGB,Color>(); private final Map<String,IAction> action_map = new HashMap<String,IAction>(); private final List<String> selection_actions = new ArrayList<String>(); + private Font mono_font; private final ITextPresentationListener presentation_listener = new ITextPresentationListener() { public void applyTextPresentation(TextPresentation presentation) { @@ -240,7 +245,12 @@ public class TCFDetailPane implements IDetailPane { private String getStyleRanges(StyledStringBuffer s) { style_ranges.clear(); for (StyledStringBuffer.Style x : s.getStyle()) { - style_ranges.add(new StyleRange(x.pos, x.len, getColor(x.fg), getColor(x.bg), x.font)); + StyleRange r = new StyleRange(x.pos, x.len, getColor(x.fg), getColor(x.bg), x.font); + if ((x.font & StyledStringBuffer.MONOSPACED) != 0) { + r.fontStyle &= ~StyledStringBuffer.MONOSPACED; + r.font = getMonospacedFont(); + } + style_ranges.add(r); } return s.toString(); } @@ -252,7 +262,23 @@ public class TCFDetailPane implements IDetailPane { return c; } + private Font getMonospacedFont() { + if (mono_font == null) { + int height = 0; + FontData[] fd = source_viewer.getControl().getFont().getFontData(); + if (fd != null && fd.length > 0) height = fd[0].getHeight(); + FontDescriptor d = JFaceResources.getFontDescriptor(JFaceResources.TEXT_FONT); + if (height != 0) d = d.setHeight(height); + mono_font = d.createFont(display); + } + return mono_font; + } + public void dispose() { + if (mono_font != null) { + mono_font.dispose(); + mono_font = null; + } for (Color c : colors.values()) c.dispose(); colors.clear(); if (source_viewer == null) return; diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java index 1e5b2ba7f..cacea21a1 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java @@ -1262,15 +1262,15 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT case cardinal: case real: bf.append("Dec: ", SWT.BOLD); - bf.append(toNumberString(10, type_class, data, offs, size, big_endian)); + bf.append(toNumberString(10, type_class, data, offs, size, big_endian), StyledStringBuffer.MONOSPACED); bf.append("\n"); break; } bf.append("Oct: ", SWT.BOLD); - bf.append(toNumberString(8, type_class, data, offs, size, big_endian)); + bf.append(toNumberString(8, type_class, data, offs, size, big_endian), StyledStringBuffer.MONOSPACED); bf.append("\n"); bf.append("Hex: ", SWT.BOLD); - bf.append(toNumberString(16, type_class, data, offs, size, big_endian)); + bf.append(toNumberString(16, type_class, data, offs, size, big_endian), StyledStringBuffer.MONOSPACED); bf.append("\n"); } String s = getTypeName(type_class, size); @@ -1283,10 +1283,10 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT bf.append(size == 1 ? " byte\n" : " bytes\n"); } else if (type_class == ISymbols.TypeClass.integer || type_class == ISymbols.TypeClass.real) { - bf.append(toNumberString(10, type_class, data, offs, size, big_endian)); + bf.append(toNumberString(10, type_class, data, offs, size, big_endian), StyledStringBuffer.MONOSPACED); } else { - bf.append(toNumberString(16, type_class, data, offs, size, big_endian)); + bf.append(toNumberString(16, type_class, data, offs, size, big_endian), StyledStringBuffer.MONOSPACED); } return true; } @@ -1313,21 +1313,21 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT case real: if (level == 0) { bf.append("Dec: ", SWT.BOLD); - bf.append(toNumberString(10, type_class, data, offs, size, big_endian)); + bf.append(toNumberString(10, type_class, data, offs, size, big_endian), StyledStringBuffer.MONOSPACED); bf.append("\n"); bf.append("Oct: ", SWT.BOLD); - bf.append(toNumberString(8, type_class, data, offs, size, big_endian)); + bf.append(toNumberString(8, type_class, data, offs, size, big_endian), StyledStringBuffer.MONOSPACED); bf.append("\n"); bf.append("Hex: ", SWT.BOLD); - bf.append(toNumberString(16, type_class, data, offs, size, big_endian)); + bf.append(toNumberString(16, type_class, data, offs, size, big_endian), StyledStringBuffer.MONOSPACED); bf.append("\n"); } else if (type_data.getTypeClass() == ISymbols.TypeClass.cardinal) { bf.append("0x"); - bf.append(toNumberString(16, type_class, data, offs, size, big_endian)); + bf.append(toNumberString(16, type_class, data, offs, size, big_endian), StyledStringBuffer.MONOSPACED); } else { - bf.append(toNumberString(10, type_class, data, offs, size, big_endian)); + bf.append(toNumberString(10, type_class, data, offs, size, big_endian), StyledStringBuffer.MONOSPACED); } break; case pointer: @@ -1335,15 +1335,15 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT case member_pointer: if (level == 0) { bf.append("Oct: ", SWT.BOLD); - bf.append(toNumberString(8, type_class, data, offs, size, big_endian)); + bf.append(toNumberString(8, type_class, data, offs, size, big_endian), StyledStringBuffer.MONOSPACED); bf.append("\n"); bf.append("Hex: ", SWT.BOLD); - bf.append(toNumberString(16, type_class, data, offs, size, big_endian)); + bf.append(toNumberString(16, type_class, data, offs, size, big_endian), StyledStringBuffer.MONOSPACED); bf.append("\n"); } else { bf.append("0x"); - bf.append(toNumberString(16, type_class, data, offs, size, big_endian)); + bf.append(toNumberString(16, type_class, data, offs, size, big_endian), StyledStringBuffer.MONOSPACED); } break; case array: @@ -1450,8 +1450,8 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT if (addr != null) { BigInteger i = JSON.toBigInteger(addr); bf.append("Address: ", SWT.BOLD); - bf.append("0x"); - bf.append(i.toString(16)); + bf.append("0x", StyledStringBuffer.MONOSPACED); + bf.append(i.toString(16), StyledStringBuffer.MONOSPACED); bf.append('\n'); } } diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeRegister.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeRegister.java index 5f2155624..9da00d6c9 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeRegister.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeRegister.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 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 @@ -241,16 +241,16 @@ public class TCFNodeRegister extends TCFNode implements IElementEditor, IWatchIn byte[] v = value.getData(); if (v != null) { bf.append("Hex: ", SWT.BOLD); - bf.append(toNumberString(16)); + bf.append(toNumberString(16), StyledStringBuffer.MONOSPACED); bf.append(", "); bf.append("Dec: ", SWT.BOLD); - bf.append(toNumberString(10)); + bf.append(toNumberString(10), StyledStringBuffer.MONOSPACED); bf.append(", "); bf.append("Oct: ", SWT.BOLD); - bf.append(toNumberString(8)); + bf.append(toNumberString(8), StyledStringBuffer.MONOSPACED); bf.append('\n'); bf.append("Bin: ", SWT.BOLD); - bf.append(toNumberString(2)); + bf.append(toNumberString(2), StyledStringBuffer.MONOSPACED); bf.append('\n'); } } |