GP-4297 Fixed screen reader decompiler api to prevent duplicate reading of the line when cursoring up or down a line

This commit is contained in:
ghidragon 2024-02-06 17:09:31 -05:00
parent dffb5fd859
commit 97fdfddecf
3 changed files with 19 additions and 11 deletions

View file

@ -102,13 +102,22 @@ public class ByteViewerComponent extends FieldPanel implements FieldMouseListene
ByteBlockInfo info = indexMap.getBlockInfo(fieldLoc.getIndex(), fieldLoc.getFieldNum());
if (info != null) {
String modelName = model.getName();
return modelName + " format at " +
info.getBlock().getLocationRepresentation(info.getOffset()) + ", value = " +
field.getText();
String location = getAccessibleLocationInfo(info.getBlock(), info.getOffset());
return modelName + " format at " + location;
}
return null;
}
private String getAccessibleLocationInfo(ByteBlock block, BigInteger offset) {
if (block instanceof MemoryByteBlock memBlock) {
// location represents an address, remove leading zeros to make screen reading concise
Address address = memBlock.getAddress(offset);
return address.toString(address.getAddressSpace().showSpaceName(), 1);
}
// otherwise use generic location representation
return block.getLocationRepresentation(offset);
}
@Override
public void buttonPressed(FieldLocation fieldLocation, Field field, MouseEvent mouseEvent) {
if (fieldLocation == null || field == null) {