impr: Add some help text to the pattern editor by default

This commit is contained in:
WerWolv
2025-11-30 14:08:21 +01:00
parent cba93e87eb
commit fa780e9706
2 changed files with 9 additions and 0 deletions

View File

@@ -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",

View File

@@ -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() {