mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
GT-3624 - Datatypes Provider - fixed preview window issues: odd font
size for structures; Copy of preview text was missing newlines; enum rendering of negative values used too many digits
This commit is contained in:
parent
3be8657ff3
commit
2e6e3d1a96
4 changed files with 25 additions and 24 deletions
|
@ -530,9 +530,6 @@ public class DataTypesProvider extends ComponentProviderAdapter {
|
||||||
|
|
||||||
String toolTipText = ToolTipUtils.getToolTipText(dataType);
|
String toolTipText = ToolTipUtils.getToolTipText(dataType);
|
||||||
String updated = HTMLUtilities.convertLinkPlaceholdersToHyperlinks(toolTipText);
|
String updated = HTMLUtilities.convertLinkPlaceholdersToHyperlinks(toolTipText);
|
||||||
|
|
||||||
// Make the text a bit bigger, for readability
|
|
||||||
updated = HTMLUtilities.setFontSize(updated, 16);
|
|
||||||
previewPane.setText(updated);
|
previewPane.setText(updated);
|
||||||
previewPane.setCaretPosition(0);
|
previewPane.setCaretPosition(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,10 +62,19 @@ public class EnumDataTypeHTMLRepresentation extends HTMLDataTypeRepresentation {
|
||||||
long[] values = enumDataType.getValues();
|
long[] values = enumDataType.getValues();
|
||||||
Arrays.sort(values);
|
Arrays.sort(values);
|
||||||
|
|
||||||
|
int n = enumDataType.getLength();
|
||||||
List<ValidatableLine> list = new ArrayList<>(values.length);
|
List<ValidatableLine> list = new ArrayList<>(values.length);
|
||||||
for (long value : values) {
|
for (long value : values) {
|
||||||
String name = enumDataType.getName(value);
|
String name = enumDataType.getName(value);
|
||||||
list.add(new TextLine(name + " = 0x" + Long.toHexString(value)));
|
|
||||||
|
String hexString = Long.toHexString(value);
|
||||||
|
if (value < 0) {
|
||||||
|
// Long will print leading FF for 8 bytes, regardless of enum size. Keep only
|
||||||
|
// n bytes worth of text. For example, when n is 2, turn FFFFFFFFFFFFFF12 into FF12
|
||||||
|
int length = hexString.length();
|
||||||
|
hexString = hexString.substring(length - (n * 2));
|
||||||
|
}
|
||||||
|
list.add(new TextLine(name + " = 0x" + hexString));
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@ -88,8 +97,14 @@ public class EnumDataTypeHTMLRepresentation extends HTMLDataTypeRepresentation {
|
||||||
// "<TT> displayName { "
|
// "<TT> displayName { "
|
||||||
String encodedDisplayName = HTMLUtilities.friendlyEncodeHTML(displayName.getText());
|
String encodedDisplayName = HTMLUtilities.friendlyEncodeHTML(displayName.getText());
|
||||||
String displayNameText = wrapStringInColor(encodedDisplayName, displayName.getTextColor());
|
String displayNameText = wrapStringInColor(encodedDisplayName, displayName.getTextColor());
|
||||||
buffy.append(TT_OPEN).append(displayNameText).append(TT_CLOSE).append(HTML_SPACE).append(
|
buffy.append(TT_OPEN)
|
||||||
"{").append(HTML_SPACE).append(BR);
|
.append(displayNameText)
|
||||||
|
.append(TT_CLOSE)
|
||||||
|
.append(HTML_SPACE)
|
||||||
|
.append(
|
||||||
|
"{")
|
||||||
|
.append(HTML_SPACE)
|
||||||
|
.append(BR);
|
||||||
|
|
||||||
int length = bodyLines.size();
|
int length = bodyLines.size();
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
|
|
|
@ -332,9 +332,9 @@ public class GraphExportTest extends AbstractGhidraHeadedIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printLines(List<String> lines) {
|
private void printLines(List<String> lines) {
|
||||||
Msg.out("\n" + testName.getMethodName());
|
Msg.debug(this, "\n" + testName.getMethodName());
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
Msg.out("\"" + line + "\",");
|
Msg.debug(this, "\"" + line + "\",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ package ghidra.util;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -797,21 +796,11 @@ public class HTMLUtilities {
|
||||||
// formatting tags (like <B>, <FONT>, etc). So, just normalize the text, not
|
// formatting tags (like <B>, <FONT>, etc). So, just normalize the text, not
|
||||||
// preserving any of the line breaks.
|
// preserving any of the line breaks.
|
||||||
//
|
//
|
||||||
String condensed = condense(updated);
|
// Note: Calling this method here causes unwanted removal of newlines. If the original
|
||||||
return condensed;
|
// need for this call is found, this can be revisited.
|
||||||
}
|
// (see history for condense() code)
|
||||||
|
// String condensed = condense(updated);
|
||||||
private static String condense(String text) {
|
return updated;
|
||||||
// replace newlines, as they are sometimes inserted where two words were expected to
|
|
||||||
// contain no whitespace
|
|
||||||
String updated = text.replaceAll("\\n", "");
|
|
||||||
StringTokenizer tokenizer = new StringTokenizer(updated);
|
|
||||||
StringBuilder buffy = new StringBuilder();
|
|
||||||
while (tokenizer.hasMoreTokens()) {
|
|
||||||
buffy.append(tokenizer.nextToken()).append(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
return buffy.toString().trim();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue