1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Limit opcode ruler width to max 20 chars

This commit is contained in:
Anton Leherbauer 2014-03-31 11:41:38 +02:00
parent 4d2a57889c
commit 7d147536f3

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2011 Wind River Systems and others. * Copyright (c) 2011, 2014 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -26,6 +26,9 @@ public class OpcodeRulerColumn extends DisassemblyRulerColumn {
public static final String ID = "org.eclipse.cdt.dsf.ui.disassemblyColumn.opcode"; //$NON-NLS-1$ public static final String ID = "org.eclipse.cdt.dsf.ui.disassemblyColumn.opcode"; //$NON-NLS-1$
/** Maximum width of column (in characters) */
private static final int MAXWIDTH= 20;
private int fRadix; private int fRadix;
private String fRadixPrefix; private String fRadixPrefix;
@ -82,6 +85,8 @@ public class OpcodeRulerColumn extends DisassemblyRulerColumn {
for (int i=str.length()+prefixLength; i < nChars; ++i) for (int i=str.length()+prefixLength; i < nChars; ++i)
buf.append('0'); buf.append('0');
buf.append(str); buf.append(str);
if (buf.length() > nChars)
buf.delete(nChars, buf.length());
return buf.toString(); return buf.toString();
} }
} else if (pos != null && !pos.fValid) { } else if (pos != null && !pos.fValid) {
@ -97,7 +102,7 @@ public class OpcodeRulerColumn extends DisassemblyRulerColumn {
@Override @Override
protected int computeNumberOfCharacters() { protected int computeNumberOfCharacters() {
DisassemblyDocument doc = (DisassemblyDocument)getParentRuler().getTextViewer().getDocument(); DisassemblyDocument doc = (DisassemblyDocument)getParentRuler().getTextViewer().getDocument();
return doc.getMaxOpcodeLength(fRadix); return Math.min(MAXWIDTH, doc.getMaxOpcodeLength(fRadix));
} }
@Override @Override