58 #define ImSnprintf _snprintf 61 #define ImSnprintf snprintf 65 #pragma warning (push) 66 #pragma warning (disable: 4996) // warning C4996: 'sprintf': This function or variable may be unsafe. 84 bool OptShowDataPreview;
87 bool OptGreyOutZeroes;
90 int OptAddrDigitsCount;
91 float OptFooterExtraHeight;
93 ImU8 (*ReadFn)(
const ImU8* data,
size_t off);
94 void (*WriteFn)(ImU8* data,
size_t off, ImU8 d);
95 bool (*HighlightFn)(
const ImU8* data,
size_t off);
98 bool ContentsWidthChanged;
99 size_t DataPreviewAddr;
100 size_t DataEditingAddr;
101 bool DataEditingTakeFocus;
102 char DataInputBuf[32];
103 char AddrInputBuf[32];
105 size_t HighlightMin, HighlightMax;
106 int PreviewEndianness;
107 ImGuiDataType PreviewDataType;
115 OptShowOptions =
true;
116 OptShowDataPreview =
false;
117 OptShowHexII =
false;
119 OptGreyOutZeroes =
true;
120 OptUpperCaseHex =
true;
122 OptAddrDigitsCount = 0;
123 OptFooterExtraHeight = 0.0f;
124 HighlightColor = IM_COL32(255, 255, 255, 50);
130 ContentsWidthChanged =
false;
131 DataPreviewAddr = DataEditingAddr = (size_t)-1;
132 DataEditingTakeFocus =
false;
133 memset(DataInputBuf, 0,
sizeof(DataInputBuf));
134 memset(AddrInputBuf, 0,
sizeof(AddrInputBuf));
135 GotoAddr = (size_t)-1;
136 HighlightMin = HighlightMax = (size_t)-1;
137 PreviewEndianness = 0;
138 PreviewDataType = ImGuiDataType_S32;
141 void GotoAddrAndHighlight(
size_t addr_min,
size_t addr_max)
144 HighlightMin = addr_min;
145 HighlightMax = addr_max;
154 float SpacingBetweenMidCols;
161 Sizes() { memset(
this, 0,
sizeof(*
this)); }
164 void CalcSizes(
Sizes& s,
size_t mem_size,
size_t base_display_addr)
167 s.AddrDigitsCount = OptAddrDigitsCount;
168 if (s.AddrDigitsCount == 0)
169 for (
size_t n = base_display_addr + mem_size - 1; n > 0; n >>= 4)
171 s.LineHeight = ImGui::GetTextLineHeight();
172 s.GlyphWidth = ImGui::CalcTextSize(
"F").x + 1;
173 s.HexCellWidth = (float)(
int)(s.GlyphWidth * 2.5f);
174 s.SpacingBetweenMidCols = (float)(
int)(s.HexCellWidth * 0.25f);
175 s.PosHexStart = (s.AddrDigitsCount + 2) * s.GlyphWidth;
176 s.PosHexEnd = s.PosHexStart + (s.HexCellWidth * Cols);
177 s.PosAsciiStart = s.PosAsciiEnd = s.PosHexEnd;
180 s.PosAsciiStart = s.PosHexEnd + s.GlyphWidth * 1;
181 if (OptMidColsCount > 0)
182 s.PosAsciiStart += (float)((Cols + OptMidColsCount - 1) / OptMidColsCount) * s.SpacingBetweenMidCols;
183 s.PosAsciiEnd = s.PosAsciiStart + Cols * s.GlyphWidth;
185 s.WindowWidth = s.PosAsciiEnd + style.ScrollbarSize + style.WindowPadding.x * 2 + s.GlyphWidth;
189 void DrawWindow(
const char* title,
void* mem_data,
size_t mem_size,
size_t base_display_addr = 0x0000)
192 CalcSizes(s, mem_size, base_display_addr);
193 ImGui::SetNextWindowSize(
ImVec2(s.WindowWidth, s.WindowWidth * 0.60f), ImGuiCond_FirstUseEver);
194 ImGui::SetNextWindowSizeConstraints(
ImVec2(0.0f, 0.0f),
ImVec2(s.WindowWidth, FLT_MAX));
197 if (ImGui::Begin(title, &Open, ImGuiWindowFlags_NoScrollbar))
199 if (ImGui::IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows) && ImGui::IsMouseReleased(ImGuiMouseButton_Right))
200 ImGui::OpenPopup(
"context");
201 DrawContents(mem_data, mem_size, base_display_addr);
202 if (ContentsWidthChanged)
204 CalcSizes(s, mem_size, base_display_addr);
205 ImGui::SetWindowSize(
ImVec2(s.WindowWidth, ImGui::GetWindowSize().y));
212 void DrawContents(
void* mem_data_void,
size_t mem_size,
size_t base_display_addr = 0x0000)
217 ImU8* mem_data = (ImU8*)mem_data_void;
219 CalcSizes(s, mem_size, base_display_addr);
224 const float height_separator = style.ItemSpacing.y;
225 float footer_height = OptFooterExtraHeight;
227 footer_height += height_separator + ImGui::GetFrameHeightWithSpacing() * 1;
228 if (OptShowDataPreview)
229 footer_height += height_separator + ImGui::GetFrameHeightWithSpacing() * 1 + ImGui::GetTextLineHeightWithSpacing() * 3;
230 ImGui::BeginChild(
"##scrolling",
ImVec2(0, -footer_height),
false, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoNav);
231 ImDrawList* draw_list = ImGui::GetWindowDrawList();
233 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,
ImVec2(0, 0));
234 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,
ImVec2(0, 0));
237 const int line_total_count = (int)((mem_size + Cols - 1) / Cols);
239 clipper.Begin(line_total_count, s.LineHeight);
241 bool data_next =
false;
243 if (ReadOnly || DataEditingAddr >= mem_size)
244 DataEditingAddr = (size_t)-1;
245 if (DataPreviewAddr >= mem_size)
246 DataPreviewAddr = (size_t)-1;
248 size_t preview_data_type_size = OptShowDataPreview ? DataTypeGetSize(PreviewDataType) : 0;
250 size_t data_editing_addr_next = (size_t)-1;
251 if (DataEditingAddr != (
size_t)-1)
254 if (ImGui::IsKeyPressed(ImGuiKey_UpArrow) && (ptrdiff_t)DataEditingAddr >= (ptrdiff_t)Cols) { data_editing_addr_next = DataEditingAddr - Cols; }
255 else if (ImGui::IsKeyPressed(ImGuiKey_DownArrow) && (ptrdiff_t)DataEditingAddr < (ptrdiff_t)mem_size - Cols){ data_editing_addr_next = DataEditingAddr + Cols; }
256 else if (ImGui::IsKeyPressed(ImGuiKey_LeftArrow) && (ptrdiff_t)DataEditingAddr > (ptrdiff_t)0) { data_editing_addr_next = DataEditingAddr - 1; }
257 else if (ImGui::IsKeyPressed(ImGuiKey_RightArrow) && (ptrdiff_t)DataEditingAddr < (ptrdiff_t)mem_size - 1) { data_editing_addr_next = DataEditingAddr + 1; }
261 ImVec2 window_pos = ImGui::GetWindowPos();
263 draw_list->AddLine(
ImVec2(window_pos.x + s.PosAsciiStart - s.GlyphWidth, window_pos.y),
ImVec2(window_pos.x + s.PosAsciiStart - s.GlyphWidth, window_pos.y + 9999), ImGui::GetColorU32(ImGuiCol_Border));
265 const ImU32 color_text = ImGui::GetColorU32(ImGuiCol_Text);
266 const ImU32 color_disabled = OptGreyOutZeroes ? ImGui::GetColorU32(ImGuiCol_TextDisabled) : color_text;
268 const char* format_address = OptUpperCaseHex ?
"%0*" _PRISizeT
"X: " :
"%0*" _PRISizeT
"x: ";
269 const char* format_data = OptUpperCaseHex ?
"%0*" _PRISizeT
"X" :
"%0*" _PRISizeT
"x";
270 const char* format_byte = OptUpperCaseHex ?
"%02X" :
"%02x";
271 const char* format_byte_space = OptUpperCaseHex ?
"%02X " :
"%02x ";
273 while (clipper.Step())
274 for (
int line_i = clipper.DisplayStart; line_i < clipper.DisplayEnd; line_i++)
276 size_t addr = (size_t)(line_i * Cols);
277 ImGui::Text(format_address, s.AddrDigitsCount, base_display_addr + addr);
280 for (
int n = 0; n < Cols && addr < mem_size; n++, addr++)
282 float byte_pos_x = s.PosHexStart + s.HexCellWidth * n;
283 if (OptMidColsCount > 0)
284 byte_pos_x += (float)(n / OptMidColsCount) * s.SpacingBetweenMidCols;
285 ImGui::SameLine(byte_pos_x);
288 bool is_highlight_from_user_range = (addr >= HighlightMin && addr < HighlightMax);
289 bool is_highlight_from_user_func = (HighlightFn && HighlightFn(mem_data, addr));
290 bool is_highlight_from_preview = (addr >= DataPreviewAddr && addr < DataPreviewAddr + preview_data_type_size);
291 if (is_highlight_from_user_range || is_highlight_from_user_func || is_highlight_from_preview)
293 ImVec2 pos = ImGui::GetCursorScreenPos();
294 float highlight_width = s.GlyphWidth * 2;
295 bool is_next_byte_highlighted = (addr + 1 < mem_size) && ((HighlightMax != (
size_t)-1 && addr + 1 < HighlightMax) || (HighlightFn && HighlightFn(mem_data, addr + 1)));
296 if (is_next_byte_highlighted || (n + 1 == Cols))
298 highlight_width = s.HexCellWidth;
299 if (OptMidColsCount > 0 && n > 0 && (n + 1) < Cols && ((n + 1) % OptMidColsCount) == 0)
300 highlight_width += s.SpacingBetweenMidCols;
302 draw_list->AddRectFilled(pos,
ImVec2(pos.x + highlight_width, pos.y + s.LineHeight), HighlightColor);
305 if (DataEditingAddr == addr)
308 bool data_write =
false;
309 ImGui::PushID((
void*)addr);
310 if (DataEditingTakeFocus)
312 ImGui::SetKeyboardFocusHere(0);
313 snprintf(AddrInputBuf, 32, format_data, s.AddrDigitsCount, base_display_addr + addr);
314 snprintf(DataInputBuf, 32, format_byte, ReadFn ? ReadFn(mem_data, addr) : mem_data[addr]);
321 UserData* user_data = (UserData*)data->UserData;
322 if (!data->HasSelection())
323 user_data->CursorPos = data->CursorPos;
324 if (data->SelectionStart == 0 && data->SelectionEnd == data->BufTextLen)
328 data->DeleteChars(0, data->BufTextLen);
329 data->InsertChars(0, user_data->CurrentBufOverwrite);
330 data->SelectionStart = 0;
331 data->SelectionEnd = 2;
336 char CurrentBufOverwrite[3];
340 user_data.CursorPos = -1;
341 snprintf(user_data.CurrentBufOverwrite, 3, format_byte, ReadFn ? ReadFn(mem_data, addr) : mem_data[addr]);
342 ImGuiInputTextFlags flags = ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_NoHorizontalScroll | ImGuiInputTextFlags_CallbackAlways;
343 flags |= ImGuiInputTextFlags_AlwaysOverwrite;
344 ImGui::SetNextItemWidth(s.GlyphWidth * 2);
345 if (ImGui::InputText(
"##data", DataInputBuf, IM_ARRAYSIZE(DataInputBuf), flags, UserData::Callback, &user_data))
346 data_write = data_next =
true;
347 else if (!DataEditingTakeFocus && !ImGui::IsItemActive())
348 DataEditingAddr = data_editing_addr_next = (size_t)-1;
349 DataEditingTakeFocus =
false;
350 if (user_data.CursorPos >= 2)
351 data_write = data_next =
true;
352 if (data_editing_addr_next != (
size_t)-1)
353 data_write = data_next =
false;
354 unsigned int data_input_value = 0;
355 if (data_write && sscanf(DataInputBuf,
"%X", &data_input_value) == 1)
358 WriteFn(mem_data, addr, (ImU8)data_input_value);
360 mem_data[addr] = (ImU8)data_input_value;
367 ImU8 b = ReadFn ? ReadFn(mem_data, addr) : mem_data[addr];
371 if ((b >= 32 && b < 128))
372 ImGui::Text(
".%c ", b);
373 else if (b == 0xFF && OptGreyOutZeroes)
374 ImGui::TextDisabled(
"## ");
378 ImGui::Text(format_byte_space, b);
382 if (b == 0 && OptGreyOutZeroes)
383 ImGui::TextDisabled(
"00 ");
385 ImGui::Text(format_byte_space, b);
387 if (!ReadOnly && ImGui::IsItemHovered() && ImGui::IsMouseClicked(0))
389 DataEditingTakeFocus =
true;
390 data_editing_addr_next = addr;
398 ImGui::SameLine(s.PosAsciiStart);
399 ImVec2 pos = ImGui::GetCursorScreenPos();
400 addr = line_i * Cols;
401 ImGui::PushID(line_i);
402 if (ImGui::InvisibleButton(
"ascii",
ImVec2(s.PosAsciiEnd - s.PosAsciiStart, s.LineHeight)))
404 DataEditingAddr = DataPreviewAddr = addr + (size_t)((ImGui::GetIO().MousePos.x - pos.x) / s.GlyphWidth);
405 DataEditingTakeFocus =
true;
408 for (
int n = 0; n < Cols && addr < mem_size; n++, addr++)
410 if (addr == DataEditingAddr)
412 draw_list->AddRectFilled(pos,
ImVec2(pos.x + s.GlyphWidth, pos.y + s.LineHeight), ImGui::GetColorU32(ImGuiCol_FrameBg));
413 draw_list->AddRectFilled(pos,
ImVec2(pos.x + s.GlyphWidth, pos.y + s.LineHeight), ImGui::GetColorU32(ImGuiCol_TextSelectedBg));
415 unsigned char c = ReadFn ? ReadFn(mem_data, addr) : mem_data[addr];
416 char display_c = (c < 32 || c >= 128) ?
'.' : c;
417 draw_list->AddText(pos, (display_c == c) ? color_text : color_disabled, &display_c, &display_c + 1);
418 pos.x += s.GlyphWidth;
422 ImGui::PopStyleVar(2);
426 ImGui::SetCursorPosX(s.WindowWidth);
427 ImGui::Dummy(
ImVec2(0.0f, 0.0f));
429 if (data_next && DataEditingAddr + 1 < mem_size)
431 DataEditingAddr = DataPreviewAddr = DataEditingAddr + 1;
432 DataEditingTakeFocus =
true;
434 else if (data_editing_addr_next != (
size_t)-1)
436 DataEditingAddr = DataPreviewAddr = data_editing_addr_next;
437 DataEditingTakeFocus =
true;
440 const bool lock_show_data_preview = OptShowDataPreview;
444 DrawOptionsLine(s, mem_data, mem_size, base_display_addr);
447 if (lock_show_data_preview)
450 DrawPreviewLine(s, mem_data, mem_size, base_display_addr);
454 void DrawOptionsLine(
const Sizes& s,
void* mem_data,
size_t mem_size,
size_t base_display_addr)
458 const char* format_range = OptUpperCaseHex ?
"Range %0*" _PRISizeT
"X..%0*" _PRISizeT
"X" :
"Range %0*" _PRISizeT
"x..%0*" _PRISizeT
"x";
461 if (ImGui::Button(
"Options"))
462 ImGui::OpenPopup(
"context");
463 if (ImGui::BeginPopup(
"context"))
465 ImGui::SetNextItemWidth(s.GlyphWidth * 7 + style.FramePadding.x * 2.0f);
466 if (ImGui::DragInt(
"##cols", &Cols, 0.2f, 4, 32,
"%d cols")) { ContentsWidthChanged =
true;
if (Cols < 1) Cols = 1; }
467 ImGui::Checkbox(
"Show Data Preview", &OptShowDataPreview);
468 ImGui::Checkbox(
"Show HexII", &OptShowHexII);
469 if (ImGui::Checkbox(
"Show Ascii", &OptShowAscii)) { ContentsWidthChanged =
true; }
470 ImGui::Checkbox(
"Grey out zeroes", &OptGreyOutZeroes);
471 ImGui::Checkbox(
"Uppercase Hex", &OptUpperCaseHex);
477 ImGui::Text(format_range, s.AddrDigitsCount, base_display_addr, s.AddrDigitsCount, base_display_addr + mem_size - 1);
479 ImGui::SetNextItemWidth((s.AddrDigitsCount + 1) * s.GlyphWidth + style.FramePadding.x * 2.0f);
480 if (ImGui::InputText(
"##addr", AddrInputBuf, IM_ARRAYSIZE(AddrInputBuf), ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_EnterReturnsTrue))
483 if (sscanf(AddrInputBuf,
"%" _PRISizeT
"X", &goto_addr) == 1)
485 GotoAddr = goto_addr - base_display_addr;
486 HighlightMin = HighlightMax = (size_t)-1;
490 if (GotoAddr != (
size_t)-1)
492 if (GotoAddr < mem_size)
494 ImGui::BeginChild(
"##scrolling");
495 ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + (GotoAddr / Cols) * ImGui::GetTextLineHeight());
497 DataEditingAddr = DataPreviewAddr = GotoAddr;
498 DataEditingTakeFocus =
true;
500 GotoAddr = (size_t)-1;
504 void DrawPreviewLine(
const Sizes& s,
void* mem_data_void,
size_t mem_size,
size_t base_display_addr)
506 IM_UNUSED(base_display_addr);
507 ImU8* mem_data = (ImU8*)mem_data_void;
509 ImGui::AlignTextToFramePadding();
510 ImGui::Text(
"Preview as:");
512 ImGui::SetNextItemWidth((s.GlyphWidth * 10.0f) + style.FramePadding.x * 2.0f + style.ItemInnerSpacing.x);
513 if (ImGui::BeginCombo(
"##combo_type", DataTypeGetDesc(PreviewDataType), ImGuiComboFlags_HeightLargest))
515 for (
int n = 0; n < ImGuiDataType_COUNT; n++)
516 if (ImGui::Selectable(DataTypeGetDesc((ImGuiDataType)n), PreviewDataType == n))
517 PreviewDataType = (ImGuiDataType)n;
521 ImGui::SetNextItemWidth((s.GlyphWidth * 6.0f) + style.FramePadding.x * 2.0f + style.ItemInnerSpacing.x);
522 ImGui::Combo(
"##combo_endianness", &PreviewEndianness,
"LE\0BE\0\0");
525 float x = s.GlyphWidth * 6.0f;
526 bool has_value = DataPreviewAddr != (size_t)-1;
528 DrawPreviewData(DataPreviewAddr, mem_data, mem_size, PreviewDataType, DataFormat_Dec, buf, (
size_t)IM_ARRAYSIZE(buf));
529 ImGui::Text(
"Dec"); ImGui::SameLine(x); ImGui::TextUnformatted(has_value ? buf :
"N/A");
531 DrawPreviewData(DataPreviewAddr, mem_data, mem_size, PreviewDataType, DataFormat_Hex, buf, (
size_t)IM_ARRAYSIZE(buf));
532 ImGui::Text(
"Hex"); ImGui::SameLine(x); ImGui::TextUnformatted(has_value ? buf :
"N/A");
534 DrawPreviewData(DataPreviewAddr, mem_data, mem_size, PreviewDataType, DataFormat_Bin, buf, (
size_t)IM_ARRAYSIZE(buf));
535 buf[IM_ARRAYSIZE(buf) - 1] = 0;
536 ImGui::Text(
"Bin"); ImGui::SameLine(x); ImGui::TextUnformatted(has_value ? buf :
"N/A");
540 const char* DataTypeGetDesc(ImGuiDataType data_type)
const 542 const char* descs[] = {
"Int8",
"Uint8",
"Int16",
"Uint16",
"Int32",
"Uint32",
"Int64",
"Uint64",
"Float",
"Double" };
543 IM_ASSERT(data_type >= 0 && data_type < ImGuiDataType_COUNT);
544 return descs[data_type];
547 size_t DataTypeGetSize(ImGuiDataType data_type)
const 549 const size_t sizes[] = { 1, 1, 2, 2, 4, 4, 8, 8,
sizeof(float),
sizeof(
double) };
550 IM_ASSERT(data_type >= 0 && data_type < ImGuiDataType_COUNT);
551 return sizes[data_type];
554 const char* DataFormatGetDesc(DataFormat data_format)
const 556 const char* descs[] = {
"Bin",
"Dec",
"Hex" };
557 IM_ASSERT(data_format >= 0 && data_format < DataFormat_COUNT);
558 return descs[data_format];
561 bool IsBigEndian()
const 569 static void* EndiannessCopyBigEndian(
void* _dst,
void* _src,
size_t s,
int is_little_endian)
571 if (is_little_endian)
573 uint8_t* dst = (uint8_t*)_dst;
574 uint8_t* src = (uint8_t*)_src + s - 1;
575 for (
int i = 0, n = (
int)s; i < n; ++i)
576 memcpy(dst++, src--, 1);
581 return memcpy(_dst, _src, s);
585 static void* EndiannessCopyLittleEndian(
void* _dst,
void* _src,
size_t s,
int is_little_endian)
587 if (is_little_endian)
589 return memcpy(_dst, _src, s);
593 uint8_t* dst = (uint8_t*)_dst;
594 uint8_t* src = (uint8_t*)_src + s - 1;
595 for (
int i = 0, n = (
int)s; i < n; ++i)
596 memcpy(dst++, src--, 1);
601 void* EndiannessCopy(
void* dst,
void* src,
size_t size)
const 603 static void* (*fp)(
void*,
void*, size_t, int) = NULL;
605 fp = IsBigEndian() ? EndiannessCopyBigEndian : EndiannessCopyLittleEndian;
606 return fp(dst, src, size, PreviewEndianness);
609 const char* FormatBinary(
const uint8_t* buf,
int width)
const 611 IM_ASSERT(width <= 64);
613 static char out_buf[64 + 8 + 1];
615 for (
int j = n - 1; j >= 0; --j)
617 for (
int i = 0; i < 8; ++i)
618 out_buf[out_n++] = (buf[j] & (1 << (7 - i))) ?
'1' :
'0';
619 out_buf[out_n++] =
' ';
621 IM_ASSERT(out_n < IM_ARRAYSIZE(out_buf));
627 void DrawPreviewData(
size_t addr,
const ImU8* mem_data,
size_t mem_size, ImGuiDataType data_type, DataFormat data_format,
char* out_buf,
size_t out_buf_size)
const 630 size_t elem_size = DataTypeGetSize(data_type);
631 size_t size = addr + elem_size > mem_size ? mem_size - addr : elem_size;
633 for (
int i = 0, n = (
int)size; i < n; ++i)
634 buf[i] = ReadFn(mem_data, addr + i);
636 memcpy(buf, mem_data + addr, size);
638 if (data_format == DataFormat_Bin)
641 EndiannessCopy(binbuf, buf, size);
642 ImSnprintf(out_buf, out_buf_size,
"%s", FormatBinary(binbuf, (
int)size * 8));
649 case ImGuiDataType_S8:
652 EndiannessCopy(&int8d, buf, size);
653 if (data_format == DataFormat_Dec) { ImSnprintf(out_buf, out_buf_size,
"%hhd", int8d);
return; }
654 if (data_format == DataFormat_Hex) { ImSnprintf(out_buf, out_buf_size,
"0x%02x", int8d & 0xFF);
return; }
657 case ImGuiDataType_U8:
660 EndiannessCopy(&uint8d, buf, size);
661 if (data_format == DataFormat_Dec) { ImSnprintf(out_buf, out_buf_size,
"%hhu", uint8d);
return; }
662 if (data_format == DataFormat_Hex) { ImSnprintf(out_buf, out_buf_size,
"0x%02x", uint8d & 0XFF);
return; }
665 case ImGuiDataType_S16:
668 EndiannessCopy(&int16d, buf, size);
669 if (data_format == DataFormat_Dec) { ImSnprintf(out_buf, out_buf_size,
"%hd", int16d);
return; }
670 if (data_format == DataFormat_Hex) { ImSnprintf(out_buf, out_buf_size,
"0x%04x", int16d & 0xFFFF);
return; }
673 case ImGuiDataType_U16:
675 uint16_t uint16d = 0;
676 EndiannessCopy(&uint16d, buf, size);
677 if (data_format == DataFormat_Dec) { ImSnprintf(out_buf, out_buf_size,
"%hu", uint16d);
return; }
678 if (data_format == DataFormat_Hex) { ImSnprintf(out_buf, out_buf_size,
"0x%04x", uint16d & 0xFFFF);
return; }
681 case ImGuiDataType_S32:
684 EndiannessCopy(&int32d, buf, size);
685 if (data_format == DataFormat_Dec) { ImSnprintf(out_buf, out_buf_size,
"%d", int32d);
return; }
686 if (data_format == DataFormat_Hex) { ImSnprintf(out_buf, out_buf_size,
"0x%08x", int32d);
return; }
689 case ImGuiDataType_U32:
691 uint32_t uint32d = 0;
692 EndiannessCopy(&uint32d, buf, size);
693 if (data_format == DataFormat_Dec) { ImSnprintf(out_buf, out_buf_size,
"%u", uint32d);
return; }
694 if (data_format == DataFormat_Hex) { ImSnprintf(out_buf, out_buf_size,
"0x%08x", uint32d);
return; }
697 case ImGuiDataType_S64:
700 EndiannessCopy(&int64d, buf, size);
701 if (data_format == DataFormat_Dec) { ImSnprintf(out_buf, out_buf_size,
"%lld", (
long long)int64d);
return; }
702 if (data_format == DataFormat_Hex) { ImSnprintf(out_buf, out_buf_size,
"0x%016llx", (
long long)int64d);
return; }
705 case ImGuiDataType_U64:
707 uint64_t uint64d = 0;
708 EndiannessCopy(&uint64d, buf, size);
709 if (data_format == DataFormat_Dec) { ImSnprintf(out_buf, out_buf_size,
"%llu", (
long long)uint64d);
return; }
710 if (data_format == DataFormat_Hex) { ImSnprintf(out_buf, out_buf_size,
"0x%016llx", (
long long)uint64d);
return; }
713 case ImGuiDataType_Float:
715 float float32d = 0.0f;
716 EndiannessCopy(&float32d, buf, size);
717 if (data_format == DataFormat_Dec) { ImSnprintf(out_buf, out_buf_size,
"%f", float32d);
return; }
718 if (data_format == DataFormat_Hex) { ImSnprintf(out_buf, out_buf_size,
"%a", float32d);
return; }
721 case ImGuiDataType_Double:
723 double float64d = 0.0;
724 EndiannessCopy(&float64d, buf, size);
725 if (data_format == DataFormat_Dec) { ImSnprintf(out_buf, out_buf_size,
"%f", float64d);
return; }
726 if (data_format == DataFormat_Hex) { ImSnprintf(out_buf, out_buf_size,
"%a", float64d);
return; }
729 case ImGuiDataType_COUNT:
740 #pragma warning (pop)
Definition: imgui_memory_editor.h:69
Definition: imgui_memory_editor.h:148