From 5112c3aa1ee91c14578fdfc4d3e5435d565c8465 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 20 Nov 2020 22:21:37 +0100 Subject: [PATCH] Added unions and padding to cheat sheet --- source/views/view_help.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/source/views/view_help.cpp b/source/views/view_help.cpp index 0fc44e59e..884c2517a 100644 --- a/source/views/view_help.cpp +++ b/source/views/view_help.cpp @@ -100,15 +100,28 @@ namespace hex { DrawTitle("Structs"); ImGui::TextWrapped( - "To bundle multiple variables together, a struct can be used."); - DrawCodeSegment("struct", 70, + "To bundle multiple variables together, a struct can be used. To insert padding bytes which won't show " + "up in the pattern data view or be highlighted, use the padding[size] syntax."); + DrawCodeSegment("struct", 85, "struct Header {\n" " u32 magic;\n" " u8 version;\n" + " padding[4];\n" " Flags flags;\n" "}" ); + DrawTitle("Unions"); + ImGui::TextWrapped( + "A union is used to make two or more variables occupy the same region of memory. " + "The union will have the size of the biggest contained variable."); + DrawCodeSegment("union", 55, + "union Color {\n" + " u32 rgba;\n" + " Components components;\n" + "}" + ); + DrawTitle("Bitfields"); ImGui::TextWrapped( "To decode values that are stored in fields that don't follow the typical 8 bit alignment, bitfields can be used. "