Add support for copying bytes formatted as Python byte-string, Python list, and C/Java array

This commit is contained in:
S-S-P 2019-06-30 20:17:24 -04:00 committed by dragonmacher
parent 7940f96c8c
commit 00ef824dbd
3 changed files with 101 additions and 1 deletions

View file

@ -43,6 +43,9 @@ public class ByteViewerClipboardProvider extends ByteCopier
List<ClipboardType> copyTypesList = new LinkedList<>();
copyTypesList.add(BYTE_STRING_TYPE);
copyTypesList.add(BYTE_STRING_NO_SPACE_TYPE);
copyTypesList.add(PYTHON_BYTE_STRING_TYPE);
copyTypesList.add(PYTHON_LIST_TYPE);
copyTypesList.add(CPP_BYTE_ARRAY_TYPE);
return copyTypesList;
}
@ -117,6 +120,18 @@ public class ByteViewerClipboardProvider extends ByteCopier
else if (copyType == BYTE_STRING_NO_SPACE_TYPE) {
byteString = copyBytesAsString(currentSelection, false, monitor);
}
else if (copyType == PYTHON_BYTE_STRING_TYPE) {
byteString = "b'"
+ copyBytesAsString(currentSelection, true, monitor).replaceAll(" ", "\\x") + "'";
}
else if (copyType == PYTHON_LIST_TYPE) {
byteString = "[ "
+ copyBytesAsString(currentSelection, true, monitor).replaceAll(" ", ", 0x") + " ]";
}
else if (copyType == CPP_BYTE_ARRAY_TYPE) {
byteString = "{ "
+ copyBytesAsString(currentSelection, true, monitor).replaceAll(" ", ", 0x") + " }";
}
else {
return null;
}