diff --git a/plugins/builtin/romfs/lang/en_US.json b/plugins/builtin/romfs/lang/en_US.json index 12f42cf21..691cba379 100644 --- a/plugins/builtin/romfs/lang/en_US.json +++ b/plugins/builtin/romfs/lang/en_US.json @@ -1001,6 +1001,7 @@ "hex.builtin.view.pattern_editor.debugger.remove_tooltip": "Remove breakpoint", "hex.builtin.view.pattern_editor.debugger.scope": "Scope", "hex.builtin.view.pattern_editor.debugger.scope.global": "Global Scope", + "hex.builtin.view.pattern_editor.default_help_text": "Enter your pattern code here and click on the Play button\nbelow to execute your code. The results will then be visible\nin the Pattern Data view.\n\nMore information can be found in the documentation.\n\n\nSimple example:\n\nimport std.io;\n\nstruct Pattern {\n u32 int;\n float floating_point;\n};\n\nPattern my_pattern @ 0x00;\nstd::print(\"0x{:08X}\", my_pattern.int);", "hex.builtin.view.pattern_editor.env_vars": "Environment Variables", "hex.builtin.view.pattern_editor.evaluating": "Evaluating...", "hex.builtin.view.pattern_editor.find_hint": "Find", diff --git a/plugins/builtin/source/content/views/view_pattern_editor.cpp b/plugins/builtin/source/content/views/view_pattern_editor.cpp index d21ffc721..55b4433eb 100644 --- a/plugins/builtin/source/content/views/view_pattern_editor.cpp +++ b/plugins/builtin/source/content/views/view_pattern_editor.cpp @@ -304,6 +304,14 @@ namespace hex::plugin::builtin { this->registerEvents(); this->registerMenuItems(); this->registerHandlers(); + + // Initialize the text editor with some basic help text + m_textEditor.setOnCreateCallback([](auto, ui::TextEditor &editor) { + std::string text = "hex.builtin.view.pattern_editor.default_help_text"_lang; + text = "// " + wolv::util::replaceStrings(text, "\n", "\n// "); + + editor.setText(text); + }); } ViewPatternEditor::~ViewPatternEditor() {