impr: Clean up some more clang-tidy issues
This commit is contained in:
parent
1690cd2740
commit
c32515bc44
@ -27,7 +27,6 @@ cppcoreguidelines-pro-type-member-init,
|
|||||||
cppcoreguidelines-slicing,
|
cppcoreguidelines-slicing,
|
||||||
cppcoreguidelines-interfaces-global-init,
|
cppcoreguidelines-interfaces-global-init,
|
||||||
cppcoreguidelines-pro-type-static-cast-downcast,
|
cppcoreguidelines-pro-type-static-cast-downcast,
|
||||||
cppcoreguidelines-avoid-capture-default-when-capturing-this,
|
|
||||||
cppcoreguidelines-narrowing-conversions,
|
cppcoreguidelines-narrowing-conversions,
|
||||||
google-default-arguments,
|
google-default-arguments,
|
||||||
google-runtime-operator,
|
google-runtime-operator,
|
||||||
@ -65,4 +64,5 @@ readability-*,
|
|||||||
-readability-else-after-return,
|
-readability-else-after-return,
|
||||||
-readability-redundant-access-specifiers,
|
-readability-redundant-access-specifiers,
|
||||||
-readability-function-cognitive-complexity,
|
-readability-function-cognitive-complexity,
|
||||||
-readability-identifier-naming'
|
-readability-identifier-naming,
|
||||||
|
-readability-qualified-auto'
|
@ -44,10 +44,10 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
class PopupAcceptPattern : public Popup<PopupAcceptPattern> {
|
class PopupAcceptPattern : public Popup<PopupAcceptPattern> {
|
||||||
public:
|
public:
|
||||||
PopupAcceptPattern(ViewPatternEditor *view) : Popup("hex.builtin.view.pattern_editor.accept_pattern"), m_view(view) {}
|
explicit PopupAcceptPattern(ViewPatternEditor *view) : Popup("hex.builtin.view.pattern_editor.accept_pattern"), m_view(view) {}
|
||||||
|
|
||||||
void drawContent() override {
|
void drawContent() override {
|
||||||
auto provider = ImHexApi::Provider::get();
|
auto* provider = ImHexApi::Provider::get();
|
||||||
|
|
||||||
ImGui::TextFormattedWrapped("{}", static_cast<const char *>("hex.builtin.view.pattern_editor.accept_pattern.desc"_lang));
|
ImGui::TextFormattedWrapped("{}", static_cast<const char *>("hex.builtin.view.pattern_editor.accept_pattern.desc"_lang));
|
||||||
|
|
||||||
@ -61,11 +61,11 @@ namespace hex::plugin::builtin {
|
|||||||
if (ImGui::BeginListBox("##patterns_accept", ImVec2(-FLT_MIN, 0))) {
|
if (ImGui::BeginListBox("##patterns_accept", ImVec2(-FLT_MIN, 0))) {
|
||||||
u32 index = 0;
|
u32 index = 0;
|
||||||
for (auto &path : this->m_view->m_possiblePatternFiles) {
|
for (auto &path : this->m_view->m_possiblePatternFiles) {
|
||||||
if (ImGui::Selectable(wolv::util::toUTF8String(path.filename()).c_str(), index == this->m_view->m_selectedPatternFile, ImGuiSelectableFlags_DontClosePopups))
|
if (ImGui::Selectable(wolv::util::toUTF8String(path.filename()).c_str(), index == this->m_selectedPatternFile, ImGuiSelectableFlags_DontClosePopups))
|
||||||
this->m_view->m_selectedPatternFile = index;
|
this->m_selectedPatternFile = index;
|
||||||
|
|
||||||
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0))
|
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0))
|
||||||
this->m_view->loadPatternFile(this->m_view->m_possiblePatternFiles[this->m_view->m_selectedPatternFile], provider);
|
this->m_view->loadPatternFile(this->m_view->m_possiblePatternFiles[this->m_selectedPatternFile], provider);
|
||||||
|
|
||||||
ImGui::InfoTooltip(wolv::util::toUTF8String(path).c_str());
|
ImGui::InfoTooltip(wolv::util::toUTF8String(path).c_str());
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
confirmButtons("hex.builtin.common.yes"_lang, "hex.builtin.common.no"_lang,
|
confirmButtons("hex.builtin.common.yes"_lang, "hex.builtin.common.no"_lang,
|
||||||
[this, provider] {
|
[this, provider] {
|
||||||
this->m_view->loadPatternFile(this->m_view->m_possiblePatternFiles[this->m_view->m_selectedPatternFile], provider);
|
this->m_view->loadPatternFile(this->m_view->m_possiblePatternFiles[this->m_selectedPatternFile], provider);
|
||||||
this->close();
|
this->close();
|
||||||
},
|
},
|
||||||
[this] {
|
[this] {
|
||||||
@ -98,6 +98,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ViewPatternEditor *m_view;
|
ViewPatternEditor *m_view;
|
||||||
|
u32 m_selectedPatternFile = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -106,7 +107,6 @@ namespace hex::plugin::builtin {
|
|||||||
std::unique_ptr<pl::PatternLanguage> m_parserRuntime;
|
std::unique_ptr<pl::PatternLanguage> m_parserRuntime;
|
||||||
|
|
||||||
std::vector<std::fs::path> m_possiblePatternFiles;
|
std::vector<std::fs::path> m_possiblePatternFiles;
|
||||||
u32 m_selectedPatternFile = 0;
|
|
||||||
bool m_runAutomatically = false;
|
bool m_runAutomatically = false;
|
||||||
bool m_triggerEvaluation = false;
|
bool m_triggerEvaluation = false;
|
||||||
|
|
||||||
@ -118,8 +118,6 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
bool m_hasUnevaluatedChanges = false;
|
bool m_hasUnevaluatedChanges = false;
|
||||||
|
|
||||||
bool m_acceptPatternWindowOpen = false;
|
|
||||||
|
|
||||||
TextEditor m_textEditor;
|
TextEditor m_textEditor;
|
||||||
|
|
||||||
std::atomic<bool> m_dangerousFunctionCalled = false;
|
std::atomic<bool> m_dangerousFunctionCalled = false;
|
||||||
|
@ -51,7 +51,7 @@ namespace hex::plugin::builtin {
|
|||||||
langDef.mTokenize = [](const char *inBegin, const char *inEnd, const char *&outBegin, const char *&outEnd, TextEditor::PaletteIndex &paletteIndex) -> bool {
|
langDef.mTokenize = [](const char *inBegin, const char *inEnd, const char *&outBegin, const char *&outEnd, TextEditor::PaletteIndex &paletteIndex) -> bool {
|
||||||
paletteIndex = TextEditor::PaletteIndex::Max;
|
paletteIndex = TextEditor::PaletteIndex::Max;
|
||||||
|
|
||||||
while (inBegin < inEnd && isascii(*inBegin) && isblank(*inBegin))
|
while (inBegin < inEnd && isascii(*inBegin) && std::isblank(*inBegin))
|
||||||
inBegin++;
|
inBegin++;
|
||||||
|
|
||||||
if (inBegin == inEnd) {
|
if (inBegin == inEnd) {
|
||||||
@ -279,9 +279,9 @@ namespace hex::plugin::builtin {
|
|||||||
ON_SCOPE_EXIT { ImGui::PopID(); };
|
ON_SCOPE_EXIT { ImGui::PopID(); };
|
||||||
|
|
||||||
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x);
|
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x);
|
||||||
constexpr static const char *Types[] = { "I", "F", "S", "B" };
|
constexpr static std::array Types = { "I", "F", "S", "B" };
|
||||||
if (ImGui::BeginCombo("", Types[static_cast<int>(type)])) {
|
if (ImGui::BeginCombo("", Types[static_cast<int>(type)])) {
|
||||||
for (auto i = 0; i < IM_ARRAYSIZE(Types); i++) {
|
for (size_t i = 0; i < Types.size(); i++) {
|
||||||
if (ImGui::Selectable(Types[i]))
|
if (ImGui::Selectable(Types[i]))
|
||||||
type = static_cast<PlData::EnvVarType>(i);
|
type = static_cast<PlData::EnvVarType>(i);
|
||||||
}
|
}
|
||||||
@ -398,8 +398,8 @@ namespace hex::plugin::builtin {
|
|||||||
ImGui::Checkbox(label.c_str(), &value);
|
ImGui::Checkbox(label.c_str(), &value);
|
||||||
variable.value = value;
|
variable.value = value;
|
||||||
} else if (variable.type == pl::core::Token::ValueType::Character) {
|
} else if (variable.type == pl::core::Token::ValueType::Character) {
|
||||||
char buffer[2];
|
std::array<char, 2> buffer;
|
||||||
ImGui::InputText(label.c_str(), buffer, 2);
|
ImGui::InputText(label.c_str(), buffer.data(), buffer.size());
|
||||||
variable.value = buffer[0];
|
variable.value = buffer[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -462,7 +462,7 @@ namespace hex::plugin::builtin {
|
|||||||
auto patternProvider = ImHexApi::Provider::get();
|
auto patternProvider = ImHexApi::Provider::get();
|
||||||
|
|
||||||
|
|
||||||
this->m_sectionWindowDrawer[patternProvider] = [id, patternProvider, dataProvider = std::move(dataProvider), hexEditor = std::move(hexEditor), patternDrawer = ui::PatternDrawer()] mutable {
|
this->m_sectionWindowDrawer[patternProvider] = [id, patternProvider, dataProvider = std::move(dataProvider), hexEditor, patternDrawer = ui::PatternDrawer()] mutable {
|
||||||
hexEditor.setProvider(dataProvider.get());
|
hexEditor.setProvider(dataProvider.get());
|
||||||
hexEditor.draw(480_scaled);
|
hexEditor.draw(480_scaled);
|
||||||
patternDrawer.setSelectionCallback([&](const auto ®ion) {
|
patternDrawer.setSelectionCallback([&](const auto ®ion) {
|
||||||
@ -724,8 +724,8 @@ namespace hex::plugin::builtin {
|
|||||||
});
|
});
|
||||||
|
|
||||||
EventManager::subscribe<EventSettingsChanged>(this, [this] {
|
EventManager::subscribe<EventSettingsChanged>(this, [this] {
|
||||||
this->m_syncPatternSourceCode = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.sync_pattern_source", 0);
|
this->m_syncPatternSourceCode = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.sync_pattern_source", 0) == 1;
|
||||||
this->m_autoLoadPatterns = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.auto_load_patterns", 1);
|
this->m_autoLoadPatterns = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.auto_load_patterns", 1) == 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
EventManager::subscribe<EventProviderOpened>(this, [this](prv::Provider *provider) {
|
EventManager::subscribe<EventProviderOpened>(this, [this](prv::Provider *provider) {
|
||||||
@ -785,9 +785,7 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this->m_possiblePatternFiles.empty()) {
|
if (!this->m_possiblePatternFiles.empty()) {
|
||||||
this->m_selectedPatternFile = 0;
|
|
||||||
PopupAcceptPattern::open(this);
|
PopupAcceptPattern::open(this);
|
||||||
this->m_acceptPatternWindowOpen = true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -883,7 +881,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
/* Place pattern... */
|
/* Place pattern... */
|
||||||
ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.place_pattern", "hex.builtin.view.pattern_editor.menu.edit.place_pattern.builtin" }, 3000,
|
ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.place_pattern", "hex.builtin.view.pattern_editor.menu.edit.place_pattern.builtin" }, 3000,
|
||||||
[&]{
|
[&, this] {
|
||||||
if (ImGui::BeginMenu("hex.builtin.view.pattern_editor.menu.edit.place_pattern.builtin.single"_lang)) {
|
if (ImGui::BeginMenu("hex.builtin.view.pattern_editor.menu.edit.place_pattern.builtin.single"_lang)) {
|
||||||
for (const auto &[type, size] : Types)
|
for (const auto &[type, size] : Types)
|
||||||
if (ImGui::MenuItem(type))
|
if (ImGui::MenuItem(type))
|
||||||
@ -902,7 +900,7 @@ namespace hex::plugin::builtin {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.place_pattern", "hex.builtin.view.pattern_editor.menu.edit.place_pattern.custom" }, 3050,
|
ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.place_pattern", "hex.builtin.view.pattern_editor.menu.edit.place_pattern.custom" }, 3050,
|
||||||
[&]{
|
[&, this] {
|
||||||
const auto &types = this->m_parserRuntime->getInternals().parser->getTypes();
|
const auto &types = this->m_parserRuntime->getInternals().parser->getTypes();
|
||||||
auto selection = ImHexApi::HexEditor::getSelection();
|
auto selection = ImHexApi::HexEditor::getSelection();
|
||||||
|
|
||||||
@ -910,7 +908,7 @@ namespace hex::plugin::builtin {
|
|||||||
if (type->isTemplateType())
|
if (type->isTemplateType())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
createNestedMenu(hex::splitString(typeName, "::"), [&] {
|
createNestedMenu(hex::splitString(typeName, "::"), [&, this] {
|
||||||
std::string variableName;
|
std::string variableName;
|
||||||
for (char &c : hex::replaceStrings(typeName, "::", "_"))
|
for (char &c : hex::replaceStrings(typeName, "::", "_"))
|
||||||
variableName += static_cast<char>(std::tolower(c));
|
variableName += static_cast<char>(std::tolower(c));
|
||||||
@ -1020,4 +1018,4 @@ namespace hex::plugin::builtin {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user