1
0
mirror of synced 2024-09-25 20:18:26 +02:00

ui: Improved byte selection text

This commit is contained in:
WerWolv 2022-06-30 11:29:20 +02:00
parent 3efdc02fed
commit 034cc0cd2f
2 changed files with 8 additions and 3 deletions

View File

@ -78,11 +78,16 @@ namespace hex {
break; break;
} }
std::string result = hex::format("{0:.2f}", value); std::string result;
if (unitIndex == 0)
result = hex::format("{0:}", value);
else
result = hex::format("{0:.2f}", value);
switch (unitIndex) { switch (unitIndex) {
case 0: case 0:
result += " Bytes"; result += ((value == 1) ? " Byte" : " Bytes");
break; break;
case 1: case 1:
result += " kB"; result += " kB";

View File

@ -967,7 +967,7 @@ namespace hex::plugin::builtin {
auto selection = this->getSelection(); auto selection = this->getSelection();
std::string value; std::string value;
if (this->isSelectionValid()) if (this->isSelectionValid())
value = hex::format("0x{0:08X} - 0x{1:08X} ({0} - {1}) ({2} {3})", selection.getStartAddress(), selection.getEndAddress(), selection.getSize(), selection.getSize() == 1 ? "Byte" : "Bytes"); value = hex::format("0x{0:08X} - 0x{1:08X} ({2})", selection.getStartAddress(), selection.getEndAddress(), hex::toByteString(selection.getSize()));
else else
value = std::string("hex.builtin.view.hex_editor.selection.none"_lang); value = std::string("hex.builtin.view.hex_editor.selection.none"_lang);