Skip to content

Commit 738566b

Browse files
committed
[debugger] Add ASCII format to watch values
1 parent 77fa77c commit 738566b

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

platforms/shared/desktop/gui_debug_memeditor.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ void MemEditor::WatchWindow()
10851085
ImGui::Separator();
10861086

10871087
const char* size_labels[] = {"8 bit", "16 bit", "24 bit", "32 bit"};
1088-
const char* format_labels[] = {"Hex", "Binary", "Decimal Unsigned", "Decimal Signed"};
1088+
const char* format_labels[] = {"Hex", "Binary", "Decimal Unsigned", "Decimal Signed", "ASCII"};
10891089

10901090
int remove = -1;
10911091

@@ -1162,7 +1162,7 @@ void MemEditor::WatchWindow()
11621162
ImGui::Text("Display as:");
11631163
//ImGui::Separator();
11641164

1165-
for (int f = 0; f < 4; f++)
1165+
for (int f = 0; f < 5; f++)
11661166
{
11671167
bool selected = (watch.format == f);
11681168
if (ImGui::Selectable(format_labels[f], selected))
@@ -2094,6 +2094,18 @@ void MemEditor::DrawWatchValue(uint32_t value, int size, int format)
20942094
ImGui::TextColored(color, "%d", signed_value);
20952095
break;
20962096
}
2097+
case 4: // ASCII
2098+
{
2099+
char ascii[5];
2100+
for (int i = 0; i < bytes; i++)
2101+
{
2102+
uint8_t c = (uint8_t)((value >> (i * 8)) & 0xFF);
2103+
ascii[i] = (c >= 32 && c < 127) ? (char)c : '.';
2104+
}
2105+
ascii[bytes] = '\0';
2106+
ImGui::TextColored(color, "%s", ascii);
2107+
break;
2108+
}
20972109
}
20982110
}
20992111

0 commit comments

Comments
 (0)